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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » NetworkDesignDocument

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

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

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