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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Administration

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

Administration support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data;
   4:  using System.IO;
   5:  using System.Linq;
   6:  using System.Reflection;
   7:  using System.Web;
   8:  using System.Xml.Linq;
   9:   
  10:  namespace Ia.Ngn.Cl.Model.Data
  11:  {
  12:      ////////////////////////////////////////////////////////////////////////////
  13:   
  14:      /// <summary publish="true">
  15:      /// Administration support class for Next Generation Network (NGN) data model.
  16:      /// </summary>
  17:      /// 
  18:      /// <remarks> 
  19:      /// Copyright © 2006-2017 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 class Administration
  32:      {
  33:          private static XDocument xDocument;
  34:          private static List<Ia.Ngn.Cl.Model.Business.Administration.Framework> frameworkList;
  35:          private static List<Ia.Ngn.Cl.Model.Business.Administration.Category> categoryList;
  36:          private static List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> staffFrameworkList;
  37:          private static List<Ia.Ngn.Cl.Model.Business.Administration.StaffContact> staffContactList;
  38:          private static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> statisticList;
  39:   
  40:          private static readonly object objectLock = new object();
  41:   
  42:          ////////////////////////////////////////////////////////////////////////////
  43:   
  44:          /// <summary>
  45:          ///
  46:          /// </summary>
  47:          public Administration() { }
  48:   
  49:          ////////////////////////////////////////////////////////////////////////////
  50:   
  51:          /// <summary>
  52:          ///
  53:          /// </summary>
  54:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Framework> FrameworkList
  55:          {
  56:              get
  57:              {
  58:                  lock (objectLock)
  59:                  {
  60:                      if (frameworkList == null || frameworkList.Count == 0) frameworkList = Ia.Ngn.Cl.Model.Data.Administration._FrameworkList;
  61:   
  62:                      return frameworkList;
  63:                  }
  64:              }
  65:          }
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          private static List<Ia.Ngn.Cl.Model.Business.Administration.Framework> _FrameworkList
  73:          {
  74:              get
  75:              {
  76:                  int id, parentId;
  77:                  string arabicName, coloredArabicName, siteNameList;
  78:                  List<string> lightBackgroundColorList;
  79:                  Ia.Ngn.Cl.Model.Business.Administration.Framework framework;
  80:   
  81:                  frameworkList = new List<Ia.Ngn.Cl.Model.Business.Administration.Framework>(Ia.Ngn.Cl.Model.Business.Administration.InitialFrameworkListLength); // needed to prevent errors
  82:   
  83:                  lightBackgroundColorList = Ia.Ngn.Cl.Model.Ui.Default.LightBackgroundColorList;
  84:   
  85:                  foreach (XElement xe in XDocument.Element("administration").Element("frameworkList").Descendants("framework"))
  86:                  {
  87:                      id = int.Parse(XmlBasedTwoDigitPerId(xe));
  88:                      parentId = Ia.Ngn.Cl.Model.Business.Administration.Framework.ParentId(id);
  89:                      arabicName = xe.Attribute("arabicName").Value;
  90:                      coloredArabicName = @"<span style=""color:" + lightBackgroundColorList[id % lightBackgroundColorList.Count] + @""">" + arabicName + "</span>";
  91:   
  92:                      framework = new Ia.Ngn.Cl.Model.Business.Administration.Framework();
  93:   
  94:                      framework.Id = id;
  95:                      framework.Level = xe.Ancestors().Count();
  96:                      framework.Guid = Guid.Parse(xe.Attribute("guid").Value);
  97:                      framework.Type = xe.Attribute("type").Value;
  98:                      framework.Name = xe.Attribute("name").Value;
  99:                      framework.ArabicName = arabicName;
 100:                      framework.ColoredArabicName = coloredArabicName;
 101:   
 102:                      if (xe.Attribute("siteNameList") != null && !string.IsNullOrEmpty(xe.Attribute("siteNameList").Value))
 103:                      {
 104:                          siteNameList = xe.Attribute("siteNameList").Value;
 105:                          framework.Sites = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where siteNameList.Contains(s.Name) select s).ToList();
 106:                      }
 107:                      else if (xe.Parent.Attribute("siteNameList") != null && !string.IsNullOrEmpty(xe.Parent.Attribute("siteNameList").Value))
 108:                      {
 109:                          siteNameList = xe.Parent.Attribute("siteNameList").Value;
 110:                          framework.Sites = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where siteNameList.Contains(s.Name) select s).ToList();
 111:                      }
 112:                      else framework.Sites = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
 113:   
 114:                      frameworkList.Add(framework);
 115:                  }
 116:   
 117:                  // Parents, authorities and children
 118:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework f in frameworkList)
 119:                  {
 120:                      parentId = Ia.Ngn.Cl.Model.Business.Administration.Framework.ParentId(f.Id);
 121:   
 122:                      /*
 123:  [InvalidOperationException: Sequence contains more than one element]
 124:  System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +348
 125:  Ia.Ngn.Cl.Model.Data.Administration.get__FrameworkList() in C:\Users\Jasem\Documents\Visual Studio 2019\Projects\Next Generation Network\cl\model\data\administration.cs:343                                 
 126:  */
 127:                      f.Parent = (from _f in frameworkList where _f.Id == parentId select _f).SingleOrDefault();
 128:   
 129:                      //HttpContext.Current.Response.Write("[" + f.ArabicName + "]" + "[" + ex.Message + "]" + "[count: " + frameworkList.Count + "]");
 130:   
 131:                      //f.Authorities = (from a in AuthorityList where a.AllowedFrameworkArabicName == f.ArabicName select a).ToList();
 132:   
 133:                      f.Children = new List<Ia.Ngn.Cl.Model.Business.Administration.Framework>();
 134:   
 135:                      if (f.Parent != null) f.Parent.Children.Add(f);
 136:                  }
 137:   
 138:                  // below: Siblings
 139:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework f in frameworkList.ToList())
 140:                  {
 141:                      f.Siblings = new List<Ia.Ngn.Cl.Model.Business.Administration.Framework>();
 142:   
 143:                      f.Siblings = (from _f in frameworkList where _f.Parent == f.Parent && _f.Id != f.Id select _f).ToList();
 144:                  }
 145:   
 146:                  // below: Descendants
 147:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework f in frameworkList.ToList())
 148:                  {
 149:                      f.Descendants = new List<Ia.Ngn.Cl.Model.Business.Administration.Framework>();
 150:   
 151:                      f.Descendants = (from _f in frameworkList
 152:                                       where _f.Id != f.Id && _f.Id > f.Id &&
 153:                                           (_f.Parent != null && (_f.Parent == f
 154:                                           || _f.Parent.Parent != null && (_f.Parent.Parent == f
 155:                                           || _f.Parent.Parent.Parent != null && (_f.Parent.Parent.Parent == f
 156:                                           || _f.Parent.Parent.Parent.Parent != null && _f.Parent.Parent.Parent.Parent == f)))
 157:                                           )
 158:                                       select _f).ToList();
 159:                  }
 160:   
 161:                  // below: Ancestors
 162:                  foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework f in frameworkList.ToList())
 163:                  {
 164:                      f.Ancestors = new List<Ia.Ngn.Cl.Model.Business.Administration.Framework>();
 165:   
 166:                      f.Ancestors = (from _f in frameworkList
 167:                                     where _f.Id != f.Id && _f.Id < f.Id &&
 168:                                         (f.Parent != null && (f.Parent == _f
 169:                                         || f.Parent.Parent != null && (f.Parent.Parent == _f
 170:                                         || f.Parent.Parent.Parent != null && (f.Parent.Parent.Parent == _f
 171:                                         || f.Parent.Parent.Parent.Parent != null && f.Parent.Parent.Parent.Parent == _f)))
 172:                                         )
 173:                                     select _f).ToList();
 174:                  }
 175:   
 176:                  //list = (from q in list select q).OrderByDescending(c => c.IsHead).ThenBy(c => c.AdministrativeFrameworkId);
 177:   
 178:                  //frameworkList = (from q in frameworkList select q).OrderBy(c => c.Id); //.ThenBy(c => c.ParentId);
 179:   
 180:                  return frameworkList.ToList();
 181:              }
 182:          }
 183:   
 184:          ////////////////////////////////////////////////////////////////////////////
 185:   
 186:          /// <summary>
 187:          ///
 188:          /// </summary>
 189:          private static string XmlBasedOneDigitPerId(XElement xeIn)
 190:          {
 191:              return XmlBasedId(xeIn, 1);
 192:          }
 193:   
 194:          ////////////////////////////////////////////////////////////////////////////
 195:   
 196:          /// <summary>
 197:          ///
 198:          /// </summary>
 199:          private static string XmlBasedTwoDigitPerId(XElement xeIn)
 200:          {
 201:              return XmlBasedId(xeIn, 2);
 202:          }
 203:   
 204:          ////////////////////////////////////////////////////////////////////////////
 205:   
 206:          /// <summary>
 207:          ///
 208:          /// </summary>
 209:          private static string XmlBasedId(XElement xe, int digit)
 210:          {
 211:              string id;
 212:   
 213:              id = string.Empty;
 214:   
 215:              while (xe.HasAttributes && xe.Attribute("id") != null)
 216:              {
 217:                  id = xe.Attribute("id").Value.PadLeft(digit, '0') + id;
 218:                  xe = xe.Parent;
 219:              }
 220:   
 221:              return id;
 222:          }
 223:   
 224:          ////////////////////////////////////////////////////////////////////////////
 225:   
 226:          /// <summary>
 227:          ///
 228:          /// </summary>
 229:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Category> CategoryList
 230:          {
 231:              get
 232:              {
 233:                  lock (objectLock)
 234:                  {
 235:                      if (categoryList == null || categoryList.Count == 0) categoryList = Ia.Ngn.Cl.Model.Data.Administration._CategoryList;
 236:   
 237:                      return categoryList;
 238:                  }
 239:              }
 240:          }
 241:   
 242:          ////////////////////////////////////////////////////////////////////////////
 243:   
 244:          /// <summary>
 245:          ///
 246:          /// </summary>
 247:          private static List<Ia.Ngn.Cl.Model.Business.Administration.Category> _CategoryList
 248:          {
 249:              get
 250:              {
 251:                  Ia.Ngn.Cl.Model.Business.Administration.Category category;
 252:   
 253:                  categoryList = new List<Ia.Ngn.Cl.Model.Business.Administration.Category>();
 254:   
 255:                  foreach (XElement xe in XDocument.Element("administration").Elements("category"))
 256:                  {
 257:                      category = new Ia.Ngn.Cl.Model.Business.Administration.Category()
 258:                      {
 259:                          Name = xe.Attribute("name").Value,
 260:                          Regex = xe.Attribute("regex").Value,
 261:                          Description = (xe.Attribute("description") != null) ? xe.Attribute("description").Value : string.Empty,
 262:                          Color = (xe.Attribute("color") != null) ? xe.Attribute("color").Value : string.Empty
 263:                      };
 264:   
 265:                      categoryList.Add(category);
 266:                  }
 267:   
 268:                  return categoryList.ToList();
 269:              }
 270:          }
 271:   
 272:          ////////////////////////////////////////////////////////////////////////////
 273:   
 274:          /// <summary>
 275:          ///
 276:          /// </summary>
 277:          public static List<Ia.Ngn.Cl.Model.Business.Administration.StaffContact> StaffContactList
 278:          {
 279:              get
 280:              {
 281:                  lock (objectLock)
 282:                  {
 283:                      if (staffContactList == null || staffContactList.Count == 0) staffContactList = Ia.Ngn.Cl.Model.Data.Administration._StaffContactList;
 284:   
 285:                      return staffContactList;
 286:                  }
 287:              }
 288:          }
 289:   
 290:          ////////////////////////////////////////////////////////////////////////////
 291:   
 292:          /// <summary>
 293:          ///
 294:          /// </summary>
 295:          private static List<Ia.Ngn.Cl.Model.Business.Administration.StaffContact> _StaffContactList
 296:          {
 297:              get
 298:              {
 299:                  Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
 300:                  List<Ia.Ngn.Cl.Model.Business.Administration.StaffContact> staffContactList;
 301:   
 302:                  staffContactList = new List<Ia.Ngn.Cl.Model.Business.Administration.StaffContact>();
 303:   
 304:                  foreach (Ia.Ngn.Cl.Model.Staff staff in Ia.Ngn.Cl.Model.Data.Staff.List)
 305:                  {
 306:                      if (staff.User != null && staff.User.Email != null)
 307:                      {
 308:                          staffContact = new Ia.Ngn.Cl.Model.Business.Administration.StaffContact() { Staff = staff };
 309:   
 310:                          staffContactList.Add(staffContact);
 311:                      }
 312:                  }
 313:   
 314:                  foreach (Ia.Ngn.Cl.Model.Contact contact in Ia.Ngn.Cl.Model.Data.Contact.List)
 315:                  {
 316:                      if (contact.Email != null)
 317:                      {
 318:                          staffContact = new Ia.Ngn.Cl.Model.Business.Administration.StaffContact() { Contact = contact };
 319:   
 320:                          staffContactList.Add(staffContact);
 321:                      }
 322:                  }
 323:   
 324:                  return staffContactList.ToList();
 325:              }
 326:          }
 327:   
 328:          ////////////////////////////////////////////////////////////////////////////
 329:   
 330:          /// <summary>
 331:          ///
 332:          /// </summary>
 333:          public static List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> StaffFrameworkList
 334:          {
 335:              get
 336:              {
 337:                  lock (objectLock)
 338:                  {
 339:                      if (staffFrameworkList == null || staffFrameworkList.Count == 0) staffFrameworkList = Ia.Ngn.Cl.Model.Data.Administration._StaffFrameworkList;
 340:   
 341:                      return staffFrameworkList;
 342:                  }
 343:              }
 344:          }
 345:   
 346:          ////////////////////////////////////////////////////////////////////////////
 347:   
 348:          /// <summary>
 349:          ///
 350:          /// </summary>
 351:          private static List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> _StaffFrameworkList
 352:          {
 353:              get
 354:              {
 355:                  List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> staffList, frameworkList;
 356:   
 357:                  staffList = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
 358:                               select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
 359:                               {
 360:                                   Guid = s.UserId,
 361:                                   FrameworkId = s.Framework.Id,
 362:                                   IsStaff = true,
 363:                                   Name = s.FirstAndMiddleName
 364:                               }
 365:                  ).ToList();
 366:   
 367:                  frameworkList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
 368:                                   select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
 369:                                   {
 370:                                       Guid = f.Guid,
 371:                                       FrameworkId = f.Id,
 372:                                       IsFramework = true,
 373:                                       Name = f.FullyQualifiedArabicName //.ArabicName
 374:                                   }
 375:                  ).ToList();
 376:   
 377:                  staffFrameworkList = staffList.Union(frameworkList).ToList();
 378:   
 379:                  return staffFrameworkList.ToList();
 380:              }
 381:          }
 382:   
 383:          ////////////////////////////////////////////////////////////////////////////
 384:          ////////////////////////////////////////////////////////////////////////////
 385:   
 386:          /// <summary>
 387:          ///
 388:          /// </summary>
 389:          public static int ServiceRequestServicesWithNullAccessCount()
 390:          {
 391:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 392:              {
 393:                  return (from srs in db.ServiceRequestServices where srs.Access == null select srs.Id).Count();
 394:              }
 395:          }
 396:   
 397:          ////////////////////////////////////////////////////////////////////////////
 398:   
 399:          /// <summary>
 400:          ///
 401:          /// </summary>
 402:          public static int ServicesWithNullAccessCount()
 403:          {
 404:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 405:              {
 406:                  return (from s in db.Service2s
 407:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
 408:                          select s.Id).Count();
 409:              }
 410:          }
 411:   
 412:          ////////////////////////////////////////////////////////////////////////////
 413:   
 414:          /// <summary>
 415:          ///
 416:          /// </summary>
 417:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> ServiceAccessStatisticWithinKuwaitNgnAreaCachedDaily
 418:          {
 419:              get
 420:              {
 421:                  if (statisticList == null || statisticList.Count == 0)
 422:                  {
 423:                      if (HttpContext.Current != null && HttpContext.Current.Application["statisticList" + DateTime.Now.Day] != null)
 424:                      {
 425:                          statisticList = HttpContext.Current.Application["statisticList" + DateTime.Now.Day] as List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea>;
 426:                      }
 427:                      else
 428:                      {
 429:                          lock (objectLock)
 430:                          {
 431:                              statisticList = null;
 432:                              statisticList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnArea();
 433:   
 434:                              if (HttpContext.Current != null) HttpContext.Current.Application["statisticList" + DateTime.Now.Day] = statisticList;
 435:                          }
 436:                      }
 437:                  }
 438:   
 439:                  return statisticList;
 440:              }
 441:          }
 442:   
 443:          ////////////////////////////////////////////////////////////////////////////
 444:   
 445:          /// <summary>
 446:          ///
 447:          /// </summary>
 448:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> ServiceAccessStatisticWithinKuwaitNgnArea()
 449:          {
 450:              if (statisticList == null || statisticList.Count == 0)
 451:              {
 452:                  int fourDigitDomain, fiveDigitDomain;
 453:                  int totalService, totalNokiaService, totalHuaweiService, totalServiceRequestService, totalAccessCapacity, totalNokiaOnt, totalHuaweiOnt, totalNokiaAccess, totalHuaweiAccess, totalAccessReadyForService;
 454:                  Dictionary<string, int> accessIdToKuwaitNgnAreaIdDictionary, accessIdToOdfIdDictionary, accessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary;
 455:                  Dictionary<string, string> serviceRequestServiceProvisionedServiceIdToAccessIdDictionary, serviceIdToAccessIdDictionary, ontIdToAccessIdDictionary;
 456:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 457:                  Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea kuwaitAreaStatistic;
 458:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 459:                  List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 460:                  List<Ia.Ngn.Cl.Model.Ont> ontList;
 461:                  List<Ia.Ngn.Cl.Model.Huawei.EmsOnt> emsOntList;
 462:                  List<Ia.Ngn.Cl.Model.Access> accessList;
 463:                  List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> kuwaitNgnAreaList;
 464:   
 465:                  statisticList = new List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea>();
 466:                  statisticList.Clear();
 467:   
 468:                  totalService = totalNokiaService = totalHuaweiService = totalServiceRequestService = totalAccessCapacity = totalNokiaOnt = totalHuaweiOnt = totalNokiaAccess = totalHuaweiAccess = totalAccessReadyForService = totalService = totalServiceRequestService = 0;
 469:   
 470:                  //kuwaitNgnAreaList = new List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>(); // I need to clear it because I add an item in it below
 471:                  kuwaitNgnAreaList = Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList;
 472:   
 473:                  //nddOntList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList;
 474:                  //ontIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdToAccessIdDictionary;
 475:   
 476:                  ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ListIncludeAccess();
 477:                  emsOntList = Ia.Ngn.Cl.Model.Data.Huawei.Ont.ListIncludeAccess();
 478:                  accessList = Ia.Ngn.Cl.Model.Data.Access.List();
 479:                  accessIdToOdfIdDictionary = Ia.Ngn.Cl.Model.Data.Access.IdToOltIdDictionary;
 480:   
 481:                  //serviceToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceIdToAccessIdDictionary;
 482:                  accessIdToKuwaitNgnAreaIdDictionary = Ia.Ngn.Cl.Model.Data.Access.IdToKuwaitNgnAreaIdDictionary;
 483:   
 484:                  serviceRequestServiceProvisionedServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceIdToAccessIdDictionary;
 485:                  serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessIdDictionary;
 486:   
 487:                  accessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary = Ia.Ngn.Cl.Model.Data.Access.AccessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary;
 488:   
 489:                  var domainToRouterVendorDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.DomainToRouterVendorDictionary;
 490:   
 491:                  var unknown = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea("Unknown", "غير معرف");
 492:   
 493:                  //ontIdToOltIdDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOltIdDictionary;
 494:   
 495:                  // - ONT capacity, usage, # of services in an ONT, type of ONT
 496:                  // - Graphics
 497:                  /*
 498:                  update statistics
 499:      Vendor,
 500:      number perfix,
 501:      4 in ONT,
 502:      0 in ONT,
 503:      Acces: ONT used by subscribers
 504:      */
 505:   
 506:                  foreach (var kna in kuwaitNgnAreaList)
 507:                  {
 508:                      kuwaitAreaStatistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea();
 509:   
 510:                      kuwaitAreaStatistic.Name = kna.NameArabicName;
 511:   
 512:                      kuwaitAreaStatistic.Symbol = kna.Symbol;
 513:   
 514:                      kuwaitAreaStatistic.ServiceRequestService = 0;
 515:   
 516:                      kuwaitAreaStatistic.NokiaService = 0;
 517:                      kuwaitAreaStatistic.HuaweiService = 0;
 518:                      kuwaitAreaStatistic.Service = 0;
 519:   
 520:                      foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
 521:                      {
 522:                          if (accessIdToKuwaitNgnAreaIdDictionary.ContainsKey(kvp.Value))
 523:                          {
 524:                              if (accessIdToKuwaitNgnAreaIdDictionary[kvp.Value] == kna.Id)
 525:                              {
 526:                                  kuwaitAreaStatistic.Service++;
 527:   
 528:                                  fiveDigitDomain = int.Parse(kvp.Key.Substring(0, 5));
 529:   
 530:                                  if (domainToRouterVendorDictionary.ContainsKey(fiveDigitDomain)) vendor = domainToRouterVendorDictionary[fiveDigitDomain];
 531:                                  else
 532:                                  {
 533:                                      fourDigitDomain = int.Parse(kvp.Key.Substring(0, 4));
 534:   
 535:                                      if (domainToRouterVendorDictionary.ContainsKey(fourDigitDomain))
 536:                                      {
 537:                                          vendor = domainToRouterVendorDictionary[fourDigitDomain];
 538:                                      }
 539:                                      else vendor = null;
 540:                                  }
 541:   
 542:                                  if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) kuwaitAreaStatistic.NokiaService++;
 543:                                  else if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei) kuwaitAreaStatistic.HuaweiService++;
 544:                                  else
 545:                                  {
 546:                                      unknown.Service++;
 547:   
 548:                                      //throw new Exception("Vendor is unknown");
 549:                                  }
 550:   
 551:                              }
 552:                          }
 553:                      }
 554:   
 555:                      kuwaitAreaStatistic.NokiaHuaweiService = (kuwaitAreaStatistic.NokiaService + kuwaitAreaStatistic.HuaweiService) + " (" + kuwaitAreaStatistic.NokiaService + "/" + kuwaitAreaStatistic.HuaweiService + ")";
 556:   
 557:   
 558:                      foreach (KeyValuePair<string, string> kvp in serviceRequestServiceProvisionedServiceIdToAccessIdDictionary)
 559:                      {
 560:                          if (accessIdToKuwaitNgnAreaIdDictionary.ContainsKey(kvp.Value))
 561:                          {
 562:                              if (accessIdToKuwaitNgnAreaIdDictionary[kvp.Value] == kna.Id)
 563:                              {
 564:                                  kuwaitAreaStatistic.ServiceRequestService++;
 565:                              }
 566:                          }
 567:                      }
 568:   
 569:                      //statistic.SiteAccessCapacity = kna.Site.Routers.SelectMany(x => x.Odfs.SelectMany(y => y.Olts)).Count() * 1024;
 570:                      //statistic.SiteAccessCapacity = f.Sum(u => kna.Site.Routers.Any(x => x.Odfs.Any(y => y.Olts.Any(z => z.Id == u.Value)))) * 1024;
 571:                      //kuwaitAreaStatistic.AccessProvisioned = accessIdToKuwaitNgnAreaIdDictionary.Count(u => u.Value == kna.Id);
 572:                      //kuwaitAreaStatistic.AccessUtilized = 0;
 573:   
 574:                      // below: this does not include SSR accesses for area
 575:                      kuwaitAreaStatistic.AccessCapacity = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Symbol == kna.Symbol select o).Sum(o => o.NumberOfPons * o.NumberOfOntsInPon); ;
 576:   
 577:                      kuwaitAreaStatistic.NokiaOnt = 0;
 578:                      kuwaitAreaStatistic.HuaweiOnt = 0;
 579:   
 580:                      foreach (var o in ontList)
 581:                      {
 582:                          if (o.Access != null)
 583:                          {
 584:                              if (accessIdToKuwaitNgnAreaIdDictionary.ContainsKey(o.Access.Id))
 585:                              {
 586:                                  if (accessIdToKuwaitNgnAreaIdDictionary[o.Access.Id] == kna.Id)
 587:                                  {
 588:                                      kuwaitAreaStatistic.NokiaOnt++;
 589:                                  }
 590:                              }
 591:                          }
 592:                          else
 593:                          {
 594:                          }
 595:                      }
 596:   
 597:                      foreach (var o in emsOntList)
 598:                      {
 599:                          if (o.Access != null)
 600:                          {
 601:                              if (accessIdToKuwaitNgnAreaIdDictionary.ContainsKey(o.Access.Id))
 602:                              {
 603:                                  if (accessIdToKuwaitNgnAreaIdDictionary[o.Access.Id] == kna.Id)
 604:                                  {
 605:                                      kuwaitAreaStatistic.HuaweiOnt++;
 606:                                  }
 607:                              }
 608:                          }
 609:                          else
 610:                          {
 611:                          }
 612:                      }
 613:   
 614:                      kuwaitAreaStatistic.NokiaHuaweiOnt = (kuwaitAreaStatistic.NokiaOnt + kuwaitAreaStatistic.HuaweiOnt) + " (" + kuwaitAreaStatistic.NokiaOnt + "/" + kuwaitAreaStatistic.HuaweiOnt + ")";
 615:   
 616:                      kuwaitAreaStatistic.NokiaAccess = 0;
 617:                      kuwaitAreaStatistic.HuaweiAccess = 0;
 618:   
 619:                      foreach (var a in accessList)
 620:                      {
 621:                          if (accessIdToKuwaitNgnAreaIdDictionary[a.Id] == kna.Id)
 622:                          {
 623:                              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == accessIdToOdfIdDictionary[a.Id] select o).SingleOrDefault();
 624:   
 625:                              if (olt != null)
 626:                              {
 627:                                  // <vendor id="1" name="Nokia" shortName="No" ... />
 628:                                  if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) kuwaitAreaStatistic.NokiaAccess++;
 629:   
 630:                                  // <vendor id="2" name="Huawei" shortName="Hu" ... />
 631:                                  else if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei) kuwaitAreaStatistic.HuaweiAccess++;
 632:                              }
 633:                              else
 634:                              {
 635:   
 636:                              }
 637:                          }
 638:                      }
 639:   
 640:                      kuwaitAreaStatistic.NokiaHuaweiAccess = (kuwaitAreaStatistic.NokiaAccess + kuwaitAreaStatistic.HuaweiAccess) + " (" + kuwaitAreaStatistic.NokiaAccess + "/" + kuwaitAreaStatistic.HuaweiAccess + ")";
 641:   
 642:   
 643:                      kuwaitAreaStatistic.AccessReadyForService = 0;
 644:   
 645:                      foreach (var a in accessList)
 646:                      {
 647:                          if (accessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary.ContainsKey(a.Id))
 648:                          {
 649:                              if (accessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary[a.Id] == kna.Id)
 650:                              {
 651:                                  kuwaitAreaStatistic.AccessReadyForService++;
 652:                              }
 653:                          }
 654:                      }
 655:   
 656:                      // totals:
 657:                      totalService += kuwaitAreaStatistic.Service;
 658:   
 659:                      totalNokiaService += kuwaitAreaStatistic.NokiaService;
 660:                      totalHuaweiService += kuwaitAreaStatistic.HuaweiService;
 661:   
 662:                      totalServiceRequestService += kuwaitAreaStatistic.ServiceRequestService;
 663:   
 664:                      totalAccessCapacity += kuwaitAreaStatistic.AccessCapacity;
 665:   
 666:                      totalNokiaOnt += kuwaitAreaStatistic.NokiaOnt;
 667:                      totalHuaweiOnt += kuwaitAreaStatistic.HuaweiOnt;
 668:   
 669:                      totalNokiaAccess += kuwaitAreaStatistic.NokiaAccess;
 670:                      totalHuaweiAccess += kuwaitAreaStatistic.HuaweiAccess;
 671:   
 672:                      totalAccessReadyForService += kuwaitAreaStatistic.AccessReadyForService;
 673:   
 674:                      statisticList.Add(kuwaitAreaStatistic);
 675:                  }
 676:   
 677:                  statisticList.Add(unknown);
 678:   
 679:                  // totals:
 680:                  kuwaitAreaStatistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea();
 681:   
 682:                  kuwaitAreaStatistic.Name = "Total";
 683:   
 684:                  kuwaitAreaStatistic.Service = totalService;
 685:                  kuwaitAreaStatistic.NokiaService = totalNokiaService;
 686:                  kuwaitAreaStatistic.HuaweiService = totalHuaweiService;
 687:                  kuwaitAreaStatistic.NokiaHuaweiService = (kuwaitAreaStatistic.NokiaService + kuwaitAreaStatistic.HuaweiService) + " (" + kuwaitAreaStatistic.NokiaService + "/" + kuwaitAreaStatistic.HuaweiService + ")";
 688:   
 689:   
 690:                  kuwaitAreaStatistic.ServiceRequestService = totalServiceRequestService;
 691:   
 692:                  kuwaitAreaStatistic.AccessCapacity = totalAccessCapacity;
 693:   
 694:                  kuwaitAreaStatistic.NokiaOnt = totalNokiaOnt;
 695:                  kuwaitAreaStatistic.HuaweiOnt = totalHuaweiOnt;
 696:                  kuwaitAreaStatistic.NokiaHuaweiOnt = (totalNokiaOnt + totalHuaweiOnt) + " (" + totalNokiaOnt + "/" + totalHuaweiOnt + ")";
 697:   
 698:                  kuwaitAreaStatistic.NokiaAccess = totalNokiaAccess;
 699:                  kuwaitAreaStatistic.HuaweiAccess = totalHuaweiAccess;
 700:                  kuwaitAreaStatistic.NokiaHuaweiAccess = (totalNokiaAccess + totalHuaweiAccess) + " (" + totalNokiaAccess + "/" + totalHuaweiAccess + ")";
 701:   
 702:                  kuwaitAreaStatistic.AccessReadyForService = totalAccessReadyForService;
 703:   
 704:                  statisticList.Add(kuwaitAreaStatistic);
 705:              }
 706:   
 707:              return statisticList;
 708:          }
 709:   
 710:          ////////////////////////////////////////////////////////////////////////////
 711:   
 712:          /// <summary>
 713:          ///
 714:          /// </summary>
 715:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> SiteStatistic()
 716:          {
 717:              int siteId;
 718:              int totalAccessCapacity, totalServiceCapacity, totalService, totalNokiaService, totalHuaweiService;
 719:              int fourDigitDomain, fiveDigitDomain;
 720:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 721:              Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site siteStatistic;
 722:              //List<Ia.Ngn.Cl.Model.Access> mainAccessList;//, accessList;
 723:              //List<Ia.Ngn.Cl.Model.Ont> mainOntList;//, ontList;
 724:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> siteStatisticList;
 725:   
 726:              siteStatisticList = new List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site>();
 727:   
 728:              totalAccessCapacity = totalServiceCapacity = totalService = totalNokiaService = totalHuaweiService = 0;
 729:   
 730:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 731:              {
 732:                  //mainAccessList = (from a in db.Accesses select a).ToList();
 733:                  //mainOntList = (from o in db.Onts select o).ToList();
 734:   
 735:                  var idToKuwaitNgnAreaIdDictionary = Ia.Ngn.Cl.Model.Data.Access.IdToKuwaitNgnAreaIdDictionary;
 736:                  var areaIdToSiteIdDictionary = Ia.Ngn.Cl.Model.Data.Service.AreaIdToSiteIdDictionary;
 737:   
 738:                  var serviceServiceToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessIdDictionary;
 739:   
 740:                  var domainToRouterVendorDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.DomainToRouterVendorDictionary;
 741:   
 742:                  var unknown = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site(); // ("Unknown", );
 743:                  unknown.Name = "Unknown (غير معرف)";
 744:   
 745:                  // site
 746:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList)
 747:                  {
 748:                      siteStatistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site();
 749:   
 750:                      siteId = site.Id;
 751:                      siteStatistic.Id = site.Id.ToString();
 752:                      siteStatistic.Name = site.NameArabicName;
 753:   
 754:                      foreach (Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea in site.KuwaitNgnAreas) siteStatistic.KuwaitAreaNameListString += kuwaitNgnArea.ArabicName + ", ";
 755:                      if (siteStatistic.KuwaitAreaNameListString != null && siteStatistic.KuwaitAreaNameListString.Length > 0) siteStatistic.KuwaitAreaNameListString = siteStatistic.KuwaitAreaNameListString.Trim(',', ' ');
 756:   
 757:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router in site.Routers) siteStatistic.DomainListString += router.DomainListString + ",";
 758:                      if (siteStatistic.DomainListString != null && siteStatistic.DomainListString.Length > 0) siteStatistic.DomainListString = siteStatistic.DomainListString.Trim(',', ' ');
 759:   
 760:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
 761:                      {
 762:                          if (olt.Odf.Router.Site.Id == siteId)
 763:                          {
 764:                              if (string.IsNullOrEmpty(siteStatistic.SymbolListString) || !siteStatistic.SymbolListString.Contains(olt.Symbol)) siteStatistic.SymbolListString += olt.Symbol + ", ";
 765:                          }
 766:                      }
 767:   
 768:                      if (siteStatistic.SymbolListString != null && siteStatistic.SymbolListString.Length > 0) siteStatistic.SymbolListString = siteStatistic.SymbolListString.Trim(',', ' ');
 769:   
 770:                      siteStatistic.AccessCapacity = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf.Router.Site.Id == siteId select o).Sum(o => o.NumberOfPons * o.NumberOfOntsInPon);
 771:                      siteStatistic.ServiceCapacity = site.NumberOfPossibleServicesWithinDomainList;
 772:   
 773:                      siteStatistic.Service = 0;
 774:   
 775:                      foreach (KeyValuePair<string, string> kvp in serviceServiceToAccessIdDictionary)
 776:                      {
 777:                          if (idToKuwaitNgnAreaIdDictionary.ContainsKey(kvp.Value))
 778:                          {
 779:                              if (areaIdToSiteIdDictionary.ContainsKey(idToKuwaitNgnAreaIdDictionary[kvp.Value]))
 780:                              {
 781:                                  if (areaIdToSiteIdDictionary[idToKuwaitNgnAreaIdDictionary[kvp.Value]] == site.Id)
 782:                                  {
 783:                                      siteStatistic.Service++;
 784:   
 785:                                      fiveDigitDomain = int.Parse(kvp.Key.Substring(0, 5));
 786:   
 787:                                      if (domainToRouterVendorDictionary.ContainsKey(fiveDigitDomain)) vendor = domainToRouterVendorDictionary[fiveDigitDomain];
 788:                                      else
 789:                                      {
 790:                                          fourDigitDomain = int.Parse(kvp.Key.Substring(0, 4));
 791:   
 792:                                          if (domainToRouterVendorDictionary.ContainsKey(fourDigitDomain))
 793:                                          {
 794:                                              vendor = domainToRouterVendorDictionary[fourDigitDomain];
 795:                                          }
 796:                                          else vendor = null;
 797:                                      }
 798:   
 799:                                      if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) siteStatistic.NokiaService++;
 800:                                      else if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei) siteStatistic.HuaweiService++;
 801:                                      else
 802:                                      {
 803:                                          unknown.Service++;
 804:   
 805:                                          //throw new Exception("Vendor is unknown");
 806:                                      }
 807:   
 808:   
 809:                                  }
 810:                              }
 811:                          }
 812:                      }
 813:   
 814:                      siteStatistic.NokiaHuaweiService = (siteStatistic.NokiaService + siteStatistic.HuaweiService) + " (" + siteStatistic.NokiaService + "/" + siteStatistic.HuaweiService + ")";
 815:   
 816:                      // totals:
 817:                      totalService += siteStatistic.Service;
 818:   
 819:                      totalNokiaService += siteStatistic.NokiaService;
 820:                      totalHuaweiService += siteStatistic.HuaweiService;
 821:   
 822:                      totalAccessCapacity += siteStatistic.AccessCapacity;
 823:                      totalServiceCapacity += siteStatistic.ServiceCapacity;
 824:   
 825:   
 826:                      siteStatisticList.Add(siteStatistic);
 827:                  }
 828:   
 829:                  siteStatisticList.Add(unknown);
 830:   
 831:                  // below: last totals row
 832:                  siteStatistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site();
 833:   
 834:                  siteStatistic.Name = "Total";
 835:   
 836:                  siteStatistic.Service = totalService;
 837:                  siteStatistic.NokiaService = totalNokiaService;
 838:                  siteStatistic.HuaweiService = totalHuaweiService;
 839:                  siteStatistic.NokiaHuaweiService = (siteStatistic.NokiaService + siteStatistic.HuaweiService) + " (" + siteStatistic.NokiaService + "/" + siteStatistic.HuaweiService + ")";
 840:   
 841:                  siteStatistic.AccessCapacity = totalAccessCapacity;
 842:                  siteStatistic.ServiceCapacity = totalServiceCapacity;
 843:   
 844:                  siteStatisticList.Add(siteStatistic);
 845:              }
 846:   
 847:              return siteStatisticList;
 848:          }
 849:   
 850:          /*
 851:          ////////////////////////////////////////////////////////////////////////////
 852:  
 853:          /// <summary>
 854:          ///
 855:          /// </summary>
 856:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> OdfStatistic()
 857:          {
 858:              Ia.Ngn.Cl.Model.Business.Administration.Statistic statistic;
 859:              List<Ia.Ngn.Cl.Model.Access> mainAccessList, accessList;
 860:              List<Ia.Ngn.Cl.Model.Ont> mainOntList, ontList;
 861:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> statisticList;
 862:  
 863:              statisticList = new List<Ia.Ngn.Cl.Model.Business.Administration.Statistic>();
 864:  
 865:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 866:              {
 867:                  mainAccessList = (from a in db.Accesses select a).ToList();
 868:                  mainOntList = (from o in db.Onts select o).ToList();
 869:  
 870:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList)
 871:                  {
 872:                      statistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic();
 873:  
 874:                      statistic.Id = odf.Id.ToString();
 875:                      statistic.Name = odf.Name;
 876:                      statistic.Site = odf.Router.Site.NameArabicName;
 877:                      statistic.Symbol = odf.Name;
 878:  
 879:                      accessList = (from a in mainAccessList where a.Odf == odf.Id.ToString() select a).ToList();
 880:                      ontList = (from o in mainOntList where o.Access != null && o.Access.Odf == odf.Id.ToString() select o).ToList();
 881:  
 882:                      foreach (Ia.Ngn.Cl.Model.Access access in accessList)
 883:                      {
 884:                      }
 885:  
 886:                      statistic.AccessCapacity = 1024;
 887:                      statistic.AccessInstalledContractor = accessList.Count();
 888:                      statistic.AccessInstalledContractorWithSerial = (from o in ontList where o.Serial != null select o).Count();
 889:  
 890:                      statisticList.Add(statistic);
 891:                  }
 892:  
 893:                  /*
 894:                  accessStatisticList = (from a in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList
 895:                       group a by a.Id into grp
 896:                       orderby grp.Key
 897:                       select new Ia.Ngn.Cl.Model.Business.Administration.Statistic()
 898:                       {
 899:                           Id = grp.Key.ToString(),
 900:                           Name = grp.SingleOrDefault().NameArabicName,
 901:                           --InstalledContractor = (from a in db.Accesses where a.AreaId == grp.Key select a.Id).Count().ToString(),
 902:                           InstalledContractorWithSerial = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != null select a.Id).Count().ToString(),
 903:                           Provisioned = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId != 0 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
 904:                           ReadyForService = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
 905:                           DefinedInCustomerDepartment = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id join sro in db.ServiceRequestOnts on a.Id equals sro.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
 906:                           Utilized = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id 
 907:                                         join sro in db.ServiceRequestOnts on a.Id equals sro.Access.Id 
 908:                                         join srs in db.ServiceRequestServices on a.Id equals srs.Access.Id
 909:                                         where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString()
 910:                       }).ToList();
 911:                   */
 912:   
 913:          /*
 914:          if (dt != null)
 915:          {
 916:              // below: the totals rows
 917:  
 918:              dr = dt.NewRow();
 919:              dr["capacity"] = dt.Compute("SUM (capacity)", "").ToString();
 920:              dr["installed_contractor"] = dt.Compute("SUM (installed_contractor)", "").ToString();
 921:              dr["installed_contractor_with_serial"] = dt.Compute("SUM (installed_contractor_with_serial)", "").ToString();
 922:              dr["provisioned"] = dt.Compute("SUM (provisioned)", "").ToString();
 923:              dr["ont_ready_for_service"] = dt.Compute("SUM (ont_ready_for_service)", "").ToString();
 924:              dr["ont_defined_cs"] = dt.Compute("SUM (ont_defined_cs)", "").ToString();
 925:              dt.Rows.Add(dr);
 926:          }
 927:           * /
 928:          }
 929:  
 930:          return statisticList;
 931:          }
 932:          */
 933:   
 934:          /*
 935:          ////////////////////////////////////////////////////////////////////////////
 936:  
 937:          /// <summary>
 938:          ///
 939:          /// </summary>
 940:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> OltStatistic()
 941:          {
 942:              Ia.Ngn.Cl.Model.Business.Administration.Statistic statistic;
 943:              List<Ia.Ngn.Cl.Model.Access> mainAccessList, accessList;
 944:              List<Ia.Ngn.Cl.Model.Ont> mainOntList, ontList;
 945:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> statisticList;
 946:  
 947:              statisticList = new List<Ia.Ngn.Cl.Model.Business.Administration.Statistic>();
 948:  
 949:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 950:              {
 951:                  /*
 952:                  var v =
 953:                      (from a in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList
 954:                       group a by a.Id into grp
 955:                       orderby grp.Key
 956:                       select new
 957:                       {
 958:                           Id = grp.Key,
 959:                           Name = grp.SingleOrDefault().NameArabicName,
 960:                           Capacity = grp.Sum(w => w.Routers.SelectMany(x => x.Odfs.SelectMany(y => y.Olts)).Count()) * 1024,
 961:                       })
 962:                      .ToList();
 963:                   * /
 964:  
 965:                  mainAccessList = (from a in db.Accesses select a).ToList();
 966:                  mainOntList = (from o in db.Onts select o).ToList();
 967:  
 968:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
 969:                  {
 970:                      statistic = new Ia.Ngn.Cl.Model.Business.Administration.Statistic();
 971:  
 972:                      statistic.Id = olt.Id.ToString();
 973:                      statistic.Name = olt.Name;
 974:                      statistic.Site = olt.Odf.Router.Site.NameArabicName;
 975:                      statistic.Symbol = olt.Symbol;
 976:  
 977:                      accessList = (from a in mainAccessList where a.Olt == olt.Id select a).ToList();
 978:                      ontList = (from o in mainOntList where o.Access != null && o.Access.Olt == olt.Id select o).ToList();
 979:  
 980:                      foreach (Ia.Ngn.Cl.Model.Access access in accessList)
 981:                      {
 982:                      }
 983:  
 984:                      statistic.AccessCapacity = 1024;
 985:                      statistic.AccessInstalledContractor = accessList.Count();
 986:                      statistic.AccessInstalledContractorWithSerial = (from o in ontList where o.Serial != null select o).Count();
 987:  
 988:                      statisticList.Add(statistic);
 989:                  }
 990:  
 991:                  /*
 992:                  accessStatisticList = (from a in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList
 993:                       group a by a.Id into grp
 994:                       orderby grp.Key
 995:                       select new Ia.Ngn.Cl.Model.Business.Administration.Statistic()
 996:                       {
 997:                           Id = grp.Key.ToString(),
 998:                           Name = grp.SingleOrDefault().NameArabicName,
 999:                           --InstalledContractor = (from a in db.Accesses where a.AreaId == grp.Key select a.Id).Count().ToString(),
1000:                           InstalledContractorWithSerial = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != null select a.Id).Count().ToString(),
1001:                           Provisioned = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId != 0 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
1002:                           ReadyForService = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
1003:                           DefinedInCustomerDepartment = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id join sro in db.ServiceRequestOnts on a.Id equals sro.Access.Id where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString(),
1004:                           Utilized = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id 
1005:                                         join sro in db.ServiceRequestOnts on a.Id equals sro.Access.Id 
1006:                                         join srs in db.ServiceRequestServices on a.Id equals srs.Access.Id
1007:                                         where a.AreaId == grp.Key && o.Serial != "ALCL00000000" && o.StateId == 1 && o.ActiveSoftware == o.PlannedSoftware select a.Id).Count().ToString()
1008:                       }).ToList();
1009:                   */
1010:   
1011:          /*
1012:          if (dt != null)
1013:          {
1014:              // below: the totals rows
1015:  
1016:              dr = dt.NewRow();
1017:              dr["capacity"] = dt.Compute("SUM (capacity)", "").ToString();
1018:              dr["installed_contractor"] = dt.Compute("SUM (installed_contractor)", "").ToString();
1019:              dr["installed_contractor_with_serial"] = dt.Compute("SUM (installed_contractor_with_serial)", "").ToString();
1020:              dr["provisioned"] = dt.Compute("SUM (provisioned)", "").ToString();
1021:              dr["ont_ready_for_service"] = dt.Compute("SUM (ont_ready_for_service)", "").ToString();
1022:              dr["ont_defined_cs"] = dt.Compute("SUM (ont_defined_cs)", "").ToString();
1023:              dt.Rows.Add(dr);
1024:          }
1025:           * /
1026:          }
1027:  
1028:          return statisticList;
1029:          }
1030:          */
1031:   
1032:          /*
1033:          ////////////////////////////////////////////////////////////////////////////
1034:  
1035:          /// <summary>
1036:          ///
1037:          /// </summary>
1038:          public static List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> PhoneStatistic(string timePeriod)
1039:          {
1040:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic> phoneStatisticList;
1041:  
1042:              /*
1043:              string s, where;
1044:              DateTime from, to;
1045:              DataTable dt;
1046:  
1047:              if (timePeriod != null)
1048:              {
1049:                  from = DateTime.Parse(timePeriod);
1050:                  to = DateTime.Parse(timePeriod);
1051:                  to = to.AddMonths(1);
1052:  
1053:                  where = " AND (sr.request_time >= '" + sqlserver.SmallDateTime(from) + "' AND sr.request_time < '" + sqlserver.SmallDateTime(to) + "') ";
1054:              }
1055:              else where = string.Empty;
1056:               * /
1057:  
1058:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1059:              {
1060:                  phoneStatisticList = (from a in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList
1061:                       group a by a.Id into grp
1062:                       orderby grp.Key
1063:                       select new Ia.Ngn.Cl.Model.Business.Administration.Statistic()
1064:                       {
1065:                           Id = grp.Key.ToString(),
1066:                           Name = grp.SingleOrDefault().NameArabicName,
1067:                           //ServiceRequests = (from sr in db.ServiceRequests where sr.AreaId == grp.Key && sr.ServiceRequestService != null select sr.Id).Count().ToString(),
1068:                           ServiceRequestServices = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key select srs.Id).Count(),
1069:                           Services = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.Access != null && s.Access.AreaId == grp.Key select s.Id).Count(),
1070:                           InternationalCalling = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.InternationalCalling == true select srs.Id).Count(),
1071:                           InternationalCallingUserControlled = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.InternationalCallingUserControlled == true select srs.Id).Count(),
1072:                           CallWaiting = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.CallWaiting == true select srs.Id).Count(),
1073:  
1074:                           AlarmCall = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.AlarmCall == true select srs.Id).Count(),
1075:  
1076:                           CallBarring = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.CallBarring == true select srs.Id).Count(),
1077:                           CallerId = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.CallerId == true select srs.Id).Count(),
1078:                           CallForwarding = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.CallForwarding == true select srs.Id).Count(),
1079:                           ConferenceCall = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.ConferenceCall == true select srs.Id).Count(),
1080:                           ServiceSuspension = (from srs in db.ServiceRequestServices where srs.Access != null && srs.Access.AreaId == grp.Key && srs.ServiceSuspension == true select srs.Id).Count()
1081:                       }).ToList();
1082:  
1083:                  /*
1084:                  if (dt != null)
1085:                  {
1086:                      // below: the totals rows
1087:                      dr = dt.NewRow();
1088:  
1089:                      dr["SRS_AccessIdNotNull"] = dt.Compute("SUM (SRS_AccessIdNotNull)", "").ToString();
1090:                      dr["IMS_AccessIdNotNull"] = dt.Compute("SUM (IMS_AccessIdNotNull)", "").ToString();
1091:                      dr["SRS_AccordingToAreaIdFromDomain"] = dt.Compute("SUM (SRS_AccordingToAreaIdFromDomain)", "").ToString();
1092:  
1093:                      dr["InternationalCalling"] = dt.Compute("SUM (InternationalCalling)", "").ToString();
1094:                      dr["InternationalCallingUserControlled"] = dt.Compute("SUM (InternationalCallingUserControlled)", "").ToString();
1095:                      dr["CallWaiting"] = dt.Compute("SUM (CallWaiting)", "").ToString();
1096:                      dr["AlarmCall"] = dt.Compute("SUM (AlarmCall)", "").ToString();
1097:                      dr["CallBarring"] = dt.Compute("SUM (CallBarring)", "").ToString();
1098:                      dr["CallerId"] = dt.Compute("SUM (CallerId)", "").ToString();
1099:                      dr["CallForwarding"] = dt.Compute("SUM (CallForwarding)", "").ToString();
1100:                      dr["ConferenceCall"] = dt.Compute("SUM (ConferenceCall)", "").ToString();
1101:                      dr["ServiceSuspension"] = dt.Compute("SUM (ServiceSuspension)", "").ToString();
1102:  
1103:                      dt.Rows.Add(dr);
1104:                  }
1105:                   * /
1106:              }
1107:  
1108:              return phoneStatisticList;
1109:          }
1110:          */
1111:   
1112:          ////////////////////////////////////////////////////////////////////////////
1113:   
1114:          /// <summary>
1115:          ///
1116:          /// </summary>
1117:          public static List<Ia.Ngn.Cl.Model.Ui.Performance> StaffAndFrameworkPerformanceReport(int daysAgo)
1118:          {
1119:              DateTime startDateTime;
1120:              List<Ia.Ngn.Cl.Model.Ui.Performance> performanceList;
1121:   
1122:              // after 2015-06-01 user report closer inserts a last historic report
1123:              // I should designate last report as CLOSED and add it to resolution list to be accessed by HEAD only.
1124:   
1125:              // if daysAgo is 0 will make it 9999 days to cover all times
1126:              startDateTime = DateTime.UtcNow.AddDays(daysAgo == 0 ? -9999 : -daysAgo);
1127:   
1128:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1129:              {
1130:                  performanceList =
1131:                      (
1132:                      from staff in (from s in db.Staff group s.UserId by s.UserId into g select new { UserId = g.Key, Count = g.Count() })
1133:   
1134:                      join resolved in (from r in db.ReportHistories where r.Resolution == 1020 && r.Created > startDateTime group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1135:                      on staff.UserId equals resolved.UserId into resolved_gj
1136:                      from re in resolved_gj.DefaultIfEmpty()
1137:   
1138:                      join attempted in (from r in db.ReportHistories where r.Resolution != 1020 && r.Created > startDateTime group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1139:                      on staff.UserId equals attempted.UserId into attempted_gj
1140:                      from at in attempted_gj.DefaultIfEmpty()
1141:   
1142:                      join inserted in
1143:                          (from r in db.Reports where r.Created > startDateTime group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1144:                      on staff.UserId equals inserted.UserId into inserted_gj
1145:                      from ins in inserted_gj.DefaultIfEmpty()
1146:   
1147:                      join open in
1148:                          (from r in db.Reports where r.Created > startDateTime group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1149:                      on staff.UserId equals open.UserId into open_gj
1150:                      from opn in open_gj.DefaultIfEmpty()
1151:   
1152:                          // below: the 20, 10, 1 give weight to the field
1153:                      orderby re.Count descending, at.Count descending, ins.Count descending
1154:   
1155:                      select new Ia.Ngn.Cl.Model.Ui.Performance
1156:                      {
1157:                          UserId = staff.UserId,
1158:                          Resolved = (re == null ? 0 : re.Count),
1159:                          Attempted = (at == null ? 0 : at.Count),
1160:                          Inserted = (ins == null ? 0 : ins.Count),
1161:                          Open = (ins == null ? 0 : opn.Count),
1162:                          AverageReportsPerDay = 0
1163:                      }).ToList();
1164:   
1165:                  /*
1166:          select users.UserId, resolved.count,attempted.count,inserted.count from
1167:          (
1168:          (select count(*) as count, UserId from Users group by UserId) as users
1169:          left outer join
1170:          (select count(*) as count, rh.UserId from ReportHistories as rh where rh.Resolution = 1020 group by rh.UserId) as resolved
1171:          on users.UserId = resolved.UserId
1172:          left outer join
1173:          (select count(*) as count, rh.UserId from ReportHistories as rh where rh.Resolution <> 1020 group by rh.UserId) as attempted
1174:          on users.UserId = attempted.UserId
1175:          left outer join
1176:          (select count(*) as count, UserId from Reports group by UserId) as inserted
1177:          on users.UserId = inserted.UserId
1178:          )
1179:          order by resolved.count*20+attempted.count*10+inserted.count desc
1180:              */
1181:              }
1182:   
1183:              return performanceList;
1184:          }
1185:   
1186:          ////////////////////////////////////////////////////////////////////////////
1187:   
1188:          /// <summary>
1189:          ///
1190:          /// </summary>
1191:          public static List<Ia.Ngn.Cl.Model.Ui.Performance> StatisticsOfResolvedAndAttemptedAndInsertedStaffReport2(Guid userId)
1192:          {
1193:              List<Ia.Ngn.Cl.Model.Ui.Performance> performanceList;
1194:   
1195:              // after 2015-06-01 user report closer inserts a last historic report
1196:              // I should designate last report as CLOSED and add it to resolution list to be accessed by HEAD only.
1197:   
1198:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1199:              {
1200:                  performanceList =
1201:                      (
1202:                      from staff in
1203:                          (from s in db.Staff group s.UserId by s.UserId into g select new { UserId = g.Key, Count = g.Count() })
1204:                      join resolved in
1205:                          (from r in db.ReportHistories where r.Resolution == 1020 group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1206:                      on staff.UserId equals resolved.UserId into resolved_gj
1207:                      from re in resolved_gj.DefaultIfEmpty()
1208:   
1209:                      join attempted in
1210:                          (from r in db.ReportHistories where r.Resolution != 1020 group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1211:                      on staff.UserId equals attempted.UserId into attempted_gj
1212:                      from at in attempted_gj.DefaultIfEmpty()
1213:   
1214:                      join inserted in
1215:                          (from r in db.Reports group r.UserId by r.UserId into g select new { UserId = g.Key, Count = g.Count() })
1216:                      on staff.UserId equals inserted.UserId into inserted_gj
1217:                      from ins in inserted_gj.DefaultIfEmpty()
1218:                          // below: the 20, 10, 1 give weight to the field
1219:                      orderby re.Count descending, at.Count descending, ins.Count descending
1220:                      select new Ia.Ngn.Cl.Model.Ui.Performance
1221:                      {
1222:                          UserId = staff.UserId,
1223:                          Resolved = (re == null ? 0 : re.Count),
1224:                          Attempted = (at == null ? 0 : at.Count),
1225:                          Inserted = (ins == null ? 0 : ins.Count),
1226:                          AverageReportsPerDay = 0
1227:                      }).ToList();
1228:   
1229:                  /*
1230:          select users.UserId, resolved.count,attempted.count,inserted.count from
1231:          (
1232:          (select count(*) as count, UserId from Users group by UserId) as users
1233:          left outer join
1234:          (select count(*) as count, rh.UserId from ReportHistories as rh where rh.Resolution = 1020 group by rh.UserId) as resolved
1235:          on users.UserId = resolved.UserId
1236:          left outer join
1237:          (select count(*) as count, rh.UserId from ReportHistories as rh where rh.Resolution <> 1020 group by rh.UserId) as attempted
1238:          on users.UserId = attempted.UserId
1239:          left outer join
1240:          (select count(*) as count, UserId from Reports group by UserId) as inserted
1241:          on users.UserId = inserted.UserId
1242:          )
1243:          order by resolved.count*20+attempted.count*10+inserted.count desc
1244:              */
1245:              }
1246:   
1247:              return performanceList.ToList();
1248:          }
1249:   
1250:          ////////////////////////////////////////////////////////////////////////////
1251:   
1252:          /// <summary>
1253:          ///
1254:          /// </summary>
1255:          public DataTable CountOfActiveNumbersInArea()
1256:          {
1257:              return CountOfActiveNumbersInAreaByTimePeriod(null);
1258:          }
1259:   
1260:          ////////////////////////////////////////////////////////////////////////////
1261:   
1262:          /// <summary>
1263:          ///
1264:          /// </summary>
1265:          public static DataTable CountOfActiveNumbersInAreaByTimePeriod(string timePeriod)
1266:          {
1267:              string s, where;
1268:              DateTime from, to;
1269:              DataTable dt;
1270:   
1271:              if (timePeriod != null)
1272:              {
1273:                  from = DateTime.Parse(timePeriod);
1274:                  to = DateTime.Parse(timePeriod);
1275:                  to = to.AddMonths(1);
1276:   
1277:                  where = null; // " AND (sr.request_time >= '" + sqlserver.SmallDateTime(from) + "' AND sr.request_time < '" + sqlserver.SmallDateTime(to) + "') ";
1278:              }
1279:              else where = string.Empty;
1280:   
1281:              s = @"SELECT COUNT(1) AS count, f.area
1282:  FROM         ia_system AS s INNER JOIN
1283:                        ia_protocol AS p ON s.lceid = p.lceid AND s.lan = p.lan INNER JOIN
1284:                        ia_standard AS st ON st.ip = p.ip INNER JOIN
1285:                        ia_field AS f ON f.id = st.id LEFT OUTER JOIN
1286:                        ia_service_request_service AS srs ON srs.dn = s.dn LEFT OUTER JOIN
1287:                        ia_service_request AS sr ON sr.id = srs.ia_service_request_id
1288:  WHERE f.area != 0 " + where + @" GROUP BY f.area ";
1289:   
1290:              dt = null; // sqlserver.Select(s);
1291:   
1292:              return dt;
1293:          }
1294:   
1295:          ////////////////////////////////////////////////////////////////////////////    
1296:   
1297:          /// <summary>
1298:          ///
1299:          /// </summary>
1300:          public static Dictionary<string, int> DateTimesWithAvailableData()
1301:          {
1302:              Dictionary<string, int> dic;
1303:   
1304:   
1305:              dic = new Dictionary<string, int>(100);
1306:   
1307:   
1308:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1309:              {
1310:                  //dic = (from q in db.ServiceRequests orderby q.RequestDateTime select q.RequestDateTime).Distinct().ToDictionary(r => r.CustomerName, r => r.Id);
1311:   
1312:                  // dictionary = (from q in ReportXDocument.Elements("report").Elements("category") select new { Id = int.Parse(q.Attribute("id").Value), Name = q.Attribute("name").Value }).ToDictionary(r => r.Id, r => r.Name);
1313:   
1314:              }
1315:   
1316:              /*
1317:          SELECT DISTINCT CONVERT(varchar(7), RequestDateTime, 102) AS date, COUNT(1) AS count
1318:          FROM [Ia_Ngn].[dbo].[ServiceRequests]
1319:          GROUP BY CONVERT(varchar(7), RequestDateTime, 102)
1320:          ORDER BY date
1321:               */
1322:   
1323:              return dic;
1324:          }
1325:   
1326:          ////////////////////////////////////////////////////////////////////////////
1327:          ////////////////////////////////////////////////////////////////////////////
1328:   
1329:          /// <summary>
1330:          /// 
1331:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
1332:          /// 
1333:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
1334:          /// 2. Add "using System.Reflection".
1335:          /// 3. See sample below.
1336:          /// 
1337:          /// </summary>
1338:   
1339:          private static XDocument XDocument
1340:          {
1341:              get
1342:              {
1343:                  Assembly _assembly;
1344:                  StreamReader streamReader;
1345:   
1346:                  if (xDocument == null)
1347:                  {
1348:                      _assembly = Assembly.GetExecutingAssembly();
1349:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.administration.xml"));
1350:   
1351:                      try
1352:                      {
1353:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
1354:                      }
1355:                      catch (Exception)
1356:                      {
1357:                      }
1358:                      finally
1359:                      {
1360:                      }
1361:                  }
1362:   
1363:                  return xDocument;
1364:              }
1365:          }
1366:   
1367:          ////////////////////////////////////////////////////////////////////////////
1368:          ////////////////////////////////////////////////////////////////////////////    
1369:      }
1370:   
1371:      ////////////////////////////////////////////////////////////////////////////
1372:      ////////////////////////////////////////////////////////////////////////////   
1373:  }