Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » NetworkDesignDocument

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

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

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