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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » NetworkDesignDocument

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

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

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