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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » NetworkDesignDocument

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

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

   1:  using Ia.Ngn.Cl.Migrations;
   2:  using System;
   3:  using System.Collections;
   4:  using System.Collections.Generic;
   5:  using System.Data;
   6:  using System.IO;
   7:  using System.Linq;
   8:  using System.Reflection;
   9:  using System.Text;
  10:  using System.Text.RegularExpressions;
  11:  using System.Web;
  12:  using System.Xml.Linq;
  13:   
  14:  namespace Ia.Ngn.Cl.Model.Data
  15:  {
  16:      ////////////////////////////////////////////////////////////////////////////
  17:   
  18:      /// <summary publish="true">
  19:      /// Network Design Document support class for Next Generation Network (NGN) data model.
  20:      /// </summary>
  21:      /// 
  22:      /// <remarks> 
  23:      /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  24:      ///
  25:      /// 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
  26:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  27:      ///
  28:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  29:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  30:      /// 
  31:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  32:      /// 
  33:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  34:      /// </remarks> 
  35:      public static partial class NetworkDesignDocument
  36:      {
  37:          private static XDocument xDocument;
  38:          private static Dictionary<string, int> ontIdToOntPonPonGroupOltIdDictionary;
  39:          private static Dictionary<string, string> ontAccessIdToOntIdDictionary, ontIdToOntAccessNameDictionary, ontAccessNameToOntAccessIdDictionary, ontAccessNameToOntIdDictionary, ontAccessIdToOntAccessNameDictionary, ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary, ontIpToOntAccessNameDictionary, ontIpToOntAccessIdDictionary, ontAccessNameToOntIpDictionary, ontAccessNameToOntMgcIpDictionary, ontAccessNameToOntPositionDictionary, ontIdDictionary, ontIpDictionary, ponNameToPonIdDictionary;
  40:          private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontAccessIdToOntDictionary, ontIdToOntDictionary, ontIpToOntDictionary, ontAccessNameToOntDictionary;
  41:          private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponIdToPonDictionary, ponNameToPonDictionary;
  42:          private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> routerDomainToSiteDictionary, pstnDomainToSiteDictionary;
  43:          private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> pstnFiveDigitDomainToPstnExchangeTypeDictionary;
  44:          private static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> pstnToFiveDigitDomainListDictionary;
  45:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> networkList;
  46:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> vendorList;
  47:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> siteList;
  48:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> pstnList;
  49:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> routerList;
  50:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> oamList;
  51:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> odfList;
  52:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList;
  53:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> ponGroupList;
  54:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponList;
  55:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList;
  56:   
  57:          private static readonly object objectLock = new object();
  58:   
  59:          /// <summary/>
  60:          public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
  61:   
  62:          ////////////////////////////////////////////////////////////////////////////
  63:   
  64:          /// <summary>
  65:          ///
  66:          /// </summary>
  67:          //public NetworkDesignDocument() { }
  68:   
  69:          ////////////////////////////////////////////////////////////////////////////
  70:   
  71:          /// <summary>
  72:          ///
  73:          /// </summary>
  74:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
  75:          {
  76:              get
  77:              {
  78:                  lock (objectLock)
  79:                  {
  80:                      if (ontList == null || ontList.Count == 0) ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OntList;
  81:   
  82:                      return ontList;
  83:                  }
  84:              }
  85:          }
  86:   
  87:          ////////////////////////////////////////////////////////////////////////////
  88:   
  89:          /// <summary>
  90:          ///
  91:          /// </summary>
  92:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> _OntList
  93:          {
  94:              get
  95:              {
  96:                  bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
  97:                  long networkNumberIpLong, ipLong, diff, l;
  98:                  string oltSymbol;
  99:   
 100:  #if DEBUG
 101:                  Dictionary<string, string> ontDictionary, proposedOntDictionary, ipDictionary;
 102:  #endif
 103:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
 104:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access access;
 105:                  Ia.Ngn.Cl.Model.Business.Ims.ImsBasicService imsBasicService;
 106:   
 107:                  ontList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
 108:  #if DEBUG
 109:                  ontDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
 110:                  proposedOntDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
 111:                  ipDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
 112:  #endif
 113:   
 114:                  var nokiaAccessNameWithPbxList = Ia.Ngn.Cl.Model.Data.Ims.NokiaAccessNameWithPbxList;
 115:   
 116:                  foreach (var ponGroup in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList)
 117:                  {
 118:                      nokiaRouter = (ponGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
 119:                      huaweiRouter = !nokiaRouter;
 120:   
 121:                      nokiaOdf = (ponGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
 122:                      huaweiOdf = !nokiaOdf;
 123:   
 124:                      oltSymbol = ponGroup.Olt.Symbol;
 125:   
 126:                      networkNumberIpLong = Ia.Cl.Model.Default.IpToDec(ponGroup.NetworkNumber);
 127:   
 128:                      // standard imsBasicService
 129:                      if (nokiaRouter)
 130:                      {
 131:                          if (nokiaOdf) imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItem(ponGroup);
 132:                          else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ponGroup);
 133:                      }
 134:                      else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.HuaweiImsBasicServiceItem(ponGroup);
 135:   
 136:                      foreach (var pon in ponGroup.PonList)
 137:                      {
 138:  #if DEBUG
 139:                          if (pon.Name == "EGL.451")
 140:                          {
 141:   
 142:                          }
 143:  #endif
 144:   
 145:                          for (int ontNumber = 1; ontNumber <= ponGroup.Olt.NumberOfOntsInPon; ontNumber++)
 146:                          {
 147:                              ont = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont();
 148:                              access = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access();
 149:   
 150:                              ont.Pon = pon;
 151:   
 152:                              ont.Rack = ponGroup.Olt.Rack;
 153:                              ont.Sub = ponGroup.Olt.Sub;
 154:                              ont.CardSlot = pon.CardSlot;  // CardSlot might change for MDUs below
 155:                              ont.Port = pon.Port;
 156:   
 157:                              ont.Number = ontNumber;
 158:   
 159:                              ont.InternalNumber = (pon.Index * ponGroup.Olt.NumberOfOntsInPon) % 32 + ont.Number;
 160:   
 161:                              ont.Position = ponGroup.Olt.AmsName + "-" + ont.CardSlot + "-" + ont.Port + "-" + ont.InternalNumber;
 162:   
 163:                              access.Id = access.AccessId(ponGroup.Olt.Id, pon.Number, ont.Number);
 164:                              access.Pon = pon.Number;
 165:                              access.ProposedPon = pon.ProposedNumber;
 166:                              access.Ont = ont.Number;
 167:   
 168:                              access.Symbol = ponGroup.Symbol;
 169:                              access.Name = ponGroup.Symbol + "." + pon.Number + "." + ont.Number;
 170:                              access.ProposedName = ponGroup.Symbol + "." + pon.ProposedNumber + "." + ont.Number;
 171:   
 172:  #if DEBUG
 173:                              if (access.Name == "SSB.44.27")
 174:                              {
 175:   
 176:                              }
 177:  #endif
 178:   
 179:                              ont.Access = access;
 180:   
 181:                              ipLong = networkNumberIpLong + pon.PonGroupPonIndex * ponGroup.Olt.NumberOfOntsInPon + ont.Number; // or ont.InternalNumber
 182:                              diff = ipLong - networkNumberIpLong;
 183:   
 184:                              if (nokiaOdf)
 185:                              {
 186:                                  // below: skip *.*.*.0 only for Nokia ONTs
 187:                                  l = (diff - 1) / 255;
 188:   
 189:                                  ipLong += l;
 190:                              }
 191:                              else //if(huaweiOdf)
 192:                              {
 193:                                  if (nokiaRouter)
 194:                                  {
 195:                                  }
 196:                                  else //if (huaweiRouter)
 197:                                  {
 198:                                      // Huawei router and ODF. Here we will skip *.*.*.0 and *.*.*.1. Go figure!
 199:                                      ipLong += 1;
 200:                                  }
 201:                              }
 202:   
 203:                              ont.Ip = Ia.Cl.Model.Default.DecToIp((int)ipLong);
 204:   
 205:                              // ont.Id is used in functions below
 206:                              ont.Id = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(pon.Id, ont.InternalNumber);
 207:   
 208:                              // special imsBasicService
 209:                              if (nokiaRouter)
 210:                              {
 211:                                  if (huaweiOdf)
 212:                                  {
 213:                                      if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
 214:                                      {
 215:                                          ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
 216:                                      }
 217:                                      else ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ont) ?? imsBasicService;
 218:                                  }
 219:                                  else
 220:                                  {
 221:                                      if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
 222:                                      {
 223:                                          ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
 224:                                      }
 225:                                      else ont.ImsBasicService = imsBasicService;
 226:                                  }
 227:                              }
 228:                              else ont.ImsBasicService = imsBasicService;
 229:   
 230:   
 231:  #if DEBUG
 232:                              // this will throw an exception if there is a duplicate ont.Access.Name
 233:                              if (ontDictionary.ContainsKey(ont.Access.Name))
 234:                              {
 235:                                  throw new ArgumentOutOfRangeException(@"ontDictionary.ContainsKey(ont.Access.Name)");
 236:                              }
 237:                              else ontDictionary[ont.Access.Name] = ont.Id;
 238:   
 239:                              // this will throw an exception if there is a duplicate ont.Access.ProposedName
 240:                              if (proposedOntDictionary.ContainsKey(ont.Access.ProposedName))
 241:                              {
 242:                                  throw new ArgumentOutOfRangeException(@"proposedOntDictionary.ContainsKey(ont.Access.ProposedName)");
 243:                              }
 244:                              else proposedOntDictionary[ont.Access.ProposedName] = ont.Id;
 245:   
 246:                              /*
 247:                              // this will throw an exception if an IP has *.*.*.0
 248:                              // over 400 Huawei ONTs with *.*.*.0 IPs
 249:                              if (Regex.IsMatch(ont.Ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0"))
 250:                              {
 251:                                  list.Add(ont.Access.Name);
 252:                              }
 253:                              */
 254:   
 255:                              // this will throw an exception if there is a duplicate ont.Ip
 256:                              if (ipDictionary.ContainsKey(ont.Ip))
 257:                              {
 258:                                  throw new ArgumentOutOfRangeException(@"ipDictionary.ContainsKey(ont.Ip)");
 259:                              }
 260:                              else ipDictionary[ont.Ip] = ont.Id;
 261:  #endif
 262:                              ontList.Add(ont);
 263:                          }
 264:                      }
 265:                  }
 266:   
 267:                  // as a precaution, this will throw an exception if there are not n number of records
 268:                  if (ontList.Count != Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
 269:                  {
 270:                      throw new ArgumentOutOfRangeException(@"(ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
 271:                  }
 272:   
 273:                  return ontList;
 274:              }
 275:          }
 276:   
 277:          ////////////////////////////////////////////////////////////////////////////
 278:   
 279:          /// <summary>
 280:          /// A Hashtable "faster" version of OntList for frequent use
 281:          /// </summary>
 282:          public static Hashtable OntAccessIdToAccessVendorHashtable
 283:          {
 284:              get
 285:              {
 286:                  Hashtable ht;
 287:   
 288:                  ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList.Count);
 289:   
 290:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList)
 291:                  {
 292:                      ht[ont.Access.Id] = ont.Pon.PonGroup.Olt.Odf.Vendor;
 293:                  }
 294:   
 295:                  return ht;
 296:              }
 297:          }
 298:   
 299:          ////////////////////////////////////////////////////////////////////////////
 300:   
 301:          /// <summary>
 302:          /// 
 303:          /// </summary>
 304:          public static List<string> OntAccessIdList
 305:          {
 306:              get
 307:              {
 308:                  List<string> list;
 309:   
 310:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList orderby o.Access.Id select o.Access.Id).ToList();
 311:   
 312:                  return list;
 313:              }
 314:          }
 315:   
 316:          ////////////////////////////////////////////////////////////////////////////
 317:   
 318:          /// <summary>
 319:          ///
 320:          /// </summary>
 321:          public static Dictionary<string, int> OntAccessIdDictionary
 322:          {
 323:              get
 324:              {
 325:                  Dictionary<string, int> dictionary;
 326:   
 327:                  dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 328:                                select o.Access.Id).ToDictionary(n => n, n => 1);
 329:   
 330:                  return dictionary;
 331:              }
 332:          }
 333:   
 334:          ////////////////////////////////////////////////////////////////////////////
 335:   
 336:          /// <summary>
 337:          ///
 338:          /// </summary>
 339:          public static Dictionary<string, string> OntAccessIdToOntIdDictionary
 340:          {
 341:              get
 342:              {
 343:                  if (ontAccessIdToOntIdDictionary == null || ontAccessIdToOntIdDictionary.Count == 0)
 344:                  {
 345:                      ontAccessIdToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 346:                                                      select new { AccessId = o.Access.Id, OntId = o.Id }).ToDictionary(n => n.AccessId, n => n.OntId);
 347:                  }
 348:   
 349:                  return ontAccessIdToOntIdDictionary;
 350:              }
 351:          }
 352:   
 353:          ////////////////////////////////////////////////////////////////////////////
 354:   
 355:          /// <summary>
 356:          ///
 357:          /// </summary>
 358:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntDictionary
 359:          {
 360:              get
 361:              {
 362:                  if (ontAccessIdToOntDictionary == null || ontAccessIdToOntDictionary.Count == 0)
 363:                  {
 364:                      ontAccessIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 365:                                                    select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
 366:                  }
 367:   
 368:                  return ontAccessIdToOntDictionary;
 369:              }
 370:          }
 371:   
 372:          ////////////////////////////////////////////////////////////////////////////
 373:   
 374:          /// <summary>
 375:          ///
 376:          /// </summary>
 377:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntDictionary
 378:          {
 379:              get
 380:              {
 381:                  if (ontIpToOntDictionary == null || ontIpToOntDictionary.Count == 0)
 382:                  {
 383:                      ontIpToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 384:                                              select new { Ip = o.Ip, Ont = o }).ToDictionary(n => n.Ip, n => n.Ont);
 385:                  }
 386:   
 387:                  return ontIpToOntDictionary;
 388:              }
 389:          }
 390:   
 391:          ////////////////////////////////////////////////////////////////////////////
 392:   
 393:          /// <summary>
 394:          ///
 395:          /// </summary>
 396:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltIdListDictionary(List<int> oltIdList)
 397:          {
 398:              var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 399:                          where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
 400:                          select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
 401:   
 402:              return list;
 403:          }
 404:   
 405:          ////////////////////////////////////////////////////////////////////////////
 406:   
 407:          /// <summary>
 408:          ///
 409:          /// </summary>
 410:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntForOltIdListDictionary(List<int> oltIdList)
 411:          {
 412:              var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 413:                          where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
 414:                          select new { OntIp = o.Ip, Ont = o }).ToDictionary(n => n.OntIp, n => n.Ont);
 415:   
 416:              return list;
 417:          }
 418:   
 419:          ////////////////////////////////////////////////////////////////////////////
 420:   
 421:          /// <summary>
 422:          ///
 423:          /// </summary>
 424:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltSymbolListDictionary(List<string> oltSymbolList)
 425:          {
 426:              var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 427:                          where oltSymbolList.Contains(o.Pon.PonGroup.Olt.Symbol)
 428:                          select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
 429:   
 430:              return list;
 431:          }
 432:   
 433:          ////////////////////////////////////////////////////////////////////////////
 434:   
 435:          /// <summary>
 436:          ///
 437:          /// </summary>
 438:          public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> RouterDomainToSiteDictionary
 439:          {
 440:              get
 441:              {
 442:                  if (routerDomainToSiteDictionary == null || routerDomainToSiteDictionary.Count == 0)
 443:                  {
 444:                      routerDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
 445:   
 446:                      var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
 447:   
 448:                      foreach (int domain in routerList.SelectMany(x => x.DomainList))
 449:                      {
 450:                          routerDomainToSiteDictionary[domain] = (from r in routerList where r.DomainList.Contains(domain) select r.Site).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
 451:                      }
 452:                  }
 453:   
 454:                  return routerDomainToSiteDictionary;
 455:              }
 456:          }
 457:   
 458:          ////////////////////////////////////////////////////////////////////////////
 459:   
 460:          /// <summary>
 461:          ///
 462:          /// </summary>
 463:          public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> PstnDomainToSiteDictionary
 464:          {
 465:              get
 466:              {
 467:                  if (pstnDomainToSiteDictionary == null || pstnDomainToSiteDictionary.Count == 0)
 468:                  {
 469:                      pstnDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
 470:   
 471:                      var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
 472:   
 473:                      foreach (int domain in pstnList.SelectMany(x => x.DomainList))
 474:                      {
 475:                          pstnDomainToSiteDictionary[domain] = (from p in pstnList where p.DomainList.Contains(domain) select p.Site).SingleOrDefault();
 476:                      }
 477:                  }
 478:   
 479:                  return routerDomainToSiteDictionary;
 480:              }
 481:          }
 482:   
 483:          ////////////////////////////////////////////////////////////////////////////
 484:   
 485:          /// <summary>
 486:          ///
 487:          /// </summary>
 488:          public static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> PstnToFiveDigitDomainListDictionary()
 489:          {
 490:              if (pstnToFiveDigitDomainListDictionary == null || pstnToFiveDigitDomainListDictionary.Count == 0)
 491:              {
 492:                  pstnToFiveDigitDomainListDictionary = new Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>>();
 493:   
 494:                  var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
 495:   
 496:                  foreach (var pstn in pstnList)
 497:                  {
 498:                      var list = new List<int>();
 499:   
 500:                      foreach (int domain in pstn.DomainList)
 501:                      {
 502:                          // already five digit domain
 503:                          if (domain > 9999) list.Add(domain);
 504:                          else
 505:                          {
 506:                              // four digit domain, we will need to create five digit domains related to it
 507:                              for (int i = 0; i <= 9; i++)
 508:                              {
 509:                                  list.Add(domain * 10 + i);
 510:                              }
 511:                          }
 512:   
 513:                          pstnToFiveDigitDomainListDictionary[pstn] = list;
 514:                      }
 515:                  }
 516:              }
 517:   
 518:              return pstnToFiveDigitDomainListDictionary;
 519:          }
 520:   
 521:          ////////////////////////////////////////////////////////////////////////////
 522:   
 523:          /// <summary>
 524:          ///
 525:          /// </summary>
 526:          public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> PstnFiveDigitDomainToVendorDictionary()
 527:          {
 528:              if (pstnFiveDigitDomainToPstnExchangeTypeDictionary == null || pstnFiveDigitDomainToPstnExchangeTypeDictionary.Count == 0)
 529:              {
 530:                  pstnFiveDigitDomainToPstnExchangeTypeDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType>();
 531:   
 532:                  var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
 533:   
 534:                  foreach (var pstn in pstnList)
 535:                  {
 536:                      foreach (int domain in pstn.DomainList)
 537:                      {
 538:                          // already five digit domain
 539:                          if (domain > 9999) pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain] = pstn.PstnExchangeType;
 540:                          else
 541:                          {
 542:                              // four digit domain, we will need to create five digit domains related to it
 543:                              for (int i = 0; i <= 9; i++)
 544:                              {
 545:                                  pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain * 10 + i] = pstn.PstnExchangeType;
 546:                              }
 547:                          }
 548:                      }
 549:                  }
 550:              }
 551:   
 552:              return pstnFiveDigitDomainToPstnExchangeTypeDictionary;
 553:          }
 554:   
 555:          ////////////////////////////////////////////////////////////////////////////
 556:   
 557:          /// <summary>
 558:          ///
 559:          /// </summary>
 560:          public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> DomainToRouterVendorDictionary
 561:          {
 562:              get
 563:              {
 564:                  var dictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
 565:   
 566:                  var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
 567:   
 568:                  foreach (int domain in routerList.SelectMany(x => x.DomainList))
 569:                  {
 570:                      dictionary[domain] = (from r in routerList
 571:                                            where r.DomainList.Contains(domain)
 572:                                            select r.Vendor).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
 573:                  }
 574:   
 575:                  return dictionary;
 576:              }
 577:          }
 578:   
 579:          ////////////////////////////////////////////////////////////////////////////
 580:   
 581:          /// <summary>
 582:          ///
 583:          /// </summary>
 584:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIdToOntDictionary
 585:          {
 586:              get
 587:              {
 588:                  if (ontIdToOntDictionary == null || ontIdToOntDictionary.Count == 0)
 589:                  {
 590:                      ontIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 591:                                              select new { OntId = o.Id, Ont = o }).ToDictionary(n => n.OntId, n => n.Ont);
 592:                  }
 593:   
 594:                  return ontIdToOntDictionary;
 595:              }
 596:          }
 597:   
 598:          ////////////////////////////////////////////////////////////////////////////
 599:   
 600:          /// <summary>
 601:          ///
 602:          /// </summary>
 603:          public static Dictionary<string, string> OntIdToOntAccessNameDictionary
 604:          {
 605:              get
 606:              {
 607:                  if (ontIdToOntAccessNameDictionary == null || ontIdToOntAccessNameDictionary.Count == 0)
 608:                  {
 609:                      ontIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 610:                                                        select new { OntId = o.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntId, n => n.OntAccessName);
 611:                  }
 612:   
 613:                  return ontIdToOntAccessNameDictionary;
 614:              }
 615:          }
 616:   
 617:          ////////////////////////////////////////////////////////////////////////////
 618:   
 619:          /// <summary>
 620:          ///
 621:          /// </summary>
 622:          public static Dictionary<string, string> OntAccessNameToOntIdDictionary
 623:          {
 624:              get
 625:              {
 626:                  if (ontAccessNameToOntIdDictionary == null || ontAccessNameToOntIdDictionary.Count == 0)
 627:                  {
 628:                      ontAccessNameToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 629:                                                        select new { OntAccessName = o.Access.Name, OntId = o.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntId);
 630:                  }
 631:   
 632:                  return ontAccessNameToOntIdDictionary;
 633:              }
 634:          }
 635:   
 636:          ////////////////////////////////////////////////////////////////////////////
 637:   
 638:          /// <summary>
 639:          ///
 640:          /// </summary>
 641:          public static Dictionary<string, string> OntAccessNameToOntAccessIdDictionary
 642:          {
 643:              get
 644:              {
 645:                  if (ontAccessNameToOntAccessIdDictionary == null || ontAccessNameToOntAccessIdDictionary.Count == 0)
 646:                  {
 647:                      ontAccessNameToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 648:                                                              select new { OntAccessName = o.Access.Name, OntAccessId = o.Access.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntAccessId);
 649:                  }
 650:   
 651:                  return ontAccessNameToOntAccessIdDictionary;
 652:              }
 653:          }
 654:   
 655:          ////////////////////////////////////////////////////////////////////////////
 656:   
 657:          /// <summary>
 658:          ///
 659:          /// </summary>
 660:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessNameToOntDictionary
 661:          {
 662:              get
 663:              {
 664:                  if (ontAccessNameToOntDictionary == null || ontAccessNameToOntDictionary.Count == 0)
 665:                  {
 666:                      ontAccessNameToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 667:                                                      select new { OntAccessName = o.Access.Name, Ont = o, }).ToDictionary(n => n.OntAccessName, n => n.Ont);
 668:                  }
 669:   
 670:                  return ontAccessNameToOntDictionary;
 671:              }
 672:          }
 673:   
 674:          ////////////////////////////////////////////////////////////////////////////
 675:   
 676:          /// <summary>
 677:          ///
 678:          /// </summary>
 679:          public static Dictionary<string, string> OntAccessIdToOntAccessNameDictionary
 680:          {
 681:              get
 682:              {
 683:                  if (ontAccessIdToOntAccessNameDictionary == null || ontAccessIdToOntAccessNameDictionary.Count == 0)
 684:                  {
 685:                      ontAccessIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 686:                                                              select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
 687:                  }
 688:   
 689:                  return ontAccessIdToOntAccessNameDictionary;
 690:              }
 691:          }
 692:   
 693:          ////////////////////////////////////////////////////////////////////////////
 694:   
 695:          /// <summary>
 696:          ///
 697:          /// </summary>
 698:          public static Dictionary<string, string> OntAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary
 699:          {
 700:              get
 701:              {
 702:                  if (ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary == null || ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary.Count == 0)
 703:                  {
 704:                      var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
 705:   
 706:                      ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 707:                                                                                          where allowedToBeMigratedOltIdList.Contains(o.Pon.PonGroup.Olt.Id)
 708:                                                                                          select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
 709:                  }
 710:   
 711:                  return ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary;
 712:              }
 713:          }
 714:   
 715:          ////////////////////////////////////////////////////////////////////////////
 716:   
 717:          /// <summary>
 718:          ///
 719:          /// </summary>
 720:          public static Dictionary<string, string> OntAccessIdToOntAccessNameForOltSymbolListDictionary(List<string> oltSymbolList)
 721:          {
 722:              var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 723:                          where oltSymbolList.Contains(o.Pon.PonGroup.Olt.Symbol)
 724:                          select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
 725:   
 726:              return list;
 727:          }
 728:   
 729:          ////////////////////////////////////////////////////////////////////////////
 730:   
 731:          /// <summary>
 732:          ///
 733:          /// </summary>
 734:          public static Dictionary<string, string> OntIpToOntAccessNameDictionary
 735:          {
 736:              get
 737:              {
 738:                  if (ontIpToOntAccessNameDictionary == null || ontIpToOntAccessNameDictionary.Count == 0)
 739:                  {
 740:                      ontIpToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 741:                                                        select new { OntIp = o.Ip, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntIp, n => n.OntAccessName);
 742:                  }
 743:   
 744:                  return ontIpToOntAccessNameDictionary;
 745:              }
 746:          }
 747:   
 748:          ////////////////////////////////////////////////////////////////////////////
 749:   
 750:          /// <summary>
 751:          ///
 752:          /// </summary>
 753:          public static Dictionary<string, string> OntIpToOntAccessIdDictionary
 754:          {
 755:              get
 756:              {
 757:                  if (ontIpToOntAccessIdDictionary == null || ontIpToOntAccessIdDictionary.Count == 0)
 758:                  {
 759:                      ontIpToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 760:                                                      select new { OntIp = o.Ip, OntAccessId = o.Access.Id }).ToDictionary(n => n.OntIp, n => n.OntAccessId);
 761:                  }
 762:   
 763:                  return ontIpToOntAccessIdDictionary;
 764:              }
 765:          }
 766:   
 767:          ////////////////////////////////////////////////////////////////////////////
 768:   
 769:          /// <summary>
 770:          ///
 771:          /// </summary>
 772:          public static Dictionary<string, string> OntAccessNameToOntIpDictionary
 773:          {
 774:              get
 775:              {
 776:                  if (ontAccessNameToOntIpDictionary == null || ontAccessNameToOntIpDictionary.Count == 0)
 777:                  {
 778:                      ontAccessNameToOntIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 779:                                                        select new { OntAccessName = o.Access.Name, OntIp = o.Ip }).ToDictionary(n => n.OntAccessName, n => n.OntIp);
 780:                  }
 781:   
 782:                  return ontAccessNameToOntIpDictionary;
 783:              }
 784:          }
 785:   
 786:          ////////////////////////////////////////////////////////////////////////////
 787:   
 788:          /// <summary>
 789:          ///
 790:          /// </summary>
 791:          public static Dictionary<string, string> OntAccessNameToOntIpInHuaweiSwitchNokiaGponDictionary()
 792:          {
 793:              var dic = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 794:                         where o.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
 795:                         && o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 796:                         select new { OntAccessName = o.Access.Name, OntIp = o.Ip }
 797:                         ).ToDictionary(n => n.OntAccessName, n => n.OntIp);
 798:   
 799:              return dic;
 800:          }
 801:   
 802:          ////////////////////////////////////////////////////////////////////////////
 803:   
 804:          /// <summary>
 805:          ///
 806:          /// </summary>
 807:          public static Dictionary<string, string> OntAccessNameToOntMgcIpDictionary
 808:          {
 809:              get
 810:              {
 811:                  if (ontAccessNameToOntMgcIpDictionary == null || ontAccessNameToOntMgcIpDictionary.Count == 0)
 812:                  {
 813:                      ontAccessNameToOntMgcIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 814:                                                           select new { OntAccessName = o.Access.Name, OntMgcIp = o.MgcIp }).ToDictionary(n => n.OntAccessName, n => n.OntMgcIp);
 815:                  }
 816:   
 817:                  return ontAccessNameToOntMgcIpDictionary;
 818:              }
 819:          }
 820:   
 821:          ////////////////////////////////////////////////////////////////////////////
 822:   
 823:          /// <summary>
 824:          ///
 825:          /// </summary>
 826:          public static Dictionary<string, string> OntAccessNameToOntPositionDictionary
 827:          {
 828:              get
 829:              {
 830:                  if (ontAccessNameToOntPositionDictionary == null || ontAccessNameToOntPositionDictionary.Count == 0)
 831:                  {
 832:                      ontAccessNameToOntPositionDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 833:                                                              select new { OntAccessName = o.Access.Name, OntPosition = o.Position }).ToDictionary(n => n.OntAccessName, n => n.OntPosition);
 834:                  }
 835:   
 836:                  return ontAccessNameToOntPositionDictionary;
 837:              }
 838:          }
 839:   
 840:          ////////////////////////////////////////////////////////////////////////////
 841:   
 842:          /// <summary>
 843:          ///
 844:          /// </summary>
 845:          public static Dictionary<string, int> OntIdToOntPonPonGroupOltIdDictionary
 846:          {
 847:              get
 848:              {
 849:                  if (ontIdToOntPonPonGroupOltIdDictionary == null || ontIdToOntPonPonGroupOltIdDictionary.Count == 0)
 850:                  {
 851:                      ontIdToOntPonPonGroupOltIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 852:                                                              select new { OntId = o.Id, OntPonPonGroupOltId = o.Pon.PonGroup.Olt.Id }).ToDictionary(n => n.OntId, n => n.OntPonPonGroupOltId);
 853:                  }
 854:   
 855:                  return ontIdToOntPonPonGroupOltIdDictionary;
 856:              }
 857:          }
 858:   
 859:          ////////////////////////////////////////////////////////////////////////////
 860:   
 861:          /// <summary>
 862:          ///
 863:          /// </summary>
 864:          public static Dictionary<string, string> OntIdDictionary
 865:          {
 866:              get
 867:              {
 868:                  if (ontIdDictionary == null || ontIdDictionary.Count == 0)
 869:                  {
 870:                      ontIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Id).ToDictionary(n => n, n => n);
 871:                  }
 872:   
 873:                  return ontIdDictionary;
 874:              }
 875:          }
 876:   
 877:          ////////////////////////////////////////////////////////////////////////////
 878:   
 879:          /// <summary>
 880:          ///
 881:          /// </summary>
 882:          public static Dictionary<string, string> OntIpDictionary
 883:          {
 884:              get
 885:              {
 886:                  if (ontIpDictionary == null || ontIpDictionary.Count == 0)
 887:                  {
 888:                      ontIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Ip).ToDictionary(n => n, n => n);
 889:                  }
 890:   
 891:                  return ontIpDictionary;
 892:              }
 893:          }
 894:   
 895:          ////////////////////////////////////////////////////////////////////////////
 896:   
 897:          /// <summary>
 898:          ///
 899:          /// </summary>
 900:          public static Dictionary<string, string> NokiaOntIpToPrimarySwitchImsFsdbDictionary
 901:          {
 902:              get
 903:              {
 904:                  Dictionary<string, string> dictionary;
 905:   
 906:                  dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 907:                                where o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 908:                                select o).Distinct().ToDictionary(n => n.Ip, n => n.PrimarySwitch + "(" + n.ImsFsdb + ")");
 909:   
 910:                  return dictionary;
 911:              }
 912:          }
 913:   
 914:          ////////////////////////////////////////////////////////////////////////////
 915:   
 916:          /// <summary>
 917:          /// 
 918:          /// </summary>
 919:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdCardPortOntNumber(int oltId, int cardSlot, int port, int ontInternalNumber)
 920:          {
 921:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
 922:   
 923:              item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 924:                      where o.Pon.PonGroup.Olt.Id == oltId && o.CardSlot == cardSlot && o.Port == port && o.InternalNumber == ontInternalNumber
 925:                      select o).SingleOrDefault();
 926:   
 927:              return item;
 928:          }
 929:   
 930:          ////////////////////////////////////////////////////////////////////////////
 931:   
 932:          /// <summary>
 933:          /// 
 934:          /// </summary>
 935:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdPonIdOntNumber(int oltId, string ponId, int ontInternalNumber)
 936:          {
 937:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
 938:   
 939:              item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 940:                      where o.Pon.PonGroup.Olt.Id == oltId && o.Pon.Id == ponId && o.InternalNumber == ontInternalNumber
 941:                      select o).SingleOrDefault();
 942:   
 943:              return item;
 944:          }
 945:   
 946:          ////////////////////////////////////////////////////////////////////////////
 947:   
 948:          /// <summary>
 949:          ///
 950:          /// </summary>
 951:          public static bool AccessNameIsWithinAllowedOntList(string inputAccessName, out string accessName)
 952:          {
 953:              // below: this checks that this accessName is within the standard possible values in network
 954:              bool isWithinAllowedOnts;
 955:              string s;
 956:   
 957:              accessName = Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(inputAccessName);
 958:   
 959:              if (!string.IsNullOrEmpty(accessName))
 960:              {
 961:                  s = accessName;
 962:   
 963:                  isWithinAllowedOnts = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == s select o).SingleOrDefault() != null;
 964:              }
 965:              else isWithinAllowedOnts = false;
 966:   
 967:              return isWithinAllowedOnts;
 968:          }
 969:   
 970:          ////////////////////////////////////////////////////////////////////////////
 971:   
 972:          /// <summary>
 973:          ///
 974:          /// </summary>
 975:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ReadOnt(string ontId)
 976:          {
 977:              return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ontId select o).SingleOrDefault();
 978:          }
 979:   
 980:          ////////////////////////////////////////////////////////////////////////////
 981:   
 982:          /// <summary>
 983:          ///
 984:          /// </summary>
 985:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByAccessName(string accessName)
 986:          {
 987:              return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
 988:          }
 989:   
 990:          ////////////////////////////////////////////////////////////////////////////
 991:   
 992:          /// <summary>
 993:          ///
 994:          /// </summary>
 995:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByOntId(string ontId)
 996:          {
 997:              return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ontId select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
 998:          }
 999:   
1000:          ////////////////////////////////////////////////////////////////////////////
1001:   
1002:          /// <summary>
1003:          ///
1004:          /// </summary>
1005:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByAccessName(string accessName)
1006:          {
1007:              return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
1008:          }
1009:   
1010:          ////////////////////////////////////////////////////////////////////////////
1011:   
1012:          /// <summary>
1013:          ///
1014:          /// </summary>
1015:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorByAccessName(string accessName)
1016:          {
1017:              return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Router.Vendor).SingleOrDefault();
1018:          }
1019:   
1020:          ////////////////////////////////////////////////////////////////////////////
1021:   
1022:          /// <summary>
1023:          ///
1024:          /// </summary>
1025:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router RouterFromService(string service)
1026:          {
1027:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
1028:   
1029:              if (!string.IsNullOrEmpty(service))
1030:              {
1031:                  if (int.TryParse(service, out int i))
1032:                  {
1033:                      router = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
1034:                                where r.DomainList.Any(u => service.StartsWith(u.ToString()))
1035:                                select r).FirstOrDefault(); //.SingleOrDefault(); // 2390 is defined in two different huawei routers
1036:                  }
1037:                  else router = null;
1038:              }
1039:              else router = null;
1040:   
1041:              return router;
1042:          }
1043:   
1044:          ////////////////////////////////////////////////////////////////////////////
1045:   
1046:          /// <summary>
1047:          ///
1048:          /// </summary>
1049:          public static bool PonNameIsWithinAllowedOntList(string ontAreaPon)
1050:          {
1051:              // below: this checks that this accessName is within the standard possible values in network
1052:   
1053:              bool isWithinAllowedOnts;
1054:   
1055:              if (ontAreaPon == null || ontAreaPon.Length == 0) isWithinAllowedOnts = false;
1056:              else
1057:              {
1058:                  isWithinAllowedOnts = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name.Contains(ontAreaPon + ".") select o).FirstOrDefault() != null;
1059:              }
1060:   
1061:              return isWithinAllowedOnts;
1062:          }
1063:   
1064:          ////////////////////////////////////////////////////////////////////////////
1065:   
1066:          /// <summary>
1067:          ///
1068:          /// </summary>
1069:          public static string OntIdFromPosition(string position)
1070:          {
1071:              string id;
1072:   
1073:              id = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Position == position select o.Id).FirstOrDefault();
1074:   
1075:              return id;
1076:          }
1077:   
1078:          ////////////////////////////////////////////////////////////////////////////
1079:   
1080:          /// <summary>
1081:          ///
1082:          /// </summary>
1083:          public static void ExportOntListToText()
1084:          {
1085:              string filePath;
1086:              StringBuilder sb;
1087:   
1088:              sb = new StringBuilder();
1089:   
1090:              foreach (var o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList) sb.AppendLine(o.Access.Name + " " + o.Position + " " + o.Id);
1091:   
1092:              filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ont-list.txt";
1093:              File.WriteAllText(filePath, sb.ToString());
1094:          }
1095:   
1096:          ////////////////////////////////////////////////////////////////////////////
1097:          ////////////////////////////////////////////////////////////////////////////
1098:   
1099:   
1100:   
1101:   
1102:   
1103:   
1104:   
1105:          ////////////////////////////////////////////////////////////////////////////
1106:          ////////////////////////////////////////////////////////////////////////////
1107:   
1108:          /// <summary>
1109:          ///
1110:          /// </summary>
1111:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonList
1112:          {
1113:              get
1114:              {
1115:                  lock (objectLock)
1116:                  {
1117:                      if (ponList == null || ponList.Count == 0) ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonList;
1118:   
1119:                      return ponList;
1120:                  }
1121:              }
1122:          }
1123:   
1124:          ////////////////////////////////////////////////////////////////////////////
1125:   
1126:          /// <summary>
1127:          ///
1128:          /// </summary>
1129:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> _PonList
1130:          {
1131:              get
1132:              {
1133:                  bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
1134:                  int ponNumber, proposedPonNumber, slot, oltPonIndex, oltPonCount, oltProposedPonCount;
1135:                  string odfName;
1136:  #if DEBUG
1137:                  Dictionary<string, string> ponIdDictionary;
1138:  #endif
1139:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
1140:   
1141:                  ponList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32); // 32 is the max number of PONs in an PonGroup (16 max per LT)
1142:  #if DEBUG
1143:                  ponIdDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32);
1144:  #endif
1145:                  foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1146:                  {
1147:                      oltPonIndex = 0;
1148:   
1149:                      nokiaRouter = (olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
1150:                      huaweiRouter = !nokiaRouter;
1151:   
1152:                      nokiaOdf = (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
1153:                      huaweiOdf = !nokiaOdf;
1154:   
1155:                      odfName = olt.Odf.Name;
1156:   
1157:                      oltPonCount = oltProposedPonCount = 0;
1158:   
1159:                      foreach (var ponGroup in olt.PonGroupList)
1160:                      {
1161:                          oltPonCount += ponGroup.UsedPonInPonGroupList.Count;
1162:   
1163:                          if (ponGroup.HasNewProposedPonList) oltProposedPonCount += ponGroup.UsedProposedPonInPonGroupList.Count;
1164:                      }
1165:   
1166:                      if (((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0)
1167:                      {
1168:                          foreach (var ponGroup in olt.PonGroupList)
1169:                          {
1170:                              if (!ponGroup.HasNewProposedPonList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)
1171:                              {
1172:                                  // below: Note that I will use the INDEX of the PON number in the UsedPonList to construct the PON Id, this will make it possible 
1173:                                  // to match this index with that from the Ip, position list, because that list does not recognize PONs.
1174:                                  for (int ponGroupPonIndex = 0; ponGroupPonIndex < ponGroup.UsedPonInPonGroupList.Count; ponGroupPonIndex++)
1175:                                  {
1176:                                      if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.HasNewProposedPonList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
1177:                                      {
1178:                                          pon = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon();
1179:   
1180:                                          ponNumber = (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex];
1181:   
1182:                                          if (ponGroup.HasNewProposedPonList) proposedPonNumber = (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex];
1183:                                          else proposedPonNumber = ponNumber;
1184:   
1185:                                          pon.Id = pon.PonId(ponGroup.Olt.Id, oltPonIndex);
1186:   
1187:                                          pon.Index = oltPonIndex;
1188:                                          pon.PonGroupPonIndex = ponGroupPonIndex;
1189:   
1190:                                          pon.PonGroup = (from l in PonGroupList where l.Id == ponGroup.Id select l).SingleOrDefault();
1191:   
1192:                                          pon.Rack = pon.PonGroup.Olt.Rack;
1193:                                          pon.Sub = pon.PonGroup.Olt.Sub;
1194:   
1195:                                          if (nokiaOdf)
1196:                                          {
1197:                                              pon.CardSlot = oltPonIndex / olt.NumberOfLts + 1;
1198:                                              pon.Port = oltPonIndex % olt.NumberOfLts + 1;
1199:                                          }
1200:                                          else //if(huaweiOdf)
1201:                                          {
1202:                                              // Huawei skips slots 9 and 10 and goes directly from 8 to 11
1203:   
1204:                                              slot = oltPonIndex / (olt.NumberOfPonsPerLt * olt.NumberOfLts / 16) + 1;
1205:   
1206:                                              if (slot > 8) slot += 2;
1207:   
1208:                                              if (ponGroup.Olt.NumberOfFirstSlot == 0) slot--;
1209:   
1210:                                              pon.CardSlot = slot;
1211:   
1212:                                              pon.Port = (16 * oltPonIndex % olt.NumberOfPons) / (32 / olt.NumberOfOntsInPon) / 16;
1213:   
1214:                                          }
1215:   
1216:                                          pon.Number = ponNumber;
1217:                                          pon.ProposedNumber = proposedPonNumber;
1218:                                          pon.Position = pon.PonGroup.Olt.AmsName + "-" + pon.CardSlot + "-" + pon.Port;
1219:                                          pon.Name = pon.PonGroup.Symbol + "." + pon.Number;
1220:   
1221:  #if DEBUG
1222:                                          if (pon.Name == "SBA.618")
1223:                                          {
1224:   
1225:                                          }
1226:  #endif
1227:   
1228:  #if DEBUG
1229:                                          // this will throw an exception if there is a duplicate pon.Id
1230:                                          if (ponIdDictionary.ContainsKey(pon.Id))
1231:                                          {
1232:                                              throw new ArgumentOutOfRangeException(@"ponDictionary.ContainsKey(pon.Id)");
1233:                                          }
1234:                                          else ponIdDictionary[pon.Id] = pon.Name;
1235:  #endif
1236:   
1237:                                          ponList.Add(pon);
1238:                                      }
1239:  #if DEBUG
1240:                                      else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0))
1241:                                      {
1242:                                          throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0)");
1243:                                      }
1244:                                      else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
1245:                                      {
1246:                                          throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0)");
1247:                                      }
1248:                                      else
1249:                                      {
1250:                                      }
1251:  #endif
1252:                                      oltPonIndex++;
1253:                                  }
1254:                              }
1255:                              else throw new ArgumentOutOfRangeException(@"Condition not met: (!ponGroup.UsesProposedList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)");
1256:                          }
1257:                      }
1258:                      else throw new ArgumentOutOfRangeException(@"Condition not met: ((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0");
1259:                  }
1260:   
1261:                  return ponList;
1262:              }
1263:          }
1264:   
1265:          ////////////////////////////////////////////////////////////////////////////
1266:   
1267:          /// <summary>
1268:          ///
1269:          /// </summary>
1270:          public static Dictionary<string, string> PonNameToPonIdDictionary
1271:          {
1272:              get
1273:              {
1274:                  if (ponNameToPonIdDictionary == null || ponNameToPonIdDictionary.Count == 0)
1275:                  {
1276:                      ponNameToPonIdDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, p.Id }).ToDictionary(n => n.Name, n => n.Id);
1277:                  }
1278:   
1279:                  return ponNameToPonIdDictionary;
1280:              }
1281:          }
1282:   
1283:          ////////////////////////////////////////////////////////////////////////////
1284:   
1285:          /// <summary>
1286:          ///
1287:          /// </summary>
1288:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonIdToPonDictionary
1289:          {
1290:              get
1291:              {
1292:                  if (ponIdToPonDictionary == null || ponIdToPonDictionary.Count == 0)
1293:                  {
1294:                      ponIdToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Id, Pon = p }).ToDictionary(n => n.Id, n => n.Pon);
1295:                  }
1296:   
1297:                  return ponIdToPonDictionary;
1298:              }
1299:          }
1300:   
1301:          ////////////////////////////////////////////////////////////////////////////
1302:   
1303:          /// <summary>
1304:          ///
1305:          /// </summary>
1306:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonNameToPonDictionary
1307:          {
1308:              get
1309:              {
1310:                  if (ponNameToPonDictionary == null || ponNameToPonDictionary.Count == 0)
1311:                  {
1312:                      ponNameToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, Pon = p }).ToDictionary(n => n.Name, n => n.Pon);
1313:                  }
1314:   
1315:                  return ponNameToPonDictionary;
1316:              }
1317:          }
1318:   
1319:          ////////////////////////////////////////////////////////////////////////////
1320:   
1321:          /// <summary>
1322:          ///
1323:          /// </summary>
1324:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon PonByOltEmsNameAndSnAndPn(string emsName, int sn, int pn)
1325:          {
1326:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
1327:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1328:   
1329:              olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltByEmsName(emsName);
1330:   
1331:              if (olt.EmsName == "OLT-QRN-ABW-01") // ABW is all screwed up with multiple PON grouped and I will use .FirstOrDefault();
1332:              {
1333:                  pon = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup.Olt.Id == olt.Id && p.CardSlot == sn && p.Port == pn select p).FirstOrDefault();
1334:              }
1335:              else
1336:              {
1337:                  pon = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup.Olt.Id == olt.Id && p.CardSlot == sn && p.Port == pn select p).SingleOrDefault();
1338:              }
1339:   
1340:              return pon;
1341:          }
1342:   
1343:          ////////////////////////////////////////////////////////////////////////////
1344:          ////////////////////////////////////////////////////////////////////////////
1345:   
1346:          /// <summary>
1347:          ///
1348:          /// </summary>
1349:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
1350:          {
1351:              get
1352:              {
1353:                  lock (objectLock)
1354:                  {
1355:                      if (ponGroupList == null || ponGroupList.Count == 0) ponGroupList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonGroupList;
1356:   
1357:                      return ponGroupList;
1358:                  }
1359:              }
1360:          }
1361:   
1362:          ////////////////////////////////////////////////////////////////////////////
1363:   
1364:          /// <summary>
1365:          ///
1366:          /// </summary>
1367:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> _PonGroupList
1368:          {
1369:              get
1370:              {
1371:                  int networkId, siteId, routerId, odfId, oltId, id;
1372:                  const string pattern = @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0";
1373:                  Regex regex;
1374:                  Hashtable idHashtable, networkNumberHashtable;
1375:  #if DEBUG
1376:                  Hashtable gatewayIpHashtable;
1377:  #endif
1378:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup;
1379:   
1380:                  regex = new Regex(pattern);
1381:                  ponGroupList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup>(16); // 16 is max number of ponGroup in ONT
1382:                  idHashtable = new Hashtable();
1383:                  networkNumberHashtable = new Hashtable();
1384:  #if DEBUG
1385:                  gatewayIpHashtable = new Hashtable();
1386:  #endif
1387:   
1388:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt").Elements("ponGroup"))
1389:                  {
1390:                      ponGroup = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup
1391:                      {
1392:                          Olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt()
1393:                      };
1394:                      ponGroup.Olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1395:                      ponGroup.Olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1396:                      ponGroup.Olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1397:   
1398:                      networkId = int.Parse(x.Parent.Parent.Parent.Parent.Parent.Attribute("id").Value);
1399:                      siteId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1400:                      routerId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1401:                      odfId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1402:                      oltId = int.Parse(x.Parent.Attribute("id").Value);
1403:                      id = int.Parse(x.Attribute("id").Value);
1404:   
1405:                      siteId = ponGroup.Olt.Odf.Router.Site.SiteId(networkId, siteId);
1406:                      routerId = ponGroup.Olt.Odf.Router.RouterId(siteId, routerId);
1407:                      odfId = ponGroup.Olt.Odf.OdfId(routerId, odfId);
1408:                      oltId = ponGroup.Olt.OltId(odfId, oltId);
1409:                      ponGroup.Id = ponGroup.PonGroupId(oltId, id);
1410:   
1411:                      ponGroup.Number = id;
1412:   
1413:                      ponGroup.Olt = (from o in OltList where o.Id == oltId select o).SingleOrDefault();
1414:   
1415:                      if (x.Attribute("symbol") != null) ponGroup.Symbol = x.Attribute("symbol").Value;
1416:                      else ponGroup.Symbol = ponGroup.Olt.Symbol;
1417:   
1418:                      ponGroup.NetworkNumber = x.Attribute("networkNumber").Value;
1419:                      // Network number must be unique and must end with *.*.*.0
1420:                      if (networkNumberHashtable.ContainsKey(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1421:                      else if (!regex.IsMatch(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not if format *.*.*.0 OLT name=" + ponGroup.Olt.Name + ". ");
1422:                      else networkNumberHashtable[ponGroup.NetworkNumber] = 1;
1423:   
1424:   
1425:                      ponGroup.PonListString = x.Attribute("list").Value;
1426:                      // below: pass ponList and change "*" to "0"
1427:                      ponGroup.UsedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.PonListString.Replace("*", "0"));
1428:   
1429:                      if (x.Attribute("proposedList") != null && x.Attribute("proposedList").Value.Length > 0)
1430:                      {
1431:                          ponGroup.ProposedPonListString = x.Attribute("proposedList").Value;
1432:   
1433:                          // below: pass ponList and change "*" to "0"
1434:                          ponGroup.UsedProposedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.ProposedPonListString.Replace("*", "0"));
1435:                      }
1436:                      else
1437:                      {
1438:                          ponGroup.ProposedPonListString = string.Empty;
1439:                          ponGroup.UsedProposedPonInPonGroupList = new List<int>();
1440:                      }
1441:   
1442:                      if (x.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Attribute("gatewayIp").Value;
1443:                      else if (x.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1444:                      else if (x.Parent.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Parent.Attribute("gatewayIp").Value;
1445:                      else throw new ArgumentException(@"ponGroup.GatewayIp could not be produced from XML document. ");
1446:   
1447:                      if (x.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Attribute("mgcIp").Value;
1448:                      else if (x.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Attribute("mgcIp").Value;
1449:                      else if (x.Parent.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Parent.Attribute("mgcIp").Value;
1450:                      else if (ponGroup.Olt.Name != "SAA-1" && (ponGroup.Olt.Name != "SDQ-1")) throw new ArgumentException(@"ponGroup.MgcIp could not be produced from XML document. ");
1451:                      // note that MgcIp need some special handling on the PON.ONT level
1452:   
1453:  #if DEBUG
1454:                      // GatewayIp number must be unique
1455:                      /*if (gatewayIpHashtable.ContainsKey(ponGroup.GatewayIp)) throw new ArgumentException(@"Lt.GatewayIp is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1456:                      else*/
1457:                      gatewayIpHashtable[ponGroup.GatewayIp] = 1;
1458:   
1459:                      // Id
1460:                      if (idHashtable.ContainsKey(ponGroup.Id)) throw new ArgumentException(@"ponGroup.Id is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1461:                      else idHashtable[ponGroup.Id] = 1;
1462:  #endif
1463:                      ponGroupList.Add(ponGroup);
1464:                  }
1465:   
1466:                  return ponGroupList;
1467:              }
1468:          }
1469:   
1470:          ////////////////////////////////////////////////////////////////////////////
1471:   
1472:          /// <summary>
1473:          ///
1474:          /// </summary>
1475:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> OltList
1476:          {
1477:              get
1478:              {
1479:                  lock (objectLock)
1480:                  {
1481:                      if (oltList == null || oltList.Count == 0) oltList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OltList;
1482:   
1483:                      return oltList;
1484:                  }
1485:              }
1486:          }
1487:   
1488:          ////////////////////////////////////////////////////////////////////////////
1489:   
1490:          /// <summary>
1491:          ///
1492:          /// </summary>
1493:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> _OltList
1494:          {
1495:              get
1496:              {
1497:                  int networkId, siteId, routerId, odfId, id;
1498:                  string fieldTypeString;
1499:                  Hashtable networkNumberHashtable;
1500:                  Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState state;
1501:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1502:   
1503:                  oltList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt>(100);
1504:                  networkNumberHashtable = new Hashtable();
1505:   
1506:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt"))
1507:                  {
1508:                      olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt();
1509:                      olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1510:                      olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1511:                      olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1512:   
1513:                      networkId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1514:                      siteId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1515:                      routerId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1516:                      odfId = int.Parse(x.Parent.Attribute("id").Value);
1517:                      id = int.Parse(x.Attribute("id").Value);
1518:   
1519:                      siteId = olt.Odf.Router.Site.SiteId(networkId, siteId);
1520:                      routerId = olt.Odf.Router.RouterId(siteId, routerId);
1521:                      odfId = olt.Odf.OdfId(routerId, odfId);
1522:                      olt.Id = olt.OltId(odfId, id);
1523:   
1524:                      olt.Odf = (from o in OdfList where o.Id == odfId select o).SingleOrDefault();
1525:   
1526:                      olt.Name = x.Attribute("name").Value;
1527:                      olt.AmsName = x.Attribute("amsName").Value;
1528:   
1529:                      if (x.Attribute("did") != null) olt.Did = int.Parse(x.Attribute("did").Value);
1530:   
1531:                      olt.Type = x.Attribute("type").Value;
1532:   
1533:                      if (x.Attribute("state") != null)
1534:                      {
1535:                          switch (x.Attribute("state").Value)
1536:                          {
1537:                              case "is-nr": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr; break;
1538:                              case "oos-au": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAu; break;
1539:                              case "oos-ma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosMa; break;
1540:                              case "oos-auma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAuma; break;
1541:                              default: state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined; break;
1542:                          }
1543:                      }
1544:                      else state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined;
1545:   
1546:                      olt.StateId = (int)state;
1547:   
1548:                      olt.IsSip = x.Attribute("isSip").Value == "true";
1549:   
1550:                      if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1551:                      {
1552:                          olt.Rack = 1;
1553:                          olt.Sub = 1;
1554:                      }
1555:                      else //if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1556:                      {
1557:                          olt.Rack = 0;
1558:                          olt.Sub = 0;
1559:                      }
1560:   
1561:                      if (x.Attribute("gatewayIp") != null) olt.GatewayIp = x.Attribute("gatewayIp").Value;
1562:                      else if (x.Parent.Attribute("gatewayIp") != null) olt.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1563:                      else olt.GatewayIp = string.Empty;
1564:   
1565:                      if (x.Attribute("mgcIp") != null) olt.MgcIp = x.Attribute("mgcIp").Value;
1566:                      else if (x.Parent.Attribute("mgcIp") != null) olt.MgcIp = x.Parent.Attribute("mgcIp").Value;
1567:                      else olt.MgcIp = string.Empty;
1568:   
1569:                      fieldTypeString = x.Attribute("fieldType").Value;
1570:   
1571:                      if (!string.IsNullOrEmpty(fieldTypeString))
1572:                      {
1573:                          if (fieldTypeString == "green") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green;
1574:                          else if (fieldTypeString == "brown") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown;
1575:                          else throw new ArgumentException(@"OLT field type unrecognized. ");
1576:                      }
1577:                      else throw new ArgumentException(@"OLT field type invalid. ");
1578:   
1579:                      olt.Symbol = x.Attribute("symbol").Value;
1580:   
1581:                      // below: the number of possible PONs differs between Nokia OLT types and Huawei
1582:                      if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1583:                      {
1584:                          olt.NumberOfPonsPerLt = 16;
1585:                          olt.NumberOfOntsInPon = 32;
1586:                          olt.NumberOfFirstSlot = 1;
1587:   
1588:                          if (olt.Type == "7342")
1589:                          {
1590:                              olt.NumberOfLts = 2;
1591:                          }
1592:                          else if (olt.Type == "7360")
1593:                          {
1594:                              olt.NumberOfLts = 16;
1595:                          }
1596:                          else
1597:                          {
1598:                              throw new ArgumentException(@"Nokia olt.Type unrecognized. ");
1599:                          }
1600:                      }
1601:                      else if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1602:                      {
1603:                          olt.NumberOfLts = 2;
1604:   
1605:                          if (olt.Type == "MA5600T")
1606:                          {
1607:                              olt.NumberOfPonsPerLt = 128;
1608:                              olt.NumberOfOntsInPon = 32;
1609:                              olt.NumberOfFirstSlot = 1;
1610:                          }
1611:                          else if (olt.Type == "MA5600T-temp")
1612:                          {
1613:                              olt.NumberOfPonsPerLt = 128 * 8;
1614:                              olt.NumberOfOntsInPon = 4;
1615:                              olt.NumberOfFirstSlot = 1;
1616:                          }
1617:                          else if (olt.Type == "MA5603T")
1618:                          {
1619:                              olt.NumberOfPonsPerLt = 128;
1620:                              olt.NumberOfOntsInPon = 32;
1621:                              olt.NumberOfFirstSlot = 0;
1622:                          }
1623:                          else
1624:                          {
1625:                              throw new ArgumentException(@"Huawei olt.Type unrecognized. ");
1626:                          }
1627:                      }
1628:                      else
1629:                      {
1630:                          throw new ArgumentException(@"olt.Odf.Vendor unrecognized. ");
1631:                      }
1632:   
1633:                      olt.NumberOfPons = olt.NumberOfLts * olt.NumberOfPonsPerLt;
1634:  #if DEBUG
1635:                      if ((olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0) throw new ArgumentException(@"(olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0");
1636:                      if (olt.NumberOfFirstSlot != 0 && olt.NumberOfFirstSlot != 1) throw new ArgumentException(@"olt.NumberOfFirstSlot == 0 || olt.NumberOfFirstSlot == 1");
1637:  #endif
1638:                      oltList.Add(olt);
1639:                  }
1640:   
1641:                  return oltList;
1642:              }
1643:          }
1644:   
1645:          ////////////////////////////////////////////////////////////////////////////
1646:          ////////////////////////////////////////////////////////////////////////////
1647:   
1648:          /// <summary>
1649:          ///
1650:          /// </summary>
1651:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> NokiaOltList
1652:          {
1653:              get
1654:              {
1655:                  return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia, 0);
1656:              }
1657:          }
1658:   
1659:          ////////////////////////////////////////////////////////////////////////////
1660:   
1661:          /// <summary>
1662:          ///
1663:          /// </summary>
1664:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltList
1665:          {
1666:              get
1667:              {
1668:                  return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei, 0);
1669:              }
1670:          }
1671:   
1672:          /*
1673:          ////////////////////////////////////////////////////////////////////////////
1674:  
1675:          /// <summary>
1676:          ///
1677:          /// </summary>
1678:          public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> NokiaOltList(int siteId)
1679:          {
1680:              return VendorOltList("No", siteId);
1681:          }
1682:  
1683:          ////////////////////////////////////////////////////////////////////////////
1684:  
1685:          /// <summary>
1686:          ///
1687:          /// </summary>
1688:          public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> HuaweiOltList(int siteId)
1689:          {
1690:              return VendorOltList("Hu", siteId);
1691:          }
1692:          */
1693:   
1694:          ////////////////////////////////////////////////////////////////////////////
1695:   
1696:          /// <summary>
1697:          ///
1698:          /// </summary>
1699:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor, int siteId)
1700:          {
1701:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1702:   
1703:              list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1704:                      where o.Odf.Vendor == vendor && (o.Odf.Router.Site.Id == siteId || siteId == 0)
1705:                      select o).ToList();
1706:   
1707:              return list;
1708:          }
1709:   
1710:          /*
1711:          ////////////////////////////////////////////////////////////////////////////
1712:  
1713:          /// <summary>
1714:          ///
1715:          /// </summary>
1716:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltTempList
1717:          {
1718:              get
1719:              {
1720:                  List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1721:  
1722:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1723:                          where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei && Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsValue(o.AmsName) && o.Symbol == "SAA" || o.Symbol == "SDQ" || o.Symbol == "ADN" || o.Symbol == "QSR" || o.Symbol == "ABW" || o.Symbol == "JBA" || o.Symbol == "ADS"
1724:                          select o).ToList();
1725:  
1726:                  return list;
1727:              }
1728:          }
1729:          */
1730:   
1731:          ////////////////////////////////////////////////////////////////////////////
1732:   
1733:          /// <summary>
1734:          ///
1735:          /// </summary>
1736:          public static List<int> NokiaOltIdList()
1737:          {
1738:              return OltIdByVendorAndSiteIdList("No", 0);
1739:          }
1740:   
1741:          ////////////////////////////////////////////////////////////////////////////
1742:   
1743:          /// <summary>
1744:          ///
1745:          /// </summary>
1746:          public static List<int> NokiaOltIdList(int siteId)
1747:          {
1748:              return OltIdByVendorAndSiteIdList("No", siteId);
1749:          }
1750:   
1751:          ////////////////////////////////////////////////////////////////////////////
1752:   
1753:          /// <summary>
1754:          ///
1755:          /// </summary>
1756:          public static List<int> HuaweiOltIdList()
1757:          {
1758:              return OltIdByVendorAndSiteIdList("Hu", 0);
1759:          }
1760:   
1761:          /*
1762:          ////////////////////////////////////////////////////////////////////////////
1763:  
1764:          /// <summary>
1765:          ///
1766:          /// </summary>
1767:          public static List<int> HuaweiOltIdTempList()
1768:          {
1769:              List<int> list;
1770:  
1771:              list = (from o in HuaweiOltTempList select o.Id).ToList();
1772:  
1773:              return list;
1774:          }
1775:          */
1776:   
1777:          ////////////////////////////////////////////////////////////////////////////
1778:   
1779:          /// <summary>
1780:          ///
1781:          /// </summary>
1782:          public static List<int> HuaweiOltIdList(int siteId)
1783:          {
1784:              return OltIdByVendorAndSiteIdList("Hu", siteId);
1785:          }
1786:   
1787:          ////////////////////////////////////////////////////////////////////////////
1788:   
1789:          /// <summary>
1790:          ///
1791:          /// </summary>
1792:          public static List<int> OltIdByVendorAndSiteIdList(string vendorShortName, int siteId)
1793:          {
1794:              List<int> list;
1795:   
1796:              list = new List<int>();
1797:   
1798:              foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1799:              {
1800:                  // siteId 0 will return all sites
1801:   
1802:                  if (olt.Odf.Vendor.ShortName == vendorShortName && (olt.Odf.Router.Site.Id == siteId || siteId == 0))
1803:                  {
1804:                      list.Add(olt.Id);
1805:                  }
1806:              }
1807:   
1808:              return list;
1809:          }
1810:   
1811:          ////////////////////////////////////////////////////////////////////////////
1812:   
1813:          /// <summary>
1814:          ///
1815:          /// </summary>
1816:          public static List<int> OltIdList
1817:          {
1818:              get
1819:              {
1820:                  List<int> list;
1821:   
1822:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList select o.Id).ToList();
1823:   
1824:                  return list;
1825:              }
1826:          }
1827:   
1828:          ////////////////////////////////////////////////////////////////////////////
1829:   
1830:          /// <summary>
1831:          ///
1832:          /// </summary>
1833:          public static List<int> HuaweiSwitchNokiaGponOltIdList
1834:          {
1835:              get
1836:              {
1837:                  List<int> list;
1838:   
1839:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1840:                          where o.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
1841:                          && o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
1842:                          select o.Id).ToList();
1843:   
1844:                  return list;
1845:              }
1846:          }
1847:   
1848:          ////////////////////////////////////////////////////////////////////////////
1849:   
1850:          /// <summary>
1851:          ///
1852:          /// </summary>
1853:          public static Hashtable OltAmsNameToIdList
1854:          {
1855:              get
1856:              {
1857:                  Hashtable ht;
1858:   
1859:                  ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1860:   
1861:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1862:                  {
1863:                      ht[olt.AmsName] = olt.Id;
1864:                  }
1865:   
1866:                  return ht;
1867:              }
1868:          }
1869:   
1870:          ////////////////////////////////////////////////////////////////////////////
1871:   
1872:          /// <summary>
1873:          ///
1874:          /// </summary>
1875:          public static Hashtable FirstPonNameInOltToOltIdList
1876:          {
1877:              get
1878:              {
1879:                  Hashtable ht;
1880:   
1881:                  ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1882:   
1883:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1884:                  {
1885:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
1886:                      {
1887:                          ht[ponGroup.PonList.First().Name] = olt.Id;
1888:                      }
1889:                  }
1890:   
1891:                  return ht;
1892:              }
1893:          }
1894:   
1895:          ////////////////////////////////////////////////////////////////////////////
1896:   
1897:          /// <summary>
1898:          ///
1899:          /// </summary>
1900:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByEmsName(string emsName)
1901:          {
1902:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1903:   
1904:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1905:   
1906:              return olt;
1907:          }
1908:   
1909:          ////////////////////////////////////////////////////////////////////////////
1910:   
1911:          /// <summary>
1912:          ///
1913:          /// </summary>
1914:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1915:          {
1916:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1917:   
1918:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Did == did select o).SingleOrDefault();
1919:   
1920:              return olt;
1921:          }
1922:   
1923:          /*
1924:          ////////////////////////////////////////////////////////////////////////////
1925:  
1926:          /// <summary>
1927:          ///
1928:          /// </summary>
1929:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1930:          {
1931:              string emsName;
1932:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt item;
1933:  
1934:              if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsKey(did))
1935:              {
1936:                  emsName = Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName[did];
1937:  
1938:                  item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1939:              }
1940:              else item = null;
1941:  
1942:              return item;
1943:          }
1944:          */
1945:   
1946:          /*
1947:          ////////////////////////////////////////////////////////////////////////////
1948:  
1949:          /// <summary>
1950:          ///
1951:          /// </summary>
1952:          public static int DidByOlt(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1953:          {
1954:          int did;
1955:          string emsName;
1956:  
1957:          emsName = olt.EmsName;
1958:  
1959:          if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsValue(emsName))
1960:          {
1961:              did = (from odem in Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName where odem.Value == emsName select odem.Key).SingleOrDefault();
1962:          }
1963:          else did = 0;
1964:  
1965:          return did;
1966:          }
1967:          */
1968:   
1969:          ////////////////////////////////////////////////////////////////////////////
1970:          ////////////////////////////////////////////////////////////////////////////
1971:   
1972:          /// <summary>
1973:          ///
1974:          /// </summary>
1975:          public static List<int> SipOltIdList
1976:          {
1977:              get
1978:              {
1979:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1980:                          where o.IsSip == true
1981:                          select o.Id).ToList();
1982:              }
1983:          }
1984:   
1985:          ////////////////////////////////////////////////////////////////////////////
1986:          ////////////////////////////////////////////////////////////////////////////
1987:   
1988:          /// <summary>
1989:          ///
1990:          /// </summary>
1991:          public static List<int> GreenFieldOltIdList
1992:          {
1993:              get
1994:              {
1995:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1996:                          where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
1997:                          select o.Id).ToList();
1998:              }
1999:          }
2000:   
2001:          ////////////////////////////////////////////////////////////////////////////
2002:   
2003:          /// <summary>
2004:          ///
2005:          /// </summary>
2006:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldOltList
2007:          {
2008:              get
2009:              {
2010:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2011:                          where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2012:                          select o).ToList();
2013:              }
2014:          }
2015:   
2016:          ////////////////////////////////////////////////////////////////////////////
2017:   
2018:          /// <summary>
2019:          ///
2020:          /// </summary>
2021:          public static List<int> GreenFieldSipOltIdList
2022:          {
2023:              get
2024:              {
2025:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2026:                          where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2027:                          select o.Id).ToList();
2028:              }
2029:          }
2030:   
2031:          ////////////////////////////////////////////////////////////////////////////
2032:   
2033:          /// <summary>
2034:          ///
2035:          /// </summary>
2036:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldSipOltList
2037:          {
2038:              get
2039:              {
2040:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2041:                          where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2042:                          select o).ToList();
2043:              }
2044:          }
2045:   
2046:          ////////////////////////////////////////////////////////////////////////////
2047:   
2048:          /// <summary>
2049:          ///
2050:          /// </summary>
2051:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> GreenFieldOntList
2052:          {
2053:              get
2054:              {
2055:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
2056:                          where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2057:                          select o).ToList();
2058:              }
2059:          }
2060:   
2061:          ////////////////////////////////////////////////////////////////////////////
2062:          ////////////////////////////////////////////////////////////////////////////
2063:   
2064:          /// <summary>
2065:          ///
2066:          /// </summary>
2067:          public static List<int> BrownFieldOltIdList
2068:          {
2069:              get
2070:              {
2071:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2072:                          where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2073:                          select o.Id).ToList();
2074:              }
2075:          }
2076:   
2077:          ////////////////////////////////////////////////////////////////////////////
2078:   
2079:          /// <summary>
2080:          ///
2081:          /// </summary>
2082:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldOltList
2083:          {
2084:              get
2085:              {
2086:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2087:                          where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2088:                          select o).ToList();
2089:              }
2090:          }
2091:   
2092:          ////////////////////////////////////////////////////////////////////////////
2093:   
2094:          /// <summary>
2095:          ///
2096:          /// </summary>
2097:          public static List<int> BrownFieldSipOltIdList
2098:          {
2099:              get
2100:              {
2101:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2102:                          where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2103:                          select o.Id).ToList();
2104:              }
2105:          }
2106:   
2107:          ////////////////////////////////////////////////////////////////////////////
2108:   
2109:          /// <summary>
2110:          ///
2111:          /// </summary>
2112:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldSipOltList
2113:          {
2114:              get
2115:              {
2116:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2117:                          where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2118:                          select o).ToList();
2119:              }
2120:          }
2121:   
2122:          ////////////////////////////////////////////////////////////////////////////
2123:   
2124:          /// <summary>
2125:          ///
2126:          /// </summary>
2127:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> BrownFieldOntList
2128:          {
2129:              get
2130:              {
2131:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
2132:                          where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2133:                          select o).ToList();
2134:              }
2135:          }
2136:   
2137:          ////////////////////////////////////////////////////////////////////////////
2138:          ////////////////////////////////////////////////////////////////////////////
2139:   
2140:          /// <summary>
2141:          ///
2142:          /// </summary>
2143:          public static List<string> IsNrNokiaOltAmsNameList
2144:          {
2145:              get
2146:              {
2147:                  List<string> list;
2148:   
2149:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2150:                          where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
2151:                          && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
2152:                          select o.AmsName).ToList();
2153:   
2154:                  return list;
2155:              }
2156:          }
2157:   
2158:          ////////////////////////////////////////////////////////////////////////////
2159:   
2160:          /// <summary>
2161:          ///
2162:          /// </summary>
2163:          public static List<string> IsNrHuaweiOltAmsNameList
2164:          {
2165:              get
2166:              {
2167:                  List<string> list;
2168:   
2169:                  list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2170:                          where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
2171:                          && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
2172:                          select o.AmsName).ToList();
2173:   
2174:                  return list;
2175:              }
2176:          }
2177:   
2178:          ////////////////////////////////////////////////////////////////////////////
2179:   
2180:          /// <summary>
2181:          ///
2182:          /// </summary>
2183:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> OdfList
2184:          {
2185:              get
2186:              {
2187:                  lock (objectLock)
2188:                  {
2189:                      if (odfList == null || odfList.Count == 0) odfList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OdfList;
2190:   
2191:                      return odfList;
2192:                  }
2193:              }
2194:          }
2195:   
2196:          ////////////////////////////////////////////////////////////////////////////
2197:   
2198:          /// <summary>
2199:          ///
2200:          /// </summary>
2201:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> _OdfList
2202:          {
2203:              get
2204:              {
2205:                  int networkId, siteId, routerId, id;
2206:                  string vendorShortName;
2207:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf;
2208:   
2209:                  odfList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf>();
2210:   
2211:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("odf"))
2212:                  {
2213:                      odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
2214:                      odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2215:                      odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2216:   
2217:                      networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
2218:                      siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2219:                      routerId = int.Parse(x.Parent.Attribute("id").Value);
2220:                      id = int.Parse(x.Attribute("id").Value);
2221:   
2222:                      siteId = odf.Router.Site.SiteId(networkId, siteId);
2223:                      routerId = odf.Router.RouterId(siteId, routerId);
2224:                      odf.Id = odf.OdfId(routerId, id);
2225:   
2226:                      odf.Name = x.Attribute("name").Value;
2227:   
2228:                      odf.GatewayIp = (x.Attribute("gatewayIp") != null) ? x.Attribute("gatewayIp").Value : string.Empty;
2229:                      odf.MgcIp = (x.Attribute("mgcIp") != null) ? x.Attribute("mgcIp").Value : string.Empty;
2230:   
2231:                      vendorShortName = x.Attribute("vendorShortName").Value;
2232:                      odf.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
2233:   
2234:                      odf.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
2235:   
2236:                      odfList.Add(odf);
2237:                  }
2238:   
2239:                  return odfList.ToList();
2240:              }
2241:          }
2242:   
2243:          ////////////////////////////////////////////////////////////////////////////
2244:   
2245:          /// <summary>
2246:          ///
2247:          /// </summary>
2248:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> OamList
2249:          {
2250:              get
2251:              {
2252:                  lock (objectLock)
2253:                  {
2254:                      if (oamList == null || oamList.Count == 0) oamList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OamList;
2255:   
2256:                      return oamList;
2257:                  }
2258:              }
2259:          }
2260:   
2261:          ////////////////////////////////////////////////////////////////////////////
2262:   
2263:          /// <summary>
2264:          ///
2265:          /// </summary>
2266:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> _OamList
2267:          {
2268:              get
2269:              {
2270:                  int networkId, siteId, routerId, id;
2271:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam oam;
2272:   
2273:                  oamList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam>();
2274:   
2275:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("oam"))
2276:                  {
2277:                      oam = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam();
2278:                      oam.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2279:                      oam.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2280:   
2281:                      networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
2282:                      siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2283:                      routerId = int.Parse(x.Parent.Attribute("id").Value);
2284:                      id = int.Parse(x.Attribute("id").Value);
2285:   
2286:                      siteId = oam.Router.Site.SiteId(networkId, siteId);
2287:                      routerId = oam.Router.RouterId(siteId, routerId);
2288:                      oam.Id = oam.OamId(routerId, id);
2289:   
2290:                      oam.Network = x.Attribute("network").Value;
2291:                      oam.Gateway = x.Attribute("gateway").Value;
2292:                      oam.Vlan = int.Parse(x.Attribute("vlan").Value);
2293:                      oam.Vpls = int.Parse(x.Attribute("vpls").Value);
2294:                      oam.FtpIp = x.Attribute("ftpIp").Value;
2295:                      oam.ConfigFile = x.Attribute("configFile").Value;
2296:   
2297:                      oam.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
2298:   
2299:                      oamList.Add(oam);
2300:                  }
2301:   
2302:                  return oamList;
2303:              }
2304:          }
2305:   
2306:          ////////////////////////////////////////////////////////////////////////////
2307:   
2308:          /// <summary>
2309:          /// Return router (switch) vendor from service number
2310:          /// </summary>
2311:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorFromService(string service)
2312:          {
2313:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
2314:   
2315:              if (int.TryParse(service, out int i))
2316:              {
2317:                  switchVendor = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.DomainList.Any(u => service.StartsWith(u.ToString())) select r.Vendor).FirstOrDefault(); //.SingleOrDefault();
2318:   
2319:                  if (switchVendor == null) switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
2320:              }
2321:              else switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
2322:   
2323:              return switchVendor;
2324:          }
2325:   
2326:          ////////////////////////////////////////////////////////////////////////////
2327:   
2328:          /// <summary>
2329:          /// Return PSTN from service number
2330:          /// </summary>
2331:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(int number)
2332:          {
2333:              return PstnFromService(number.ToString());
2334:          }
2335:   
2336:          ////////////////////////////////////////////////////////////////////////////
2337:   
2338:          /// <summary>
2339:          /// Return PSTN from service number
2340:          /// </summary>
2341:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(string service)
2342:          {
2343:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
2344:   
2345:              if (int.TryParse(service, out int i))
2346:              {
2347:                  pstn = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList
2348:                          where p.DomainList.Any(u => service.StartsWith(u.ToString()))
2349:                          select p).SingleOrDefault();
2350:              }
2351:              else pstn = null;
2352:   
2353:              return pstn;
2354:          }
2355:   
2356:          ////////////////////////////////////////////////////////////////////////////
2357:   
2358:          /// <summary>
2359:          ///
2360:          /// </summary>
2361:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> PstnList
2362:          {
2363:              get
2364:              {
2365:                  lock (objectLock)
2366:                  {
2367:                      if (pstnList == null || pstnList.Count == 0) pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PstnList;
2368:   
2369:                      return pstnList;
2370:                  }
2371:              }
2372:          }
2373:   
2374:          ////////////////////////////////////////////////////////////////////////////
2375:   
2376:          /// <summary>
2377:          ///
2378:          /// </summary>
2379:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> _PstnList
2380:          {
2381:              get
2382:              {
2383:                  int networkId, siteId, id;
2384:                  string pstnExchangeTypeString;
2385:  #if DEBUG
2386:                  //Dictionary<int, int> domainDictionary;
2387:  #endif
2388:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
2389:   
2390:  #if DEBUG
2391:                  //domainDictionary = new Dictionary<int, int>(100);
2392:  #endif
2393:                  pstnList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn>();
2394:   
2395:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("pstn"))
2396:                  {
2397:                      pstn = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn();
2398:                      pstn.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2399:   
2400:                      networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2401:                      siteId = int.Parse(x.Parent.Attribute("id").Value);
2402:                      id = int.Parse(x.Attribute("id").Value);
2403:   
2404:                      siteId = pstn.Site.SiteId(networkId, siteId);
2405:                      pstn.Id = pstn.PstnId(siteId, id);
2406:                      pstn.Name = x.Attribute("name").Value;
2407:   
2408:                      //if (x.Attribute("ip") != null) pstn.Ip = x.Attribute("ip").Value;
2409:                      //else pstn.Ip = string.Empty;
2410:   
2411:                      pstn.DomainListString = x.Attribute("domainList").Value;
2412:   
2413:                      pstn.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(pstn.DomainListString);
2414:   
2415:  #if DEBUG
2416:                      /*
2417:                      foreach (int i in pstn.DomainList)
2418:                      {
2419:                          // this will throw an exception if there are similar domains in pstns
2420:                          if (domainDictionary.ContainsKey(i))
2421:                          {
2422:                              throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
2423:                          }
2424:                          else domainDictionary[i] = 1;
2425:                      }
2426:                      */
2427:  #endif
2428:   
2429:                      pstnExchangeTypeString = x.Attribute("type").Value;
2430:   
2431:                      if (pstnExchangeTypeString == "EWSD") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd;
2432:                      else if (pstnExchangeTypeString == "AXE") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe;
2433:  #if DEBUG
2434:                      else throw new ArgumentOutOfRangeException(@"Unknown PSTN exchange type: " + pstnExchangeTypeString);
2435:  #endif
2436:   
2437:                      pstn.Site = (from s in SiteList where s.Id == siteId select s).SingleOrDefault();
2438:   
2439:                      pstnList.Add(pstn);
2440:                  }
2441:   
2442:                  return pstnList;
2443:              }
2444:          }
2445:   
2446:          ////////////////////////////////////////////////////////////////////////////
2447:   
2448:          /// <summary>
2449:          ///
2450:          /// </summary>
2451:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> RouterList
2452:          {
2453:              get
2454:              {
2455:                  lock (objectLock)
2456:                  {
2457:                      if (routerList == null || routerList.Count == 0) routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._RouterList;
2458:   
2459:                      return routerList;
2460:                  }
2461:              }
2462:          }
2463:   
2464:          ////////////////////////////////////////////////////////////////////////////
2465:   
2466:          /// <summary>
2467:          ///
2468:          /// </summary>
2469:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> _RouterList
2470:          {
2471:              get
2472:              {
2473:                  int networkId, siteId, id;
2474:                  string vendorShortName;
2475:  #if DEBUG
2476:                  //Dictionary<int, int> domainDictionary;
2477:  #endif
2478:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
2479:   
2480:  #if DEBUG
2481:                  //domainDictionary = new Dictionary<int, int>(100);
2482:  #endif
2483:                  routerList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router>();
2484:   
2485:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router"))
2486:                  {
2487:                      router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2488:                      router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2489:   
2490:                      networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2491:                      siteId = int.Parse(x.Parent.Attribute("id").Value);
2492:                      id = int.Parse(x.Attribute("id").Value);
2493:   
2494:                      siteId = router.Site.SiteId(networkId, siteId);
2495:                      router.Id = router.RouterId(siteId, id);
2496:                      router.Name = x.Attribute("name").Value;
2497:   
2498:                      router.DomainListString = x.Attribute("domainList").Value;
2499:   
2500:                      router.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(router.DomainListString);
2501:   
2502:  #if DEBUG
2503:                      /*
2504:                      foreach (int i in router.DomainList)
2505:                      {
2506:                          // this will throw an exception if there are similar domains in routers
2507:                          if (domainDictionary.ContainsKey(i))
2508:                          {
2509:                              throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
2510:                          }
2511:                          else domainDictionary[i] = 1;
2512:                      }
2513:                      */
2514:  #endif
2515:   
2516:                      vendorShortName = x.Attribute("vendorShortName").Value;
2517:                      router.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
2518:   
2519:                      router.Site = (from s in SiteList where s.Id == siteId select s).SingleOrDefault();
2520:   
2521:                      routerList.Add(router);
2522:                  }
2523:   
2524:                  return routerList;
2525:              }
2526:          }
2527:   
2528:          ////////////////////////////////////////////////////////////////////////////
2529:   
2530:          /// <summary>
2531:          ///
2532:          /// </summary>
2533:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList
2534:          {
2535:              get
2536:              {
2537:                  lock (objectLock)
2538:                  {
2539:                      if (siteList == null || siteList.Count == 0) siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SiteList;
2540:   
2541:                      return siteList;
2542:                  }
2543:              }
2544:          }
2545:   
2546:          ////////////////////////////////////////////////////////////////////////////
2547:   
2548:          /// <summary>
2549:          ///
2550:          /// </summary>
2551:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> _SiteList
2552:          {
2553:              get
2554:              {
2555:                  int networkId, id;
2556:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
2557:   
2558:                  siteList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
2559:   
2560:                  foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site"))
2561:                  {
2562:                      site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2563:                      networkId = int.Parse(x.Parent.Attribute("id").Value);
2564:                      id = int.Parse(x.Attribute("id").Value);
2565:   
2566:                      site.Id = site.SiteId(networkId, id);
2567:                      site.Name = x.Attribute("name").Value;
2568:                      site.ArabicName = x.Attribute("arabicName").Value;
2569:                      site.AreaSymbolList = x.Attribute("areaSymbolList").Value.Split(',').ToList();
2570:   
2571:                      site.Network = (from n in NetworkList where n.Id == networkId select n).SingleOrDefault();
2572:   
2573:                      siteList.Add(site);
2574:                  }
2575:   
2576:                  return siteList;
2577:              }
2578:          }
2579:   
2580:          ////////////////////////////////////////////////////////////////////////////
2581:   
2582:          /// <summary>
2583:          ///
2584:          /// </summary>
2585:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> NetworkList
2586:          {
2587:              get
2588:              {
2589:                  lock (objectLock)
2590:                  {
2591:                      if (networkList == null || networkList.Count == 0)
2592:                      {
2593:                          networkList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> { new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network(1, "Next Generation Network") };
2594:                      }
2595:   
2596:                      return networkList;
2597:                  }
2598:              }
2599:          }
2600:   
2601:          ////////////////////////////////////////////////////////////////////////////
2602:   
2603:          /// <summary>
2604:          ///
2605:          /// </summary>
2606:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> VendorList
2607:          {
2608:              get
2609:              {
2610:                  lock (objectLock)
2611:                  {
2612:                      if (vendorList == null || vendorList.Count == 0)
2613:                      {
2614:                          vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>
2615:                      {
2616:                          new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(0, "Undefined", "Un", "غير معرف", @"~\image\undefined.png"),
2617:                          new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(1, "Nokia", "No", "نوكيا", @"~\image\nokia-icon.png"),
2618:                          new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(2, "Huawei", "Hu", "هواوي", @"~\image\huawei-icon.png"),
2619:                          new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(3, "Ericsson", "Er", "إريكسون", @"~\image\ericsson-icon.png"),
2620:                          new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(4, "Siemens", "Si", "سيمينس", @"~\image\siemens-icon.png")
2621:                      };
2622:                      }
2623:   
2624:                      return vendorList;
2625:                  }
2626:              }
2627:          }
2628:   
2629:          ////////////////////////////////////////////////////////////////////////////
2630:   
2631:          /// <summary>
2632:          ///
2633:          /// </summary>
2634:          public static string AmsNameFromOltId(int oltId)
2635:          {
2636:              string amsName;
2637:   
2638:              try
2639:              {
2640:                  amsName = (from o in OltList where o.Id == oltId select o.AmsName).FirstOrDefault();
2641:              }
2642:              catch (Exception)
2643:              {
2644:                  amsName = null;
2645:              }
2646:   
2647:              return amsName;
2648:          }
2649:   
2650:          ////////////////////////////////////////////////////////////////////////////
2651:   
2652:          /// <summary>
2653:          ///
2654:          /// </summary>
2655:          public static bool CheckIntegrityOfOntList()
2656:          {
2657:              bool isValid;
2658:              string v;
2659:              Dictionary<string, string> dic, a, b;
2660:   
2661:              dic = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntAccessNameDictionary;
2662:              a = new Dictionary<string, string>();
2663:              b = new Dictionary<string, string>();
2664:   
2665:              isValid = true;
2666:   
2667:              foreach (string s in dic.Keys)
2668:              {
2669:                  v = dic[s];
2670:   
2671:                  if (!a.ContainsKey(v)) a[v] = "1";
2672:                  else if (a.ContainsKey(v))
2673:                  {
2674:                      if (!v.Contains("RSL"))
2675:                      {
2676:                          b[v] = "1";
2677:                          isValid = false;
2678:                      }
2679:                  }
2680:              }
2681:   
2682:              return isValid;
2683:          }
2684:   
2685:          ////////////////////////////////////////////////////////////////////////////
2686:          ////////////////////////////////////////////////////////////////////////////
2687:   
2688:          /// <summary>
2689:          /// 
2690:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
2691:          /// 
2692:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
2693:          /// 2. Add "using System.Reflection".
2694:          /// 3. See sample below.
2695:          /// 
2696:          /// </summary>
2697:          private static XDocument XDocument
2698:          {
2699:              get
2700:              {
2701:                  if (xDocument == null)
2702:                  {
2703:                      Assembly _assembly;
2704:                      StreamReader streamReader;
2705:   
2706:                      _assembly = Assembly.GetExecutingAssembly();
2707:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.network-design-document.xml"));
2708:   
2709:                      try
2710:                      {
2711:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
2712:                      }
2713:                      catch (Exception)
2714:                      {
2715:                      }
2716:                      finally
2717:                      {
2718:                      }
2719:                  }
2720:   
2721:                  return xDocument;
2722:              }
2723:          }
2724:   
2725:          /*
2726:          ////////////////////////////////////////////////////////////////////////////
2727:  
2728:          /// <summary>
2729:          ///
2730:          /// </summary>
2731:          public static void WriteNddPonsTable()
2732:          {
2733:              DataTable dataTable;
2734:              Ia.Cl.Model.Result result;
2735:              Ia.Cl.Model.Db.SqlServer sqlServer;
2736:  
2737:              sqlServer = new Ia.Cl.Model.Db.SqlServer();
2738:  
2739:              var _ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList;
2740:  
2741:              if (_ponList.Count > 7000)
2742:              {
2743:                  // must seperate using{} to guarantee a clean close of connection before populating
2744:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2745:                  {
2746:                      if (db.Database.Exists())
2747:                      {
2748:                          // delete all current records
2749:                          var all = from c in db.NddPons select c;
2750:                          db.NddPons.RemoveRange(all);
2751:                          db.SaveChanges();
2752:                      }
2753:                  }
2754:  
2755:                  var nddPonList = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>();
2756:  
2757:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2758:                  {
2759:                      foreach (var pon in _ponList)
2760:                      {
2761:                          var nddPon = new Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon
2762:                          {
2763:                              Id = pon.Id,
2764:                              Index = pon.Index,
2765:                              PonGroupPonIndex = pon.PonGroupPonIndex,
2766:                              Rack = pon.Rack,
2767:                              Sub = pon.Sub,
2768:                              CardSlot = pon.CardSlot,
2769:                              Port = pon.Port,
2770:                              Number = pon.Number,
2771:                              ProposedNumber = pon.ProposedNumber,
2772:                              Position = pon.Position,
2773:                              Name = pon.Name,
2774:                              ProposedName = pon.ProposedName,
2775:                              PonGroupId = pon.PonGroup.Id
2776:                          };
2777:  
2778:                          nddPonList.Add(nddPon);
2779:                      }
2780:  
2781:                      dataTable = Ia.Cl.Model.Default.GenerateDataTableFromGenericClassList<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>(nddPonList, "NddPons");
2782:  
2783:                      if (dataTable != null && dataTable.Rows.Count > 0)
2784:                      {
2785:                          sqlServer.SqlBulkCopy(dataTable, out result);
2786:                      }
2787:                  }
2788:              }
2789:              else
2790:              {
2791:  
2792:              }
2793:          }
2794:  
2795:          ////////////////////////////////////////////////////////////////////////////
2796:  
2797:          /// <summary>
2798:          ///
2799:          /// </summary>
2800:          public static List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon> NddPonList()
2801:          {
2802:              var list = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>();
2803:  
2804:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
2805:              {
2806:                  list = (from np in db.NddPons select np).ToList();
2807:              }
2808:  
2809:              return list;
2810:          }
2811:  
2812:          ////////////////////////////////////////////////////////////////////////////
2813:  
2814:          /// <summary>
2815:          ///
2816:          /// </summary>
2817:          public static void WriteNddOntsTable()
2818:          {
2819:              DataTable dataTable;
2820:              Ia.Cl.Model.Result result;
2821:              Ia.Cl.Model.Db.SqlServer sqlServer;
2822:  
2823:              sqlServer = new Ia.Cl.Model.Db.SqlServer();
2824:  
2825:              var _ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList;
2826:  
2827:              if (_ontList.Count == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
2828:              {
2829:                  // must seperate using{} to guarantee a clean close of connection before populating
2830:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2831:                  {
2832:                      if (db.Database.Exists())
2833:                      {
2834:                          // delete all current records
2835:                          var all = from c in db.NddOnts select c;
2836:                          db.NddOnts.RemoveRange(all);
2837:                          db.SaveChanges();
2838:                      }
2839:                  }
2840:  
2841:                  var nddOntList = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt>();
2842:  
2843:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2844:                  {
2845:                      var _nddPonList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NddPonList();
2846:  
2847:                      foreach (var ont in _ontList)
2848:                      {
2849:                          var nddOnt = new Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt
2850:                          {
2851:                              Id = ont.Id,
2852:                              Rack = ont.Rack,
2853:                              Sub = ont.Sub,
2854:                              CardSlot = ont.CardSlot,
2855:                              Port = ont.Port,
2856:                              Number = ont.Number,
2857:                              InternalNumber = ont.InternalNumber,
2858:                              Position = ont.Position,
2859:                              Ip = ont.Ip,
2860:                              ImsBasicServiceMgcIp = ont.ImsBasicService.MgcIp,
2861:                              NddPon = (from np in _nddPonList where np.Id == ont.Pon.Id select np).Single()
2862:                          };
2863:  
2864:                          nddOntList.Add(nddOnt);
2865:                      }
2866:  
2867:                      dataTable = Ia.Cl.Model.Default.GenerateDataTableFromGenericClassList<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt>(nddOntList, "NddOnts");
2868:  
2869:                      if (dataTable != null && dataTable.Rows.Count > 0)
2870:                      {
2871:                          if (dataTable.Rows.Count == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
2872:                          {
2873:                              sqlServer.SqlBulkCopy(dataTable, out result);
2874:                          }
2875:                          else
2876:                          {
2877:                              throw new ArgumentOutOfRangeException(@"(_ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
2878:                          }
2879:                      }
2880:                      else
2881:                      {
2882:                          throw new ArgumentOutOfRangeException(@"dataTable is null or empty");
2883:                      }
2884:                  }
2885:              }
2886:              else
2887:              {
2888:                  throw new ArgumentOutOfRangeException(@"(_ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
2889:              }
2890:          }
2891:          */
2892:      }
2893:   
2894:      ////////////////////////////////////////////////////////////////////////////
2895:      ////////////////////////////////////////////////////////////////////////////    
2896:  }