شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

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 for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Xml.Linq;
   3:  using System.IO;
   4:  using System.Data;
   5:  using System.Data.Entity;
   6:  using System.Collections.Generic;
   7:  using System.Reflection;
   8:  using System.Linq;
   9:  using System.Diagnostics;
  10:  using System.Web;
  11:  using System.Collections;
  12:   
  13:  namespace Ia.Ngn.Cl.Model.Data
  14:  {
  15:      ////////////////////////////////////////////////////////////////////////////
  16:   
  17:      /// <summary publish="true">
  18:      /// Report support class for Next Generation Network (NGN) data model.
  19:      /// </summary>
  20:      /// 
  21:      /// <remarks> 
  22:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  23:      ///
  24:      /// 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
  25:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  26:      ///
  27:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  28:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  29:      /// 
  30:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  31:      /// 
  32:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  33:      /// </remarks> 
  34:      public partial class Report
  35:      {
  36:          private static XDocument xDocument;
  37:          private static List<Ia.Ngn.Cl.Model.Business.Report.Category> categoryList;
  38:          private static List<Ia.Ngn.Cl.Model.Business.Report.Area> areaList;
  39:          private static List<Ia.Ngn.Cl.Model.Business.Report.Indication> indicationList;
  40:          private static List<Ia.Ngn.Cl.Model.Business.Report.Action> actionList;
  41:          private static List<Ia.Ngn.Cl.Model.Business.Report.Resolution> resolutionList;
  42:          /*
  43:          private static List<Ia.Ngn.Cl.Model.Business.Report.Severity> severityList;
  44:          private static List<Ia.Ngn.Cl.Model.Business.Report.Priority> priorityList;
  45:          private static List<Ia.Ngn.Cl.Model.Business.Report.Status> statusList;
  46:          private static List<Ia.Ngn.Cl.Model.Business.Report.Estimate> estimateList;
  47:          private static List<Ia.Ngn.Cl.Model.Business.Report.ServiceType> serviceTypeList;
  48:          private static List<Ia.Ngn.Cl.Model.Business.Report.CustomerCare> customerCare;
  49:           */
  50:   
  51:          private static List<Ia.Ngn.Cl.Model.Report> openStatusOrClosedStatusWithinLast24HourReportList;
  52:          private static Dictionary<Guid, List<int>> reportResponsibilityByStaffGuidDictionary, reportReadabilityByFrameworkGuidDictionary;
  53:          private static readonly object objectLock = new object();
  54:   
  55:          ////////////////////////////////////////////////////////////////////////////
  56:   
  57:          /// <summary>
  58:          ///
  59:          /// </summary>
  60:          public Report() { }
  61:   
  62:          ////////////////////////////////////////////////////////////////////////////
  63:          ////////////////////////////////////////////////////////////////////////////
  64:   
  65:          /// <summary>
  66:          ///
  67:          /// </summary>
  68:          public static int Create(Ia.Ngn.Cl.Model.Report report, out string result)
  69:          {
  70:              int id;
  71:   
  72:              id = -1;
  73:              result = string.Empty;
  74:   
  75:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  76:              {
  77:                  report.Created = report.Updated = DateTime.UtcNow.AddHours(3);
  78:   
  79:                  db.Reports.Add(report);
  80:                  db.SaveChanges();
  81:   
  82:                  id = report.Id;
  83:              }
  84:   
  85:              OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
  86:   
  87:              return id;
  88:          }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////
  91:   
  92:          /// <summary>
  93:          ///
  94:          /// </summary>
  95:          public static Ia.Ngn.Cl.Model.Report Read(int reportId)
  96:          {
  97:              Ia.Ngn.Cl.Model.Report report;
  98:   
  99:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 100:              {
 101:                  report = (from r in db.Reports where r.Id == reportId select r).Include(r => r.ReportHistories).SingleOrDefault();
 102:              }
 103:   
 104:              return report;
 105:          }
 106:   
 107:          ////////////////////////////////////////////////////////////////////////////
 108:   
 109:          /// <summary>
 110:          ///
 111:          /// </summary>
 112:          public static List<Ia.Ngn.Cl.Model.Report> ReadList(string service)
 113:          {
 114:              List<Ia.Ngn.Cl.Model.Report> reportList;
 115:   
 116:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 117:              {
 118:                  try
 119:                  {
 120:                      reportList = (from r in db.Reports where r.Service == service select r).Include(r => r.ReportHistories).ToList();
 121:                  }
 122:                  catch
 123:                  {
 124:                      reportList = null;
 125:                  }
 126:              }
 127:   
 128:              return reportList;
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:          /// <summary>
 134:          ///
 135:          /// </summary>
 136:          public static List<Ia.Ngn.Cl.Model.Report> ReadListForServiceFromReportId(int reportId)
 137:          {
 138:              List<Ia.Ngn.Cl.Model.Report> reportList;
 139:   
 140:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 141:              {
 142:                  try
 143:                  {
 144:                      reportList = (from _r in db.Reports join r in db.Reports on _r.Service equals r.Service where r.Id == reportId select r).Include(r => r.ReportHistories).ToList();
 145:                  }
 146:                  catch
 147:                  {
 148:                      reportList = null;
 149:                  }
 150:              }
 151:   
 152:              return reportList;
 153:          }
 154:   
 155:          /*
 156:          ////////////////////////////////////////////////////////////////////////////
 157:  
 158:          /// <summary>
 159:          ///
 160:          /// </summary>
 161:          public static bool UpdateMigratedList(List<Ia.Ngn.Cl.Model.Report> reportList, out string result)
 162:          {
 163:              bool b;
 164:              Ia.Ngn.Cl.Model.Report report;
 165:  
 166:              b = false;
 167:              result = string.Empty;
 168:  
 169:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 170:              {
 171:                  foreach (Ia.Ngn.Cl.Model.Report updatedReport in reportList)
 172:                  {
 173:                      report = (from r in db.Reports where r.Id == updatedReport.Id select r).SingleOrDefault();
 174:  
 175:                      if (report == null)
 176:                      {
 177:                          //updatedReport.Created = updatedReport.Updated = DateTime.UtcNow.AddHours(3);
 178:  
 179:                          db.Reports.Add(updatedReport);
 180:                      }
 181:                      else
 182:                      {
 183:                          // below: copy values from updatedReport to report
 184:  
 185:                          report.UpdateMigrated(updatedReport);
 186:  
 187:                          db.Reports.Attach(report);
 188:  
 189:                          db.Entry(report).State = System.Data.Entity.EntityState.Modified;
 190:                      }
 191:  
 192:                      b = true;
 193:  
 194:                  }
 195:  
 196:                  db.SaveChanges();
 197:  
 198:                  DbContextProbablyUpdated();
 199:  
 200:                  b = true;
 201:              }
 202:  
 203:              return b;
 204:          }
 205:          */
 206:   
 207:          ////////////////////////////////////////////////////////////////////////////
 208:   
 209:          /// <summary>
 210:          ///
 211:          /// </summary>
 212:          public static bool CloseStatus(Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
 213:          {
 214:              bool b;
 215:   
 216:              b = false;
 217:   
 218:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 219:              {
 220:                  report.Status = (int)Ia.Ngn.Cl.Model.Business.Report.Status.Closed;
 221:   
 222:                  report.Updated = DateTime.UtcNow.AddHours(3);
 223:                  //this.UserId = staff.UserId;
 224:                  // above: can't do that because it will remove the name of the record inserter
 225:   
 226:                  db.Reports.Attach(report);
 227:                  db.Entry(report).State = System.Data.Entity.EntityState.Modified;
 228:                  db.SaveChanges();
 229:   
 230:                  OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
 231:   
 232:                  b = true;
 233:              }
 234:   
 235:              return b;
 236:          }
 237:   
 238:          ////////////////////////////////////////////////////////////////////////////
 239:   
 240:          /// <summary>
 241:          ///
 242:          /// </summary>
 243:          public static bool OpenStatus(Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
 244:          {
 245:              bool b;
 246:   
 247:              b = false;
 248:   
 249:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 250:              {
 251:                  report.Status = (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open;
 252:   
 253:                  report.Updated = DateTime.UtcNow.AddHours(3);
 254:                  //this.UserId = staff.UserId;
 255:                  // above: can't do that because it will remove the name of the record inserter
 256:   
 257:                  db.Reports.Attach(report);
 258:                  db.Entry(report).State = System.Data.Entity.EntityState.Modified;
 259:                  db.SaveChanges();
 260:   
 261:                  OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
 262:   
 263:                  b = true;
 264:              }
 265:   
 266:              return b;
 267:          }
 268:   
 269:          ////////////////////////////////////////////////////////////////////////////
 270:   
 271:          /// <summary>
 272:          ///
 273:          /// </summary>
 274:          public static bool NullifyUserId(Guid userId, out int numberOfRecordsUpdated)
 275:          {
 276:              return MoveUserId(userId, Guid.Empty, out numberOfRecordsUpdated);
 277:          }
 278:   
 279:          ////////////////////////////////////////////////////////////////////////////
 280:   
 281:          /// <summary>
 282:          ///
 283:          /// </summary>
 284:          public static bool MoveUserId(Guid fromUserId, Guid toUserId, out int numberOfRecordsUpdated)
 285:          {
 286:              bool b;
 287:   
 288:              b = false;
 289:              numberOfRecordsUpdated = 0;
 290:   
 291:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 292:              {
 293:                  var query = (from r in db.Reports where r.UserId == fromUserId select r).ToList();
 294:   
 295:                  foreach (var v in query)
 296:                  {
 297:                      v.UserId = toUserId;
 298:                      numberOfRecordsUpdated++;
 299:                  }
 300:   
 301:                  db.SaveChanges();
 302:   
 303:                  OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
 304:   
 305:                  b = true;
 306:              }
 307:   
 308:              return b;
 309:          }
 310:   
 311:          ////////////////////////////////////////////////////////////////////////////
 312:   
 313:          /// <summary>
 314:          ///
 315:          /// </summary>
 316:          public static bool Delete(int id/*, out string result*/)
 317:          {
 318:              bool b;
 319:   
 320:              b = false;
 321:              //result = string.Empty;
 322:   
 323:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 324:              {
 325:                  var v = (from r in db.Reports where r.Id == id select r).FirstOrDefault();
 326:   
 327:                  db.Reports.Remove(v);
 328:                  db.SaveChanges();
 329:   
 330:                  OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear();
 331:   
 332:                  b = true;
 333:              }
 334:   
 335:              return b;
 336:          }
 337:   
 338:          ////////////////////////////////////////////////////////////////////////////
 339:          ////////////////////////////////////////////////////////////////////////////
 340:   
 341:          /// <summary>
 342:          ///
 343:          /// </summary>
 344:          public static bool StaffHasResponsibilityReport(Ia.Ngn.Cl.Model.Staff staff)
 345:          {
 346:              bool has;
 347:   
 348:              if (Ia.Ngn.Cl.Model.Data.Report.ReportResponsibilityByStaffGuidDictionary.ContainsKey(staff.UserId))
 349:              {
 350:                  var reportIdList = Ia.Ngn.Cl.Model.Data.Report.ReportResponsibilityByStaffGuidDictionary[staff.UserId];
 351:   
 352:                  has = reportIdList.Count > 0;
 353:              }
 354:              else has = false;
 355:   
 356:              return has;
 357:          }
 358:   
 359:          ////////////////////////////////////////////////////////////////////////////
 360:   
 361:          /// <summary>
 362:          ///
 363:          /// </summary>
 364:          public static bool FrameworkHasReadabilityReport(Guid guid)
 365:          {
 366:              bool has;
 367:   
 368:              if (Ia.Ngn.Cl.Model.Data.Report.ReportReadabilityByFrameworkGuidDictionary.ContainsKey(guid))
 369:              {
 370:                  var reportIdList = Ia.Ngn.Cl.Model.Data.Report.ReportReadabilityByFrameworkGuidDictionary[guid];
 371:   
 372:                  has = reportIdList.Count > 0;
 373:              }
 374:              else has = false;
 375:   
 376:              return has;
 377:          }
 378:   
 379:          ////////////////////////////////////////////////////////////////////////////
 380:   
 381:          /// <summary>
 382:          ///
 383:          /// </summary>
 384:          private static void StaffFrameworkAncestorAndDescendantUserIdListAndStaffSubordinatesUserIdList(Ia.Ngn.Cl.Model.Staff staff, out List<Guid> staffFrameworkAncestorAndDescendantUserIdList, out List<Guid> staffSubordinatesUserIdList)
 385:          {
 386:              staffFrameworkAncestorAndDescendantUserIdList = new List<Guid>();
 387:              staffSubordinatesUserIdList = new List<Guid>();
 388:   
 389:              // below: add self framework
 390:              staffFrameworkAncestorAndDescendantUserIdList.Add(staff.Framework.Guid);
 391:   
 392:              // below: add ancestor frameworks
 393:              if (staff.Framework.Ancestors != null)
 394:              {
 395:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework ancestor in staff.Framework.Ancestors.ToList())
 396:                      staffFrameworkAncestorAndDescendantUserIdList.Add(ancestor.Guid);
 397:              }
 398:   
 399:              // below: add decendant frameworks
 400:              if (staff.Framework.Descendants != null)
 401:              {
 402:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework descendant in staff.Framework.Descendants.ToList())
 403:                      staffFrameworkAncestorAndDescendantUserIdList.Add(descendant.Guid);
 404:              }
 405:   
 406:              // below: add children staff
 407:              if (staff.Subordinates != null)
 408:              {
 409:                  foreach (Ia.Ngn.Cl.Model.Staff subordinate in staff.Subordinates.ToList()) staffSubordinatesUserIdList.Add(subordinate.UserId);
 410:              }
 411:          }
 412:   
 413:          ////////////////////////////////////////////////////////////////////////////
 414:   
 415:          /// <summary>
 416:          ///
 417:          /// </summary>
 418:          private static void FrameworkAncestorAndDescendantUserIdListAndFrameworkStaffSubordinatesUserIdList(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, out List<Guid> staffFrameworkAncestorAndDescendantUserIdList, out List<Guid> staffSubordinatesUserIdList)
 419:          {
 420:              staffFrameworkAncestorAndDescendantUserIdList = new List<Guid>();
 421:              staffSubordinatesUserIdList = new List<Guid>();
 422:   
 423:              // below: add self framework
 424:              staffFrameworkAncestorAndDescendantUserIdList.Add(framework.Guid);
 425:   
 426:              if (framework.Ancestors != null)
 427:              {
 428:                  // below: add ancestor frameworks
 429:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework ancestor in framework.Ancestors) staffFrameworkAncestorAndDescendantUserIdList.Add(ancestor.Guid);
 430:              }
 431:   
 432:              if (framework.Descendants != null)
 433:              {
 434:                  // below: add decendants
 435:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework descendant in framework.Descendants) staffFrameworkAncestorAndDescendantUserIdList.Add(descendant.Guid);
 436:              }
 437:   
 438:              // below: add children staff of any of the list of frameworks collected
 439:              staffSubordinatesUserIdList = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
 440:                                             join sfadu in staffFrameworkAncestorAndDescendantUserIdList on s.Framework.Guid equals sfadu
 441:                                             select s.UserId).ToList();
 442:          }
 443:   
 444:          ////////////////////////////////////////////////////////////////////////////
 445:          ////////////////////////////////////////////////////////////////////////////
 446:   
 447:          /// <summary>
 448:          ///
 449:          /// </summary>
 450:          public static List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> ReadSpecificUserIdListAndSiteIdReportWithReportOpenStatusList(List<Guid> userIdList, int siteId)
 451:          {
 452:              List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> reportAccessServiceRequestList;
 453:   
 454:              if (siteId == 0) reportAccessServiceRequestList = _ReadSpecificUserIdListReportWithReportOpenStatusList(userIdList);
 455:              else
 456:              {
 457:                  var v = _ReadSpecificUserIdListReportWithReportOpenStatusList(userIdList);
 458:   
 459:                  if (v != null)
 460:                  {
 461:                      reportAccessServiceRequestList = (from rasr in v
 462:                                                        join s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList on siteId equals s.Id
 463:                                                        where rasr.Access != null && s.KuwaitNgnAreas.Any(u => u.Id == rasr.Access.AreaId)
 464:                                                        select rasr).ToList();
 465:                  }
 466:                  else
 467:                  {
 468:                      reportAccessServiceRequestList = new List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest>();
 469:                  }
 470:              }
 471:   
 472:              return reportAccessServiceRequestList;
 473:          }
 474:   
 475:          ////////////////////////////////////////////////////////////////////////////
 476:   
 477:          /// <summary>
 478:          ///
 479:          /// </summary>
 480:          private static List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> _ReadSpecificUserIdListReportWithReportOpenStatusList(List<Guid> userIdList)
 481:          {
 482:              string prividUser, accessId;
 483:              List<string> serviceIdList, prividUserList;
 484:              Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest reportAccessServiceRequest;
 485:              List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> reportAccessServiceRequestList;
 486:              List<Ia.Ngn.Cl.Model.Report> reportList;
 487:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 488:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 489:   
 490:              reportAccessServiceRequestList = null;
 491:   
 492:              serviceIdList = new List<string>();
 493:              prividUserList = new List<string>();
 494:   
 495:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 496:              {
 497:                  if (userIdList != null && userIdList.Count > 0)
 498:                  {
 499:                      reportList = (from r in db.Reports
 500:                                    join srs in db.ServiceRequestServices on r.Service equals srs.Service into gj
 501:                                    where (r.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open && (r.ReportHistories.Any(y => userIdList.Any(z => z == y.UserId))))
 502:                                    orderby r.Created
 503:                                    from sub in gj.DefaultIfEmpty()
 504:                                    select r).Include(x => x.ReportHistories).ToList();
 505:   
 506:                      if (reportList.Count > 0)
 507:                      {
 508:                          foreach (var v in reportList)
 509:                          {
 510:                              serviceIdList.Add(v.Service);
 511:   
 512:                              prividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(v.Service);
 513:                              prividUserList.Add(prividUser);
 514:                          }
 515:   
 516:                          serviceRequestServiceList = (from srs in db.ServiceRequestServices
 517:                                                       where serviceIdList.Contains(srs.Service)
 518:                                                       select srs).ToList();
 519:   
 520:                          agcfEndpointList = (from ep in db.AgcfEndpoints
 521:                                              where prividUserList.Contains(ep.PrividUser)
 522:                                              select ep).ToList();
 523:   
 524:                          reportAccessServiceRequestList = new List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest>();
 525:   
 526:                          foreach (Ia.Ngn.Cl.Model.Report report in reportList)
 527:                          {
 528:                              // below: the aggregate function will check the last entry
 529:                              if (userIdList.Contains(report.ReportHistories.Aggregate((i, j) => i.Id > j.Id ? i : j).UserId))
 530:                              {
 531:                                  reportAccessServiceRequest = new Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest();
 532:   
 533:                                  reportAccessServiceRequest.Report = report;
 534:                                  reportAccessServiceRequest.Report.ReportHistories = report.ReportHistories; // this to force inclusion of ReportHistories
 535:   
 536:                                  if (report.ServiceType == 1)
 537:                                  {
 538:                                      reportAccessServiceRequest.Access = (from srs in serviceRequestServiceList where srs.Service == report.Service select srs.Access).FirstOrDefault();
 539:   
 540:                                      prividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(report.Service);
 541:                                      reportAccessServiceRequest.Port = (from ep in agcfEndpointList where ep.Id == prividUser select ep.FlatTermID).SingleOrDefault();
 542:                                  }
 543:                                  else //if(report.ServiceType == 2)
 544:                                  {
 545:                                      accessId = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == report.Service select o.Access.Id).SingleOrDefault();
 546:   
 547:                                      if (!string.IsNullOrEmpty(accessId))
 548:                                      {
 549:                                          reportAccessServiceRequest.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
 550:                                      }
 551:                                      else reportAccessServiceRequest.Access = null;
 552:   
 553:                                      reportAccessServiceRequest.Port = 0;
 554:                                  }
 555:   
 556:                                  reportAccessServiceRequestList.Add(reportAccessServiceRequest);
 557:                              }
 558:                          }
 559:                      }
 560:                      else
 561:                      {
 562:                      }
 563:                  }
 564:                  else
 565:                  {
 566:                  }
 567:              }
 568:   
 569:              return reportAccessServiceRequestList;
 570:          }
 571:   
 572:          ////////////////////////////////////////////////////////////////////////////
 573:          ////////////////////////////////////////////////////////////////////////////
 574:   
 575:          /// <summary>
 576:          ///
 577:          /// </summary>
 578:          public static List<Ia.Ngn.Cl.Model.Report> OpenStatusOrClosedStatusWithinLast24HourReportList
 579:          {
 580:              get
 581:              {
 582:                  if (openStatusOrClosedStatusWithinLast24HourReportList == null || openStatusOrClosedStatusWithinLast24HourReportList.Count == 0)
 583:                  {
 584:                      if (HttpContext.Current != null && HttpContext.Current.Application["openStatusOrClosedStatusWithinLast24HourReportList"] != null)
 585:                      {
 586:                          openStatusOrClosedStatusWithinLast24HourReportList = HttpContext.Current.Application["openStatusOrClosedStatusWithinLast24HourReportList"] as List<Ia.Ngn.Cl.Model.Report>;
 587:                      }
 588:                      else
 589:                      {
 590:                          lock (objectLock)
 591:                          {
 592:                              openStatusOrClosedStatusWithinLast24HourReportList = Ia.Ngn.Cl.Model.Data.Report._OpenStatusOrClosedStatusWithinLast24HourReportList();
 593:   
 594:                              if (HttpContext.Current != null) HttpContext.Current.Application["openStatusOrClosedStatusWithinLast24HourReportList"] = openStatusOrClosedStatusWithinLast24HourReportList;
 595:                          }
 596:                      }
 597:                  }
 598:   
 599:                  return openStatusOrClosedStatusWithinLast24HourReportList;
 600:              }
 601:          }
 602:   
 603:          ////////////////////////////////////////////////////////////////////////////
 604:   
 605:          /// <summary>
 606:          ///
 607:          /// </summary>
 608:          public static void OpenStatusOrClosedStatusWithinLast24HourReportListClear()
 609:          {
 610:              openStatusOrClosedStatusWithinLast24HourReportList = null;
 611:   
 612:              if (HttpContext.Current != null) HttpContext.Current.Application.Remove("openStatusOrClosedStatusWithinLast24HourReportList");
 613:          }
 614:   
 615:          ////////////////////////////////////////////////////////////////////////////
 616:   
 617:          /// <summary>
 618:          ///
 619:          /// </summary>
 620:          private static List<Ia.Ngn.Cl.Model.Report> _OpenStatusOrClosedStatusWithinLast24HourReportList()
 621:          {
 622:              DateTime before24Hour;
 623:   
 624:              List<Ia.Ngn.Cl.Model.Report> list;
 625:   
 626:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 627:              {
 628:                  before24Hour = DateTime.UtcNow.AddHours(3).AddDays(-1);
 629:   
 630:                  list = (from r in db.Reports
 631:                          where r.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open || (r.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Closed && r.Updated >= before24Hour)
 632:                          orderby r.Created
 633:                          select r).Include(x => x.ReportHistories).ToList();
 634:              }
 635:   
 636:              return list;
 637:          }
 638:   
 639:          ////////////////////////////////////////////////////////////////////////////
 640:   
 641:          /// <summary>
 642:          ///
 643:          /// </summary>
 644:          public static List<Ia.Ngn.Cl.Model.Report> OpenStatusOrClosedStatusWithinLast24HourByReportIdReportList(List<int> reportIdList)
 645:          {
 646:              return (from r in OpenStatusOrClosedStatusWithinLast24HourReportList join rid in reportIdList on r.Id equals rid select r).ToList();
 647:          }
 648:   
 649:          ////////////////////////////////////////////////////////////////////////////
 650:          ////////////////////////////////////////////////////////////////////////////
 651:   
 652:          /// <summary>
 653:          ///
 654:          /// </summary>
 655:          public static Dictionary<Guid, List<int>> ReportResponsibilityByStaffGuidDictionary
 656:          {
 657:              get
 658:              {
 659:                  if (reportResponsibilityByStaffGuidDictionary == null || reportResponsibilityByStaffGuidDictionary.Count == 0)
 660:                  {
 661:                      if (HttpContext.Current != null && HttpContext.Current.Application["reportResponsibilityByStaffGuidDictionary"] != null)
 662:                      {
 663:                          reportResponsibilityByStaffGuidDictionary = HttpContext.Current.Application["reportResponsibilityByStaffGuidDictionary"] as Dictionary<Guid, List<int>>;
 664:                      }
 665:                      else
 666:                      {
 667:                          lock (objectLock)
 668:                          {
 669:                              reportResponsibilityByStaffGuidDictionary = Ia.Ngn.Cl.Model.Data.Report._ReportResponsibilityByStaffGuidDictionary();
 670:   
 671:                              if (HttpContext.Current != null) HttpContext.Current.Application["reportResponsibilityByStaffGuidDictionary"] = reportResponsibilityByStaffGuidDictionary;
 672:                          }
 673:                      }
 674:                  }
 675:   
 676:                  return reportResponsibilityByStaffGuidDictionary;
 677:              }
 678:          }
 679:   
 680:          ////////////////////////////////////////////////////////////////////////////
 681:   
 682:          /// <summary>
 683:          ///
 684:          /// </summary>
 685:          public static void ReportResponsibilityByStaffGuidDictionaryClear()
 686:          {
 687:              reportResponsibilityByStaffGuidDictionary = null;
 688:   
 689:              if (HttpContext.Current != null) HttpContext.Current.Application.Remove("reportResponsibilityByStaffGuidDictionary");
 690:          }
 691:   
 692:          ////////////////////////////////////////////////////////////////////////////
 693:   
 694:          /// <summary>
 695:          ///
 696:          /// </summary>
 697:          private static Dictionary<Guid, List<int>> _ReportResponsibilityByStaffGuidDictionary()
 698:          {
 699:              Dictionary<Guid, List<int>> dictionary;
 700:   
 701:              dictionary = new Dictionary<Guid, List<int>>();
 702:   
 703:              var staffList = Ia.Ngn.Cl.Model.Data.Staff.List;
 704:   
 705:              var reportList = Ia.Ngn.Cl.Model.Data.Report.OpenStatusOrClosedStatusWithinLast24HourReportList;
 706:   
 707:              // I will exclude closed reports
 708:              reportList = (from r in reportList where r.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open select r).ToList();
 709:   
 710:              foreach (var staff in staffList)
 711:              {
 712:                  if (staff.UserId != Guid.Empty)
 713:                  {
 714:                      StaffFrameworkAncestorAndDescendantUserIdListAndStaffSubordinatesUserIdList(staff, out List<Guid> staffFrameworkAncestorAndDescendantUserIdList, out List<Guid> staffSubordinatesUserIdList);
 715:   
 716:                      var re = (from r in reportList
 717:                                where r.LastReportHistory == null && Ia.Ngn.Cl.Model.Business.Authority.StaffIsResponsibleForAllOpenReportWithNoReportHistory(staff)
 718:                                || r.LastReportHistory == null && r.UserId == staff.UserId
 719:                                || r.LastReportHistory == null && staffSubordinatesUserIdList.Contains(r.UserId)
 720:                                || r.LastReportHistory == null && staffFrameworkAncestorAndDescendantUserIdList.Contains(r.UserId)
 721:                                || r.LastReportHistory != null && r.LastReportHistory.UserId == staff.UserId
 722:                                || r.LastReportHistory != null && staffSubordinatesUserIdList.Contains(r.LastReportHistory.UserId)
 723:                                || r.LastReportHistory != null && staffFrameworkAncestorAndDescendantUserIdList.Contains(r.LastReportHistory.UserId)
 724:                                select r).ToList();
 725:   
 726:                      if (re.Count > 0) dictionary[staff.UserId] = re.Select(r => r.Id).ToList();
 727:                  }
 728:              }
 729:   
 730:              return dictionary;
 731:          }
 732:   
 733:          ////////////////////////////////////////////////////////////////////////////
 734:          ////////////////////////////////////////////////////////////////////////////
 735:   
 736:          /// <summary>
 737:          ///
 738:          /// </summary>
 739:          public static Dictionary<Guid, List<int>> ReportReadabilityByFrameworkGuidDictionary
 740:          {
 741:              get
 742:              {
 743:                  if (reportReadabilityByFrameworkGuidDictionary == null || reportReadabilityByFrameworkGuidDictionary.Count == 0)
 744:                  {
 745:                      if (HttpContext.Current != null && HttpContext.Current.Application["reportReadabilityByFrameworkGuidDictionary"] != null)
 746:                      {
 747:                          reportReadabilityByFrameworkGuidDictionary = HttpContext.Current.Application["reportReadabilityByFrameworkGuidDictionary"] as Dictionary<Guid, List<int>>;
 748:                      }
 749:                      else
 750:                      {
 751:                          lock (objectLock)
 752:                          {
 753:                              reportReadabilityByFrameworkGuidDictionary = Ia.Ngn.Cl.Model.Data.Report._ReportReadabilityByFrameworkGuidDictionary();
 754:   
 755:                              if (HttpContext.Current != null) HttpContext.Current.Application["reportReadabilityByFrameworkGuidDictionary"] = reportReadabilityByFrameworkGuidDictionary;
 756:                          }
 757:                      }
 758:                  }
 759:   
 760:                  return reportReadabilityByFrameworkGuidDictionary;
 761:              }
 762:          }
 763:   
 764:          ////////////////////////////////////////////////////////////////////////////
 765:   
 766:          /// <summary>
 767:          ///
 768:          /// </summary>
 769:          public static void ReportReadabilityByFrameworkGuidDictionaryClear()
 770:          {
 771:              reportReadabilityByFrameworkGuidDictionary = null;
 772:   
 773:              if (HttpContext.Current != null) HttpContext.Current.Application.Remove("reportReadabilityByFrameworkGuidDictionary");
 774:          }
 775:   
 776:          ////////////////////////////////////////////////////////////////////////////
 777:   
 778:          /// <summary>
 779:          ///
 780:          /// </summary>
 781:          private static Dictionary<Guid, List<int>> _ReportReadabilityByFrameworkGuidDictionary()
 782:          {
 783:              Dictionary<Guid, List<int>> dic;
 784:   
 785:              dic = new Dictionary<Guid, List<int>>();
 786:   
 787:              var frameworkList = Ia.Ngn.Cl.Model.Data.Administration.FrameworkList;
 788:   
 789:              var reportList = Ia.Ngn.Cl.Model.Data.Report.OpenStatusOrClosedStatusWithinLast24HourReportList;
 790:   
 791:              // will add all reports to the Guid.Empty framework
 792:              dic[Guid.Empty] = reportList.Select(r => r.Id).ToList();
 793:   
 794:              foreach (var framework in frameworkList)
 795:              {
 796:                  if (framework.Guid != Guid.Empty)
 797:                  {
 798:                      FrameworkAncestorAndDescendantUserIdListAndFrameworkStaffSubordinatesUserIdList(framework, out List<Guid> staffFrameworkAncestorAndDescendantUserIdList, out List<Guid> staffSubordinatesUserIdList);
 799:   
 800:                      var re = (from r in reportList
 801:                                where r.LastReportHistory == null && Ia.Ngn.Cl.Model.Business.Authority.FrameworkIsResponsibleForAllOpenReportWithNoReportHistory(framework)
 802:                                || r.LastReportHistory == null && r.UserId == framework.Guid
 803:                                || staffSubordinatesUserIdList.Contains(r.UserId)
 804:                                || staffFrameworkAncestorAndDescendantUserIdList.Contains(r.UserId)
 805:                                || r.LastReportHistory != null && r.LastReportHistory.UserId == framework.Guid
 806:                                || r.LastReportHistory != null && staffFrameworkAncestorAndDescendantUserIdList.Contains(r.LastReportHistory.UserId)
 807:                                || r.ReportHistories != null && r.ReportHistories.Any(u => staffSubordinatesUserIdList.Contains(u.UserId))
 808:                                || r.LastReportHistory != null && staffSubordinatesUserIdList.Contains(r.LastReportHistory.UserId)
 809:                                select r).ToList();
 810:   
 811:                      if (re.Count > 0) dic[framework.Guid] = re.Select(r => r.Id).ToList();
 812:                  }
 813:              }
 814:   
 815:              return dic;
 816:          }
 817:   
 818:          ////////////////////////////////////////////////////////////////////////////    
 819:   
 820:          /// <summary>
 821:          ///
 822:          /// </summary>
 823:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Framework> ReportReadabilityByFrameworkList
 824:          {
 825:              get
 826:              {
 827:                  return (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList join r in ReportReadabilityByFrameworkGuidDictionary on f.Guid equals r.Key select f).ToList();
 828:              }
 829:   
 830:   
 831:              /*
 832:              Hashtable frameworkGuidHashtable;
 833:              //Ia.Ngn.Cl.Model.Staff staff;
 834:              List<Guid> userIdList;
 835:              List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> list;
 836:  
 837:              frameworkGuidHashtable = new Hashtable();
 838:              userIdList = new List<Guid>();
 839:  
 840:              var reportList = Ia.Ngn.Cl.Model.Data.Report.OpenStatusOrClosedStatusWithinLast24HourReportList;
 841:  
 842:              foreach (Ia.Ngn.Cl.Model.Business.Administration.StaffFramework sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList)
 843:              {
 844:                  if (sf.IsFramework)
 845:                  {
 846:                      var rl = Ia.Ngn.Cl.Model.Data.Report.FrameworkReadabilityReportList(reportList, sf.Guid);
 847:  
 848:                      if (rl.Count > 0) frameworkGuidHashtable[sf.Guid] = 1;
 849:                  }
 850:              }
 851:  
 852:              foreach (Guid userId in frameworkGuidHashtable.Keys) userIdList.Add(userId);
 853:  
 854:              list = (from u in userIdList
 855:                      join sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList on u equals sf.Guid
 856:                      where sf.IsFramework == true && Ia.Ngn.Cl.Model.Business.Authority.FrameworkParentOfAllReportsThatWillBeHandledInReportSection.Descendants.Any(u => u.Guid == sf.Guid)
 857:                      select sf).OrderBy(c => c.Name).ToList(); //.OrderByDescending(c => c.IsStaff).ThenBy(c => c.FrameworkId).ToList();
 858:  
 859:              // convert StaffFramework to Framework
 860:              var list2 = (from l in list join f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList on l.FrameworkId equals f.Id select f).ToList();
 861:  
 862:              return list2;
 863:              */
 864:          }
 865:   
 866:          ////////////////////////////////////////////////////////////////////////////
 867:          ////////////////////////////////////////////////////////////////////////////
 868:   
 869:          /// <summary>
 870:          /// When a report list is updated I will reset local lists to null to generate new list
 871:          /// </summary>
 872:          public static void OpenStatusOrClosedWithinLast24HourAndResponsibilityAndReadabilityReportListClear()
 873:          {
 874:              OpenStatusOrClosedStatusWithinLast24HourReportListClear();
 875:              ReportResponsibilityByStaffGuidDictionaryClear();
 876:              ReportReadabilityByFrameworkGuidDictionaryClear();
 877:          }
 878:   
 879:          ////////////////////////////////////////////////////////////////////////////
 880:          ////////////////////////////////////////////////////////////////////////////
 881:   
 882:          /*
 883:          ////////////////////////////////////////////////////////////////////////////
 884:  
 885:          /// <summary>
 886:          ///
 887:          /// </summary>
 888:          public static List<Ia.Ngn.Cl.Model.Report> OpenStatusAndClosedStatusWithinLast24HourWithNonEmptyReportHistoryReportList()
 889:          {
 890:              var reportList = OpenStatusOrClosedStatusWithinLast24HourReportList;
 891:  
 892:              var lastReportHistoryNotNullReportList = (from r in reportList where r.LastReportHistory != null select r).ToList();
 893:  
 894:              return lastReportHistoryNotNullReportList;
 895:          }
 896:          */
 897:   
 898:          ////////////////////////////////////////////////////////////////////////////
 899:   
 900:          /// <summary>
 901:          ///
 902:          /// </summary>
 903:          public static List<Ia.Ngn.Cl.Model.Report> ReadOpenStatusReportList
 904:          {
 905:              get
 906:              {
 907:                  List<Ia.Ngn.Cl.Model.Report> reportList;
 908:   
 909:                  reportList = (from r in OpenStatusOrClosedStatusWithinLast24HourReportList where r.Status == (int)Ia.Ngn.Cl.Model.Business.Report.Status.Open orderby r.Created select r).ToList();
 910:   
 911:                  return reportList;
 912:              }
 913:          }
 914:   
 915:          ////////////////////////////////////////////////////////////////////////////
 916:   
 917:          /// <summary>
 918:          ///
 919:          /// </summary>
 920:          public static List<Ia.Ngn.Cl.Model.Report> ReadSingleAsList(int reportId)
 921:          {
 922:              List<Ia.Ngn.Cl.Model.Report> reportList;
 923:   
 924:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 925:              {
 926:                  reportList = (from r in db.Reports where r.Id == reportId select r).Include(x => x.ReportHistories).ToList();
 927:              }
 928:   
 929:              return reportList;
 930:          }
 931:   
 932:          /*
 933:          ////////////////////////////////////////////////////////////////////////////
 934:  
 935:          /// <summary>
 936:          ///
 937:          /// </summary>
 938:          public static DateTime LastUpdatedDateTime()
 939:          {
 940:              DateTime lastUpdatedDateTime;
 941:  
 942:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 943:              {
 944:                  try
 945:                  {
 946:                      lastUpdatedDateTime = (from r in db.Reports orderby r.Updated descending select r.Updated).Take(1).Single();
 947:                  }
 948:                  catch
 949:                  {
 950:                      lastUpdatedDateTime = Ia.Ngn.Cl.Model.Business.Administration.SqlFriendlyJanuary1st1753NullDateTime;
 951:                  }
 952:              }
 953:  
 954:              return lastUpdatedDateTime;
 955:          }
 956:  
 957:          ////////////////////////////////////////////////////////////////////////////
 958:  
 959:          /// <summary>
 960:          ///
 961:          /// </summary>
 962:          public static DateTime LastUpdatedDateTimeOfHistory()
 963:          {
 964:              DateTime lastUpdatedDateTime;
 965:  
 966:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 967:              {
 968:                  try
 969:                  {
 970:                      lastUpdatedDateTime = (from rh in db.ReportHistories orderby rh.Updated descending select rh.Updated).Take(1).Single();
 971:                  }
 972:                  catch
 973:                  {
 974:                      lastUpdatedDateTime = Ia.Ngn.Cl.Model.Business.Administration.SqlFriendlyJanuary1st1753NullDateTime;
 975:                  }
 976:              }
 977:  
 978:              return lastUpdatedDateTime;
 979:          }
 980:          */
 981:   
 982:          ////////////////////////////////////////////////////////////////////////////
 983:   
 984:          /// <summary>
 985:          ///
 986:          /// </summary>
 987:          public static Dictionary<int, string> CategoryDictionary
 988:          {
 989:              get
 990:              {
 991:                  Dictionary<int, string> dictionary;
 992:   
 993:                  dictionary = new Dictionary<int, string>(100);
 994:   
 995:                  dictionary = (from c in XDocument.Elements("report").Elements("category")
 996:                                select new { Id = int.Parse(c.Attribute("id").Value), Name = c.Attribute("name").Value }).ToDictionary(r => r.Id, r => r.Name);
 997:   
 998:                  return dictionary;
 999:              }
1000:          }
1001:   
1002:          ////////////////////////////////////////////////////////////////////////////
1003:   
1004:          /// <summary>
1005:          ///
1006:          /// </summary>
1007:          public static Dictionary<int, string> CategoryAreaIndicationDictionary(int categoryId, int areaId)
1008:          {
1009:              Dictionary<int, string> dictionary;
1010:   
1011:              dictionary = new Dictionary<int, string>(100);
1012:   
1013:              dictionary = (from i in XDocument.Elements("report").Elements("category").Elements("area").Elements("indicationList")
1014:                            where i.Parent.Parent.Attribute("id").Value == categoryId.ToString() && i.Parent.Attribute("id").Value == areaId.ToString()
1015:                            select new { Id = int.Parse(i.Attribute("id").Value), Name = i.Attribute("id").Value }).ToDictionary(r => r.Id, r => r.Name);
1016:   
1017:              return dictionary;
1018:          }
1019:   
1020:          ////////////////////////////////////////////////////////////////////////////
1021:   
1022:          /// <summary>
1023:          ///
1024:          /// </summary>
1025:          public static Dictionary<int, string> IndicationColoredDictionary
1026:          {
1027:              get
1028:              {
1029:                  return Dictionary(false, true, "category", "area", "indicationList", "indication").Concat(GeneralIndicationColoredDictionary).ToDictionary(q => q.Key, q => q.Value);
1030:              }
1031:          }
1032:   
1033:          ////////////////////////////////////////////////////////////////////////////
1034:   
1035:          /// <summary>
1036:          ///
1037:          /// </summary>
1038:          public static Dictionary<int, string> ActionDictionary
1039:          {
1040:              get
1041:              {
1042:                  return Dictionary(false, false, "category", "area", "actionList", "action").Concat(GeneralActionDictionary).ToDictionary(q => q.Key, q => q.Value);
1043:              }
1044:          }
1045:   
1046:          ////////////////////////////////////////////////////////////////////////////
1047:   
1048:          /// <summary>
1049:          ///
1050:          /// </summary>
1051:          public static Dictionary<int, string> ActionColoredDictionary
1052:          {
1053:              get
1054:              {
1055:                  return Dictionary(false, true, "category", "area", "actionList", "action").Concat(GeneralActionColoredDictionary).ToDictionary(q => q.Key, q => q.Value);
1056:              }
1057:          }
1058:   
1059:          ////////////////////////////////////////////////////////////////////////////
1060:   
1061:          /// <summary>
1062:          ///
1063:          /// </summary>
1064:          public static Dictionary<int, string> ResolutionColoredDictionary
1065:          {
1066:              get
1067:              {
1068:                  return Dictionary(false, true, "resolution");
1069:              }
1070:          }
1071:   
1072:          ////////////////////////////////////////////////////////////////////////////
1073:   
1074:          /// <summary>
1075:          ///
1076:          /// </summary>
1077:          public static Dictionary<int, string> ResolutionEnglishAndArabicColoredDictionary
1078:          {
1079:              get
1080:              {
1081:                  return Dictionary(true, true, "resolution");
1082:              }
1083:          }
1084:   
1085:          ////////////////////////////////////////////////////////////////////////////
1086:   
1087:          /// <summary>
1088:          ///
1089:          /// </summary>
1090:          public static Dictionary<int, string> ResolutionDictionary
1091:          {
1092:              get
1093:              {
1094:                  return Dictionary(false, false, "resolution");
1095:              }
1096:          }
1097:   
1098:          ////////////////////////////////////////////////////////////////////////////
1099:   
1100:          /// <summary>
1101:          ///
1102:          /// </summary>
1103:          public static Dictionary<int, string> GeneralActionDictionary
1104:          {
1105:              get
1106:              {
1107:                  return Dictionary(false, false, "action");
1108:              }
1109:          }
1110:   
1111:          ////////////////////////////////////////////////////////////////////////////
1112:   
1113:          /// <summary>
1114:          ///
1115:          /// </summary>
1116:          public static Dictionary<int, string> GeneralActionColoredDictionary
1117:          {
1118:              get
1119:              {
1120:                  return Dictionary(false, true, "action");
1121:              }
1122:          }
1123:   
1124:          ////////////////////////////////////////////////////////////////////////////
1125:   
1126:          /// <summary>
1127:          ///
1128:          /// </summary>
1129:          public static Dictionary<int, string> GeneralIndicationDictionary
1130:          {
1131:              get
1132:              {
1133:                  return Dictionary(false, false, "indication");
1134:              }
1135:          }
1136:   
1137:          ////////////////////////////////////////////////////////////////////////////
1138:   
1139:          /// <summary>
1140:          ///
1141:          /// </summary>
1142:          public static Dictionary<int, string> GeneralIndicationColoredDictionary
1143:          {
1144:              get
1145:              {
1146:                  return Dictionary(false, true, "indication");
1147:              }
1148:          }
1149:   
1150:          ////////////////////////////////////////////////////////////////////////////
1151:   
1152:          /// <summary>
1153:          ///
1154:          /// </summary>
1155:          public static Dictionary<int, string> EstimateDictionary
1156:          {
1157:              get
1158:              {
1159:                  return Dictionary(false, false, "estimate");
1160:              }
1161:          }
1162:   
1163:          ////////////////////////////////////////////////////////////////////////////
1164:   
1165:          /// <summary>
1166:          ///
1167:          /// </summary>
1168:          public static Dictionary<int, string> EstimateColoredDictionary
1169:          {
1170:              get
1171:              {
1172:                  return Dictionary(false, true, "estimate");
1173:              }
1174:          }
1175:   
1176:          ////////////////////////////////////////////////////////////////////////////
1177:   
1178:          /// <summary>
1179:          ///
1180:          /// </summary>
1181:          public static Dictionary<int, string> StatusDictionary
1182:          {
1183:              get
1184:              {
1185:                  return Dictionary(false, false, "status");
1186:              }
1187:          }
1188:   
1189:          ////////////////////////////////////////////////////////////////////////////
1190:   
1191:          /// <summary>
1192:          ///
1193:          /// </summary>
1194:          public static Dictionary<int, string> StatusColoredDictionary
1195:          {
1196:              get
1197:              {
1198:                  return Dictionary(false, true, "status");
1199:              }
1200:          }
1201:   
1202:          ////////////////////////////////////////////////////////////////////////////
1203:   
1204:          /// <summary>
1205:          ///
1206:          /// </summary>
1207:          public static Dictionary<int, string> PriorityDictionary
1208:          {
1209:              get
1210:              {
1211:                  return Dictionary(false, false, "priority");
1212:              }
1213:          }
1214:   
1215:          ////////////////////////////////////////////////////////////////////////////
1216:   
1217:          /// <summary>
1218:          ///
1219:          /// </summary>
1220:          public static Dictionary<int, string> PriorityColoredDictionary
1221:          {
1222:              get
1223:              {
1224:                  return Dictionary(false, true, "priority");
1225:              }
1226:          }
1227:   
1228:          ////////////////////////////////////////////////////////////////////////////
1229:   
1230:          /// <summary>
1231:          ///
1232:          /// </summary>
1233:          public static Dictionary<int, string> SeverityDictionary
1234:          {
1235:              get
1236:              {
1237:                  return Dictionary(false, false, "severity");
1238:              }
1239:          }
1240:   
1241:          ////////////////////////////////////////////////////////////////////////////
1242:   
1243:          /// <summary>
1244:          ///
1245:          /// </summary>
1246:          public static Dictionary<int, string> SeverityColoredDictionary
1247:          {
1248:              get
1249:              {
1250:                  return Dictionary(false, true, "severity");
1251:              }
1252:          }
1253:   
1254:          ////////////////////////////////////////////////////////////////////////////
1255:   
1256:          /// <summary>
1257:          ///
1258:          /// </summary>
1259:          public static Dictionary<int, string> CategoryAreaDictionary()
1260:          {
1261:              return Dictionary(false, false, "category", "area");
1262:          }
1263:   
1264:          ////////////////////////////////////////////////////////////////////////////
1265:   
1266:          /// <summary>
1267:          ///
1268:          /// </summary>
1269:          public static Dictionary<int, string> CategoryAreaDictionary(int categoryId)
1270:          {
1271:              return ColoredDictionary("category", "area", categoryId, false);
1272:          }
1273:   
1274:          ////////////////////////////////////////////////////////////////////////////
1275:   
1276:          /// <summary>
1277:          ///
1278:          /// </summary>
1279:          public static Dictionary<int, string> CategoryAreaColoredDictionary
1280:          {
1281:              get
1282:              {
1283:                  return Dictionary(false, true, "category", "area");
1284:              }
1285:          }
1286:   
1287:          ////////////////////////////////////////////////////////////////////////////
1288:   
1289:          /// <summary>
1290:          /// Returns a Dictionary<int, string> dictionary of elements. If parameter isColored is true the dictionary will contain HTML formatted colored list
1291:          /// </summary>
1292:          private static Dictionary<int, string> Dictionary(bool englishAndArabicName, bool isColored, params string[] elementList)
1293:          {
1294:              int id;
1295:              string name, color;
1296:              Dictionary<int, string> dictionary;
1297:              IEnumerable<XElement> xElementIenumerable;
1298:   
1299:              dictionary = new Dictionary<int, string>(10);
1300:              xElementIenumerable = null;
1301:   
1302:              try
1303:              {
1304:                  switch (elementList.Length)
1305:                  {
1306:                      case 1: xElementIenumerable = XDocument.Element("report").Elements(elementList[0]); break;
1307:                      case 2: xElementIenumerable = XDocument.Element("report").Elements(elementList[0]).Elements(elementList[1]); break;
1308:                      case 3: xElementIenumerable = XDocument.Element("report").Elements(elementList[0]).Elements(elementList[1]).Elements(elementList[2]); break;
1309:                      case 4: xElementIenumerable = XDocument.Element("report").Elements(elementList[0]).Elements(elementList[1]).Elements(elementList[2]).Elements(elementList[3]); break;
1310:                      default: break;
1311:                  }
1312:   
1313:                  foreach (XElement x in xElementIenumerable)
1314:                  {
1315:                      id = int.Parse(x.Attribute("id").Value);
1316:   
1317:                      if (englishAndArabicName)
1318:                      {
1319:                          if (x.Attribute("arabicName") != null)
1320:                          {
1321:                              name = x.Attribute("name").Value + " (" + x.Attribute("arabicName").Value + ")";
1322:                          }
1323:                          else name = x.Attribute("name").Value;
1324:                      }
1325:                      else name = x.Attribute("name").Value;
1326:   
1327:                      color = x.Attribute("color")?.Value;
1328:   
1329:                      // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1330:                      name = name.Replace(" ", "&nbsp;");
1331:   
1332:                      ColoredDictionaryItem(ref dictionary, isColored, id, name, color);
1333:                  }
1334:              }
1335:              catch (Exception e)
1336:              {
1337:   
1338:              }
1339:   
1340:              return dictionary;
1341:          }
1342:   
1343:          ////////////////////////////////////////////////////////////////////////////
1344:   
1345:          /// <summary>
1346:          /// Returns a Dictionary<int, string> dictionary of elements. If parameter isColored is true the dictionary will contain HTML formatted colored list
1347:          /// </summary>
1348:          private static Dictionary<int, string> ColoredDictionary(string element, string secondElement, int categoryId, bool isColored)
1349:          {
1350:              int id;
1351:              string name, color;
1352:              Dictionary<int, string> dictionary;
1353:   
1354:              dictionary = new Dictionary<int, string>(100);
1355:   
1356:              foreach (XElement x in XDocument.Element("report").Elements(element).Elements(secondElement))
1357:              {
1358:                  if (x.Parent.Attribute("id").Value == categoryId.ToString())
1359:                  {
1360:                      id = int.Parse(x.Attribute("id").Value);
1361:                      name = x.Attribute("name").Value;
1362:                      color = x.Attribute("color")?.Value;
1363:   
1364:                      ColoredDictionaryItem(ref dictionary, isColored, id, name, color);
1365:                  }
1366:              }
1367:   
1368:              return dictionary;
1369:          }
1370:   
1371:          ////////////////////////////////////////////////////////////////////////////
1372:   
1373:          /// <summary>
1374:          /// Returns a Dictionary<int, string> dictionary of elements. If parameter isColored is true the dictionary will contain HTML formatted colored list
1375:          /// </summary>
1376:          private static Dictionary<int, string> Dictionary(string element, string secondElement, string thirdElement, string fourthElement, int categoryId, int categoryAreaId, bool isColored)
1377:          {
1378:              int id;
1379:              string name, color;
1380:              Dictionary<int, string> dictionary;
1381:   
1382:              dictionary = new Dictionary<int, string>(100);
1383:   
1384:              foreach (XElement x in XDocument.Element("report").Elements(element).Elements(secondElement).Elements(thirdElement).Elements(fourthElement))
1385:              {
1386:                  if (x.Parent.Parent.Parent.Attribute("id").Value == categoryId.ToString() && x.Parent.Parent.Attribute("id").Value == categoryAreaId.ToString())
1387:                  {
1388:                      id = int.Parse(x.Attribute("id").Value);
1389:                      name = x.Attribute("name").Value;
1390:                      color = x.Attribute("color")?.Value; // same as color = (x.Attribute("color") != null) ? x.Attribute("color").Value : null;
1391:   
1392:                      ColoredDictionaryItem(ref dictionary, isColored, id, name, color);
1393:                  }
1394:              }
1395:   
1396:              return dictionary;
1397:          }
1398:   
1399:          ////////////////////////////////////////////////////////////////////////////
1400:   
1401:          /// <summary>
1402:          ///
1403:          /// </summary>
1404:          private static void ColoredDictionaryItem(ref Dictionary<int, string> dictionary, bool isColored, int id, string name, string color)
1405:          {
1406:              List<string> lightBackgroundColorList;
1407:   
1408:              if (isColored)
1409:              {
1410:                  if (!string.IsNullOrEmpty(color))
1411:                  {
1412:                      dictionary.Add(id, @"<span style=""color:" + color + @""">" + name + "</span>");
1413:                  }
1414:                  else
1415:                  {
1416:                      lightBackgroundColorList = Ia.Ngn.Cl.Model.Ui.Default.LightBackgroundColorList;
1417:   
1418:                      dictionary.Add(id, @"<span style=""color:" + lightBackgroundColorList[id % lightBackgroundColorList.Count] + @""">" + name + "</span>");
1419:                  }
1420:              }
1421:              else
1422:              {
1423:                  dictionary.Add(id, name);
1424:              }
1425:          }
1426:   
1427:          ////////////////////////////////////////////////////////////////////////////
1428:   
1429:          /// <summary>
1430:          ///
1431:          /// </summary>
1432:          private static string ColoredName(int id, string name)
1433:          {
1434:              return ColoredName(id, name, null);
1435:          }
1436:   
1437:          ////////////////////////////////////////////////////////////////////////////
1438:   
1439:          /// <summary>
1440:          ///
1441:          /// </summary>
1442:          private static string ColoredName(int id, string name, string color)
1443:          {
1444:              string coloredName;
1445:              List<string> lightBackgroundColorList;
1446:   
1447:              lightBackgroundColorList = Ia.Ngn.Cl.Model.Ui.Default.LightBackgroundColorList;
1448:   
1449:              if (!string.IsNullOrEmpty(color)) coloredName = @"<span style=""color:" + color + @""">" + name + "</span>";
1450:              else coloredName = @"<span style=""color:" + lightBackgroundColorList[id % lightBackgroundColorList.Count] + @""">" + name + "</span>";
1451:   
1452:              return coloredName;
1453:          }
1454:   
1455:          ////////////////////////////////////////////////////////////////////////////
1456:          ////////////////////////////////////////////////////////////////////////////
1457:   
1458:          /// <summary>
1459:          ///
1460:          /// </summary>
1461:          public static List<Ia.Ngn.Cl.Model.Business.Report.Category> CategoryList
1462:          {
1463:              get
1464:              {
1465:                  if (categoryList == null || categoryList.Count == 0)
1466:                  {
1467:                      int id;
1468:                      Ia.Ngn.Cl.Model.Business.Report.Category category;
1469:   
1470:                      categoryList = new List<Ia.Ngn.Cl.Model.Business.Report.Category>();
1471:   
1472:                      foreach (XElement x in XDocument.Element("report").Elements("category"))
1473:                      {
1474:                          category = new Ia.Ngn.Cl.Model.Business.Report.Category();
1475:   
1476:                          id = int.Parse(x.Attribute("id").Value);
1477:   
1478:                          category.Id = id;
1479:                          category.Name = x.Attribute("name").Value;
1480:                          category.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
1481:   
1482:                          categoryList.Add(category);
1483:                      }
1484:                  }
1485:   
1486:                  return categoryList;
1487:              }
1488:          }
1489:   
1490:          ////////////////////////////////////////////////////////////////////////////
1491:   
1492:          /// <summary>
1493:          ///
1494:          /// </summary>
1495:          public static List<Ia.Ngn.Cl.Model.Business.Report.Area> AreaList
1496:          {
1497:              get
1498:              {
1499:                  if (areaList == null || areaList.Count == 0)
1500:                  {
1501:                      int categoryId, id;
1502:                      Ia.Ngn.Cl.Model.Business.Report.Area area;
1503:   
1504:                      areaList = new List<Ia.Ngn.Cl.Model.Business.Report.Area>();
1505:   
1506:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area"))
1507:                      {
1508:                          area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1509:                          area.Category = new Ia.Ngn.Cl.Model.Business.Report.Category();
1510:   
1511:                          categoryId = int.Parse(x.Parent.Attribute("id").Value);
1512:                          id = int.Parse(x.Attribute("id").Value);
1513:   
1514:                          area.Id = area.AreaId(categoryId, id);
1515:                          area.XmlId = id;
1516:                          area.Category = (from c in CategoryList where c.Id == categoryId select c).SingleOrDefault();
1517:                          area.Name = x.Attribute("name").Value;
1518:                          area.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
1519:   
1520:                          if (x.Attribute("framework") != null)
1521:                          {
1522:                              area.Frameworks = new List<string>(100);
1523:   
1524:                              foreach (string s in x.Attribute("framework").Value.Split(',')) area.Frameworks.Add(s);
1525:                          }
1526:   
1527:                          areaList.Add(area);
1528:                      }
1529:                  }
1530:   
1531:                  return areaList;
1532:              }
1533:          }
1534:   
1535:          ////////////////////////////////////////////////////////////////////////////
1536:   
1537:          /// <summary>
1538:          ///
1539:          /// </summary>
1540:          public static List<Ia.Ngn.Cl.Model.Business.Report.Indication> IndicationList
1541:          {
1542:              get
1543:              {
1544:                  if (indicationList == null || indicationList.Count == 0)
1545:                  {
1546:                      int categoryId, areaId, id;
1547:                      Ia.Ngn.Cl.Model.Business.Report.Indication indication;
1548:   
1549:                      indicationList = new List<Ia.Ngn.Cl.Model.Business.Report.Indication>();
1550:   
1551:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area").Elements("indicationList").Elements("indication"))
1552:                      {
1553:                          indication = new Ia.Ngn.Cl.Model.Business.Report.Indication();
1554:                          indication.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1555:   
1556:                          categoryId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1557:                          areaId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1558:                          id = int.Parse(x.Attribute("id").Value);
1559:   
1560:                          areaId = indication.Area.AreaId(categoryId, areaId);
1561:   
1562:                          indication.Id = indication.IndicationId(areaId, id);
1563:                          indication.XmlId = id;
1564:                          indication.Area = (from a in AreaList where a.Id == areaId select a).SingleOrDefault();
1565:   
1566:                          // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1567:                          if (x.Attribute("obsolete") != null) indication.Obsolete = (x.Attribute("obsolete").Value == "true") ? true : false;
1568:                          else indication.Obsolete = false;
1569:   
1570:                          // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1571:                          if (x.Attribute("canInsert") != null) indication.CanInsert = (x.Attribute("canInsert").Value == "true") ? true : false;
1572:                          else indication.CanInsert = true;
1573:   
1574:                          indication.Color = (x.Attribute("color") != null) ? x.Attribute("color").Value : string.Empty;
1575:   
1576:                          // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1577:                          indication.Name = x.Attribute("name").Value.Replace(" ", "&nbsp;");
1578:                          indication.ColoredName = ColoredName(id, indication.Name, indication.Color);
1579:   
1580:                          if (x.Attribute("arabicName") != null && x.Attribute("arabicName").Value != string.Empty)
1581:                          {
1582:                              indication.ArabicName = x.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1583:                              indication.ColoredArabicName = ColoredName(id, indication.ArabicName, indication.Color);
1584:                          }
1585:                          else
1586:                          {
1587:                              indication.ArabicName = string.Empty;
1588:                              indication.ColoredArabicName = string.Empty;
1589:                          }
1590:   
1591:                          if (indication.ArabicName != string.Empty) indication.EnglishAndArabicName = indication.Name + "&nbsp;(" + indication.ArabicName + ")";
1592:                          else indication.EnglishAndArabicName = indication.Name;
1593:   
1594:                          if (indication.ColoredArabicName != string.Empty) indication.ColoredEnglishAndArabicName = indication.ColoredName + "&nbsp;(" + indication.ColoredArabicName + ")";
1595:                          else indication.ColoredEnglishAndArabicName = indication.ColoredName;
1596:   
1597:                          if (x.Parent.Attribute("framework") != null)
1598:                          {
1599:                              indication.Frameworks = new List<string>(100);
1600:   
1601:                              foreach (string s in x.Parent.Attribute("framework").Value.Split(',')) indication.Frameworks.Add(s);
1602:                          }
1603:   
1604:                          indicationList.Add(indication);
1605:                      }
1606:   
1607:                      // below: add the general indications to all areas
1608:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area"))
1609:                      {
1610:                          foreach (XElement y in XDocument.Element("report").Elements("indication"))
1611:                          {
1612:                              indication = new Ia.Ngn.Cl.Model.Business.Report.Indication();
1613:                              indication.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1614:   
1615:                              categoryId = int.Parse(x.Parent.Attribute("id").Value);
1616:                              areaId = int.Parse(x.Attribute("id").Value);
1617:                              id = int.Parse(y.Attribute("id").Value); // y
1618:   
1619:                              areaId = indication.Area.AreaId(categoryId, areaId);
1620:   
1621:                              indication.Id = indication.IndicationId(areaId, id);
1622:                              indication.XmlId = id;
1623:                              indication.Area = null;// (from q in AreaList where q.Id == areaId select q).SingleOrDefault();
1624:   
1625:                              // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1626:                              if (y.Attribute("obsolete") != null) indication.Obsolete = (y.Attribute("obsolete").Value == "true") ? true : false;
1627:                              else indication.Obsolete = false;
1628:   
1629:                              // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1630:                              if (y.Attribute("canInsert") != null) indication.CanInsert = (y.Attribute("canInsert").Value == "true") ? true : false;
1631:                              else indication.CanInsert = true;
1632:   
1633:                              indication.Color = (y.Attribute("color") != null) ? y.Attribute("color").Value : string.Empty;
1634:   
1635:                              // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1636:                              indication.Name = y.Attribute("name").Value.Replace(" ", "&nbsp;");
1637:                              indication.ColoredName = ColoredName(id, indication.Name, indication.Color);
1638:   
1639:                              if (y.Attribute("arabicName") != null && y.Attribute("arabicName").Value != string.Empty)
1640:                              {
1641:                                  indication.ArabicName = y.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1642:                                  indication.ColoredArabicName = ColoredName(id, indication.ArabicName, indication.Color);
1643:                              }
1644:                              else
1645:                              {
1646:                                  indication.ArabicName = string.Empty;
1647:                                  indication.ColoredArabicName = string.Empty;
1648:                              }
1649:   
1650:                              if (indication.ArabicName != string.Empty) indication.EnglishAndArabicName = indication.Name + "&nbsp;(" + indication.ArabicName + ")";
1651:                              else indication.EnglishAndArabicName = indication.Name;
1652:   
1653:                              if (indication.ColoredArabicName != string.Empty) indication.ColoredEnglishAndArabicName = indication.ColoredName + "&nbsp;(" + indication.ColoredArabicName + ")";
1654:                              else indication.ColoredEnglishAndArabicName = indication.ColoredName;
1655:   
1656:                              indicationList.Add(indication);
1657:                          }
1658:                      }
1659:                  }
1660:   
1661:                  return indicationList;
1662:              }
1663:          }
1664:   
1665:          ////////////////////////////////////////////////////////////////////////////
1666:   
1667:          /// <summary>
1668:          ///
1669:          /// </summary>
1670:          public static List<Ia.Ngn.Cl.Model.Business.Report.Action> ActionList
1671:          {
1672:              get
1673:              {
1674:                  if (actionList == null || actionList.Count == 0)
1675:                  {
1676:                      int categoryId, areaId, id;
1677:                      Ia.Ngn.Cl.Model.Business.Report.Action action;
1678:   
1679:                      actionList = new List<Ia.Ngn.Cl.Model.Business.Report.Action>();
1680:   
1681:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area").Elements("actionList").Elements("action"))
1682:                      {
1683:                          action = new Ia.Ngn.Cl.Model.Business.Report.Action();
1684:                          action.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1685:   
1686:                          categoryId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1687:                          areaId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1688:                          id = int.Parse(x.Attribute("id").Value);
1689:   
1690:                          areaId = action.Area.AreaId(categoryId, areaId);
1691:   
1692:                          action.Id = action.ActionId(areaId, id);
1693:                          action.XmlId = id;
1694:                          action.Area = (from a in AreaList where a.Id == areaId select a).SingleOrDefault();
1695:   
1696:                          // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1697:                          if (x.Attribute("obsolete") != null) action.Obsolete = (x.Attribute("obsolete").Value == "true") ? true : false;
1698:                          else action.Obsolete = false;
1699:   
1700:                          // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1701:                          if (x.Attribute("canInsert") != null) action.CanInsert = (x.Attribute("canInsert").Value == "true") ? true : false;
1702:                          else action.CanInsert = true;
1703:   
1704:                          action.Color = (x.Attribute("color") != null) ? x.Attribute("color").Value : string.Empty;
1705:   
1706:                          // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1707:                          action.Name = x.Attribute("name").Value.Replace(" ", "&nbsp;");
1708:                          action.ColoredName = ColoredName(id, action.Name, action.Color);
1709:   
1710:                          if (x.Attribute("arabicName") != null && x.Attribute("arabicName").Value != string.Empty)
1711:                          {
1712:                              action.ArabicName = x.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1713:                              action.ColoredArabicName = ColoredName(id, action.ArabicName, action.Color);
1714:                          }
1715:                          else
1716:                          {
1717:                              action.ArabicName = string.Empty;
1718:                              action.ColoredArabicName = string.Empty;
1719:                          }
1720:   
1721:                          if (action.ArabicName != string.Empty) action.EnglishAndArabicName = action.Name + "&nbsp;(" + action.ArabicName + ")";
1722:                          else action.EnglishAndArabicName = action.Name;
1723:   
1724:                          if (action.ColoredArabicName != string.Empty) action.ColoredEnglishAndArabicName = action.ColoredName + "&nbsp;(" + action.ColoredArabicName + ")";
1725:                          else action.ColoredEnglishAndArabicName = action.ColoredName;
1726:   
1727:                          if (x.Parent.Attribute("framework") != null)
1728:                          {
1729:                              action.Frameworks = new List<string>(100);
1730:   
1731:                              foreach (string s in x.Parent.Attribute("framework").Value.Split(',')) action.Frameworks.Add(s);
1732:                          }
1733:   
1734:                          actionList.Add(action);
1735:                      }
1736:   
1737:                      // below: add the general actions to all areas
1738:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area"))
1739:                      {
1740:                          foreach (XElement y in XDocument.Element("report").Elements("action"))
1741:                          {
1742:                              action = new Ia.Ngn.Cl.Model.Business.Report.Action();
1743:                              action.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1744:   
1745:                              categoryId = int.Parse(x.Parent.Attribute("id").Value);
1746:                              areaId = int.Parse(x.Attribute("id").Value);
1747:                              id = int.Parse(y.Attribute("id").Value); // y
1748:   
1749:                              areaId = action.Area.AreaId(categoryId, areaId);
1750:   
1751:                              action.Id = action.ActionId(areaId, id);
1752:                              action.XmlId = id;
1753:                              action.Area = null; // (from q in AreaList where q.Id == areaId select q).SingleOrDefault();
1754:   
1755:                              // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1756:                              if (y.Attribute("obsolete") != null) action.Obsolete = (y.Attribute("obsolete").Value == "true") ? true : false;
1757:                              else action.Obsolete = false;
1758:   
1759:                              // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1760:                              if (y.Attribute("canInsert") != null) action.CanInsert = (y.Attribute("canInsert").Value == "true") ? true : false;
1761:                              else action.CanInsert = true;
1762:   
1763:                              action.Color = (y.Attribute("color") != null) ? y.Attribute("color").Value : string.Empty;
1764:   
1765:                              // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1766:                              action.Name = y.Attribute("name").Value.Replace(" ", "&nbsp;");
1767:                              action.ColoredName = ColoredName(id, action.Name, action.Color);
1768:   
1769:                              if (y.Attribute("arabicName") != null && y.Attribute("arabicName").Value != string.Empty)
1770:                              {
1771:                                  action.ArabicName = y.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1772:                                  action.ColoredArabicName = ColoredName(id, action.ArabicName, action.Color);
1773:                              }
1774:                              else
1775:                              {
1776:                                  action.ArabicName = string.Empty;
1777:                                  action.ColoredArabicName = string.Empty;
1778:                              }
1779:   
1780:                              if (action.ArabicName != string.Empty) action.EnglishAndArabicName = action.Name + "&nbsp;(" + action.ArabicName + ")";
1781:                              else action.EnglishAndArabicName = action.Name;
1782:   
1783:                              if (action.ColoredArabicName != string.Empty) action.ColoredEnglishAndArabicName = action.ColoredName + "&nbsp;(" + action.ColoredArabicName + ")";
1784:                              else action.ColoredEnglishAndArabicName = action.ColoredName;
1785:   
1786:                              actionList.Add(action);
1787:                          }
1788:                      }
1789:                  }
1790:   
1791:                  return actionList;
1792:              }
1793:          }
1794:   
1795:          ////////////////////////////////////////////////////////////////////////////
1796:   
1797:          /// <summary>
1798:          ///
1799:          /// </summary>
1800:          public static List<Ia.Ngn.Cl.Model.Business.Report.Resolution> ResolutionList
1801:          {
1802:              get
1803:              {
1804:                  if (resolutionList == null || resolutionList.Count == 0)
1805:                  {
1806:                      int categoryId, areaId, id;
1807:                      Ia.Ngn.Cl.Model.Business.Report.Resolution resolution;
1808:   
1809:                      resolutionList = new List<Ia.Ngn.Cl.Model.Business.Report.Resolution>();
1810:   
1811:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area").Elements("resolutionList").Elements("resolution"))
1812:                      {
1813:                          resolution = new Ia.Ngn.Cl.Model.Business.Report.Resolution();
1814:                          resolution.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1815:   
1816:                          categoryId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1817:                          areaId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1818:                          id = int.Parse(x.Attribute("id").Value);
1819:   
1820:                          areaId = resolution.Area.AreaId(categoryId, areaId);
1821:   
1822:                          resolution.Id = resolution.ResolutionId(areaId, id);
1823:                          resolution.XmlId = id;
1824:                          resolution.Area = (from a in AreaList where a.Id == areaId select a).SingleOrDefault();
1825:   
1826:                          // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1827:                          if (x.Attribute("obsolete") != null) resolution.Obsolete = (x.Attribute("obsolete").Value == "true") ? true : false;
1828:                          else resolution.Obsolete = false;
1829:   
1830:                          // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1831:                          if (x.Attribute("canInsert") != null) resolution.CanInsert = (x.Attribute("canInsert").Value == "true") ? true : false;
1832:                          else resolution.CanInsert = true;
1833:   
1834:                          resolution.Color = (x.Attribute("color") != null) ? x.Attribute("color").Value : string.Empty;
1835:   
1836:                          // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1837:                          resolution.Name = x.Attribute("name").Value.Replace(" ", "&nbsp;");
1838:                          resolution.ColoredName = ColoredName(id, resolution.Name, resolution.Color);
1839:   
1840:                          if (x.Attribute("arabicName") != null && x.Attribute("arabicName").Value != string.Empty)
1841:                          {
1842:                              resolution.ArabicName = x.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1843:                              resolution.ColoredArabicName = ColoredName(id, resolution.ArabicName, resolution.Color);
1844:                          }
1845:                          else
1846:                          {
1847:                              resolution.ArabicName = string.Empty;
1848:                              resolution.ColoredArabicName = string.Empty;
1849:                          }
1850:   
1851:                          if (resolution.ArabicName != string.Empty) resolution.EnglishAndArabicName = resolution.Name + "&nbsp;(" + resolution.ArabicName + ")";
1852:                          else resolution.EnglishAndArabicName = resolution.Name;
1853:   
1854:                          if (resolution.ColoredArabicName != string.Empty) resolution.ColoredEnglishAndArabicName = resolution.ColoredName + "&nbsp;(" + resolution.ColoredArabicName + ")";
1855:                          else resolution.ColoredEnglishAndArabicName = resolution.ColoredName;
1856:   
1857:                          resolutionList.Add(resolution);
1858:                      }
1859:   
1860:                      // below: add the general resolutions to all areas
1861:                      foreach (XElement x in XDocument.Element("report").Elements("category").Elements("area"))
1862:                      {
1863:                          foreach (XElement y in XDocument.Element("report").Elements("resolution"))
1864:                          {
1865:                              resolution = new Ia.Ngn.Cl.Model.Business.Report.Resolution();
1866:                              resolution.Area = new Ia.Ngn.Cl.Model.Business.Report.Area();
1867:   
1868:                              categoryId = int.Parse(x.Parent.Attribute("id").Value);
1869:                              areaId = int.Parse(x.Attribute("id").Value);
1870:                              id = int.Parse(y.Attribute("id").Value); // y
1871:   
1872:                              areaId = resolution.Area.AreaId(categoryId, areaId);
1873:   
1874:                              resolution.Id = resolution.ResolutionId(areaId, id);
1875:                              resolution.XmlId = id;
1876:                              resolution.Area = (from a in AreaList where a.Id == areaId select a).SingleOrDefault();
1877:   
1878:                              // below: obsolete indicates weather the attribute is still used as a selection, but it must remain as a value of int in the storage
1879:                              if (y.Attribute("obsolete") != null) resolution.Obsolete = (y.Attribute("obsolete").Value == "true") ? true : false;
1880:                              else resolution.Obsolete = false;
1881:   
1882:                              // below: canInsert indicates weather the attribute is used as a selection, but it must remain as a value of int in the storage
1883:                              if (y.Attribute("canInsert") != null) resolution.CanInsert = (y.Attribute("canInsert").Value == "true") ? true : false;
1884:                              else resolution.CanInsert = true;
1885:   
1886:                              resolution.Color = (y.Attribute("color") != null) ? y.Attribute("color").Value : string.Empty;
1887:   
1888:                              // below: replace spaces ' ' with HTML fixed space "&nbsp;"
1889:                              resolution.Name = y.Attribute("name").Value.Replace(" ", "&nbsp;");
1890:                              resolution.ColoredName = ColoredName(id, resolution.Name, resolution.Color);
1891:   
1892:                              if (y.Attribute("arabicName") != null && y.Attribute("arabicName").Value != string.Empty)
1893:                              {
1894:                                  resolution.ArabicName = y.Attribute("arabicName").Value.Replace(" ", "&nbsp;");
1895:                                  resolution.ColoredArabicName = ColoredName(id, resolution.ArabicName, resolution.Color);
1896:                              }
1897:                              else
1898:                              {
1899:                                  resolution.ArabicName = string.Empty;
1900:                                  resolution.ColoredArabicName = string.Empty;
1901:                              }
1902:   
1903:                              if (resolution.ArabicName != string.Empty) resolution.EnglishAndArabicName = resolution.Name + "&nbsp;(" + resolution.ArabicName + ")";
1904:                              else resolution.EnglishAndArabicName = resolution.Name;
1905:   
1906:                              if (resolution.ColoredArabicName != string.Empty) resolution.ColoredEnglishAndArabicName = resolution.ColoredName + "&nbsp;(" + resolution.ColoredArabicName + ")";
1907:                              else resolution.ColoredEnglishAndArabicName = resolution.ColoredName;
1908:   
1909:                              resolutionList.Add(resolution);
1910:                          }
1911:                      }
1912:                  }
1913:   
1914:                  return resolutionList;
1915:              }
1916:          }
1917:   
1918:          ////////////////////////////////////////////////////////////////////////////
1919:          ////////////////////////////////////////////////////////////////////////////
1920:   
1921:          /// <summary>
1922:          /// 
1923:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
1924:          /// 
1925:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
1926:          /// 2. Add "using System.Reflection".
1927:          /// 3. See sample below.
1928:          /// 
1929:          /// </summary>
1930:   
1931:          public static XDocument XDocument
1932:          {
1933:              get
1934:              {
1935:                  if (xDocument == null)
1936:                  {
1937:                      Assembly _assembly;
1938:                      StreamReader streamReader;
1939:   
1940:                      _assembly = Assembly.GetExecutingAssembly();
1941:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.report.xml"));
1942:   
1943:                      try
1944:                      {
1945:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
1946:                      }
1947:                      catch (Exception)
1948:                      {
1949:                      }
1950:                      finally
1951:                      {
1952:                      }
1953:                  }
1954:   
1955:                  return xDocument;
1956:              }
1957:          }
1958:   
1959:          ////////////////////////////////////////////////////////////////////////////
1960:          ////////////////////////////////////////////////////////////////////////////    
1961:      }
1962:   
1963:      ////////////////////////////////////////////////////////////////////////////
1964:      ////////////////////////////////////////////////////////////////////////////   
1965:  }