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

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