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

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