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

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