)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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 Optical Fiber Network (OFN) data model.

    1: using System;
    2: using System.Collections;
    3: using System.Collections.Generic;
    4: using System.Data;
    5: using System.IO;
    6: using System.Linq;
    7: using System.Reflection;
    8: using System.Text;
    9: using System.Text.RegularExpressions;
   10: using System.Xml.Linq;
   11:  
   12: namespace Ia.Ngn.Cl.Model.Data
   13: {
   14:     ////////////////////////////////////////////////////////////////////////////
   15:  
   16:     /// <summary publish="true">
   17:     /// Network Design Document support class for Optical Fiber Network (OFN) data model.
   18:     /// </summary>
   19:     /// 
   20:     /// <remarks> 
   21:     /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   22:     ///
   23:     /// 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
   24:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   25:     ///
   26:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   27:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   28:     /// 
   29:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   30:     /// 
   31:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   32:     /// </remarks> 
   33:     public static class NetworkDesignDocument
   34:     {
   35:         private static XDocument xDocument;
   36:  
   37:         private static List<string> ontIdList, ontAccessIdList;
   38:  
   39:         private static Dictionary<int, int> didToOltIdDictionary;
   40:         private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> routerDomainToSiteDictionary, msanDomainToSiteDictionary, pstnDomainToSiteDictionary;
   41:         private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> pstnFiveDigitDomainToPstnExchangeTypeDictionary;
   42:         private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> domainToRouterVendorDictionary;
   43:         private static Dictionary<string, string> ontAccessIdToOntIdDictionary, ontIdToOntAccessNameDictionary, ontAccessNameToOntAccessIdDictionary, ontAccessNameToOntIdDictionary, ontAccessIdToOntAccessNameDictionary, ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary, ontIpToOntAccessIdDictionary, ontAccessNameToOntIpDictionary, ontIdDictionary, ontIpDictionary, ponNameToPonIdDictionary, ontIpToPrimarySwitchImsFsdbDictionary, nokiaOntIpToPrimarySwitchImsFsdbDictionary;
   44:         private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontAccessIdToOntDictionary, ontIdToOntDictionary, ontIpToOntDictionary, ontAccessNameToOntDictionary, ontPositionToOntDictionary;
   45:         private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponIdToPonDictionary, ponNameToPonDictionary;
   46:         private static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> pstnToFiveDigitDomainListDictionary;
   47:  
   48:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> networkList;
   49:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> vendorList;
   50:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> siteList, legacySiteList;
   51:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> pstnList, legacyPstnList;
   52:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan> msanList;
   53:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX> softXList;
   54:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> routerList;
   55:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> oamList;
   56:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> odfList;
   57:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList;
   58:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> ponGroupList;
   59:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponList;
   60:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList, greenFieldOntList, brownFieldOntList;
   61:  
   62:         private static readonly object objectLock = new object();
   63:  
   64:         /// <summary/>
   65:         public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
   66:  
   67:         ////////////////////////////////////////////////////////////////////////////
   68:  
   69:         /// <summary>
   70:         ///
   71:         /// </summary>
   72:         //public NetworkDesignDocument() { }
   73:  
   74:         ////////////////////////////////////////////////////////////////////////////
   75:  
   76:         /// <summary>
   77:         ///
   78:         /// </summary>
   79:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
   80:         {
   81:             get
   82:             {
   83:                 if (ontList == null || ontList.Count == 0)
   84:                 {
   85:                     lock (objectLock)
   86:                     {
   87:                         ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OntList;
   88:                     }
   89:                 }
   90:  
   91:                 return ontList;
   92:             }
   93:         }
   94:  
   95:         ////////////////////////////////////////////////////////////////////////////
   96:  
   97:         /// <summary>
   98:         ///
   99:         /// </summary>
  100:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> _OntList
  101:         {
  102:             get
  103:             {
  104:                 bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
  105:                 long networkNumberIpLong, ipLong, diff, l;
  106:                 string oltSymbol;
  107:  
  108: #if DEBUG
  109:                 Dictionary<string, string> ontDictionary, /*proposedOntDictionary,*/ ipDictionary;
  110: #endif
  111:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
  112:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access access;
  113:                 Ia.Ngn.Cl.Model.Business.Ims.ImsBasicService imsBasicService;
  114:  
  115:                 var ontList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
  116: #if DEBUG
  117:                 ontDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
  118:                 //proposedOntDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
  119:                 ipDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
  120: #endif
  121:  
  122:                 var nokiaAccessNameWithPbxList = new List<string>(); // Ia.Ngn.Cl.Model.Data.Ims.NokiaAccessNameWithPbxList;
  123:  
  124:                 foreach (var ponGroup in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList)
  125:                 {
  126:                     nokiaRouter = (ponGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
  127:                     huaweiRouter = !nokiaRouter;
  128:  
  129:                     nokiaOdf = (ponGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
  130:                     huaweiOdf = !nokiaOdf;
  131:  
  132:                     oltSymbol = ponGroup.Olt.Symbol;
  133:  
  134:                     networkNumberIpLong = Ia.Cl.Model.Default.IpToDec(ponGroup.NetworkNumber);
  135:  
  136:                     // standard imsBasicService
  137:                     if (nokiaRouter)
  138:                     {
  139:                         if (nokiaOdf) imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItem(ponGroup);
  140:                         else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ponGroup);
  141:                     }
  142:                     else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.HuaweiImsBasicServiceItem(ponGroup);
  143:  
  144:                     foreach (var pon in ponGroup.PonList)
  145:                     {
  146: #if DEBUG
  147:                         if (pon.Name == "ABW.144")
  148:                         {
  149:  
  150:                         }
  151: #endif
  152:  
  153:                         for (int ontNumber = 1; ontNumber <= ponGroup.Olt.NumberOfOntsInPon; ontNumber++)
  154:                         {
  155:                             ont = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont();
  156:                             access = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access();
  157:  
  158:                             ont.Pon = pon;
  159:  
  160:                             ont.Rack = ponGroup.Olt.Rack;
  161:                             ont.Sub = ponGroup.Olt.Sub;
  162:                             ont.CardSlot = pon.CardSlot;  // CardSlot might change for MDUs below
  163:                             ont.Port = pon.Port;
  164:  
  165:                             ont.Number = ontNumber;
  166:  
  167:                             ont.InternalNumber = (pon.Index * ponGroup.Olt.NumberOfOntsInPon) % 32 + ont.Number;
  168:  
  169:                             ont.Position = ponGroup.Olt.AmsName + "-" + ont.CardSlot + "-" + ont.Port + "-" + ont.InternalNumber;
  170:  
  171:                             access.Id = access.AccessId(ponGroup.Olt.Id, pon.Number, ont.Number);
  172:                             access.Pon = pon.Number;
  173:                             //access.ProposedPon = pon.ProposedNumber;
  174:                             access.Ont = ont.Number;
  175:  
  176:                             access.Symbol = ponGroup.Symbol;
  177:                             access.Name = ponGroup.Symbol + "." + pon.Number + "." + ont.Number;
  178:                             //access.ProposedName = ponGroup.Symbol + "." + pon.ProposedNumber + "." + ont.Number;
  179:  
  180: #if DEBUG
  181:                             if (access.Name == "SSB.44.27")
  182:                             {
  183:  
  184:                             }
  185: #endif
  186:  
  187:                             ont.Access = access;
  188:  
  189:                             ipLong = networkNumberIpLong + pon.PonGroupPonIndex * ponGroup.Olt.NumberOfOntsInPon + ont.Number; // or ont.InternalNumber
  190:                             diff = ipLong - networkNumberIpLong;
  191:  
  192:                             if (nokiaOdf)
  193:                             {
  194:                                 // below: skip *.*.*.0 only for Nokia ONTs
  195:                                 l = (diff - 1) / 255;
  196:  
  197:                                 ipLong += l;
  198:                             }
  199:                             else //if(huaweiOdf)
  200:                             {
  201:                                 if (nokiaRouter)
  202:                                 {
  203:                                 }
  204:                                 else //if (huaweiRouter)
  205:                                 {
  206:                                     // Huawei router and ODF. Here we will skip *.*.*.0 and *.*.*.1. Go figure!
  207:                                     ipLong += 1;
  208:                                 }
  209:                             }
  210:  
  211:                             ont.Ip = Ia.Cl.Model.Default.DecToIp((int)ipLong);
  212:  
  213:                             // ont.Id is used in functions below
  214:                             ont.Id = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(pon.Id, ont.InternalNumber);
  215:  
  216:                             // special imsBasicService
  217:                             if (nokiaRouter)
  218:                             {
  219:                                 if (huaweiOdf)
  220:                                 {
  221:                                     if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
  222:                                     {
  223:                                         ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
  224:                                     }
  225:                                     else ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ont) ?? imsBasicService;
  226:                                 }
  227:                                 else
  228:                                 {
  229:                                     if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
  230:                                     {
  231:                                         ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
  232:                                     }
  233:                                     else ont.ImsBasicService = imsBasicService;
  234:                                 }
  235:                             }
  236:                             else ont.ImsBasicService = imsBasicService;
  237:  
  238:  
  239: #if DEBUG
  240:                             // this will throw an exception if there is a duplicate ont.Access.Name
  241:                             if (ontDictionary.ContainsKey(ont.Access.Name))
  242:                             {
  243:                                 throw new ArgumentOutOfRangeException(@"ontDictionary.ContainsKey(ont.Access.Name)");
  244:                             }
  245:                             else ontDictionary[ont.Access.Name] = ont.Id;
  246:  
  247:                             /*
  248:                             // this will throw an exception if there is a duplicate ont.Access.ProposedName
  249:                             if (proposedOntDictionary.ContainsKey(ont.Access.ProposedName))
  250:                             {
  251:                                 throw new ArgumentOutOfRangeException(@"proposedOntDictionary.ContainsKey(ont.Access.ProposedName)");
  252:                             }
  253:                             else proposedOntDictionary[ont.Access.ProposedName] = ont.Id;
  254:                             */
  255:  
  256:                             /*
  257:                             // this will throw an exception if an IP has *.*.*.0
  258:                             // over 400 Huawei ONTs with *.*.*.0 IPs
  259:                             if (Regex.IsMatch(ont.Ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0"))
  260:                             {
  261:                                 list.Add(ont.Access.Name);
  262:                             }
  263:                             */
  264:  
  265:                             // this will throw an exception if there is a duplicate ont.Ip
  266:                             if (ipDictionary.ContainsKey(ont.Ip))
  267:                             {
  268:                                 throw new ArgumentOutOfRangeException(@"ipDictionary.ContainsKey(ont.Ip)");
  269:                             }
  270:                             else ipDictionary[ont.Ip] = ont.Id;
  271: #endif
  272:                             ontList.Add(ont);
  273:                         }
  274:                     }
  275:                 }
  276:  
  277:                 // as a precaution, this will throw an exception if there are not n number of records
  278:                 if (ontList.Count != Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
  279:                 {
  280:                     throw new ArgumentOutOfRangeException(@"(ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
  281:                 }
  282:  
  283:                 return ontList;
  284:             }
  285:         }
  286:  
  287:         ////////////////////////////////////////////////////////////////////////////
  288:  
  289:         /// <summary>
  290:         /// 
  291:         /// </summary>
  292:         public static List<string> OntIdList
  293:         {
  294:             get
  295:             {
  296:                 if (ontIdList == null || ontIdList.Count == 0)
  297:                 {
  298:                     lock (objectLock)
  299:                     {
  300:                         ontIdList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  301:                                      orderby o.Id
  302:                                      select o.Id).ToList();
  303:                     }
  304:                 }
  305:  
  306:                 return ontIdList;
  307:             }
  308:         }
  309:  
  310:         ////////////////////////////////////////////////////////////////////////////
  311:  
  312:         /// <summary>
  313:         /// 
  314:         /// </summary>
  315:         public static List<string> OntAccessIdList
  316:         {
  317:             get
  318:             {
  319:                 if (ontAccessIdList == null || ontAccessIdList.Count == 0)
  320:                 {
  321:                     lock (objectLock)
  322:                     {
  323:                         ontAccessIdList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  324:                                            orderby o.Access.Id
  325:                                            select o.Access.Id).ToList();
  326:                     }
  327:                 }
  328:  
  329:                 return ontAccessIdList;
  330:             }
  331:         }
  332:  
  333:         ////////////////////////////////////////////////////////////////////////////
  334:  
  335:         /// <summary>
  336:         ///
  337:         /// </summary>
  338:         public static Dictionary<string, string> OntAccessIdToOntIdDictionary
  339:         {
  340:             get
  341:             {
  342:                 if (ontAccessIdToOntIdDictionary == null || ontAccessIdToOntIdDictionary.Count == 0)
  343:                 {
  344:                     lock (objectLock)
  345:                     {
  346:                         ontAccessIdToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  347:                                                         select new { AccessId = o.Access.Id, OntId = o.Id }).ToDictionary(n => n.AccessId, n => n.OntId);
  348:                     }
  349:                 }
  350:  
  351:                 return ontAccessIdToOntIdDictionary;
  352:             }
  353:         }
  354:  
  355:         ////////////////////////////////////////////////////////////////////////////
  356:  
  357:         /// <summary>
  358:         ///
  359:         /// </summary>
  360:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntDictionary
  361:         {
  362:             get
  363:             {
  364:                 if (ontAccessIdToOntDictionary == null || ontAccessIdToOntDictionary.Count == 0)
  365:                 {
  366:                     lock (objectLock)
  367:                     {
  368:                         ontAccessIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  369:                                                       select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
  370:                     }
  371:                 }
  372:  
  373:                 return ontAccessIdToOntDictionary;
  374:             }
  375:         }
  376:  
  377:         ////////////////////////////////////////////////////////////////////////////
  378:  
  379:         /// <summary>
  380:         ///
  381:         /// </summary>
  382:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntDictionary
  383:         {
  384:             get
  385:             {
  386:                 if (ontIpToOntDictionary == null || ontIpToOntDictionary.Count == 0)
  387:                 {
  388:                     lock (objectLock)
  389:                     {
  390:                         ontIpToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  391:                                                 select new { Ip = o.Ip, Ont = o }).ToDictionary(n => n.Ip, n => n.Ont);
  392:                     }
  393:                 }
  394:  
  395:                 return ontIpToOntDictionary;
  396:             }
  397:         }
  398:  
  399:         ////////////////////////////////////////////////////////////////////////////
  400:  
  401:         /// <summary>
  402:         ///
  403:         /// </summary>
  404:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltIdListDictionary(List<int> oltIdList)
  405:         {
  406:             lock (objectLock)
  407:             {
  408:                 var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  409:                             where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
  410:                             select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
  411:  
  412:                 return list;
  413:             }
  414:         }
  415:  
  416:         ////////////////////////////////////////////////////////////////////////////
  417:  
  418:         /// <summary>
  419:         ///
  420:         /// </summary>
  421:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntForOltIdListDictionary(List<int> oltIdList)
  422:         {
  423:             lock (objectLock)
  424:             {
  425:                 var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  426:                             where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
  427:                             select new { OntIp = o.Ip, Ont = o }).ToDictionary(n => n.OntIp, n => n.Ont);
  428:  
  429:                 return list;
  430:             }
  431:         }
  432:  
  433:         ////////////////////////////////////////////////////////////////////////////
  434:  
  435:         /// <summary>
  436:         ///
  437:         /// </summary>
  438:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltSymbolListDictionary(List<string> oltSymbolList)
  439:         {
  440:             lock (objectLock)
  441:             {
  442:                 var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  443:                             where oltSymbolList.Contains(o.Pon.PonGroup.Olt.Symbol)
  444:                             select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
  445:  
  446:                 return list;
  447:             }
  448:         }
  449:  
  450:         ////////////////////////////////////////////////////////////////////////////
  451:  
  452:         /// <summary>
  453:         ///
  454:         /// </summary>
  455:         public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> RouterDomainToSiteDictionary
  456:         {
  457:             get
  458:             {
  459:                 if (routerDomainToSiteDictionary == null || routerDomainToSiteDictionary.Count == 0)
  460:                 {
  461:                     lock (objectLock)
  462:                     {
  463:                         routerDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
  464:  
  465:                         var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
  466:  
  467:                         foreach (int domain in routerList.SelectMany(u => u.DomainList))
  468:                         {
  469:                             routerDomainToSiteDictionary[domain] = (from r in routerList where r.DomainList.Contains(domain) select r.Site).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
  470:                         }
  471:                     }
  472:                 }
  473:  
  474:                 return routerDomainToSiteDictionary;
  475:             }
  476:         }
  477:  
  478:         ////////////////////////////////////////////////////////////////////////////
  479:  
  480:         /// <summary>
  481:         ///
  482:         /// </summary>
  483:         public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> MsanDomainToSiteDictionary
  484:         {
  485:             get
  486:             {
  487:                 if (msanDomainToSiteDictionary == null || msanDomainToSiteDictionary.Count == 0)
  488:                 {
  489:                     lock (objectLock)
  490:                     {
  491:                         msanDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
  492:  
  493:                         var msanList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.MsanList;
  494:  
  495:                         foreach (int domain in msanList.SelectMany(u => u.DomainList))
  496:                         {
  497:                             msanDomainToSiteDictionary[domain] = (from m in msanList where m.DomainList.Contains(domain) select m.Site).FirstOrDefault(); //.SingleOrDefault();
  498:                         }
  499:                     }
  500:                 }
  501:  
  502:                 return msanDomainToSiteDictionary;
  503:             }
  504:         }
  505:  
  506:         ////////////////////////////////////////////////////////////////////////////
  507:  
  508:         /// <summary>
  509:         ///
  510:         /// </summary>
  511:         public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> PstnDomainToSiteDictionary
  512:         {
  513:             get
  514:             {
  515:                 if (pstnDomainToSiteDictionary == null || pstnDomainToSiteDictionary.Count == 0)
  516:                 {
  517:                     lock (objectLock)
  518:                     {
  519:                         pstnDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
  520:  
  521:                         var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
  522:  
  523:                         foreach (int domain in pstnList.SelectMany(u => u.DomainList))
  524:                         {
  525:                             pstnDomainToSiteDictionary[domain] = (from p in pstnList where p.DomainList.Contains(domain) select p.Site).SingleOrDefault();
  526:                         }
  527:                     }
  528:                 }
  529:  
  530:                 return pstnDomainToSiteDictionary;
  531:             }
  532:         }
  533:  
  534:         ////////////////////////////////////////////////////////////////////////////
  535:  
  536:         /// <summary>
  537:         ///
  538:         /// </summary>
  539:         public static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> PstnToFiveDigitDomainListDictionary()
  540:         {
  541:             if (pstnToFiveDigitDomainListDictionary == null || pstnToFiveDigitDomainListDictionary.Count == 0)
  542:             {
  543:                 lock (objectLock)
  544:                 {
  545:                     pstnToFiveDigitDomainListDictionary = new Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>>();
  546:  
  547:                     var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
  548:  
  549:                     foreach (var pstn in pstnList)
  550:                     {
  551:                         var list = new List<int>();
  552:  
  553:                         foreach (int domain in pstn.DomainList)
  554:                         {
  555:                             // already five digit domain
  556:                             if (domain > 9999) list.Add(domain);
  557:                             else
  558:                             {
  559:                                 // four digit domain, we will need to create five digit domains related to it
  560:                                 for (int i = 0; i <= 9; i++)
  561:                                 {
  562:                                     list.Add(domain * 10 + i);
  563:                                 }
  564:                             }
  565:  
  566:                             pstnToFiveDigitDomainListDictionary[pstn] = list;
  567:                         }
  568:                     }
  569:                 }
  570:             }
  571:  
  572:             return pstnToFiveDigitDomainListDictionary;
  573:         }
  574:  
  575:         ////////////////////////////////////////////////////////////////////////////
  576:  
  577:         /// <summary>
  578:         ///
  579:         /// </summary>
  580:         public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> PstnFiveDigitDomainToVendorDictionary()
  581:         {
  582:             if (pstnFiveDigitDomainToPstnExchangeTypeDictionary == null || pstnFiveDigitDomainToPstnExchangeTypeDictionary.Count == 0)
  583:             {
  584:                 lock (objectLock)
  585:                 {
  586:                     pstnFiveDigitDomainToPstnExchangeTypeDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType>();
  587:  
  588:                     var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
  589:  
  590:                     foreach (var pstn in pstnList)
  591:                     {
  592:                         foreach (int domain in pstn.DomainList)
  593:                         {
  594:                             // already five digit domain
  595:                             if (domain > 9999) pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain] = pstn.PstnExchangeType;
  596:                             else
  597:                             {
  598:                                 // four digit domain, we will need to create five digit domains related to it
  599:                                 for (int i = 0; i <= 9; i++)
  600:                                 {
  601:                                     pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain * 10 + i] = pstn.PstnExchangeType;
  602:                                 }
  603:                             }
  604:                         }
  605:                     }
  606:                 }
  607:             }
  608:  
  609:             return pstnFiveDigitDomainToPstnExchangeTypeDictionary;
  610:         }
  611:  
  612:         ////////////////////////////////////////////////////////////////////////////
  613:  
  614:         /// <summary>
  615:         ///
  616:         /// </summary>
  617:         public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> DomainToRouterVendorDictionary
  618:         {
  619:             get
  620:             {
  621:                 if (domainToRouterVendorDictionary == null || domainToRouterVendorDictionary.Count == 0)
  622:                 {
  623:                     lock (objectLock)
  624:                     {
  625:                         domainToRouterVendorDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
  626:  
  627:                         var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
  628:  
  629:                         foreach (int domain in routerList.SelectMany(u => u.DomainList))
  630:                         {
  631:                             domainToRouterVendorDictionary[domain] = (from r in routerList
  632:                                                                       where r.DomainList.Contains(domain)
  633:                                                                       select r.Vendor).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
  634:                         }
  635:                     }
  636:                 }
  637:  
  638:                 return domainToRouterVendorDictionary;
  639:             }
  640:         }
  641:  
  642:         ////////////////////////////////////////////////////////////////////////////
  643:  
  644:         /// <summary>
  645:         ///
  646:         /// </summary>
  647:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIdToOntDictionary
  648:         {
  649:             get
  650:             {
  651:                 if (ontIdToOntDictionary == null || ontIdToOntDictionary.Count == 0)
  652:                 {
  653:                     lock (objectLock)
  654:                     {
  655:                         ontIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  656:                                                 select new { OntId = o.Id, Ont = o }).ToDictionary(n => n.OntId, n => n.Ont);
  657:                     }
  658:                 }
  659:                 return ontIdToOntDictionary;
  660:             }
  661:         }
  662:  
  663:         ////////////////////////////////////////////////////////////////////////////
  664:  
  665:         /// <summary>
  666:         ///
  667:         /// </summary>
  668:         public static Dictionary<string, string> OntIdToOntAccessNameDictionary
  669:         {
  670:             get
  671:             {
  672:                 if (ontIdToOntAccessNameDictionary == null || ontIdToOntAccessNameDictionary.Count == 0)
  673:                 {
  674:                     lock (objectLock)
  675:                     {
  676:                         ontIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  677:                                                           select new { OntId = o.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntId, n => n.OntAccessName);
  678:                     }
  679:                 }
  680:  
  681:                 return ontIdToOntAccessNameDictionary;
  682:             }
  683:         }
  684:  
  685:         ////////////////////////////////////////////////////////////////////////////
  686:  
  687:         /// <summary>
  688:         ///
  689:         /// </summary>
  690:         public static Dictionary<string, string> OntAccessNameToOntIdDictionary
  691:         {
  692:             get
  693:             {
  694:                 if (ontAccessNameToOntIdDictionary == null || ontAccessNameToOntIdDictionary.Count == 0)
  695:                 {
  696:                     lock (objectLock)
  697:                     {
  698:                         ontAccessNameToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  699:                                                           select new { OntAccessName = o.Access.Name, OntId = o.Id }).ToDictionary(n => n.OntAccessName, n => n.OntId);
  700:                     }
  701:                 }
  702:  
  703:                 return ontAccessNameToOntIdDictionary;
  704:             }
  705:         }
  706:  
  707:         ////////////////////////////////////////////////////////////////////////////
  708:  
  709:         /// <summary>
  710:         ///
  711:         /// </summary>
  712:         public static Dictionary<string, string> OntAccessNameToOntAccessIdDictionary
  713:         {
  714:             get
  715:             {
  716:                 if (ontAccessNameToOntAccessIdDictionary == null || ontAccessNameToOntAccessIdDictionary.Count == 0)
  717:                 {
  718:                     lock (objectLock)
  719:                     {
  720:                         ontAccessNameToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  721:                                                                 select new { OntAccessName = o.Access.Name, OntAccessId = o.Access.Id }).ToDictionary(n => n.OntAccessName, n => n.OntAccessId);
  722:                     }
  723:                 }
  724:  
  725:                 return ontAccessNameToOntAccessIdDictionary;
  726:             }
  727:         }
  728:  
  729:         ////////////////////////////////////////////////////////////////////////////
  730:  
  731:         /// <summary>
  732:         ///
  733:         /// </summary>
  734:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessNameToOntDictionary
  735:         {
  736:             get
  737:             {
  738:                 if (ontAccessNameToOntDictionary == null || ontAccessNameToOntDictionary.Count == 0)
  739:                 {
  740:                     lock (objectLock)
  741:                     {
  742:                         ontAccessNameToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  743:                                                         select new { OntAccessName = o.Access.Name, Ont = o }).ToDictionary(n => n.OntAccessName, n => n.Ont);
  744:                     }
  745:                 }
  746:  
  747:                 return ontAccessNameToOntDictionary;
  748:             }
  749:         }
  750:  
  751:         ////////////////////////////////////////////////////////////////////////////
  752:  
  753:         /// <summary>
  754:         ///
  755:         /// </summary>
  756:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntPositionToOntDictionary
  757:         {
  758:             get
  759:             {
  760:                 if (ontPositionToOntDictionary == null || ontPositionToOntDictionary.Count == 0)
  761:                 {
  762:                     lock (objectLock)
  763:                     {
  764:                         ontPositionToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  765:                                                       select new { OntPosition = o.Position, Ont = o }).ToDictionary(n => n.OntPosition, n => n.Ont);
  766:                     }
  767:                 }
  768:  
  769:                 return ontPositionToOntDictionary;
  770:             }
  771:         }
  772:  
  773:         ////////////////////////////////////////////////////////////////////////////
  774:  
  775:         /// <summary>
  776:         ///
  777:         /// </summary>
  778:         public static Dictionary<string, string> OntAccessIdToOntAccessNameDictionary
  779:         {
  780:             get
  781:             {
  782:                 if (ontAccessIdToOntAccessNameDictionary == null || ontAccessIdToOntAccessNameDictionary.Count == 0)
  783:                 {
  784:                     lock (objectLock)
  785:                     {
  786:                         ontAccessIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  787:                                                                 select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
  788:                     }
  789:                 }
  790:  
  791:                 return ontAccessIdToOntAccessNameDictionary;
  792:             }
  793:         }
  794:  
  795:         ////////////////////////////////////////////////////////////////////////////
  796:  
  797:         /// <summary>
  798:         ///
  799:         /// </summary>
  800:         public static Dictionary<string, string> OntAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary
  801:         {
  802:             get
  803:             {
  804:                 if (ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary == null || ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary.Count == 0)
  805:                 {
  806:                     lock (objectLock)
  807:                     {
  808:                         var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
  809:  
  810:                         ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  811:                                                                                             where allowedToBeMigratedOltIdList.Contains(o.Pon.PonGroup.Olt.Id)
  812:                                                                                             select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
  813:                     }
  814:                 }
  815:  
  816:                 return ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary;
  817:             }
  818:         }
  819:  
  820:         ////////////////////////////////////////////////////////////////////////////
  821:  
  822:         /// <summary>
  823:         ///
  824:         /// </summary>
  825:         public static Dictionary<string, string> OntIpToOntAccessIdDictionary
  826:         {
  827:             get
  828:             {
  829:                 if (ontIpToOntAccessIdDictionary == null || ontIpToOntAccessIdDictionary.Count == 0)
  830:                 {
  831:                     lock (objectLock)
  832:                     {
  833:                         ontIpToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  834:                                                         select new { OntIp = o.Ip, OntAccessId = o.Access.Id }).ToDictionary(n => n.OntIp, n => n.OntAccessId);
  835:                     }
  836:                 }
  837:  
  838:                 return ontIpToOntAccessIdDictionary;
  839:             }
  840:         }
  841:  
  842:         ////////////////////////////////////////////////////////////////////////////
  843:  
  844:         /// <summary>
  845:         ///
  846:         /// </summary>
  847:         public static Dictionary<string, string> OntAccessNameToOntIpDictionary
  848:         {
  849:             get
  850:             {
  851:                 if (ontAccessNameToOntIpDictionary == null || ontAccessNameToOntIpDictionary.Count == 0)
  852:                 {
  853:                     lock (objectLock)
  854:                     {
  855:                         ontAccessNameToOntIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  856:                                                           select new { OntAccessName = o.Access.Name, OntIp = o.Ip }).ToDictionary(n => n.OntAccessName, n => n.OntIp);
  857:                     }
  858:                 }
  859:  
  860:                 return ontAccessNameToOntIpDictionary;
  861:             }
  862:         }
  863:  
  864:         ////////////////////////////////////////////////////////////////////////////
  865:  
  866:         /// <summary>
  867:         ///
  868:         /// </summary>
  869:         public static Dictionary<string, string> OntIdDictionary
  870:         {
  871:             get
  872:             {
  873:                 if (ontIdDictionary == null || ontIdDictionary.Count == 0)
  874:                 {
  875:                     lock (objectLock)
  876:                     {
  877:                         ontIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  878:                                            select o.Id).ToDictionary(n => n, n => n);
  879:                     }
  880:                 }
  881:  
  882:                 return ontIdDictionary;
  883:             }
  884:         }
  885:  
  886:         ////////////////////////////////////////////////////////////////////////////
  887:  
  888:         /// <summary>
  889:         ///
  890:         /// </summary>
  891:         public static Dictionary<string, string> OntIpDictionary
  892:         {
  893:             get
  894:             {
  895:                 if (ontIpDictionary == null || ontIpDictionary.Count == 0)
  896:                 {
  897:                     lock (objectLock)
  898:                     {
  899:                         ontIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  900:                                            select o.Ip).ToDictionary(n => n, n => n);
  901:                     }
  902:                 }
  903:                 return ontIpDictionary;
  904:             }
  905:         }
  906:  
  907:         ////////////////////////////////////////////////////////////////////////////
  908:  
  909:         /// <summary>
  910:         ///
  911:         /// </summary>
  912:         public static Dictionary<string, string> OntIpToPrimarySwitchImsFsdbDictionary
  913:         {
  914:             get
  915:             {
  916:                 if (ontIpToPrimarySwitchImsFsdbDictionary == null || ontIpToPrimarySwitchImsFsdbDictionary.Count == 0)
  917:                 {
  918:                     lock (objectLock)
  919:                     {
  920:                         ontIpToPrimarySwitchImsFsdbDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  921:                                                                  select o).Distinct().ToDictionary(n => n.Ip, n => n.PrimarySwitch + " (" + n.ImsFsdb + ")");
  922:                     }
  923:                 }
  924:  
  925:                 return ontIpToPrimarySwitchImsFsdbDictionary;
  926:             }
  927:         }
  928:  
  929:         ////////////////////////////////////////////////////////////////////////////
  930:  
  931:         /// <summary>
  932:         ///
  933:         /// </summary>
  934:         public static Dictionary<string, string> NokiaOntIpToPrimarySwitchImsFsdbDictionary
  935:         {
  936:             get
  937:             {
  938:                 if (nokiaOntIpToPrimarySwitchImsFsdbDictionary == null || nokiaOntIpToPrimarySwitchImsFsdbDictionary.Count == 0)
  939:                 {
  940:                     lock (objectLock)
  941:                     {
  942:                         nokiaOntIpToPrimarySwitchImsFsdbDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
  943:                                                                       where o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
  944:                                                                       select o).Distinct().ToDictionary(n => n.Ip, n => n.PrimarySwitch + " (" + n.ImsFsdb + ")");
  945:                     }
  946:                 }
  947:  
  948:                 return nokiaOntIpToPrimarySwitchImsFsdbDictionary;
  949:             }
  950:         }
  951:  
  952:         ////////////////////////////////////////////////////////////////////////////
  953:  
  954:         /// <summary>
  955:         ///
  956:         /// </summary>
  957:         public static bool AccessNameIsWithinAllowedOntList(string inputAccessName, out string accessName)
  958:         {
  959:             // below: this checks that this accessName is within the standard possible values in network
  960:             bool isWithinAllowedOnts;
  961:  
  962:             var nddOnt = Ia.Ngn.Cl.Model.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(inputAccessName);
  963:  
  964:             if (nddOnt != null)
  965:             {
  966:                 isWithinAllowedOnts = true;
  967:                 accessName = nddOnt.Access.Name;
  968:             }
  969:             else
  970:             {
  971:                 isWithinAllowedOnts = false;
  972:                 accessName = string.Empty;
  973:             }
  974:  
  975:             return isWithinAllowedOnts;
  976:         }
  977:  
  978:         ////////////////////////////////////////////////////////////////////////////
  979:  
  980:         /// <summary>
  981:         ///
  982:         /// </summary>
  983:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntById(string ontId)
  984:         {
  985:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
  986:  
  987:             if (!string.IsNullOrEmpty(ontId))
  988:             {
  989:                 var d = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
  990:  
  991:                 if (d.ContainsKey(ontId)) ont = d[ontId];
  992:                 else ont = null;
  993:             }
  994:             else ont = null;
  995:  
  996:             return ont;
  997:         }
  998:  
  999:         ////////////////////////////////////////////////////////////////////////////
 1000:  
 1001:         /// <summary>
 1002:         ///
 1003:         /// </summary>
 1004:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByAccessName(string accessName)
 1005:         {
 1006:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1007:  
 1008:             if (!string.IsNullOrEmpty(accessName))
 1009:             {
 1010:                 accessName = accessName.ToUpper();
 1011:  
 1012:                 nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary.ContainsKey(accessName) ?
 1013:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary[accessName] : null;
 1014:             }
 1015:             else nddOnt = null;
 1016:  
 1017:             return nddOnt;
 1018:         }
 1019:  
 1020:         ////////////////////////////////////////////////////////////////////////////
 1021:  
 1022:         /// <summary>
 1023:         ///
 1024:         /// </summary>
 1025:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOntAccessId(string accessId)
 1026:         {
 1027:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1028:  
 1029:             if (!string.IsNullOrEmpty(accessId))
 1030:             {
 1031:                 nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary.ContainsKey(accessId) ?
 1032:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary[accessId] : null;
 1033:             }
 1034:             else nddOnt = null;
 1035:  
 1036:             return nddOnt;
 1037:         }
 1038:  
 1039:         ////////////////////////////////////////////////////////////////////////////
 1040:  
 1041:         /// <summary>
 1042:         ///
 1043:         /// </summary>
 1044:         public static string AccessNameByOntId(string ontId)
 1045:         {
 1046:             string accessName;
 1047:  
 1048:             if (!string.IsNullOrEmpty(ontId))
 1049:             {
 1050:                 var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary.ContainsKey(ontId) ?
 1051:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary[ontId] : null;
 1052:  
 1053:                 if (nddOnt != null)
 1054:                 {
 1055:                     accessName = nddOnt.Access.Name;
 1056:                 }
 1057:                 else accessName = string.Empty;
 1058:             }
 1059:             else accessName = string.Empty;
 1060:  
 1061:             return accessName;
 1062:         }
 1063:  
 1064:         ////////////////////////////////////////////////////////////////////////////
 1065:  
 1066:         /// <summary>
 1067:         ///
 1068:         /// </summary>
 1069:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByIp(string ip)
 1070:         {
 1071:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1072:  
 1073:             if (!string.IsNullOrEmpty(ip))
 1074:             {
 1075:                 nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIpToOntDictionary.ContainsKey(ip) ?
 1076:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIpToOntDictionary[ip] : null;
 1077:             }
 1078:             else nddOnt = null;
 1079:  
 1080:             return nddOnt;
 1081:         }
 1082:  
 1083:         ////////////////////////////////////////////////////////////////////////////
 1084:  
 1085:         /// <summary>
 1086:         ///
 1087:         /// </summary>
 1088:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> AccessVendorListByOntIdList(List<string> ontIdList)
 1089:         {
 1090:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 1091:             var vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
 1092:  
 1093:             foreach (var ontId in ontIdList)
 1094:             {
 1095:                 if (!string.IsNullOrEmpty(ontId))
 1096:                 {
 1097:                     var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntById(ontId);
 1098:  
 1099:                     vendor = (nddOnt != null) ? nddOnt.Pon.PonGroup.Olt.Odf.Vendor : Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1100:                 }
 1101:                 else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1102:  
 1103:                 vendorList.Add(vendor);
 1104:             }
 1105:  
 1106:             return vendorList;
 1107:         }
 1108:  
 1109:         ////////////////////////////////////////////////////////////////////////////
 1110:  
 1111:         /// <summary>
 1112:         ///
 1113:         /// </summary>
 1114:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> SwitchVendorListByOntIdList(List<string> ontIdList)
 1115:         {
 1116:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 1117:             var vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
 1118:  
 1119:             foreach (var ontId in ontIdList)
 1120:             {
 1121:                 if (!string.IsNullOrEmpty(ontId))
 1122:                 {
 1123:                     var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntById(ontId);
 1124:  
 1125:                     vendor = (nddOnt != null) ? nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor : Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1126:                 }
 1127:                 else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1128:  
 1129:                 vendorList.Add(vendor);
 1130:             }
 1131:  
 1132:             return vendorList;
 1133:         }
 1134:  
 1135:         ////////////////////////////////////////////////////////////////////////////
 1136:  
 1137:         /// <summary>
 1138:         ///
 1139:         /// </summary>
 1140:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByOntAccessId(string ontAccessId)
 1141:         {
 1142:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 1143:  
 1144:             if (!string.IsNullOrEmpty(ontAccessId))
 1145:             {
 1146:                 var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary.ContainsKey(ontAccessId) ?
 1147:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary[ontAccessId] : null;
 1148:  
 1149:                 if (nddOnt != null)
 1150:                 {
 1151:                     vendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 1152:                 }
 1153:                 else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1154:             }
 1155:             else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1156:  
 1157:             return vendor;
 1158:         }
 1159:  
 1160:         ////////////////////////////////////////////////////////////////////////////
 1161:  
 1162:         /// <summary>
 1163:         ///
 1164:         /// </summary>
 1165:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByAccessName(string accessName)
 1166:         {
 1167:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 1168:  
 1169:             if (!string.IsNullOrEmpty(accessName))
 1170:             {
 1171:                 accessName = accessName.ToUpper();
 1172:  
 1173:                 var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary.ContainsKey(accessName) ?
 1174:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary[accessName] : null;
 1175:  
 1176:                 if (nddOnt != null)
 1177:                 {
 1178:                     vendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 1179:                 }
 1180:                 else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1181:             }
 1182:             else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1183:  
 1184:             return vendor;
 1185:         }
 1186:  
 1187:         ////////////////////////////////////////////////////////////////////////////
 1188:  
 1189:         /// <summary>
 1190:         ///
 1191:         /// </summary>
 1192:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorByAccessName(string accessName)
 1193:         {
 1194:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 1195:  
 1196:             if (!string.IsNullOrEmpty(accessName))
 1197:             {
 1198:                 accessName = accessName.ToUpper();
 1199:  
 1200:                 var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary.ContainsKey(accessName) ?
 1201:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary[accessName] : null;
 1202:  
 1203:                 if (nddOnt != null)
 1204:                 {
 1205:                     vendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
 1206:                 }
 1207:                 else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1208:             }
 1209:             else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 1210:  
 1211:             return vendor;
 1212:         }
 1213:  
 1214:         ////////////////////////////////////////////////////////////////////////////
 1215:  
 1216:         /// <summary>
 1217:         ///
 1218:         /// </summary>
 1219:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router RouterFromService(string service)
 1220:         {
 1221:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
 1222:  
 1223:             if (!string.IsNullOrEmpty(service))
 1224:             {
 1225:                 if (int.TryParse(service, out int i))
 1226:                 {
 1227:                     router = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
 1228:                               where r.DomainList.Any(u => service.StartsWith(u.ToString()))
 1229:                               select r).FirstOrDefault(); //.SingleOrDefault(); // 2390 is defined in two different huawei routers
 1230:                 }
 1231:                 else router = null;
 1232:             }
 1233:             else router = null;
 1234:  
 1235:             return router;
 1236:         }
 1237:  
 1238:         ////////////////////////////////////////////////////////////////////////////
 1239:  
 1240:         /// <summary>
 1241:         ///
 1242:         /// </summary>
 1243:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByPosition(string position)
 1244:         {
 1245:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1246:  
 1247:             if (!string.IsNullOrEmpty(position))
 1248:             {
 1249:                 nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntPositionToOntDictionary.ContainsKey(position) ?
 1250:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntPositionToOntDictionary[position] : null;
 1251:             }
 1252:             else nddOnt = null;
 1253:  
 1254:             return nddOnt;
 1255:         }
 1256:  
 1257:         ////////////////////////////////////////////////////////////////////////////
 1258:  
 1259:         /// <summary>
 1260:         ///
 1261:         /// </summary>
 1262:         public static string OntIdByPosition(string position)
 1263:         {
 1264:             string ontId;
 1265:  
 1266:             if (!string.IsNullOrEmpty(position))
 1267:             {
 1268:                 var ont = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntPositionToOntDictionary.ContainsKey(position) ?
 1269:                     Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntPositionToOntDictionary[position] : null;
 1270:  
 1271:                 if (ont != null) ontId = ont.Id;
 1272:                 else ontId = string.Empty;
 1273:             }
 1274:             else ontId = string.Empty;
 1275:  
 1276:             return ontId;
 1277:         }
 1278:  
 1279:         ////////////////////////////////////////////////////////////////////////////
 1280:         ////////////////////////////////////////////////////////////////////////////
 1281:  
 1282:  
 1283:  
 1284:  
 1285:  
 1286:  
 1287:  
 1288:         ////////////////////////////////////////////////////////////////////////////
 1289:         ////////////////////////////////////////////////////////////////////////////
 1290:  
 1291:         /// <summary>
 1292:         ///
 1293:         /// </summary>
 1294:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonList
 1295:         {
 1296:             get
 1297:             {
 1298:                 if (ponList == null || ponList.Count == 0)
 1299:                 {
 1300:                     lock (objectLock)
 1301:                     {
 1302:                         ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonList;
 1303:                     }
 1304:                 }
 1305:  
 1306:                 return ponList;
 1307:             }
 1308:         }
 1309:  
 1310:         ////////////////////////////////////////////////////////////////////////////
 1311:  
 1312:         /// <summary>
 1313:         ///
 1314:         /// </summary>
 1315:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> _PonList
 1316:         {
 1317:             get
 1318:             {
 1319:                 bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
 1320:                 int ponNumber, slot, oltPonIndex, oltPonCount;
 1321:                 //int proposedPonNumber, oltProposedPonCount;
 1322:                 string odfName;
 1323: #if DEBUG
 1324:                 Dictionary<string, string> ponIdDictionary;
 1325: #endif
 1326:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
 1327:  
 1328:                 var 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)
 1329: #if DEBUG
 1330:                 ponIdDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32);
 1331: #endif
 1332:                 foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
 1333:                 {
 1334:                     oltPonIndex = 0;
 1335:  
 1336:                     nokiaRouter = (olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
 1337:                     huaweiRouter = !nokiaRouter;
 1338:  
 1339:                     nokiaOdf = (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
 1340:                     huaweiOdf = !nokiaOdf;
 1341:  
 1342:                     odfName = olt.Odf.Name;
 1343:  
 1344:                     oltPonCount = /*oltProposedPonCount =*/ 0;
 1345:  
 1346:                     foreach (var ponGroup in olt.PonGroupList)
 1347:                     {
 1348:                         oltPonCount += ponGroup.UsedPonInPonGroupList.Count;
 1349:  
 1350:                         //if (ponGroup.HasNewProposedPonList) oltProposedPonCount += ponGroup.UsedProposedPonInPonGroupList.Count;
 1351:                     }
 1352:  
 1353:                     //if (/*((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) &&*/ oltPonCount % 32 == 0)
 1354:                     //{
 1355:                     foreach (var ponGroup in olt.PonGroupList)
 1356:                     {
 1357:                         //if (!ponGroup.HasNewProposedPonList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)
 1358:                         //{
 1359:                         // 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 
 1360:                         // to match this index with that from the Ip, position list, because that list does not recognize PONs.
 1361:                         for (int ponGroupPonIndex = 0; ponGroupPonIndex < ponGroup.UsedPonInPonGroupList.Count; ponGroupPonIndex++)
 1362:                         {
 1363:                             if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0)// && (!ponGroup.HasNewProposedPonList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
 1364:                             {
 1365:                                 pon = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon();
 1366:  
 1367:                                 ponNumber = (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex];
 1368:  
 1369:                                 //if (ponGroup.HasNewProposedPonList) proposedPonNumber = (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex];
 1370:                                 //else proposedPonNumber = ponNumber;
 1371:  
 1372:                                 pon.Id = pon.PonId(ponGroup.Olt.Id, oltPonIndex);
 1373:  
 1374:                                 pon.Index = oltPonIndex;
 1375:                                 pon.PonGroupPonIndex = ponGroupPonIndex;
 1376:  
 1377:                                 pon.PonGroup = (from l in PonGroupList where l.Id == ponGroup.Id select l).SingleOrDefault();
 1378:  
 1379:                                 pon.Rack = pon.PonGroup.Olt.Rack;
 1380:                                 pon.Sub = pon.PonGroup.Olt.Sub;
 1381:  
 1382:                                 if (nokiaOdf)
 1383:                                 {
 1384:                                     pon.CardSlot = oltPonIndex / olt.NumberOfLts + 1;
 1385:                                     pon.Port = oltPonIndex % olt.NumberOfLts + 1;
 1386:                                 }
 1387:                                 else //if(huaweiOdf)
 1388:                                 {
 1389:                                     // Huawei skips slots 9 and 10 and goes directly from 8 to 11
 1390:  
 1391:                                     slot = oltPonIndex / (olt.NumberOfPonsPerLt * olt.NumberOfLts / 16) + 1;
 1392:  
 1393:                                     if (slot > 8) slot += 2;
 1394:  
 1395:                                     if (ponGroup.Olt.NumberOfFirstSlot == 0) slot--;
 1396:  
 1397:                                     pon.CardSlot = slot;
 1398:  
 1399:                                     pon.Port = (16 * oltPonIndex % olt.NumberOfPons) / (32 / olt.NumberOfOntsInPon) / 16;
 1400:  
 1401:                                 }
 1402:  
 1403:                                 pon.Number = ponNumber;
 1404:                                 //pon.ProposedNumber = proposedPonNumber;
 1405:                                 pon.Position = pon.PonGroup.Olt.AmsName + "-" + pon.CardSlot + "-" + pon.Port;
 1406:                                 pon.Name = pon.PonGroup.Symbol + "." + pon.Number;
 1407:  
 1408: #if DEBUG
 1409:                                 if (pon.Name == "SBA.618")
 1410:                                 {
 1411:  
 1412:                                 }
 1413: #endif
 1414:  
 1415: #if DEBUG
 1416:                                 // this will throw an exception if there is a duplicate pon.Id
 1417:                                 if (ponIdDictionary.ContainsKey(pon.Id))
 1418:                                 {
 1419:                                     throw new ArgumentOutOfRangeException(@"ponDictionary.ContainsKey(pon.Id)");
 1420:                                 }
 1421:                                 else ponIdDictionary[pon.Id] = pon.Name;
 1422: #endif
 1423:  
 1424:                                 ponList.Add(pon);
 1425:                             }
 1426: #if DEBUG
 1427:                             /*
 1428:                             else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0))
 1429:                             {
 1430:                                 throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0)");
 1431:                             }
 1432:                             else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
 1433:                             {
 1434:                                 throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0)");
 1435:                             }
 1436:                             else
 1437:                             {
 1438:                             }
 1439:                             */
 1440: #endif
 1441:                             oltPonIndex++;
 1442:                         }
 1443:                         //}
 1444:                         //else throw new ArgumentOutOfRangeException(@"Condition not met: (!ponGroup.UsesProposedList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)");
 1445:                     }
 1446:                     //}
 1447:                     //else throw new ArgumentOutOfRangeException(@"Condition not met: ((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0");
 1448:                 }
 1449:  
 1450:                 return ponList;
 1451:             }
 1452:         }
 1453:  
 1454:         ////////////////////////////////////////////////////////////////////////////
 1455:  
 1456:         /// <summary>
 1457:         ///
 1458:         /// </summary>
 1459:         public static Dictionary<string, string> PonNameToPonIdDictionary
 1460:         {
 1461:             get
 1462:             {
 1463:                 if (ponNameToPonIdDictionary == null || ponNameToPonIdDictionary.Count == 0)
 1464:                 {
 1465:                     lock (objectLock)
 1466:                     {
 1467:                         ponNameToPonIdDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList
 1468:                                                     select new { p.Name, p.Id }).ToDictionary(n => n.Name, n => n.Id);
 1469:                     }
 1470:                 }
 1471:  
 1472:                 return ponNameToPonIdDictionary;
 1473:             }
 1474:         }
 1475:  
 1476:         ////////////////////////////////////////////////////////////////////////////
 1477:  
 1478:         /// <summary>
 1479:         ///
 1480:         /// </summary>
 1481:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonIdToPonDictionary
 1482:         {
 1483:             get
 1484:             {
 1485:                 if (ponIdToPonDictionary == null || ponIdToPonDictionary.Count == 0)
 1486:                 {
 1487:                     lock (objectLock)
 1488:                     {
 1489:                         ponIdToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList
 1490:                                                 select new { p.Id, Pon = p }).ToDictionary(n => n.Id, n => n.Pon);
 1491:                     }
 1492:                 }
 1493:  
 1494:                 return ponIdToPonDictionary;
 1495:             }
 1496:         }
 1497:  
 1498:         ////////////////////////////////////////////////////////////////////////////
 1499:  
 1500:         /// <summary>
 1501:         ///
 1502:         /// </summary>
 1503:         public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonNameToPonDictionary
 1504:         {
 1505:             get
 1506:             {
 1507:                 if (ponNameToPonDictionary == null || ponNameToPonDictionary.Count == 0)
 1508:                 {
 1509:                     lock (objectLock)
 1510:                     {
 1511:                         ponNameToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList
 1512:                                                   select new { p.Name, Pon = p }).ToDictionary(n => n.Name, n => n.Pon);
 1513:                     }
 1514:                 }
 1515:  
 1516:                 return ponNameToPonDictionary;
 1517:             }
 1518:         }
 1519:  
 1520:         ////////////////////////////////////////////////////////////////////////////
 1521:  
 1522:         /// <summary>
 1523:         ///
 1524:         /// </summary>
 1525:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon PonByOltEmsNameAndSnAndPnAndOptionallyOntId(string emsName, int sn, int pn, int ontId)
 1526:         {
 1527:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
 1528:  
 1529:             var olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltByEmsName(emsName);
 1530:  
 1531:             if (olt.EmsName == "OLT-QRN-ABW-01") // ABW is all screwed up with multiple PON grouped. I will use ontId and read PON from OntList
 1532:             {
 1533:                 pon = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 1534:                        where o.Pon.PonGroup.Olt.Id == olt.Id && o.CardSlot == sn && o.Port == pn && o.InternalNumber == ontId
 1535:                        select o.Pon).SingleOrDefault();
 1536:             }
 1537:             else
 1538:             {
 1539:                 pon = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList
 1540:                        where p.PonGroup.Olt.Id == olt.Id && p.CardSlot == sn && p.Port == pn
 1541:                        select p).SingleOrDefault();
 1542:             }
 1543:  
 1544:             return pon;
 1545:         }
 1546:  
 1547:         ////////////////////////////////////////////////////////////////////////////
 1548:         ////////////////////////////////////////////////////////////////////////////
 1549:  
 1550:         /// <summary>
 1551:         ///
 1552:         /// </summary>
 1553:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
 1554:         {
 1555:             get
 1556:             {
 1557:                 if (ponGroupList == null || ponGroupList.Count == 0)
 1558:                 {
 1559:                     lock (objectLock)
 1560:                     {
 1561:                         ponGroupList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonGroupList;
 1562:                     }
 1563:                 }
 1564:  
 1565:                 return ponGroupList;
 1566:             }
 1567:         }
 1568:  
 1569:         ////////////////////////////////////////////////////////////////////////////
 1570:  
 1571:         /// <summary>
 1572:         ///
 1573:         /// </summary>
 1574:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> _PonGroupList
 1575:         {
 1576:             get
 1577:             {
 1578:                 int networkId, siteId, routerId, odfId, oltId, id;
 1579:                 const string pattern = @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0";
 1580:                 Regex regex;
 1581:                 Hashtable idHashtable, networkNumberHashtable;
 1582: #if DEBUG
 1583:                 Hashtable gatewayIpHashtable;
 1584: #endif
 1585:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup;
 1586:  
 1587:                 regex = new Regex(pattern);
 1588:                 var ponGroupList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup>(16); // 16 is max number of ponGroup in ONT
 1589:                 idHashtable = new Hashtable();
 1590:                 networkNumberHashtable = new Hashtable();
 1591: #if DEBUG
 1592:                 gatewayIpHashtable = new Hashtable();
 1593: #endif
 1594:  
 1595:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 1596:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 1597:                                        select n).Single();
 1598:  
 1599:                 foreach (XElement x in networkXElement.Elements("site").Elements("router").Elements("odf").Elements("olt").Elements("ponGroup"))
 1600:                 {
 1601:                     ponGroup = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup
 1602:                     {
 1603:                         Olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt()
 1604:                     };
 1605:                     ponGroup.Olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
 1606:                     ponGroup.Olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
 1607:                     ponGroup.Olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 1608:  
 1609:                     networkId = int.Parse(x.Parent.Parent.Parent.Parent.Parent.Attribute("id").Value);
 1610:                     siteId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
 1611:                     routerId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
 1612:                     odfId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 1613:                     oltId = int.Parse(x.Parent.Attribute("id").Value);
 1614:                     id = int.Parse(x.Attribute("id").Value);
 1615:  
 1616:                     siteId = ponGroup.Olt.Odf.Router.Site.SiteId(networkId, siteId);
 1617:                     routerId = ponGroup.Olt.Odf.Router.RouterId(siteId, routerId);
 1618:                     odfId = ponGroup.Olt.Odf.OdfId(routerId, odfId);
 1619:                     oltId = ponGroup.Olt.OltId(odfId, oltId);
 1620:                     ponGroup.Id = ponGroup.PonGroupId(oltId, id);
 1621:  
 1622:                     ponGroup.Number = id;
 1623:  
 1624:                     ponGroup.Olt = (from o in OltList where o.Id == oltId select o).Single(); //.SingleOrDefault();
 1625:  
 1626:                     if (x.Attribute("symbol") != null) ponGroup.Symbol = x.Attribute("symbol").Value;
 1627:                     else ponGroup.Symbol = ponGroup.Olt.Symbol;
 1628:  
 1629:                     ponGroup.NetworkNumber = x.Attribute("networkNumber").Value;
 1630:                     // Network number must be unique and must end with *.*.*.0
 1631:                     if (networkNumberHashtable.ContainsKey(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
 1632:                     else if (!regex.IsMatch(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not if format *.*.*.0 OLT name=" + ponGroup.Olt.Name + ". ");
 1633:                     else networkNumberHashtable[ponGroup.NetworkNumber] = 1;
 1634:  
 1635:  
 1636:                     ponGroup.PonListString = x.Attribute("list").Value;
 1637:                     // below: pass ponList and change "*" to "0"
 1638:                     ponGroup.UsedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.PonListString.Replace("*", "0"));
 1639:  
 1640:                     /*
 1641:                     if (x.Attribute("proposedList") != null && x.Attribute("proposedList").Value.Length > 0)
 1642:                     {
 1643:                         ponGroup.ProposedPonListString = x.Attribute("proposedList").Value;
 1644: 
 1645:                         // below: pass ponList and change "*" to "0"
 1646:                         ponGroup.UsedProposedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.ProposedPonListString.Replace("*", "0"));
 1647:                     }
 1648:                     else
 1649:                     {
 1650:                         ponGroup.ProposedPonListString = string.Empty;
 1651:                         ponGroup.UsedProposedPonInPonGroupList = new List<int>();
 1652:                     }
 1653:                     */
 1654:  
 1655:                     if (x.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Attribute("gatewayIp").Value;
 1656:                     else if (x.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
 1657:                     else if (x.Parent.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Parent.Attribute("gatewayIp").Value;
 1658:                     else throw new ArgumentException(@"ponGroup.GatewayIp could not be produced from XML document. ");
 1659:  
 1660:                     if (x.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Attribute("mgcIp").Value;
 1661:                     else if (x.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Attribute("mgcIp").Value;
 1662:                     else if (x.Parent.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Parent.Attribute("mgcIp").Value;
 1663:                     else if (ponGroup.Olt.Name != "SAA-1" && (ponGroup.Olt.Name != "SDQ-1")) throw new ArgumentException(@"ponGroup.MgcIp could not be produced from XML document. ");
 1664:                     // note that MgcIp need some special handling on the PON.ONT level
 1665:  
 1666: #if DEBUG
 1667:                     // GatewayIp number must be unique
 1668:                     /*if (gatewayIpHashtable.ContainsKey(ponGroup.GatewayIp)) throw new ArgumentException(@"Lt.GatewayIp is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
 1669:                     else*/
 1670:                     gatewayIpHashtable[ponGroup.GatewayIp] = 1;
 1671:  
 1672:                     // Id
 1673:                     if (idHashtable.ContainsKey(ponGroup.Id)) throw new ArgumentException(@"ponGroup.Id is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
 1674:                     else idHashtable[ponGroup.Id] = 1;
 1675: #endif
 1676:                     ponGroupList.Add(ponGroup);
 1677:                 }
 1678:  
 1679:                 return ponGroupList;
 1680:             }
 1681:         }
 1682:  
 1683:         ////////////////////////////////////////////////////////////////////////////
 1684:  
 1685:         /// <summary>
 1686:         ///
 1687:         /// </summary>
 1688:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> OltList
 1689:         {
 1690:             get
 1691:             {
 1692:                 if (oltList == null || oltList.Count == 0)
 1693:                 {
 1694:                     lock (objectLock)
 1695:                     {
 1696:                         oltList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OltList;
 1697:                     }
 1698:                 }
 1699:  
 1700:                 return oltList;
 1701:             }
 1702:         }
 1703:  
 1704:         ////////////////////////////////////////////////////////////////////////////
 1705:  
 1706:         /// <summary>
 1707:         ///
 1708:         /// </summary>
 1709:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> _OltList
 1710:         {
 1711:             get
 1712:             {
 1713:                 int networkId, siteId, routerId, odfId, id;
 1714:                 string fieldTypeString;
 1715:                 Hashtable networkNumberHashtable;
 1716:                 //Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState state;
 1717:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 1718:  
 1719:                 var oltList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt>(100);
 1720:                 networkNumberHashtable = new Hashtable();
 1721:  
 1722:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 1723:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 1724:                                        select n).Single();
 1725:  
 1726:                 foreach (XElement x in networkXElement.Elements("site").Elements("router").Elements("odf").Elements("olt"))
 1727:                 {
 1728:                     olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt();
 1729:                     olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
 1730:                     olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
 1731:                     olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 1732:  
 1733:                     networkId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
 1734:                     siteId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
 1735:                     routerId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 1736:                     odfId = int.Parse(x.Parent.Attribute("id").Value);
 1737:                     id = int.Parse(x.Attribute("id").Value);
 1738:  
 1739:                     siteId = olt.Odf.Router.Site.SiteId(networkId, siteId);
 1740:                     routerId = olt.Odf.Router.RouterId(siteId, routerId);
 1741:                     odfId = olt.Odf.OdfId(routerId, odfId);
 1742:                     olt.Id = olt.OltId(odfId, id);
 1743:  
 1744:                     olt.Odf = (from o in OdfList where o.Id == odfId select o).Single(); //.SingleOrDefault();
 1745:  
 1746:                     olt.Name = x.Attribute("name").Value;
 1747:                     olt.AmsName = x.Attribute("amsName").Value;
 1748:  
 1749:                     if (x.Attribute("did") != null) olt.Did = int.Parse(x.Attribute("did").Value);
 1750:  
 1751:                     olt.Type = x.Attribute("type").Value;
 1752:  
 1753:                     /*
 1754:                     if (x.Attribute("state") != null)
 1755:                     {
 1756:                         switch (x.Attribute("state").Value)
 1757:                         {
 1758:                             case "is-nr": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr; break;
 1759:                             case "oos-au": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAu; break;
 1760:                             case "oos-ma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosMa; break;
 1761:                             case "oos-auma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAuma; break;
 1762:                             default: state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined; break;
 1763:                         }
 1764:                     }
 1765:                     else state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined;
 1766:                     */
 1767:  
 1768:                     //olt.StateId = (int)state;
 1769:  
 1770:                     olt.IsSip = x.Attribute("isSip").Value == "true";
 1771:  
 1772:                     if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1773:                     {
 1774:                         olt.Rack = 1;
 1775:                         olt.Sub = 1;
 1776:                     }
 1777:                     else //if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1778:                     {
 1779:                         olt.Rack = 0;
 1780:                         olt.Sub = 0;
 1781:                     }
 1782:  
 1783:                     if (x.Attribute("gatewayIp") != null) olt.GatewayIp = x.Attribute("gatewayIp").Value;
 1784:                     else if (x.Parent.Attribute("gatewayIp") != null) olt.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
 1785:                     else olt.GatewayIp = string.Empty;
 1786:  
 1787:                     if (x.Attribute("mgcIp") != null) olt.MgcIp = x.Attribute("mgcIp").Value;
 1788:                     else if (x.Parent.Attribute("mgcIp") != null) olt.MgcIp = x.Parent.Attribute("mgcIp").Value;
 1789:                     else olt.MgcIp = string.Empty;
 1790:  
 1791:                     fieldTypeString = x.Attribute("fieldType").Value;
 1792:  
 1793:                     if (!string.IsNullOrEmpty(fieldTypeString))
 1794:                     {
 1795:                         if (fieldTypeString == "green") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green;
 1796:                         else if (fieldTypeString == "brown") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown;
 1797:                         else throw new ArgumentException(@"OLT field type unrecognized. ");
 1798:                     }
 1799:                     else throw new ArgumentException(@"OLT field type invalid. ");
 1800:  
 1801:                     olt.Symbol = x.Attribute("symbol").Value;
 1802:  
 1803:                     // below: the number of possible PONs differs between Nokia OLT types and Huawei
 1804:                     if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1805:                     {
 1806:                         olt.NumberOfPonsPerLt = 16;
 1807:                         olt.NumberOfOntsInPon = 32;
 1808:                         olt.NumberOfFirstSlot = 1;
 1809:  
 1810:                         if (olt.Type == "7342")
 1811:                         {
 1812:                             olt.NumberOfLts = 2;
 1813:                         }
 1814:                         else if (olt.Type == "7360")
 1815:                         {
 1816:                             olt.NumberOfLts = 16;
 1817:                         }
 1818:                         else
 1819:                         {
 1820:                             throw new ArgumentException(@"Nokia olt.Type unrecognized. ");
 1821:                         }
 1822:                     }
 1823:                     else if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1824:                     {
 1825:                         olt.NumberOfLts = 2;
 1826:  
 1827:                         if (olt.Type == "MA5600T")
 1828:                         {
 1829:                             olt.NumberOfPonsPerLt = 128;
 1830:                             olt.NumberOfOntsInPon = 32;
 1831:                             olt.NumberOfFirstSlot = 1;
 1832:                         }
 1833:                         else if (olt.Type == "MA5600T-temp")
 1834:                         {
 1835:                             olt.NumberOfPonsPerLt = 128 * 8;
 1836:                             olt.NumberOfOntsInPon = 4;
 1837:                             olt.NumberOfFirstSlot = 1;
 1838:                         }
 1839:                         else if (olt.Type == "MA5603T")
 1840:                         {
 1841:                             olt.NumberOfPonsPerLt = 128;
 1842:                             olt.NumberOfOntsInPon = 32;
 1843:                             olt.NumberOfFirstSlot = 0;
 1844:                         }
 1845:                         else
 1846:                         {
 1847:                             throw new ArgumentException(@"Huawei olt.Type unrecognized. ");
 1848:                         }
 1849:                     }
 1850:                     else
 1851:                     {
 1852:                         throw new ArgumentException(@"olt.Odf.Vendor unrecognized. ");
 1853:                     }
 1854:  
 1855:                     olt.NumberOfPons = olt.NumberOfLts * olt.NumberOfPonsPerLt;
 1856: #if DEBUG
 1857:                     if ((olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0) throw new ArgumentException(@"(olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0");
 1858:                     if (olt.NumberOfFirstSlot != 0 && olt.NumberOfFirstSlot != 1) throw new ArgumentException(@"olt.NumberOfFirstSlot == 0 || olt.NumberOfFirstSlot == 1");
 1859: #endif
 1860:                     oltList.Add(olt);
 1861:                 }
 1862:  
 1863:                 return oltList;
 1864:             }
 1865:         }
 1866:  
 1867:         ////////////////////////////////////////////////////////////////////////////
 1868:         ////////////////////////////////////////////////////////////////////////////
 1869:  
 1870:         /// <summary>
 1871:         ///
 1872:         /// </summary>
 1873:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> NokiaOltList
 1874:         {
 1875:             get
 1876:             {
 1877:                 lock (objectLock)
 1878:                 {
 1879:                     return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia, 0);
 1880:                 }
 1881:             }
 1882:         }
 1883:  
 1884:         ////////////////////////////////////////////////////////////////////////////
 1885:  
 1886:         /// <summary>
 1887:         ///
 1888:         /// </summary>
 1889:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltList
 1890:         {
 1891:             get
 1892:             {
 1893:                 lock (objectLock)
 1894:                 {
 1895:                     return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei, 0);
 1896:                 }
 1897:             }
 1898:         }
 1899:  
 1900:         ////////////////////////////////////////////////////////////////////////////
 1901:  
 1902:         /// <summary>
 1903:         ///
 1904:         /// </summary>
 1905:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor, int siteId)
 1906:         {
 1907:             lock (objectLock)
 1908:             {
 1909:                 List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
 1910:  
 1911:                 list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 1912:                         where o.Odf.Vendor == vendor && (o.Odf.Router.Site.Id == siteId || siteId == 0)
 1913:                         select o).ToList();
 1914:  
 1915:                 return list;
 1916:             }
 1917:         }
 1918:  
 1919:         ////////////////////////////////////////////////////////////////////////////
 1920:  
 1921:         /// <summary>
 1922:         ///
 1923:         /// </summary>
 1924:         public static List<int> NokiaOltIdList()
 1925:         {
 1926:             return OltIdByVendorAndSiteIdList("No", 0);
 1927:         }
 1928:  
 1929:         ////////////////////////////////////////////////////////////////////////////
 1930:  
 1931:         /// <summary>
 1932:         ///
 1933:         /// </summary>
 1934:         public static List<int> NokiaOltIdList(int siteId)
 1935:         {
 1936:             return OltIdByVendorAndSiteIdList("No", siteId);
 1937:         }
 1938:  
 1939:         ////////////////////////////////////////////////////////////////////////////
 1940:  
 1941:         /// <summary>
 1942:         ///
 1943:         /// </summary>
 1944:         public static List<int> HuaweiOltIdList()
 1945:         {
 1946:             return OltIdByVendorAndSiteIdList("Hu", 0);
 1947:         }
 1948:  
 1949:         ////////////////////////////////////////////////////////////////////////////
 1950:  
 1951:         /// <summary>
 1952:         ///
 1953:         /// </summary>
 1954:         public static List<int> HuaweiOltIdList(int siteId)
 1955:         {
 1956:             return OltIdByVendorAndSiteIdList("Hu", siteId);
 1957:         }
 1958:  
 1959:         ////////////////////////////////////////////////////////////////////////////
 1960:  
 1961:         /// <summary>
 1962:         ///
 1963:         /// </summary>
 1964:         public static List<int> OltIdByVendorAndSiteIdList(string vendorShortName, int siteId)
 1965:         {
 1966:             List<int> list;
 1967:  
 1968:             list = new List<int>();
 1969:  
 1970:             foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
 1971:             {
 1972:                 // siteId 0 will return all sites
 1973:  
 1974:                 if (olt.Odf.Vendor.ShortName == vendorShortName && (olt.Odf.Router.Site.Id == siteId || siteId == 0))
 1975:                 {
 1976:                     list.Add(olt.Id);
 1977:                 }
 1978:             }
 1979:  
 1980:             return list;
 1981:         }
 1982:  
 1983:         ////////////////////////////////////////////////////////////////////////////
 1984:  
 1985:         /// <summary>
 1986:         ///
 1987:         /// </summary>
 1988:         public static List<int> NokiaSwitchNokiaAccessOltIdList
 1989:         {
 1990:             get
 1991:             {
 1992:                 lock (objectLock)
 1993:                 {
 1994:                     var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 1995:                                 where o.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 1996:                                 && o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 1997:                                 select o.Id).ToList();
 1998:  
 1999:                     return list;
 2000:                 }
 2001:             }
 2002:         }
 2003:  
 2004:         ////////////////////////////////////////////////////////////////////////////
 2005:  
 2006:         /// <summary>
 2007:         ///
 2008:         /// </summary>
 2009:         public static List<int> HuaweiSwitchNokiaAccessOltIdList
 2010:         {
 2011:             get
 2012:             {
 2013:                 lock (objectLock)
 2014:                 {
 2015:                     var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2016:                                 where o.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
 2017:                                 && o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 2018:                                 select o.Id).ToList();
 2019:  
 2020:                     return list;
 2021:                 }
 2022:             }
 2023:         }
 2024:  
 2025:         ////////////////////////////////////////////////////////////////////////////
 2026:  
 2027:         /// <summary>
 2028:         ///
 2029:         /// </summary>
 2030:         public static List<int> NokiaRouterHuaweiAccessOltIdList
 2031:         {
 2032:             get
 2033:             {
 2034:                 lock (objectLock)
 2035:                 {
 2036:                     var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2037:                                 where o.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 2038:                                 && o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
 2039:                                 select o.Id).ToList();
 2040:  
 2041:                     return list;
 2042:                 }
 2043:             }
 2044:         }
 2045:  
 2046:         ////////////////////////////////////////////////////////////////////////////
 2047:         ////////////////////////////////////////////////////////////////////////////
 2048:  
 2049:         /// <summary>
 2050:         ///
 2051:         /// </summary>
 2052:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByEmsName(string emsName)
 2053:         {
 2054:             var olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2055:                        where o.EmsName == emsName
 2056:                        select o).SingleOrDefault();
 2057:  
 2058:             return olt;
 2059:         }
 2060:  
 2061:         ////////////////////////////////////////////////////////////////////////////
 2062:  
 2063:         /// <summary>
 2064:         ///
 2065:         /// </summary>
 2066:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByAmsName(string amsName)
 2067:         {
 2068:             var olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2069:                        where o.AmsName == amsName
 2070:                        select o).SingleOrDefault();
 2071:  
 2072:             return olt;
 2073:         }
 2074:  
 2075:         ////////////////////////////////////////////////////////////////////////////
 2076:  
 2077:         /// <summary>
 2078:         ///
 2079:         /// </summary>
 2080:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
 2081:         {
 2082:             var olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2083:                        where o.Did == did
 2084:                        select o).SingleOrDefault();
 2085:  
 2086:             return olt;
 2087:         }
 2088:  
 2089:         ////////////////////////////////////////////////////////////////////////////
 2090:  
 2091:         /// <summary>
 2092:         ///
 2093:         /// </summary>
 2094:         public static Dictionary<int, int> DidToOltIdDictionary
 2095:         {
 2096:             get
 2097:             {
 2098:                 if (didToOltIdDictionary == null || didToOltIdDictionary.Count == 0)
 2099:                 {
 2100:                     lock (objectLock)
 2101:                     {
 2102:                         didToOltIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2103:                                                 where o.Did != 0
 2104:                                                 select new { o.Did, OltId = o.Id }).ToDictionary(n => n.Did, n => n.OltId);
 2105:                     }
 2106:                 }
 2107:  
 2108:                 return didToOltIdDictionary;
 2109:             }
 2110:         }
 2111:  
 2112:         ////////////////////////////////////////////////////////////////////////////
 2113:         ////////////////////////////////////////////////////////////////////////////
 2114:  
 2115:         /// <summary>
 2116:         ///
 2117:         /// </summary>
 2118:         public static List<int> SipOltIdList
 2119:         {
 2120:             get
 2121:             {
 2122:                 lock (objectLock)
 2123:                 {
 2124:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2125:                             where o.IsSip == true
 2126:                             select o.Id).ToList();
 2127:                 }
 2128:             }
 2129:         }
 2130:  
 2131:         ////////////////////////////////////////////////////////////////////////////
 2132:         ////////////////////////////////////////////////////////////////////////////
 2133:  
 2134:         /// <summary>
 2135:         ///
 2136:         /// </summary>
 2137:         public static List<int> GreenFieldOltIdList
 2138:         {
 2139:             get
 2140:             {
 2141:                 lock (objectLock)
 2142:                 {
 2143:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2144:                             where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
 2145:                             select o.Id).ToList();
 2146:                 }
 2147:             }
 2148:         }
 2149:  
 2150:         ////////////////////////////////////////////////////////////////////////////
 2151:  
 2152:         /// <summary>
 2153:         ///
 2154:         /// </summary>
 2155:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldOltList
 2156:         {
 2157:             get
 2158:             {
 2159:                 lock (objectLock)
 2160:                 {
 2161:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2162:                             where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
 2163:                             select o).ToList();
 2164:                 }
 2165:             }
 2166:         }
 2167:  
 2168:         ////////////////////////////////////////////////////////////////////////////
 2169:  
 2170:         /// <summary>
 2171:         ///
 2172:         /// </summary>
 2173:         public static List<int> GreenFieldSipOltIdList
 2174:         {
 2175:             get
 2176:             {
 2177:                 lock (objectLock)
 2178:                 {
 2179:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2180:                             where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
 2181:                             select o.Id).ToList();
 2182:                 }
 2183:             }
 2184:         }
 2185:  
 2186:         ////////////////////////////////////////////////////////////////////////////
 2187:  
 2188:         /// <summary>
 2189:         ///
 2190:         /// </summary>
 2191:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldSipOltList
 2192:         {
 2193:             get
 2194:             {
 2195:                 lock (objectLock)
 2196:                 {
 2197:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2198:                             where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
 2199:                             select o).ToList();
 2200:                 }
 2201:             }
 2202:         }
 2203:  
 2204:         ////////////////////////////////////////////////////////////////////////////
 2205:  
 2206:         /// <summary>
 2207:         ///
 2208:         /// </summary>
 2209:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> GreenFieldOntList
 2210:         {
 2211:             get
 2212:             {
 2213:                 if (greenFieldOntList == null || greenFieldOntList.Count == 0)
 2214:                 {
 2215:                     lock (objectLock)
 2216:                     {
 2217:                         greenFieldOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 2218:                                              where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
 2219:                                              select o).ToList();
 2220:  
 2221:                     }
 2222:                 }
 2223:  
 2224:                 return greenFieldOntList;
 2225:             }
 2226:         }
 2227:  
 2228:         ////////////////////////////////////////////////////////////////////////////
 2229:         ////////////////////////////////////////////////////////////////////////////
 2230:  
 2231:         /// <summary>
 2232:         ///
 2233:         /// </summary>
 2234:         public static List<int> BrownFieldOltIdList
 2235:         {
 2236:             get
 2237:             {
 2238:                 lock (objectLock)
 2239:                 {
 2240:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2241:                             where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
 2242:                             select o.Id).ToList();
 2243:                 }
 2244:             }
 2245:         }
 2246:  
 2247:         ////////////////////////////////////////////////////////////////////////////
 2248:  
 2249:         /// <summary>
 2250:         ///
 2251:         /// </summary>
 2252:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldOltList
 2253:         {
 2254:             get
 2255:             {
 2256:                 lock (objectLock)
 2257:                 {
 2258:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2259:                             where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
 2260:                             select o).ToList();
 2261:                 }
 2262:             }
 2263:         }
 2264:  
 2265:         ////////////////////////////////////////////////////////////////////////////
 2266:  
 2267:         /// <summary>
 2268:         ///
 2269:         /// </summary>
 2270:         public static List<int> BrownFieldSipOltIdList
 2271:         {
 2272:             get
 2273:             {
 2274:                 lock (objectLock)
 2275:                 {
 2276:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2277:                             where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
 2278:                             select o.Id).ToList();
 2279:                 }
 2280:             }
 2281:         }
 2282:  
 2283:         ////////////////////////////////////////////////////////////////////////////
 2284:  
 2285:         /// <summary>
 2286:         ///
 2287:         /// </summary>
 2288:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldSipOltList
 2289:         {
 2290:             get
 2291:             {
 2292:                 lock (objectLock)
 2293:                 {
 2294:                     return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2295:                             where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
 2296:                             select o).ToList();
 2297:                 }
 2298:             }
 2299:         }
 2300:  
 2301:         ////////////////////////////////////////////////////////////////////////////
 2302:  
 2303:         /// <summary>
 2304:         ///
 2305:         /// </summary>
 2306:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> BrownFieldOntList
 2307:         {
 2308:             get
 2309:             {
 2310:                 if (brownFieldOntList == null || brownFieldOntList.Count == 0)
 2311:                 {
 2312:                     lock (objectLock)
 2313:                     {
 2314:                         brownFieldOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 2315:                                              where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
 2316:                                              select o).ToList();
 2317:  
 2318:                     }
 2319:                 }
 2320:  
 2321:                 return brownFieldOntList;
 2322:             }
 2323:         }
 2324:  
 2325:         ////////////////////////////////////////////////////////////////////////////
 2326:         ////////////////////////////////////////////////////////////////////////////
 2327:  
 2328:         /// <summary>
 2329:         ///
 2330:         /// </summary>
 2331:         public static List<string> NokiaOltAmsNameList
 2332:         {
 2333:             get
 2334:             {
 2335:                 lock (objectLock)
 2336:                 {
 2337:                     List<string> list;
 2338:  
 2339:                     list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2340:                             where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
 2341:                             //&& o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
 2342:                             select o.AmsName).ToList();
 2343:  
 2344:                     return list;
 2345:                 }
 2346:             }
 2347:         }
 2348:  
 2349:         ////////////////////////////////////////////////////////////////////////////
 2350:  
 2351:         /// <summary>
 2352:         ///
 2353:         /// </summary>
 2354:         public static List<string> HuaweiOltAmsNameList
 2355:         {
 2356:             get
 2357:             {
 2358:                 lock (objectLock)
 2359:                 {
 2360:                     List<string> list;
 2361:  
 2362:                     list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
 2363:                             where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
 2364:                             //&& o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
 2365:                             select o.AmsName).ToList();
 2366:  
 2367:                     return list;
 2368:                 }
 2369:             }
 2370:         }
 2371:  
 2372:         ////////////////////////////////////////////////////////////////////////////
 2373:  
 2374:         /// <summary>
 2375:         ///
 2376:         /// </summary>
 2377:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> OdfList
 2378:         {
 2379:             get
 2380:             {
 2381:                 if (odfList == null || odfList.Count == 0)
 2382:                 {
 2383:                     lock (objectLock)
 2384:                     {
 2385:                         odfList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OdfList;
 2386:                     }
 2387:                 }
 2388:  
 2389:                 return odfList;
 2390:             }
 2391:         }
 2392:  
 2393:         ////////////////////////////////////////////////////////////////////////////
 2394:  
 2395:         /// <summary>
 2396:         ///
 2397:         /// </summary>
 2398:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> _OdfList
 2399:         {
 2400:             get
 2401:             {
 2402:                 int networkId, siteId, routerId, id;
 2403:                 string vendorShortName;
 2404:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf;
 2405:  
 2406:                 var odfList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf>();
 2407:  
 2408:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 2409:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 2410:                                        select n).Single();
 2411:  
 2412:                 foreach (XElement x in networkXElement.Elements("site").Elements("router").Elements("odf"))
 2413:                 {
 2414:                     odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
 2415:                     odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
 2416:                     odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 2417:  
 2418:                     networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
 2419:                     siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 2420:                     routerId = int.Parse(x.Parent.Attribute("id").Value);
 2421:                     id = int.Parse(x.Attribute("id").Value);
 2422:  
 2423:                     siteId = odf.Router.Site.SiteId(networkId, siteId);
 2424:                     routerId = odf.Router.RouterId(siteId, routerId);
 2425:                     odf.Id = odf.OdfId(routerId, id);
 2426:  
 2427:                     odf.Name = x.Attribute("name").Value;
 2428:  
 2429:                     odf.GatewayIp = (x.Attribute("gatewayIp") != null) ? x.Attribute("gatewayIp").Value : string.Empty;
 2430:                     odf.MgcIp = (x.Attribute("mgcIp") != null) ? x.Attribute("mgcIp").Value : string.Empty;
 2431:  
 2432:                     vendorShortName = x.Attribute("vendorShortName").Value;
 2433:                     odf.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).Single(); //.si.SingleOrDefault();
 2434:  
 2435:                     odf.Router = (from r in RouterList where r.Id == routerId select r).Single(); //.SingleOrDefault();
 2436:  
 2437:                     odfList.Add(odf);
 2438:                 }
 2439:  
 2440:                 return odfList.ToList();
 2441:             }
 2442:         }
 2443:  
 2444:         ////////////////////////////////////////////////////////////////////////////
 2445:  
 2446:         /// <summary>
 2447:         ///
 2448:         /// </summary>
 2449:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> OamList
 2450:         {
 2451:             get
 2452:             {
 2453:                 if (oamList == null || oamList.Count == 0)
 2454:                 {
 2455:                     lock (objectLock)
 2456:                     {
 2457:                         oamList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OamList;
 2458:                     }
 2459:                 }
 2460:  
 2461:                 return oamList;
 2462:             }
 2463:         }
 2464:  
 2465:         ////////////////////////////////////////////////////////////////////////////
 2466:  
 2467:         /// <summary>
 2468:         ///
 2469:         /// </summary>
 2470:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> _OamList
 2471:         {
 2472:             get
 2473:             {
 2474:                 int networkId, siteId, routerId, id;
 2475:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam oam;
 2476:  
 2477:                 var oamList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam>();
 2478:  
 2479:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 2480:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 2481:                                        select n).Single();
 2482:  
 2483:                 foreach (XElement x in networkXElement.Elements("site").Elements("router").Elements("oam"))
 2484:                 {
 2485:                     oam = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam();
 2486:                     oam.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
 2487:                     oam.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 2488:  
 2489:                     networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
 2490:                     siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 2491:                     routerId = int.Parse(x.Parent.Attribute("id").Value);
 2492:                     id = int.Parse(x.Attribute("id").Value);
 2493:  
 2494:                     siteId = oam.Router.Site.SiteId(networkId, siteId);
 2495:                     routerId = oam.Router.RouterId(siteId, routerId);
 2496:                     oam.Id = oam.OamId(routerId, id);
 2497:  
 2498:                     oam.Network = x.Attribute("network").Value;
 2499:                     oam.Gateway = x.Attribute("gateway").Value;
 2500:                     oam.Vlan = int.Parse(x.Attribute("vlan").Value);
 2501:                     oam.Vpls = int.Parse(x.Attribute("vpls").Value);
 2502:                     oam.FtpIp = x.Attribute("ftpIp").Value;
 2503:                     oam.ConfigFile = x.Attribute("configFile").Value;
 2504:  
 2505:                     oam.Router = (from r in RouterList where r.Id == routerId select r).Single(); //.SingleOrDefault();
 2506:  
 2507:                     oamList.Add(oam);
 2508:                 }
 2509:  
 2510:                 return oamList;
 2511:             }
 2512:         }
 2513:  
 2514:         ////////////////////////////////////////////////////////////////////////////
 2515:  
 2516:         /// <summary>
 2517:         ///
 2518:         /// </summary>
 2519:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorByService(string service)
 2520:         {
 2521:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 2522:  
 2523:             if (int.TryParse(service, out int i))
 2524:             {
 2525:                 switchVendor = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
 2526:                                 where r.DomainList.Any(u => service.StartsWith(u.ToString()))
 2527:                                 select r.Vendor).FirstOrDefault(); //.SingleOrDefault();
 2528:  
 2529:                 if (switchVendor == null) switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 2530:             }
 2531:             else switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 2532:  
 2533:             return switchVendor;
 2534:         }
 2535:  
 2536:         ////////////////////////////////////////////////////////////////////////////
 2537:  
 2538:         /// <summary>
 2539:         ///
 2540:         /// </summary>
 2541:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> SwitchVendorListByServiceList(List<string> serviceList)
 2542:         {
 2543:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 2544:             var switchVendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
 2545:  
 2546:             foreach (var service in serviceList)
 2547:             {
 2548:                 if (int.TryParse(service, out int i))
 2549:                 {
 2550:                     switchVendor = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
 2551:                                     where r.DomainList.Any(u => service.StartsWith(u.ToString()))
 2552:                                     select r.Vendor).FirstOrDefault(); //.SingleOrDefault();
 2553:  
 2554:                     if (switchVendor == null) switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 2555:                 }
 2556:                 else switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 2557:  
 2558:                 switchVendorList.Add(switchVendor);
 2559:             }
 2560:  
 2561:             return switchVendorList;
 2562:         }
 2563:  
 2564:         ////////////////////////////////////////////////////////////////////////////
 2565:  
 2566:         /// <summary>
 2567:         ///
 2568:         /// </summary>
 2569:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(int number)
 2570:         {
 2571:             return PstnFromService(number.ToString());
 2572:         }
 2573:  
 2574:         ////////////////////////////////////////////////////////////////////////////
 2575:  
 2576:         /// <summary>
 2577:         ///
 2578:         /// </summary>
 2579:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(string service)
 2580:         {
 2581:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
 2582:  
 2583:             if (int.TryParse(service, out int i))
 2584:             {
 2585:                 pstn = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList
 2586:                         where p.DomainList.Any(u => service.StartsWith(u.ToString()))
 2587:                         select p).SingleOrDefault();
 2588:             }
 2589:             else pstn = null;
 2590:  
 2591:             return pstn;
 2592:         }
 2593:  
 2594:         ////////////////////////////////////////////////////////////////////////////
 2595:  
 2596:         /// <summary>
 2597:         ///
 2598:         /// </summary>
 2599:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> PstnThatUsesNpServerList
 2600:         {
 2601:             get
 2602:             {
 2603:                 var list = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList
 2604:                             where p.UsesNpServer == true
 2605:                             select p).ToList();
 2606:  
 2607:                 return list;
 2608:             }
 2609:         }
 2610:  
 2611:         ////////////////////////////////////////////////////////////////////////////
 2612:  
 2613:         /// <summary>
 2614:         ///
 2615:         /// </summary>
 2616:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> PstnList
 2617:         {
 2618:             get
 2619:             {
 2620:                 if (pstnList == null || pstnList.Count == 0)
 2621:                 {
 2622:                     lock (objectLock)
 2623:                     {
 2624:                         var networkId = 1; // <network id="1" name="Optical Fiber Network">
 2625:  
 2626:                         pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PstnList(networkId);
 2627:                     }
 2628:                 }
 2629:  
 2630:                 return pstnList;
 2631:             }
 2632:         }
 2633:  
 2634:         ////////////////////////////////////////////////////////////////////////////
 2635:  
 2636:         /// <summary>
 2637:         ///
 2638:         /// </summary>
 2639:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> LegacyPstnList
 2640:         {
 2641:             get
 2642:             {
 2643:                 if (legacyPstnList == null || legacyPstnList.Count == 0)
 2644:                 {
 2645:                     lock (objectLock)
 2646:                     {
 2647:                         var networkId = 2; // <network id="2" name="Legacy">
 2648:  
 2649:                         legacyPstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PstnList(networkId);
 2650:                     }
 2651:                 }
 2652:  
 2653:                 return legacyPstnList;
 2654:             }
 2655:         }
 2656:  
 2657:         ////////////////////////////////////////////////////////////////////////////
 2658:  
 2659:         /// <summary>
 2660:         ///
 2661:         /// </summary>
 2662:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> OfnAndLegacyPstnList
 2663:         {
 2664:             get
 2665:             {
 2666:                 var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
 2667:                 var legacyPstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.LegacyPstnList;
 2668:  
 2669:                 var list = pstnList.Union(legacyPstnList).ToList();
 2670:  
 2671:                 return list;
 2672:             }
 2673:         }
 2674:  
 2675:         ////////////////////////////////////////////////////////////////////////////
 2676:  
 2677:         /// <summary>
 2678:         ///
 2679:         /// </summary>
 2680:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn LegacyPstnFromService(int number)
 2681:         {
 2682:             return LegacyPstnFromService(number.ToString());
 2683:         }
 2684:  
 2685:         ////////////////////////////////////////////////////////////////////////////
 2686:  
 2687:         /// <summary>
 2688:         ///
 2689:         /// </summary>
 2690:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn LegacyPstnFromService(string service)
 2691:         {
 2692:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
 2693:  
 2694:             if (int.TryParse(service, out int i))
 2695:             {
 2696:                 pstn = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.LegacyPstnList
 2697:                         where p.DomainList.Any(u => service.StartsWith(u.ToString()))
 2698:                         select p).SingleOrDefault();
 2699:             }
 2700:             else pstn = null;
 2701:  
 2702:             return pstn;
 2703:         }
 2704:  
 2705:         ////////////////////////////////////////////////////////////////////////////
 2706:  
 2707:         /// <summary>
 2708:         ///
 2709:         /// </summary>
 2710:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> _PstnList(int networkId)
 2711:         {
 2712:             int siteId, id;
 2713:             string pstnExchangeTypeString, usesNpServerString;
 2714: #if DEBUG
 2715:             //Dictionary<int, int> domainDictionary;
 2716: #endif
 2717:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
 2718:  
 2719: #if DEBUG
 2720:             //domainDictionary = new Dictionary<int, int>(100);
 2721: #endif
 2722:             var pstnList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn>();
 2723:  
 2724:             var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 2725:                                    where n.Attribute("id").Value == networkId.ToString()
 2726:                                    select n).Single();
 2727:  
 2728:             foreach (XElement x in networkXElement.Elements("site").Elements("pstn"))
 2729:             {
 2730:                 pstn = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn();
 2731:                 pstn.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 2732:  
 2733:                 networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 2734:                 siteId = int.Parse(x.Parent.Attribute("id").Value);
 2735:                 id = int.Parse(x.Attribute("id").Value);
 2736:  
 2737:                 siteId = pstn.Site.SiteId(networkId, siteId);
 2738:                 pstn.Id = pstn.PstnId(siteId, id);
 2739:                 pstn.Name = x.Attribute("name").Value;
 2740:                 pstn.ArabicName = x.Attribute("arabicName").Value;
 2741:  
 2742:                 //if (x.Attribute("ip") != null) pstn.Ip = x.Attribute("ip").Value;
 2743:                 //else pstn.Ip = string.Empty;
 2744:  
 2745:                 pstn.DomainListString = x.Attribute("domainList").Value;
 2746:  
 2747:                 pstn.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(pstn.DomainListString);
 2748:  
 2749: #if DEBUG
 2750:                 /*
 2751:                 foreach (int i in pstn.DomainList)
 2752:                 {
 2753:                     // this will throw an exception if there are similar domains in pstns
 2754:                     if (domainDictionary.ContainsKey(i))
 2755:                     {
 2756:                         throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
 2757:                     }
 2758:                     else domainDictionary[i] = 1;
 2759:                 }
 2760:                 */
 2761: #endif
 2762:  
 2763:                 pstnExchangeTypeString = x.Attribute("type").Value;
 2764:  
 2765:                 if (pstnExchangeTypeString == "EWSD") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd;
 2766:                 else if (pstnExchangeTypeString == "AXE") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe;
 2767:                 else if (pstnExchangeTypeString == "MRD") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.NortelMeridian;
 2768: #if DEBUG
 2769:                 else throw new ArgumentOutOfRangeException(@"Unknown PSTN exchange type: " + pstnExchangeTypeString);
 2770: #endif
 2771:                 usesNpServerString = x.Attribute("usesNpServer") != null ? x.Attribute("usesNpServer").Value : "false";
 2772:                 pstn.UsesNpServer = usesNpServerString == "true";
 2773:  
 2774:                 if (networkId == 1) pstn.Site = (from s in SiteList where s.Id == siteId select s).Single(); // <network id="1" name="Optical Fiber Network">
 2775:                 else /*if(networkId == 2)*/ pstn.Site = (from s in LegacySiteList where s.Id == siteId select s).Single(); // <network id="2" name="Legacy">
 2776:  
 2777:                 pstnList.Add(pstn);
 2778:             }
 2779:  
 2780:             return pstnList;
 2781:         }
 2782:  
 2783:         ////////////////////////////////////////////////////////////////////////////
 2784:  
 2785:         /// <summary>
 2786:         ///
 2787:         /// </summary>
 2788:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromName(string name)
 2789:         {
 2790:             var pstn = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where p.Name == name select p).Single();
 2791:  
 2792:             return pstn;
 2793:         }
 2794:  
 2795:         ////////////////////////////////////////////////////////////////////////////
 2796:         ////////////////////////////////////////////////////////////////////////////
 2797:  
 2798:         /// <summary>
 2799:         ///
 2800:         /// </summary>
 2801:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan> MsanList
 2802:         {
 2803:             get
 2804:             {
 2805:                 if (msanList == null || msanList.Count == 0)
 2806:                 {
 2807:                     lock (objectLock)
 2808:                     {
 2809:                         msanList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._MsanList;
 2810:                     }
 2811:                 }
 2812:  
 2813:                 return msanList;
 2814:             }
 2815:         }
 2816:  
 2817:         ////////////////////////////////////////////////////////////////////////////
 2818:  
 2819:         /// <summary>
 2820:         ///
 2821:         /// </summary>
 2822:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan> _MsanList
 2823:         {
 2824:             get
 2825:             {
 2826:                 int networkId, siteId, id;
 2827:                 //string usesNpServerString;
 2828: #if DEBUG
 2829:                 //Dictionary<int, int> domainDictionary;
 2830: #endif
 2831:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan;
 2832:  
 2833: #if DEBUG
 2834:                 //domainDictionary = new Dictionary<int, int>(100);
 2835: #endif
 2836:                 var msanList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan>();
 2837:  
 2838:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 2839:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 2840:                                        select n).Single();
 2841:  
 2842:                 foreach (XElement x in networkXElement.Elements("site").Elements("msan"))
 2843:                 {
 2844:                     msan = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan();
 2845:                     msan.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 2846:  
 2847:                     networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 2848:                     siteId = int.Parse(x.Parent.Attribute("id").Value);
 2849:                     id = int.Parse(x.Attribute("id").Value);
 2850:  
 2851:                     siteId = msan.Site.SiteId(networkId, siteId);
 2852:                     msan.Id = msan.MsanId(siteId, id);
 2853:                     msan.NameSymbol = x.Attribute("nameSymbol").Value;
 2854:  
 2855:                     msan.DomainListString = x.Attribute("domainList").Value;
 2856:  
 2857:                     msan.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(msan.DomainListString);
 2858:  
 2859:                     //usesNpServerString = x.Attribute("usesNpServer").Value;
 2860:                     msan.UsesNpServer = false; // usesNpServerString == "true";
 2861:  
 2862:                     msan.Site = (from s in SiteList where s.Id == siteId select s).Single(); //.SingleOrDefault();
 2863:  
 2864: #if DEBUG
 2865:                     /*
 2866:                      
 2867:                     // You might have and MSAN on a site but the equivalent domains in another site
 2868:                     if (msan.DomainList != null)
 2869:                     {
 2870:                         foreach (var s in msan.DomainList)
 2871:                         {
 2872:                             if (!msan.Site.DomainList.Contains(s))
 2873:                             {
 2874:                                 throw new ArgumentOutOfRangeException(@"msan.Site.DomainList does not contain " + s + ".");
 2875:                             }
 2876:                         }
 2877:                     }
 2878:                     */
 2879:  
 2880:  
 2881:                     /*
 2882:                     foreach (int i in msan.DomainList)
 2883:                     {
 2884:                         // this will throw an exception if there are similar domains in pstns
 2885:                         if (domainDictionary.ContainsKey(i))
 2886:                         {
 2887:                             throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
 2888:                         }
 2889:                         else domainDictionary[i] = 1;
 2890:                     }
 2891:                     */
 2892: #endif
 2893:  
 2894:                     msanList.Add(msan);
 2895:                 }
 2896:  
 2897:                 return msanList;
 2898:             }
 2899:         }
 2900:  
 2901:         ////////////////////////////////////////////////////////////////////////////
 2902:  
 2903:         /// <summary>
 2904:         ///
 2905:         /// </summary>
 2906:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan MsanFromNameSymbol(string nameSymbol)
 2907:         {
 2908:             var msanList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.MsanList;
 2909:  
 2910:             var msan = (from m in msanList
 2911:                         where m.NameSymbol == nameSymbol
 2912:                         select m).SingleOrDefault();
 2913:  
 2914:             return msan;
 2915:         }
 2916:  
 2917:         ////////////////////////////////////////////////////////////////////////////
 2918:  
 2919:         /// <summary>
 2920:         ///
 2921:         /// </summary>
 2922:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan MsanFromSiteName(string siteName)
 2923:         {
 2924:             var siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList;
 2925:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan;
 2926:  
 2927:             var site = (from s in siteList
 2928:                         where s.Name == siteName
 2929:                         select s).SingleOrDefault();
 2930:  
 2931:             msan = (site != null && site.Msans.Count != 0) ? site.Msans.FirstOrDefault() : null;
 2932:  
 2933:             return msan;
 2934:         }
 2935:  
 2936:         ////////////////////////////////////////////////////////////////////////////
 2937:         ////////////////////////////////////////////////////////////////////////////
 2938:  
 2939:         /// <summary>
 2940:         ///
 2941:         /// </summary>
 2942:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX> SoftXList
 2943:         {
 2944:             get
 2945:             {
 2946:                 if (softXList == null || softXList.Count == 0)
 2947:                 {
 2948:                     lock (objectLock)
 2949:                     {
 2950:                         softXList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SoftXList;
 2951:                     }
 2952:                 }
 2953:  
 2954:                 return softXList;
 2955:             }
 2956:         }
 2957:  
 2958:         ////////////////////////////////////////////////////////////////////////////
 2959:  
 2960:         /// <summary>
 2961:         ///
 2962:         /// </summary>
 2963:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX> _SoftXList
 2964:         {
 2965:             get
 2966:             {
 2967:                 int networkId, siteId, id;
 2968: #if DEBUG
 2969:                 //Dictionary<int, int> domainDictionary;
 2970: #endif
 2971:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX softX;
 2972:  
 2973: #if DEBUG
 2974:                 //domainDictionary = new Dictionary<int, int>(100);
 2975: #endif
 2976:                 var softXList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX>();
 2977:  
 2978:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 2979:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 2980:                                        select n).Single();
 2981:  
 2982:                 foreach (XElement x in networkXElement.Elements("site").Elements("softx"))
 2983:                 {
 2984:                     softX = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.SoftX();
 2985:                     softX.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 2986:  
 2987:                     networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 2988:                     siteId = int.Parse(x.Parent.Attribute("id").Value);
 2989:                     id = int.Parse(x.Attribute("id").Value);
 2990:  
 2991:                     siteId = softX.Site.SiteId(networkId, siteId);
 2992:                     softX.Id = softX.SoftXId(siteId, id);
 2993:  
 2994:                     softX.DomainListString = x.Attribute("domainList").Value;
 2995:  
 2996:                     softX.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(softX.DomainListString);
 2997:  
 2998:                     softX.Site = (from s in SiteList where s.Id == siteId select s).Single(); //.SingleOrDefault();
 2999:  
 3000: #if DEBUG
 3001:                     /*
 3002:                     if (softX.DomainList != null)
 3003:                     {
 3004:                         foreach (var s in softX.DomainList)
 3005:                         {
 3006:                             if (!softX.Site.DomainList.Contains(s))
 3007:                             {
 3008:                                 throw new ArgumentOutOfRangeException(@"softX.Site.DomainList does not contain " + s + ".");
 3009:                             }
 3010:                         }
 3011:                     }
 3012:                     */
 3013:  
 3014:                     /*
 3015:                     foreach (int i in softX.DomainList)
 3016:                     {
 3017:                         // this will throw an exception if there are similar domains in sps
 3018:                         if (domainDictionary.ContainsKey(i))
 3019:                         {
 3020:                             throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
 3021:                         }
 3022:                         else domainDictionary[i] = 1;
 3023:                     }
 3024:                     */
 3025: #endif
 3026:  
 3027:                     softXList.Add(softX);
 3028:                 }
 3029:  
 3030:                 return softXList;
 3031:             }
 3032:         }
 3033:  
 3034:         ////////////////////////////////////////////////////////////////////////////
 3035:         ////////////////////////////////////////////////////////////////////////////
 3036:  
 3037:         /// <summary>
 3038:         ///
 3039:         /// </summary>
 3040:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> RouterList
 3041:         {
 3042:             get
 3043:             {
 3044:                 if (routerList == null || routerList.Count == 0)
 3045:                 {
 3046:                     lock (objectLock)
 3047:                     {
 3048:                         routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._RouterList;
 3049:                     }
 3050:                 }
 3051:  
 3052:                 return routerList;
 3053:             }
 3054:         }
 3055:  
 3056:         ////////////////////////////////////////////////////////////////////////////
 3057:  
 3058:         /// <summary>
 3059:         ///
 3060:         /// </summary>
 3061:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> _RouterList
 3062:         {
 3063:             get
 3064:             {
 3065:                 int networkId, siteId, id;
 3066:                 string vendorShortName;
 3067: #if DEBUG
 3068:                 //Dictionary<int, int> domainDictionary;
 3069: #endif
 3070:                 Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
 3071:  
 3072: #if DEBUG
 3073:                 //domainDictionary = new Dictionary<int, int>(100);
 3074: #endif
 3075:                 var routerList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router>();
 3076:  
 3077:                 var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 3078:                                        where n.Attribute("id").Value == "1" // <network id="1" name="Optical Fiber Network">
 3079:                                        select n).Single();
 3080:  
 3081:                 foreach (XElement x in networkXElement.Elements("site").Elements("router"))
 3082:                 {
 3083:                     router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
 3084:                     router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 3085:  
 3086:                     networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
 3087:                     siteId = int.Parse(x.Parent.Attribute("id").Value);
 3088:                     id = int.Parse(x.Attribute("id").Value);
 3089:  
 3090:                     siteId = router.Site.SiteId(networkId, siteId);
 3091:                     router.Id = router.RouterId(siteId, id);
 3092:                     router.Name = x.Attribute("name").Value;
 3093:                     router.Type = x.Attribute("type").Value;
 3094:  
 3095:                     router.DomainListString = x.Attribute("domainList").Value;
 3096:  
 3097:                     router.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(router.DomainListString);
 3098:  
 3099: #if DEBUG
 3100:                     /*
 3101:                     foreach (int i in router.DomainList)
 3102:                     {
 3103:                         // this will throw an exception if there are similar domains in routers
 3104:                         if (domainDictionary.ContainsKey(i))
 3105:                         {
 3106:                             throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
 3107:                         }
 3108:                         else domainDictionary[i] = 1;
 3109:                     }
 3110:                     */
 3111: #endif
 3112:  
 3113:                     vendorShortName = x.Attribute("vendorShortName").Value;
 3114:                     router.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).Single(); //.s.SingleOrDefault();
 3115:  
 3116:                     router.Site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Id == siteId select s).Single(); //.SingleOrDefault();
 3117:  
 3118:                     routerList.Add(router);
 3119:                 }
 3120:  
 3121:                 return routerList;
 3122:             }
 3123:         }
 3124:  
 3125:         ////////////////////////////////////////////////////////////////////////////
 3126:         ////////////////////////////////////////////////////////////////////////////
 3127:  
 3128:         /// <summary>
 3129:         ///
 3130:         /// </summary>
 3131:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList
 3132:         {
 3133:             get
 3134:             {
 3135:                 if (siteList == null || siteList.Count == 0)
 3136:                 {
 3137:                     lock (objectLock)
 3138:                     {
 3139:                         var networkId = 1; // <network id="1" name="Optical Fiber Network">
 3140:  
 3141:                         siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SiteList(networkId);
 3142:                     }
 3143:                 }
 3144:  
 3145:                 return siteList;
 3146:             }
 3147:         }
 3148:  
 3149:         ////////////////////////////////////////////////////////////////////////////
 3150:  
 3151:         /// <summary>
 3152:         ///
 3153:         /// </summary>
 3154:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> LegacySiteList
 3155:         {
 3156:             get
 3157:             {
 3158:                 if (legacySiteList == null || legacySiteList.Count == 0)
 3159:                 {
 3160:                     lock (objectLock)
 3161:                     {
 3162:                         var networkId = 2; // <network id="2" name="Legacy">
 3163:  
 3164:                         legacySiteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SiteList(networkId);
 3165:                     }
 3166:                 }
 3167:  
 3168:                 return legacySiteList;
 3169:             }
 3170:         }
 3171:  
 3172:         ////////////////////////////////////////////////////////////////////////////
 3173:  
 3174:         /// <summary>
 3175:         ///
 3176:         /// </summary>
 3177:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> _SiteList(int networkId)
 3178:         {
 3179:             int id;
 3180:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
 3181:  
 3182:             var siteList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
 3183:  
 3184:             var networkXElement = (from n in XDocument.Element("networkDesignDocument").Elements("network")
 3185:                                    where n.Attribute("id").Value == networkId.ToString()
 3186:                                    select n).Single();
 3187:  
 3188:             foreach (XElement x in networkXElement.Elements("site"))
 3189:             {
 3190:                 site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
 3191:                 networkId = int.Parse(x.Parent.Attribute("id").Value);
 3192:                 id = int.Parse(x.Attribute("id").Value);
 3193:  
 3194:                 site.Id = site.SiteId(networkId, id);
 3195:                 site.Name = x.Attribute("name").Value;
 3196:                 site.ArabicName = x.Attribute("arabicName").Value;
 3197:  
 3198:                 site.Network = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NetworkList
 3199:                                 where n.Id == networkId
 3200:                                 select n).Single();
 3201:  
 3202:                 siteList.Add(site);
 3203:             }
 3204:  
 3205:             return siteList;
 3206:         }
 3207:  
 3208:         ////////////////////////////////////////////////////////////////////////////
 3209:  
 3210:         /// <summary>
 3211:         ///
 3212:         /// </summary>
 3213:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site SiteFromName(string name)
 3214:         {
 3215:             var site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Name == name select s).Single();
 3216:  
 3217:             return site;
 3218:         }
 3219:  
 3220:         ////////////////////////////////////////////////////////////////////////////
 3221:         ////////////////////////////////////////////////////////////////////////////
 3222:  
 3223:         /// <summary>
 3224:         ///
 3225:         /// </summary>
 3226:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> NetworkList
 3227:         {
 3228:             get
 3229:             {
 3230:                 if (networkList == null || networkList.Count == 0)
 3231:                 {
 3232:                     lock (objectLock)
 3233:                     {
 3234:                         networkList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network>
 3235:                         {
 3236:                             new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network(1, "Optical Fiber Network"),
 3237:                             new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network(2, "Legacy")
 3238:                         };
 3239:                     }
 3240:                 }
 3241:  
 3242:                 return networkList;
 3243:             }
 3244:         }
 3245:  
 3246:         ////////////////////////////////////////////////////////////////////////////
 3247:         ////////////////////////////////////////////////////////////////////////////
 3248:  
 3249:         /// <summary>
 3250:         ///
 3251:         /// </summary>
 3252:         public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> VendorList
 3253:         {
 3254:             get
 3255:             {
 3256:                 if (vendorList == null || vendorList.Count == 0)
 3257:                 {
 3258:                     lock (objectLock)
 3259:                     {
 3260:                         vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>
 3261:                     {
 3262:                         new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(0, "Undefined", "Un", "غير معرف", @"~\image\undefined.png"),
 3263:                         new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(1, "Nokia", "No", "نوكيا", @"~\image\nokia-icon.png"),
 3264:                         new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(2, "Huawei", "Hu", "هواوي", @"~\image\huawei-icon.png"),
 3265:                         new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(3, "Ericsson", "Er", "إريكسون", @"~\image\ericsson-icon.png"),
 3266:                         new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(4, "Siemens", "Si", "سيمينس", @"~\image\siemens-icon.png")
 3267:                     };
 3268:                     }
 3269:                 }
 3270:  
 3271:                 return vendorList;
 3272:             }
 3273:         }
 3274:  
 3275:         ////////////////////////////////////////////////////////////////////////////
 3276:  
 3277:         /// <summary>
 3278:         ///
 3279:         /// </summary>
 3280:         public static string AmsNameFromOltId(int oltId)
 3281:         {
 3282:             var amsName = (from o in OltList
 3283:                            where o.Id == oltId
 3284:                            select o.AmsName).FirstOrDefault();
 3285:  
 3286:             return amsName;
 3287:         }
 3288:  
 3289:         ////////////////////////////////////////////////////////////////////////////
 3290:  
 3291:         /// <summary>
 3292:         ///
 3293:         /// </summary>
 3294:         public static string XDocument2()
 3295:         {
 3296:             return xDocument.ToString();
 3297:         }
 3298:  
 3299:         ////////////////////////////////////////////////////////////////////////////
 3300:         ////////////////////////////////////////////////////////////////////////////
 3301:  
 3302:         /// <summary>
 3303:         /// 
 3304:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 3305:         /// 
 3306:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 3307:         /// 2. Add "using System.Reflection".
 3308:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
 3309:         /// 
 3310:         /// </summary>
 3311:         private static XDocument XDocument
 3312:         {
 3313:             get
 3314:             {
 3315:                 if (xDocument == null)
 3316:                 {
 3317:                     lock (objectLock)
 3318:                     {
 3319:                         Assembly _assembly;
 3320:                         StreamReader streamReader;
 3321:  
 3322:                         _assembly = Assembly.GetExecutingAssembly();
 3323:                         streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.network-design-document.xml"));
 3324:  
 3325:                         try
 3326:                         {
 3327:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 3328:                         }
 3329:                         catch (Exception)
 3330:                         {
 3331:                         }
 3332:                         finally
 3333:                         {
 3334:                         }
 3335:                     }
 3336:                 }
 3337:  
 3338:                 return xDocument;
 3339:             }
 3340:         }
 3341:     }
 3342:  
 3343:     ////////////////////////////////////////////////////////////////////////////
 3344:     ////////////////////////////////////////////////////////////////////////////    
 3345: }