)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » Report

Public general use code classes and xml files that we've compiled and used over the years:

Report support class of Optical Fiber Network (OFN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.Linq;
    5:  
    6: namespace Ia.Ngn.Cl.Model.Business
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Report support class of Optical Fiber Network (OFN) business model.
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public class Report
   28:     {
   29:         public enum Status { Open = 1, Closed = 2 }
   30:  
   31:         public enum ServiceType { Unspecified = 0, Dn = 1, AccessName = 2, AccessUnknown = 3 }
   32:  
   33:         ////////////////////////////////////////////////////////////////////////////
   34:  
   35:         /// <summary>
   36:         ///
   37:         /// </summary>
   38:         public Report() { }
   39:  
   40:         ////////////////////////////////////////////////////////////////////////////
   41:  
   42:         /// <summary>
   43:         ///
   44:         /// </summary>
   45:         public class Category
   46:         {
   47:             /// <summary/>
   48:             public Category() { }
   49:  
   50:             /// <summary/>
   51:             public int Id { get; set; }
   52:  
   53:             /// <summary/>
   54:             public string Name { get; set; }
   55:  
   56:             /// <summary/>
   57:             public string ArabicName { get; set; }
   58:  
   59:             /// <summary/>
   60:             public virtual ICollection<Ia.Ngn.Cl.Model.Business.Report.Area> Areas
   61:             {
   62:                 get
   63:                 {
   64:                     return (from a in Ia.Ngn.Cl.Model.Data.Report.AreaList
   65:                             where a.Category.Id == this.Id
   66:                             select a).ToList();
   67:                 }
   68:             }
   69:         }
   70:  
   71:         ////////////////////////////////////////////////////////////////////////////
   72:  
   73:         /// <summary>
   74:         ///
   75:         /// </summary>
   76:         public class Area
   77:         {
   78:             /// <summary/>
   79:             public Area() { }
   80:  
   81:             /// <summary/>
   82:             public int Id { get; set; }
   83:  
   84:             /// <summary/>
   85:             public int XmlId { get; set; }
   86:  
   87:             /// <summary/>
   88:             public string Name { get; set; }
   89:  
   90:             /// <summary/>
   91:             public string ArabicName { get; set; }
   92:  
   93:             /// <summary/>
   94:             public List<string> Frameworks { get; set; }
   95:  
   96:             /// <summary/>
   97:             public virtual Category Category { get; set; }
   98:  
   99:             /// <summary/>
  100:             public virtual ICollection<Indication> Indications
  101:             {
  102:                 get
  103:                 {
  104:                     return (from i in Ia.Ngn.Cl.Model.Data.Report.IndicationList
  105:                             where i.Area.Id == this.Id
  106:                             select i).ToList();
  107:                 }
  108:             }
  109:             /// <summary/>
  110:             public virtual ICollection<Action> Actions
  111:             {
  112:                 get
  113:                 {
  114:                     return (from a in Ia.Ngn.Cl.Model.Data.Report.ActionList
  115:                             where a.Area.Id == this.Id
  116:                             select a).ToList();
  117:                 }
  118:             }
  119:             /// <summary/>
  120:             public virtual ICollection<Resolution> Resolutions
  121:             {
  122:                 get
  123:                 {
  124:                     return (from r in Ia.Ngn.Cl.Model.Data.Report.ResolutionList
  125:                             where r.Area.Id == this.Id
  126:                             select r).ToList();
  127:                 }
  128:             }
  129:  
  130:             /// <summary/>
  131:             public int AreaId(int categoryId, int areaId)
  132:             {
  133:                 return categoryId * 100 + areaId;
  134:             }
  135:         }
  136:  
  137:         ////////////////////////////////////////////////////////////////////////////
  138:  
  139:         /// <summary>
  140:         ///
  141:         /// </summary>
  142:         public class Indication
  143:         {
  144:             /// <summary/>
  145:             public Indication() { }
  146:  
  147:             /// <summary/>
  148:             public int Id { get; set; }
  149:  
  150:             /// <summary/>
  151:             public int XmlId { get; set; }
  152:  
  153:             /// <summary/>
  154:             public bool Obsolete { get; set; }
  155:  
  156:             /// <summary/>
  157:             public bool CanInsert { get; set; }
  158:  
  159:             /// <summary/>
  160:             public string Name { get; set; }
  161:  
  162:             /// <summary/>
  163:             public string ArabicName { get; set; }
  164:  
  165:             /// <summary/>
  166:             public string ColoredName { get; set; }
  167:  
  168:             /// <summary/>
  169:             public string ColoredArabicName { get; set; }
  170:  
  171:             /// <summary/>
  172:             public string EnglishAndArabicName { get; set; }
  173:  
  174:             /// <summary/>
  175:             public string ColoredEnglishAndArabicName { get; set; }
  176:  
  177:             /// <summary/>
  178:             public string Color { get; set; }
  179:  
  180:             /// <summary/>
  181:             public List<string> Frameworks { get; set; }
  182:  
  183:             /// <summary/>
  184:             public virtual Area Area { get; set; }
  185:  
  186:             /// <summary/>
  187:             public int IndicationId(int areaId, int indicationId)
  188:             {
  189:                 return areaId * 10000 + indicationId;
  190:             }
  191:         }
  192:  
  193:         ////////////////////////////////////////////////////////////////////////////
  194:  
  195:         /// <summary>
  196:         ///
  197:         /// </summary>
  198:         public class Action
  199:         {
  200:             /// <summary/>
  201:             public Action() { }
  202:  
  203:             /// <summary/>
  204:             public int Id { get; set; }
  205:  
  206:             /// <summary/>
  207:             public int XmlId { get; set; }
  208:  
  209:             /// <summary/>
  210:             public bool Obsolete { get; set; }
  211:  
  212:             /// <summary/>
  213:             public bool CanInsert { get; set; }
  214:  
  215:             /// <summary/>
  216:             public string Name { get; set; }
  217:  
  218:             /// <summary/>
  219:             public string ArabicName { get; set; }
  220:  
  221:             /// <summary/>
  222:             public string ColoredName { get; set; }
  223:  
  224:             /// <summary/>
  225:             public string ColoredArabicName { get; set; }
  226:  
  227:             /// <summary/>
  228:             public string EnglishAndArabicName { get; set; }
  229:  
  230:             /// <summary/>
  231:             public string ColoredEnglishAndArabicName { get; set; }
  232:  
  233:             /// <summary/>
  234:             public string Color { get; set; }
  235:  
  236:             /// <summary/>
  237:             public List<string> Frameworks { get; set; }
  238:  
  239:             /// <summary/>
  240:             public virtual Area Area { get; set; }
  241:  
  242:             /// <summary/>
  243:             public int ActionId(int areaId, int actionId)
  244:             {
  245:                 return areaId * 10000 + actionId;
  246:             }
  247:         }
  248:  
  249:         ////////////////////////////////////////////////////////////////////////////
  250:  
  251:         /// <summary>
  252:         ///
  253:         /// </summary>
  254:         public class Resolution
  255:         {
  256:             /// <summary/>
  257:             public Resolution() { }
  258:  
  259:             /// <summary/>
  260:             public int Id { get; set; }
  261:  
  262:             /// <summary/>
  263:             public int XmlId { get; set; }
  264:  
  265:             /// <summary/>
  266:             public bool Obsolete { get; set; }
  267:  
  268:             /// <summary/>
  269:             public bool CanInsert { get; set; }
  270:  
  271:             /// <summary/>
  272:             public string Name { get; set; }
  273:  
  274:             /// <summary/>
  275:             public string ArabicName { get; set; }
  276:  
  277:             /// <summary/>
  278:             public string ColoredName { get; set; }
  279:  
  280:             /// <summary/>
  281:             public string ColoredArabicName { get; set; }
  282:  
  283:             /// <summary/>
  284:             public string EnglishAndArabicName { get; set; }
  285:  
  286:             /// <summary/>
  287:             public string ColoredEnglishAndArabicName { get; set; }
  288:  
  289:             /// <summary/>
  290:             public string Color { get; set; }
  291:  
  292:             /// <summary/>
  293:             public virtual Area Area { get; set; }
  294:  
  295:             /// <summary/>
  296:             public int ResolutionId(int areaId, int resolutionId)
  297:             {
  298:                 return areaId * 10000 + resolutionId;
  299:             }
  300:         }
  301:  
  302:         ////////////////////////////////////////////////////////////////////////////
  303:         ////////////////////////////////////////////////////////////////////////////
  304:  
  305:         /// <summary>
  306:         ///
  307:         /// </summary>
  308:         public static bool StaffHasResponsibilityReport(Ia.Ngn.Cl.Model.Staff staff)
  309:         {
  310:             bool has;
  311:  
  312:             if (Ia.Ngn.Cl.Model.Data.Report.ReportResponsibilityByStaffGuidDictionary.ContainsKey(staff.UserId))
  313:             {
  314:                 var list = Ia.Ngn.Cl.Model.Data.Report.ReportResponsibilityByStaffGuidDictionary[staff.UserId];
  315:  
  316:                 has = list.Count > 0;
  317:             }
  318:             else has = false;
  319:  
  320:             return has;
  321:         }
  322:  
  323:         ////////////////////////////////////////////////////////////////////////////
  324:  
  325:         /// <summary>
  326:         ///
  327:         /// </summary>
  328:         public static bool StaffHasResponsibilityLic(Ia.Ngn.Cl.Model.Staff staff)
  329:         {
  330:             bool has;
  331:  
  332:             var list = Ia.Ngn.Cl.Model.Data.Report.LicResponsibilityByStaff(staff);
  333:  
  334:             has = list.Count > 0;
  335:  
  336:             return has;
  337:         }
  338:  
  339:         ////////////////////////////////////////////////////////////////////////////
  340:  
  341:         /// <summary>
  342:         ///
  343:         /// </summary>
  344:         public static bool FrameworkHasReadabilityReport(Guid guid)
  345:         {
  346:             bool has;
  347:  
  348:             if (Ia.Ngn.Cl.Model.Data.Report.ReportReadabilityByFrameworkGuidDictionary.ContainsKey(guid))
  349:             {
  350:                 var reportIdList = Ia.Ngn.Cl.Model.Data.Report.ReportReadabilityByFrameworkGuidDictionary[guid];
  351:  
  352:                 has = reportIdList.Count > 0;
  353:             }
  354:             else has = false;
  355:  
  356:             return has;
  357:         }
  358:  
  359:  
  360:         ////////////////////////////////////////////////////////////////////////////
  361:  
  362:         /// <summary>
  363:         ///
  364:         /// </summary>
  365:         public static void CloseLastUpdatedOverNDaysReportsWithNegligenceResolution(int numberOfPastDays)
  366:         {
  367:             bool reportInserted, reportClosed;
  368:             int area, indication, resolution, action, estimate;
  369:             string detail, note;
  370:             Guid userId;
  371:             DateTime now;
  372:             Ia.Cl.Model.Result result;
  373:  
  374:             now = DateTime.UtcNow.AddHours(3);
  375:  
  376:             var reportList = Ia.Ngn.Cl.Model.Data.Report.ListWhereStatusIsOpenAndNoReportHistoriesAndUpdatedBeforeDateTime(now.AddDays(-numberOfPastDays));
  377:  
  378:             if (reportList.Count > 0)
  379:             {
  380:                 indication = 1000;
  381:                 // <indication id="1000" name="Unspecified" arabicName="غير محدد"/>
  382:  
  383:                 resolution = 1026;
  384:                 // <resolution id="1026" name="Negligence" arabicName="إهمال" color="DarkOrange" />
  385:  
  386:                 action = 1000;
  387:                 // <action id="1000" name="Unspecified" arabicName="غير محدد"/>
  388:  
  389:                 estimate = 0;
  390:  
  391:                 userId = Guid.Empty;
  392:  
  393:                 result = new Ia.Cl.Model.Result();
  394:  
  395:                 area = 11; // <area id="11" name="Service"
  396:  
  397:                 foreach (var report in reportList)
  398:                 {
  399:                     detail = string.Empty; // StaffFrameworkArabicName(report);
  400:                     note = string.Empty;
  401:  
  402:                     var reportHistory = new Ia.Ngn.Cl.Model.ReportHistory
  403:                     {
  404:                         Report = Ia.Ngn.Cl.Model.Data.Report.Read(report.Id),
  405:                         Area = area,
  406:                         Indication = indication,
  407:                         Resolution = resolution,
  408:                         Action = action,
  409:                         Estimate = estimate,
  410:                         Detail = detail,
  411:                         UserId = userId,
  412:                         Note = note,
  413:                         Created = now,
  414:                         Updated = now
  415:                     };
  416:  
  417:                     reportInserted = Ia.Ngn.Cl.Model.Data.ReportHistory.Create(reportHistory, out _);
  418:  
  419:                     if (reportInserted)
  420:                     {
  421:                         reportClosed = Ia.Ngn.Cl.Model.Data.Report.CloseStatus(report);
  422:  
  423:                         if (reportClosed)
  424:                         {
  425:                             result.AddSuccess("Report history for report.Id: " + report.Id + " successfully inserted and report closed.");
  426:                         }
  427:                         else
  428:                         {
  429:                             result.AddWarning("Report history for report.Id: " + report.Id + " successfully inserted but report not closed.");
  430:                         }
  431:                     }
  432:                     else
  433:                     {
  434:                         result.AddError("Report history for report.Id: " + report.Id + " not inserted.");
  435:                     }
  436:                 }
  437:  
  438:                 Ia.Ngn.Cl.Model.Data.Report.OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
  439:             }
  440:         }
  441:  
  442:         ////////////////////////////////////////////////////////////////////////////
  443:  
  444:         /// <summary>
  445:         ///
  446:         /// </summary>
  447:         private static string StaffFrameworkArabicName(Ia.Ngn.Cl.Model.Report report)
  448:         {
  449:             string text;
  450:  
  451:             if (report.LastReportHistory != null)
  452:             {
  453:                 if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(report.LastReportHistory.UserId))
  454:                 {
  455:                     text = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
  456:                             where f.Guid == report.LastReportHistory.UserId
  457:                             select f.ArabicName).SingleOrDefault();
  458:                 }
  459:                 else
  460:                 {
  461:                     text = (from _s in Ia.Ngn.Cl.Model.Data.Staff.List
  462:                             where _s.UserId == report.LastReportHistory.UserId
  463:                             select _s.Framework.ArabicName).SingleOrDefault();
  464:                 }
  465:             }
  466:             else
  467:             {
  468:                 text = string.Empty;
  469:             }
  470:  
  471:             return text;
  472:         }
  473:  
  474:         ////////////////////////////////////////////////////////////////////////////
  475:         ////////////////////////////////////////////////////////////////////////////   
  476:     }
  477:  
  478:     ////////////////////////////////////////////////////////////////////////////
  479:     ////////////////////////////////////////////////////////////////////////////   
  480: }