)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Service (Ia.Ftn.Cl.Models.Data)

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

Service support class for Fixed Telecommunications Network (FTN) data model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.IO;
    5: using System.Linq;
    6: using System.Reflection;
    7: using System.Xml.Linq;
    8: using System.Text.RegularExpressions;
    9: using Microsoft.EntityFrameworkCore;
   10:  
   11: namespace Ia.Ftn.Cl.Models.Data
   12: {
   13:     ////////////////////////////////////////////////////////////////////////////
   14:  
   15:     /// <summary publish="true">
   16:     /// Service support class for Fixed Telecommunications Network (FTN) data model.
   17:     /// </summary>
   18:     /// 
   19:     /// <remarks> 
   20:     /// Copyright © 2006-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   21:     /// </remarks> 
   22:     public class Service
   23:     {
   24:         private static XDocument xDocument;
   25:         private static List<int> nokiaSwitchNokiaAccessDomainList, huaweiSwitchNokiaAccessDomainList, huaweiAccessDomainList;
   26:         private static List<Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea> kuwaitFtnAreaList;
   27:         private static List<int> domainList, pstnDomainList, axePstnDomainList, ewsdPstnDomainList, migrationDomainList, nokiaSwitchDomainList, huaweiSwitchDomainList, msanDomainList, softxDomainList, spsDomainList;
   28:         private static List<int> legacyPstnDomainList, legacyAxePstnDomainList, legacyEwsdPstnDomainList, legacyMrdPstnDomainList;
   29:         private static List<Ia.Ftn.Cl.Models.Business.Service.ServiceType> serviceTypeList;
   30:         private static Dictionary<string, int> serviceIdToServiceRequestServicePositionDictionary;
   31:         private static List<int> serviceList = new List<int>();
   32:  
   33:         private static readonly object objectLock = new object();
   34:  
   35:         ////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public class ServiceAccessFnSnPnPort
   41:         {
   42:             public ServiceAccessFnSnPnPort()
   43:             {
   44:                 this.Service = string.Empty;
   45:                 this.ServiceId = string.Empty;
   46:                 this.AccessId = string.Empty;
   47:                 this.Fn = -1;
   48:                 this.Sn = -1;
   49:                 this.Pn = -1;
   50:                 this.Port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
   51:             }
   52:  
   53:             /// <summary/>
   54:             public string Service { get; set; }
   55:  
   56:             /// <summary/>
   57:             public string ServiceId { get; set; }
   58:  
   59:             /// <summary/>
   60:             public string AccessId { get; set; }
   61:  
   62:             /// <summary/>
   63:             public int Fn { get; set; }
   64:  
   65:             /// <summary/>
   66:             public int Sn { get; set; }
   67:  
   68:             /// <summary/>
   69:             public int Pn { get; set; }
   70:  
   71:             /// <summary/>
   72:             public int Port { get; set; }
   73:         }
   74:  
   75:         ////////////////////////////////////////////////////////////////////////////
   76:  
   77:         /// <summary>
   78:         ///
   79:         /// </summary>
   80:         public Service() { }
   81:  
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         ///
   86:         /// </summary>
   87:         public static Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor> ImsServiceToOntRouterVendorInAllowedToBeMigratedOltDictionary
   88:         {
   89:             get
   90:             {
   91:                 string service, accessId;
   92:                 Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor> dictionary;
   93:  
   94:                 var imsServiceToAccessIdInAllowedToBeMigratedOltDictionary = Ia.Ftn.Cl.Models.Data.Service2.ImsServiceToAccessIdInAllowedToBeMigratedOltDictionary;
   95:  
   96:                 var allowedToBeMigratedAccessIdToOntDictionary = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedAccessIdToOntDictionary;
   97:  
   98:                 dictionary = new Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor>();
   99:  
  100:                 foreach (KeyValuePair<string, string> kvp in imsServiceToAccessIdInAllowedToBeMigratedOltDictionary)
  101:                 {
  102:                     service = kvp.Key;
  103:                     accessId = kvp.Value;
  104:  
  105:                     if (allowedToBeMigratedAccessIdToOntDictionary.ContainsKey(accessId)) // I had to add this after adding 2467,2480 MSAN domains. I do not know why.
  106:                     {
  107:                         dictionary[service] = allowedToBeMigratedAccessIdToOntDictionary[accessId].Pon.PonGroup.Olt.Odf.Router.Vendor;
  108:                     }
  109:                 }
  110:  
  111:                 return dictionary;
  112:             }
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:  
  117:         /// <summary>
  118:         ///
  119:         /// </summary>
  120:         public static Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor> ImsServiceToOntAndMsanRouterVendorInAllowedToBeMigratedOltAndDomainDictionary
  121:         {
  122:             get
  123:             {
  124:                 string service, accessId;
  125:                 Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor> dictionary;
  126:  
  127:                 var imsServiceToAccessIdInAllowedToBeMigratedOltDictionary = Ia.Ftn.Cl.Models.Data.Service2.ImsServiceToAccessIdInAllowedToBeMigratedOltDictionary;
  128:  
  129:                 var allowedToBeMigratedAccessIdToOntDictionary = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedAccessIdToOntDictionary;
  130:  
  131:                 dictionary = new Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor>();
  132:  
  133:                 foreach (KeyValuePair<string, string> kvp in imsServiceToAccessIdInAllowedToBeMigratedOltDictionary)
  134:                 {
  135:                     service = kvp.Key;
  136:                     accessId = kvp.Value;
  137:  
  138:                     if (allowedToBeMigratedAccessIdToOntDictionary.ContainsKey(accessId)) // I had to add this after adding 2467,2480 MSAN domains. I do not know why.
  139:                     {
  140:                         dictionary[service] = allowedToBeMigratedAccessIdToOntDictionary[accessId].Pon.PonGroup.Olt.Odf.Router.Vendor;
  141:                     }
  142:                 }
  143:  
  144:  
  145:                 var msanServiceList = Ia.Ftn.Cl.Models.Data.Service2.MsanServiceInAllowedToBeMigratedDomainList;
  146:  
  147:                 foreach (var s in msanServiceList)
  148:                 {
  149:                     if (!dictionary.ContainsKey(s)) dictionary[s] = Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei; // all MSAN services are within Huawei routers
  150:                 }
  151:  
  152:                 return dictionary;
  153:             }
  154:         }
  155:  
  156:         ////////////////////////////////////////////////////////////////////////////
  157:  
  158:         /// <summary>
  159:         ///
  160:         /// </summary>
  161:         public static Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site> ImsServiceToOntAndMsanSiteInAllowedToBeMigratedOltAndDomainDictionary
  162:         {
  163:             get
  164:             {
  165:                 string service, accessId;
  166:                 Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site> dictionary;
  167:  
  168:                 var imsServiceToAccessIdInAllowedToBeMigratedOltDictionary = Ia.Ftn.Cl.Models.Data.Service2.ImsServiceToAccessIdInAllowedToBeMigratedOltDictionary;
  169:  
  170:                 var allowedToBeMigratedAccessIdToOntDictionary = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedAccessIdToOntDictionary;
  171:  
  172:                 dictionary = new Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site>();
  173:  
  174:                 foreach (KeyValuePair<string, string> kvp in imsServiceToAccessIdInAllowedToBeMigratedOltDictionary)
  175:                 {
  176:                     service = kvp.Key;
  177:                     accessId = kvp.Value;
  178:  
  179:                     if (allowedToBeMigratedAccessIdToOntDictionary.ContainsKey(accessId)) // I had to add this after adding 2467,2480 MSAN domains. I do not know why.
  180:                     {
  181:                         dictionary[service] = allowedToBeMigratedAccessIdToOntDictionary[accessId].Pon.PonGroup.Olt.Odf.Router.Site;
  182:                     }
  183:                 }
  184:  
  185:  
  186:                 var msanServiceToSiteInAllowedToBeMigratedDomainListDictionary = Ia.Ftn.Cl.Models.Data.Service2.MsanServiceToSiteInAllowedToBeMigratedDomainListDictionary;
  187:  
  188:                 foreach (var kvp in msanServiceToSiteInAllowedToBeMigratedDomainListDictionary)
  189:                 {
  190:                     service = kvp.Key;
  191:  
  192:                     if (!dictionary.ContainsKey(service))
  193:                     {
  194:                         dictionary[service] = msanServiceToSiteInAllowedToBeMigratedDomainListDictionary[service];
  195:                     }
  196:                 }
  197:  
  198:                 return dictionary;
  199:             }
  200:         }
  201:  
  202:         ////////////////////////////////////////////////////////////////////////////
  203:  
  204:         /// <summary>
  205:         ///
  206:         /// </summary>
  207:         public static Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site> ImsServiceToOntSiteInAllowedToBeMigratedOltDictionary
  208:         {
  209:             get
  210:             {
  211:                 string service, accessId;
  212:                 Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site> dictionary;
  213:  
  214:                 var imsServiceToAccessIdInAllowedToBeMigratedOltDictionary = Ia.Ftn.Cl.Models.Data.Service2.ImsServiceToAccessIdInAllowedToBeMigratedOltDictionary;
  215:  
  216:                 var allowedToBeMigratedAccessIdToOntDictionary = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedAccessIdToOntDictionary;
  217:  
  218:                 dictionary = new Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site>();
  219:  
  220:                 foreach (KeyValuePair<string, string> kvp in imsServiceToAccessIdInAllowedToBeMigratedOltDictionary)
  221:                 {
  222:                     service = kvp.Key;
  223:                     accessId = kvp.Value;
  224:  
  225:                     if (allowedToBeMigratedAccessIdToOntDictionary.ContainsKey(accessId)) // I had to add this after adding 2467,2480 MSAN domains. I do not know why.
  226:                     {
  227:                         dictionary[service] = allowedToBeMigratedAccessIdToOntDictionary[accessId].Pon.PonGroup.Olt.Odf.Router.Site;
  228:                     }
  229:                 }
  230:  
  231:                 return dictionary;
  232:             }
  233:         }
  234:  
  235:         ////////////////////////////////////////////////////////////////////////////
  236:  
  237:         /// <summary>
  238:         ///
  239:         /// </summary>
  240:         public static List<string> ServiceThatDoNotExistInServiceRequestServiceServiceIdList()
  241:         {
  242:             List<string> list;
  243:  
  244:             using (var db = new Ia.Ftn.Cl.Db())
  245:             {
  246:                 list = (from s in db.Service2
  247:                         join srs in db.ServiceRequestServices on s.Id equals srs.Id into gj
  248:                         from subsrs in gj.DefaultIfEmpty()
  249:                         where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService && subsrs.Id == null
  250:                         select s.Id).ToList();
  251:             }
  252:  
  253:             return list;
  254:         }
  255:  
  256:         ////////////////////////////////////////////////////////////////////////////
  257:  
  258:         /// <summary>
  259:         ///
  260:         /// </summary>
  261:         public static void DifferenceBetweenServiceAndServiceRequestOntDetailsOfTheCustomerDepartmentDatabase(out List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt> toInsertIntoCustomerDepartment, out List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt> toRemoveFromCustomerDepartment)
  262:         {
  263:             List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt> toRemoveBecauseServicePositionIsUndefinedList, toRemoveFromCustomerDepartmentBecauseDoesNotExistInService, toOverwriteByRemovingFirstInCustomerDepartment;
  264:             Dictionary<string, int> serviceIdToPositionDictionary;
  265:  
  266:             toRemoveBecauseServicePositionIsUndefinedList = new List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt>();
  267:  
  268:             serviceIdToPositionDictionary = Ia.Ftn.Cl.Models.Data.Service.ServiceIdToServiceRequestServicePositionDictionaryReloaded;
  269:  
  270:             using (var db = new Ia.Ftn.Cl.Db())
  271:             {
  272:                 // insert into db:
  273:                 /*
  274: select s.Id, s.Service, s.ServiceType, sro.Id from Service2 s
  275: inner join ServiceRequestOnts sro on s.Access_Id = sro.Access_Id
  276: left outer join ServiceRequestOntDetails srod on s.Service = srod.Service
  277: where s.ServiceType = 1 and srod.Id is null
  278: order by s.Service
  279: */
  280:                 var toInsertIntoCustomerDepartment0 = (from s in db.Service2
  281:                                                        join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
  282:                                                        join srod in db.ServiceRequestOntDetails on s.Service equals srod.Service
  283:                                                        into gj
  284:                                                        from srodgj in gj.DefaultIfEmpty()
  285:                                                        where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService && srodgj.Id == null //&& s.Access != null //&& sro.Access != null
  286:                                                        select new Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt()
  287:                                                        {
  288:                                                            ServiceId = s.Id,
  289:                                                            Service = s.Service,
  290:                                                            ServiceType = s.ServiceType,
  291:                                                            ServiceRequestOnt = sro
  292:                                                        }).Distinct().AsNoTracking().ToList();
  293:  
  294:                 foreach (var v in toInsertIntoCustomerDepartment0)
  295:                 {
  296:                     if (serviceIdToPositionDictionary.ContainsKey(v.ServiceId))
  297:                     {
  298:                         v.ServicePosition = serviceIdToPositionDictionary[v.ServiceId];
  299:                     }
  300:                     else toRemoveBecauseServicePositionIsUndefinedList.Add(v);
  301:                 }
  302:  
  303:                 // I will remove the following from list because the service position is not defined 
  304:                 foreach (var v in toRemoveBecauseServicePositionIsUndefinedList) toInsertIntoCustomerDepartment0.Remove(v);
  305:  
  306:                 toInsertIntoCustomerDepartment0 = toInsertIntoCustomerDepartment0.OrderBy(u => u.Service).ToList();
  307:  
  308:  
  309:                 // remove from db:
  310:  
  311:                 toOverwriteByRemovingFirstInCustomerDepartment = (from s in db.Service2
  312:                                                                   join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
  313:                                                                   join srod in db.ServiceRequestOntDetails on s.Service equals srod.Service
  314:                                                                   where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService
  315:                                                                   && srod.ServiceRequestOnt != null
  316:                                                                   && (srod.ServiceRequestOnt.Id != sro.Access.Id || srod.ServiceRequestOnt.Id == sro.Access.Id && (srod.Service != s.Service || srod.ServicePosition != s.Port))
  317:                                                                   select new Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt()
  318:                                                                   {
  319:                                                                       ServiceId = s.Id,
  320:                                                                       Service = s.Service,
  321:                                                                       ServiceType = s.ServiceType,
  322:                                                                       ServiceRequestOnt = srod.ServiceRequestOnt
  323:                                                                   }).Distinct().AsNoTracking().ToList();
  324:  
  325:                 toRemoveFromCustomerDepartmentBecauseDoesNotExistInService = (from srod in db.ServiceRequestOntDetails
  326:                                                                               join sro in db.ServiceRequestOnts on srod.ServiceRequestOnt.Id equals sro.Id
  327:                                                                               join s in db.Service2 on srod.Service equals s.Service
  328:                                                                               into gj
  329:                                                                               from subs in gj.DefaultIfEmpty()
  330:                                                                               where /*subs.ServiceType == Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService &&*/ subs.Id == null && sro.Access != null //&& srod.Service == "25488888"
  331:                                                                               select new Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt()
  332:                                                                               {
  333:                                                                                   Service = srod.Service,
  334:                                                                                   ServiceRequestOnt = sro
  335:                                                                               }).Distinct().AsNoTracking().ToList();
  336:  
  337:                 var toRemoveFromCustomerDepartment0 = toRemoveFromCustomerDepartmentBecauseDoesNotExistInService.Union(toOverwriteByRemovingFirstInCustomerDepartment).Distinct().ToList();
  338:  
  339:  
  340:                 toInsertIntoCustomerDepartment = new List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt>();
  341:                 toRemoveFromCustomerDepartment = new List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt>();
  342:  
  343:                 foreach (var v in toInsertIntoCustomerDepartment0)
  344:                 {
  345:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(v.Service))
  346:                     {
  347:                         toInsertIntoCustomerDepartment.Add(v);
  348:                     }
  349:                 }
  350:  
  351:                 foreach (var v in toRemoveFromCustomerDepartment0)
  352:                 {
  353:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(v.Service))
  354:                     {
  355:                         toRemoveFromCustomerDepartment.Add(v);
  356:                     }
  357:                 }
  358:             }
  359:         }
  360:  
  361:         ////////////////////////////////////////////////////////////////////////////
  362:  
  363:         /// <summary>
  364:         ///
  365:         /// </summary>
  366:         public static List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt> ServiceServiceRequestOntDetailWithMismatchedInformationInServiceRequestOntDetailList()
  367:         {
  368:             List<Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt> list;
  369:             Dictionary<string, int> serviceIdToPositionDictionary;
  370:  
  371:             serviceIdToPositionDictionary = Ia.Ftn.Cl.Models.Data.Service.ServiceIdToServiceRequestServicePositionDictionary;
  372:  
  373:             using (var db = new Ia.Ftn.Cl.Db())
  374:             {
  375:                 list = (from s in db.Service2
  376:                         join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
  377:                         join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id /*into gj
  378:                         from subsrod in gj.DefaultIfEmpty()*/
  379:                         where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService && /*subsrod.Id == null &&*/ s.Access != null && sro.Access != null
  380:                         select new Ia.Ftn.Cl.Models.Business.ServiceServiceRequestOnt()
  381:                         {
  382:                             ServiceId = s.Id,
  383:                             Service = s.Service,
  384:                             ServiceType = s.ServiceType,
  385:                             ServiceRequestOnt = sro
  386:                         }).ToList();
  387:  
  388:                 foreach (var v in list)
  389:                 {
  390:                     if (serviceIdToPositionDictionary.ContainsKey(v.ServiceId))
  391:                     {
  392:                         v.ServicePosition = serviceIdToPositionDictionary[v.ServiceId];
  393:                     }
  394:                 }
  395:             }
  396:  
  397:             return list.OrderBy(u => u.Service).ToList();
  398:         }
  399:  
  400:         ////////////////////////////////////////////////////////////////////////////
  401:  
  402:         /// <summary>
  403:         ///
  404:         /// </summary>
  405:         public static Dictionary<string, int> ServiceIdToServiceRequestServicePositionDictionary
  406:         {
  407:             get
  408:             {
  409:                 if (serviceIdToServiceRequestServicePositionDictionary == null || serviceIdToServiceRequestServicePositionDictionary.Count == 0)
  410:                 {
  411:                     lock (objectLock)
  412:                     {
  413:                         serviceIdToServiceRequestServicePositionDictionary = Ia.Ftn.Cl.Models.Data.Service._ServiceIdToServiceRequestServicePositionDictionary;
  414:                     }
  415:                 }
  416:  
  417:                 return serviceIdToServiceRequestServicePositionDictionary;
  418:             }
  419:         }
  420:  
  421:         ////////////////////////////////////////////////////////////////////////////
  422:  
  423:         /// <summary>
  424:         ///
  425:         /// </summary>
  426:         public static Dictionary<string, int> ServiceIdToServiceRequestServicePositionDictionaryReloaded
  427:         {
  428:             get
  429:             {
  430:                 if (serviceIdToServiceRequestServicePositionDictionary != null) serviceIdToServiceRequestServicePositionDictionary.Clear();
  431:  
  432:                 return ServiceIdToServiceRequestServicePositionDictionary;
  433:             }
  434:         }
  435:  
  436:         ////////////////////////////////////////////////////////////////////////////
  437:  
  438:         /// <summary>
  439:         ///
  440:         /// </summary>
  441:         private static Dictionary<string, int> _ServiceIdToServiceRequestServicePositionDictionary
  442:         {
  443:             get
  444:             {
  445:                 var list = new HashSet<ServiceAccessFnSnPnPort>();
  446:  
  447:                 var serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  448:  
  449:                 using (var db = new Ia.Ftn.Cl.Db())
  450:                 {
  451:                     // No-No non-SIP SFU/MDU
  452:                     var list1 = (from a in db.Accesses
  453:                                  join o in db.Onts on a.Id equals o.Access.Id
  454:                                  join osv in db.OntServiceVoips on o.Id equals osv.Ont.Id
  455:                                  join gr in db.AgcfGatewayRecords on osv.Ip equals gr.IP1
  456:                                  join ep in db.AgcfEndpoints on gr.Id equals ep.AgcfGatewayRecord.Id
  457:                                  select new ServiceAccessFnSnPnPort
  458:                                  {
  459:                                      Service = ep.PrividUser,
  460:                                      AccessId = a.Id,
  461:                                      Port = ep.FlatTermID
  462:                                  }).AsNoTracking().ToHashSet<ServiceAccessFnSnPnPort>();
  463:  
  464:                     // No-Hu or Hu-Hu SIP SFU
  465:                     var list2 = (from a in db.Accesses
  466:                                  join eo in db.EmsOnts on a.Id equals eo.Access.Id
  467:                                  join eosi in db.EmsOntSipInfoes on eo.Id equals eosi.EmsOnt.Id
  468:                                  select new ServiceAccessFnSnPnPort
  469:                                  {
  470:                                      Service = eosi.SIPUSERNAME,
  471:                                      AccessId = a.Id,
  472:                                      Port = eosi.TEL
  473:                                  }).AsNoTracking().ToHashSet<ServiceAccessFnSnPnPort>();
  474:  
  475:                     //  No-Hu or Hu-Hu SIP MDU
  476:                     var list3 = (from a in db.Accesses
  477:                                  join eo in db.EmsOnts on a.Id equals eo.Access.Id
  478:                                  join evpu in db.EmsVoipPstnUsers on eo.Id equals evpu.EmsOnt.Id
  479:                                  select new ServiceAccessFnSnPnPort
  480:                                  {
  481:                                      Service = evpu.DN,
  482:                                      AccessId = a.Id,
  483:                                      Fn = evpu.FN,
  484:                                      Sn = evpu.SN,
  485:                                      Pn = evpu.PN,
  486:                                      Port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown,
  487:                                  }).AsNoTracking().ToHashSet<ServiceAccessFnSnPnPort>();
  488:  
  489:                     // Hu-No non-SIP SFU/MDU
  490:                     var list4 = (from a in db.Accesses
  491:                                  join o in db.Onts on a.Id equals o.Access.Id
  492:                                  join osv in db.OntServiceVoips on o.Id equals osv.Ont.Id
  493:                                  join m in db.Mgws on osv.Ip equals m.RA1
  494:                                  join asb in db.Asbrs on m.Id equals asb.Mgw.Id
  495:                                  select new ServiceAccessFnSnPnPort
  496:                                  {
  497:                                      Service = asb.PUI,
  498:                                      AccessId = a.Id,
  499:                                      Port = int.Parse(asb.TID)
  500:                                  }).AsNoTracking().ToHashSet<ServiceAccessFnSnPnPort>();
  501:  
  502:                     var list0 = list1.Union(list2).Union(list3).Union(list4).ToHashSet();
  503:  
  504:                     string id;
  505:                     var hashSet = new HashSet<string>();
  506:  
  507:                     foreach (var l in list0)
  508:                     {
  509:                         // debug
  510:                         //if (l.Service.Contains("25413662"))
  511:                         //{
  512:                         //}
  513:  
  514:                         l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Service);
  515:  
  516:                         l.ServiceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(l.Service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
  517:  
  518:                         if (l.Port == Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  519:                         {
  520:                             l.Port = Ia.Ftn.Cl.Models.Data.Huawei.Default.MduDevPortByAccessIdFnSnPn(l.AccessId, l.Fn, l.Sn, l.Pn);
  521:                         }
  522:  
  523:                         id = l.AccessId + ":" + l.Service + ":" + l.ServiceId + ":" + l.Fn + ":" + l.Sn + ":" + l.Pn + ":" + l.Port;
  524:  
  525:                         if (hashSet.Contains(id))
  526:                         {
  527:  
  528:                         }
  529:                         else
  530:                         {
  531:                             list.Add(l);
  532:  
  533:                             hashSet.Add(id);
  534:                         }
  535:                     }
  536:  
  537:                     /*
  538:                     var d = new Dictionary<string, ServiceAccessFnSnPnPort>();
  539: 
  540:                     var uuu = (from i in list1 where i.Service == "24901414" select i).ToList();
  541: 
  542:                     var y = list1.Distinct().ToList();
  543: 
  544:                     foreach (var l in list1)
  545:                     {
  546:                         if (d.ContainsKey(l.Service))
  547:                         {
  548: 
  549:                         }
  550:                         else d[l.Service] = l;
  551:                     }
  552: 
  553:                     var l0 = list1.OrderBy(u => u.Service).ToHashSet();
  554:                     var l01 = list1.Distinct().ToHashSet();
  555:                     var l1 = list1.Select(u => u.Service).Intersect(list1.Select(u => u.Service)).ToHashSet();
  556:                     var l2 = list1.Select(u => u.Service).Intersect(list2.Select(u => u.Service)).ToHashSet();
  557:                     var l3 = list1.Select(u => u.Service).Intersect(list3.Select(u => u.Service)).ToHashSet();
  558:                     var l4 = list1.Select(u => u.Service).Intersect(list4.Select(u => u.Service)).ToHashSet();
  559: 
  560:                     var l5 = list2.Select(u => u.Service).Intersect(list2.Select(u => u.Service)).ToHashSet();
  561:                     var l6 = list2.Select(u => u.Service).Intersect(list3.Select(u => u.Service)).ToHashSet();
  562:                     var l7 = list2.Select(u => u.Service).Intersect(list4.Select(u => u.Service)).ToHashSet();
  563: 
  564:                     var l8 = list3.Select(u => u.Service).Intersect(list3.Select(u => u.Service)).ToHashSet();
  565:                     var l9 = list3.Select(u => u.Service).Intersect(list4.Select(u => u.Service)).ToHashSet();
  566: 
  567:                     var l10 = list4.Select(u => u.Service).Intersect(list4.Select(u => u.Service)).ToHashSet();
  568:                     */
  569:  
  570:  
  571:                 }
  572:  
  573:                 var dictionary = new Dictionary<string, int>(list.Count);
  574:  
  575:                 foreach (var l in list)
  576:                 {
  577:                     if (dictionary.ContainsKey(l.ServiceId))
  578:                     {
  579:                         // debug
  580:                     }
  581:  
  582:                     if (l.Port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown && l.Port != 0)
  583:                     {
  584:                         dictionary[l.ServiceId] = l.Port;
  585:                     }
  586:                 }
  587:  
  588:                 return dictionary;
  589:             }
  590:         }
  591:  
  592:         /*
  593:         ////////////////////////////////////////////////////////////////////////////
  594: 
  595:         /// <summary>
  596:         ///
  597:         /// </summary>
  598:         private static Dictionary<string, int> _ServiceIdToServiceRequestServicePositionDictionaryOld
  599:         {
  600:             get
  601:             {
  602:                 string key;
  603:                 Dictionary<string, int> dictionary;
  604: 
  605:                 var nokiaToNokiaDictionary = new Dictionary<string, int>();
  606:                 var nokiaToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
  607:                 var nokiaToHuaweiEmsVoipPstnUsersDictionary = new Dictionary<string, int>();
  608:                 var huaweiToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
  609:                 var huaweiToHuaweiEmsVoipPstnUsersDictionary = new Dictionary<string, int>();
  610:                 var huaweiToNokiaAsbrsDictionary = new Dictionary<string, int>();
  611: 
  612: #if DEBUG
  613:                 var dummyVarToDrawRefractorToBelow = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service("0000000");
  614: #endif
  615: 
  616:                 using (var db = new Ia.Ftn.Cl.Model.Ftn())
  617:                 {
  618:                     // No-No
  619:                     nokiaToNokiaDictionary = (from s in db.Subscribers
  620:                                               join sp in db.SubParties on s.SubParty.Id equals sp.Id
  621:                                               join ep in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals ep.Id
  622:                                               select new { s.Id, ep.FlatTermID }).Distinct().AsNoTracking().ToDictionary(u => u.Id, u => u.FlatTermID);
  623: 
  624: 
  625:                     // No-Hu ONT with EmsOntSipInfo
  626:                     // select * from Subscribers as s inner join EmsOntSipInfoes as eosi on s.PartyId = eosi.SIPUSERNAME 
  627:                     var list = (from s in db.Subscribers
  628:                                 join eosi in db.EmsOntSipInfoes on s.PartyId equals eosi.SIPUSERNAME
  629:                                 select new { s.Id, eosi.TEL }).AsNoTracking().ToList();
  630: 
  631:                     foreach (var l in list)
  632:                     {
  633:                         if (!nokiaToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.Id))
  634:                         {
  635:                             nokiaToHuaweiEmsOntSipInfoesDictionary[l.Id] = l.TEL;
  636:                         }
  637:                     }
  638: 
  639: 
  640: 
  641:                     // No-Hu MDU with EmsVoipPstnUser
  642:                     // select s.Id, evpu.PN from Subscribers as s inner join EmsVoipPstnUsers as evpu on s.PartyId = '+' + evpu.DN
  643:                     var list2 = (from s in db.Subscribers
  644:                                  join evpu in db.EmsVoipPstnUsers on s.PartyId equals "+" + evpu.DN // see: Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
  645:                                  where evpu.EmsOnt != null && evpu.EmsOnt.Access != null
  646:                                  select new { s.Id, AccessId = evpu.EmsOnt.Access.Id, evpu.FN, evpu.SN, evpu.PN }).AsNoTracking().ToList();
  647: 
  648:                     foreach (var l in list2)
  649:                     {
  650:                         if (!nokiaToHuaweiEmsVoipPstnUsersDictionary.ContainsKey(l.Id))
  651:                         {
  652:                             nokiaToHuaweiEmsVoipPstnUsersDictionary[l.Id] = l.PN;
  653:                         }
  654:                     }
  655: 
  656: 
  657: 
  658:                     // Hu-Hu ONT with EmsOntSipInfo
  659:                     // I will use SIPUSERNAME because looks similar for Nokia and Huawei switches, but SIPNAME sometimes like +96525422460@ims.moc.kw and like priv_96524602282
  660:                     // select s.IMPU, eosi.SIPUSERNAME, eosi.TEL from Sbrs as s inner join EmsOntSipInfoes as eosi on s.IMPU = 'sip:' + eosi.SIPNAME
  661:                     var list3 = (from s in db.Sbrs
  662:                                  join eosi in db.EmsOntSipInfoes on s.IMPU equals "sip:" + eosi.SIPNAME  // see: Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain()
  663:                                  select new { s.IMPU, eosi.TEL }).AsNoTracking().ToList();
  664: 
  665:                     foreach (var l in list3)
  666:                     {
  667:                         if (!huaweiToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.IMPU))
  668:                         {
  669:                             huaweiToHuaweiEmsOntSipInfoesDictionary[l.IMPU] = l.TEL;
  670:                         }
  671:                     }
  672: 
  673: 
  674:                     // Hu-Hu MDU with EmsVoipPstnUser
  675:                     // select * from Sbrs s inner join EmsVoipPstnUsers evpu on s.IMPU = 'sip:+' + evpu.DN + '@ims.moc.kw'
  676:                     huaweiToHuaweiEmsVoipPstnUsersDictionary = (from s in db.Sbrs
  677:                                                                 join evpu in db.EmsVoipPstnUsers on s.IMPU equals "sip:+" + evpu.DN + "@ims.moc.kw" // see: Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
  678:                                                                 where evpu.EmsOnt != null && evpu.EmsOnt.Access != null
  679:                                                                 select new { s.IMPU, AccessId = evpu.EmsOnt.Access.Id, evpu.FN, evpu.SN, evpu.PN }).Distinct().AsNoTracking().ToDictionary(u => u.IMPU, u => u.PN);
  680: 
  681: 
  682:                     // Hu-No non-SIP SFU/MDU
  683:                     var list5 = (from s in db.Sbrs
  684:                                  join a in db.Asbrs on s.IMPU equals a.PUI
  685:                                  select new { s.IMPU, TID = int.Parse(a.TID) }).AsNoTracking().ToList();
  686: 
  687:                     foreach (var l in list5)
  688:                     {
  689:                         if (!huaweiToNokiaAsbrsDictionary.ContainsKey(l.IMPU))
  690:                         {
  691:                             huaweiToNokiaAsbrsDictionary[l.IMPU] = l.TID;
  692:                         }
  693:                     }
  694: 
  695:                     dictionary = new Dictionary<string, int>(nokiaToNokiaDictionary.Count + nokiaToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsVoipPstnUsersDictionary.Count);
  696: 
  697: 
  698:                     foreach (KeyValuePair<string, int> kvp in nokiaToNokiaDictionary)
  699:                     {
  700:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  701:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  702:                         dictionary[key] = kvp.Value;
  703:                     }
  704: 
  705:                     foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsOntSipInfoesDictionary)
  706:                     {
  707:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  708:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  709:                         dictionary[key] = kvp.Value;
  710:                     }
  711: 
  712:                     foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsVoipPstnUsersDictionary)
  713:                     {
  714:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  715:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  716:                         dictionary[key] = Ia.Ftn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value);
  717:                     }
  718: 
  719:                     foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsOntSipInfoesDictionary)
  720:                     {
  721:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  722:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  723:                         dictionary[key] = kvp.Value;
  724:                     }
  725: 
  726:                     foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsVoipPstnUsersDictionary)
  727:                     {
  728:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  729:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  730:                         dictionary[key] = Ia.Ftn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value);
  731:                     }
  732: 
  733:                     foreach (KeyValuePair<string, int> kvp in huaweiToNokiaAsbrsDictionary)
  734:                     {
  735:                         key = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
  736:                         key = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(key, Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService);
  737:                         dictionary[key] = kvp.Value;
  738:                     }
  739:                 }
  740: 
  741:                 return dictionary;
  742:             }
  743:         }
  744:         */
  745:  
  746:         ////////////////////////////////////////////////////////////////////////////
  747:  
  748:         /// <summary>
  749:         ///
  750:         /// </summary>
  751:         public static void AccessIdAndPortByService(string service, out string accessId, out int port)
  752:         {
  753:             // see Ia.Ftn.Cl.Model.Data.Service._ServiceIdToPositionDictionary;
  754:  
  755:             var serviceAccessFnSnPnPort = new ServiceAccessFnSnPnPort();
  756:  
  757:             if (!string.IsNullOrEmpty(service))
  758:             {
  759:                 var serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  760:                 var serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  761:  
  762:                 var router = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterFromService(service);
  763:  
  764:                 if (router != null)
  765:                 {
  766:                     if (router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia || router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei)
  767:                     {
  768:                         using (var db = new Ia.Ftn.Cl.Db())
  769:                         {
  770:                             if (router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  771:                             {
  772:                                 var prividUser = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.PrividUser(service);
  773:  
  774:                                 // attempt to find access of No-No non-SIP SFU/MDU
  775:                                 serviceAccessFnSnPnPort = (from a in db.Accesses
  776:                                                            join o in db.Onts on a.Id equals o.Access.Id
  777:                                                            join osv in db.OntServiceVoips on o.Id equals osv.Ont.Id
  778:                                                            join gr in db.AgcfGatewayRecords on osv.Ip equals gr.IP1
  779:                                                            join ep in db.AgcfEndpoints on gr.Id equals ep.AgcfGatewayRecord.Id
  780:                                                            where ep.PrividUser == prividUser
  781:                                                            select new ServiceAccessFnSnPnPort { AccessId = a.Id, Port = ep.FlatTermID }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  782:  
  783:                                 if (serviceAccessFnSnPnPort == null)
  784:                                 {
  785:                                     var impi = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Impi(service);
  786:                                     var impuAid = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuAid(service);
  787:  
  788:                                     // attempt to find access of No-Hu or Hu-Hu SIP SFU
  789:                                     serviceAccessFnSnPnPort = (from a in db.Accesses
  790:                                                                join eo in db.EmsOnts on a.Id equals eo.Access.Id
  791:                                                                join eosi in db.EmsOntSipInfoes on eo.Id equals eosi.EmsOnt.Id
  792:                                                                where eosi.SIPNAME == impi || eosi.SIPUSERNAME == impuAid
  793:                                                                orderby eo.ResultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.Succeeded descending, eosi.Created descending
  794:                                                                select new ServiceAccessFnSnPnPort
  795:                                                                {
  796:                                                                    AccessId = a.Id,
  797:                                                                    Port = eosi.TEL
  798:                                                                }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  799:  
  800:                                     if (serviceAccessFnSnPnPort == null)
  801:                                     {
  802:                                         var dn = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ServiceWithCountryCode(service);
  803:  
  804:                                         // attempt to find access of No-Hu or Hu-Hu SIP MDU
  805:                                         serviceAccessFnSnPnPort = (from a in db.Accesses
  806:                                                                    join eo in db.EmsOnts on a.Id equals eo.Access.Id
  807:                                                                    join evpu in db.EmsVoipPstnUsers on eo.Id equals evpu.EmsOnt.Id
  808:                                                                    join ed in db.EmsDevs on evpu.DID equals ed.DID
  809:                                                                    where evpu.EmsOnt != null && evpu.DN == dn
  810:                                                                    orderby ed.ResultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.Succeeded descending, evpu.Created descending
  811:                                                                    select new ServiceAccessFnSnPnPort
  812:                                                                    {
  813:                                                                        AccessId = a.Id,
  814:                                                                        Fn = evpu.FN,
  815:                                                                        Sn = evpu.SN,
  816:                                                                        Pn = evpu.PN,
  817:                                                                    }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  818:  
  819:                                         if (serviceAccessFnSnPnPort == null)
  820:                                         {
  821:  
  822:                                         }
  823:                                         else serviceAccessFnSnPnPort.Port = Ia.Ftn.Cl.Models.Data.Huawei.Default.MduDevPortByAccessIdFnSnPn(serviceAccessFnSnPnPort.AccessId, serviceAccessFnSnPnPort.Fn, serviceAccessFnSnPnPort.Sn, serviceAccessFnSnPnPort.Pn);
  824:                                     }
  825:                                     else
  826:                                     {
  827:  
  828:                                     }
  829:                                 }
  830:                                 else
  831:                                 {
  832:  
  833:                                 }
  834:                             }
  835:                             else //if(router.Vendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  836:                             {
  837:                                 var impi = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Impi(service);
  838:                                 var impuAid = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuAid(service);
  839:  
  840:                                 // attempt to find access of No-Hu or Hu-Hu SIP SFU
  841:                                 serviceAccessFnSnPnPort = (from a in db.Accesses
  842:                                                            join eo in db.EmsOnts on a.Id equals eo.Access.Id
  843:                                                            join eosi in db.EmsOntSipInfoes on eo.Id equals eosi.EmsOnt.Id
  844:                                                            where eosi.SIPNAME == impi || eosi.SIPUSERNAME == impuAid
  845:                                                            orderby eo.ResultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.Succeeded descending, eosi.Created descending
  846:                                                            select new ServiceAccessFnSnPnPort
  847:                                                            {
  848:                                                                AccessId = a.Id,
  849:                                                                Port = eosi.TEL
  850:                                                            }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  851:  
  852:                                 if (serviceAccessFnSnPnPort == null)
  853:                                 {
  854:                                     var dn = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ServiceWithCountryCode(service);
  855:  
  856:                                     // attempt to find access of No-Hu or Hu-Hu SIP MDU
  857:                                     serviceAccessFnSnPnPort = (from a in db.Accesses
  858:                                                                join eo in db.EmsOnts on a.Id equals eo.Access.Id
  859:                                                                join evpu in db.EmsVoipPstnUsers on eo.Id equals evpu.EmsOnt.Id
  860:                                                                join ed in db.EmsDevs on evpu.DID equals ed.DID
  861:                                                                where evpu.EmsOnt != null && evpu.DN == dn
  862:                                                                orderby ed.ResultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.Succeeded descending, evpu.Created descending
  863:                                                                select new ServiceAccessFnSnPnPort
  864:                                                                {
  865:                                                                    AccessId = a.Id,
  866:                                                                    Fn = evpu.FN,
  867:                                                                    Sn = evpu.SN,
  868:                                                                    Pn = evpu.PN,
  869:                                                                }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  870:  
  871:                                     if (serviceAccessFnSnPnPort == null)
  872:                                     {
  873:                                         var pui = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuSipDomain(service);
  874:  
  875:                                         // attempt to find access of Hu-No non-SIP SFU/MDU
  876:                                         serviceAccessFnSnPnPort = (from a in db.Accesses
  877:                                                                    join o in db.Onts on a.Id equals o.Access.Id
  878:                                                                    join osv in db.OntServiceVoips on o.Id equals osv.Ont.Id
  879:                                                                    join m in db.Mgws on osv.Ip equals m.RA1
  880:                                                                    join asb in db.Asbrs on m.Id equals asb.Mgw.Id
  881:                                                                    where asb.PUI == pui
  882:                                                                    select new ServiceAccessFnSnPnPort
  883:                                                                    {
  884:                                                                        AccessId = a.Id,
  885:                                                                        Port = int.Parse(asb.TID)
  886:                                                                    }).AsNoTracking().FirstOrDefault(); //.SingleOrDefault();
  887:                                     }
  888:                                     else serviceAccessFnSnPnPort.Port = Ia.Ftn.Cl.Models.Data.Huawei.Default.MduDevPortByAccessIdFnSnPn(serviceAccessFnSnPnPort.AccessId, serviceAccessFnSnPnPort.Fn, serviceAccessFnSnPnPort.Sn, serviceAccessFnSnPnPort.Pn);
  889:                                 }
  890:                                 else
  891:                                 {
  892:  
  893:                                 }
  894:                             }
  895:                         }
  896:                     }
  897:                     else
  898:                     {
  899:  
  900:                     }
  901:                 }
  902:                 else
  903:                 {
  904:  
  905:                 }
  906:             }
  907:             else
  908:             {
  909:  
  910:             }
  911:  
  912:             if (serviceAccessFnSnPnPort != null)
  913:             {
  914:                 accessId = serviceAccessFnSnPnPort.AccessId;
  915:                 port = serviceAccessFnSnPnPort.Port;
  916:             }
  917:             else
  918:             {
  919:                 accessId = string.Empty;
  920:                 port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
  921:             }
  922:         }
  923:  
  924:         ////////////////////////////////////////////////////////////////////////////
  925:         ////////////////////////////////////////////////////////////////////////////
  926:  
  927:         /// <summary>
  928:         ///
  929:         /// </summary>
  930:         public static List<Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea> KuwaitFtnAreaList
  931:         {
  932:             get
  933:             {
  934:                 if (kuwaitFtnAreaList == null || kuwaitFtnAreaList.Count == 0)
  935:                 {
  936:                     lock (objectLock)
  937:                     {
  938:                         kuwaitFtnAreaList = Ia.Ftn.Cl.Models.Data.Service._KuwaitFtnAreaList;
  939:                     }
  940:                 }
  941:  
  942:                 return kuwaitFtnAreaList;
  943:             }
  944:         }
  945:  
  946:         ////////////////////////////////////////////////////////////////////////////
  947:  
  948:         /// <summary>
  949:         ///
  950:         /// </summary>
  951:         private static List<Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea> _KuwaitFtnAreaList
  952:         {
  953:             get
  954:             {
  955:                 int id;
  956:                 string symbol;
  957:                 Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea kuwaitFtnArea;
  958:  
  959:                 kuwaitFtnAreaList = new List<Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea>();
  960:  
  961:                 foreach (XElement xe in XDocument.Element("service").Elements("areaList").Elements("area"))
  962:                 {
  963:                     kuwaitFtnArea = new Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea();
  964:  
  965:                     id = int.Parse(xe.Attribute("id").Value);
  966:                     kuwaitFtnArea.Id = id;
  967:  
  968:                     symbol = xe.Attribute("symbol").Value;
  969:                     kuwaitFtnArea.Symbol = symbol;
  970:  
  971:                     kuwaitFtnArea.ServiceRequestAddressProvinceAreaName = xe.Attribute("serviceRequestAddressProvinceAreaName").Value;
  972:  
  973:                     kuwaitFtnArea.Name = (from ka in Ia.Cl.Models.Kuwait.KuwaitAreaList where ka.Id == id select ka.Name).SingleOrDefault();
  974:                     kuwaitFtnArea.ArabicName = (from ka in Ia.Cl.Models.Kuwait.KuwaitAreaList where ka.Id == id select ka.ArabicName).SingleOrDefault();
  975:  
  976:                     kuwaitFtnArea.SiteList = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList where s.AreaSymbolList.Contains(symbol) select s).ToList();
  977:  
  978:                     if (kuwaitFtnArea.SiteList != null) kuwaitFtnAreaList.Add(kuwaitFtnArea);
  979:                 }
  980:  
  981:                 return kuwaitFtnAreaList;
  982:             }
  983:         }
  984:  
  985:         ////////////////////////////////////////////////////////////////////////////
  986:  
  987:         /// <summary>
  988:         ///
  989:         /// </summary>
  990:         public static Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea KuwaitFtnAreaById(int id)
  991:         {
  992:             Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea kuwaitFtnArea;
  993:  
  994:             if (id > 0)
  995:             {
  996:                 kuwaitFtnArea = (from kna in Ia.Ftn.Cl.Models.Data.Service.KuwaitFtnAreaList
  997:                                  where kna.Id == id
  998:                                  select kna).SingleOrDefault();
  999:             }
 1000:             else kuwaitFtnArea = null;
 1001:  
 1002:             return kuwaitFtnArea;
 1003:         }
 1004:  
 1005:         ////////////////////////////////////////////////////////////////////////////
 1006:  
 1007:         /// <summary>
 1008:         ///
 1009:         /// </summary>
 1010:         public static Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea KuwaitFtnAreaBySymbol(string symbol)
 1011:         {
 1012:             Ia.Ftn.Cl.Models.Business.Service.KuwaitFtnArea kuwaitFtnArea;
 1013:  
 1014:             if (!string.IsNullOrEmpty(symbol))
 1015:             {
 1016:                 kuwaitFtnArea = (from kna in Ia.Ftn.Cl.Models.Data.Service.KuwaitFtnAreaList
 1017:                                  where kna.Symbol == symbol
 1018:                                  select kna).SingleOrDefault();
 1019:             }
 1020:             else kuwaitFtnArea = null;
 1021:  
 1022:             return kuwaitFtnArea;
 1023:         }
 1024:  
 1025:         ////////////////////////////////////////////////////////////////////////////
 1026:  
 1027:         /// <summary>
 1028:         ///
 1029:         /// </summary>
 1030:         public static Dictionary<int, string> AreaIdToSymbolDictionary
 1031:         {
 1032:             get
 1033:             {
 1034:                 Dictionary<int, string> dictionary;
 1035:  
 1036:                 dictionary = (from kna in Ia.Ftn.Cl.Models.Data.Service.KuwaitFtnAreaList
 1037:                               select new { kna.Id, kna.Symbol }).ToDictionary(u => u.Id, u => u.Symbol);
 1038:  
 1039:                 return dictionary;
 1040:             }
 1041:         }
 1042:  
 1043:         ////////////////////////////////////////////////////////////////////////////
 1044:  
 1045:         /// <summary>
 1046:         ///
 1047:         /// </summary>
 1048:         public static Dictionary<int, string> AreaIdToNameArabicNameDictionary
 1049:         {
 1050:             get
 1051:             {
 1052:                 Dictionary<int, string> dictionary;
 1053:  
 1054:                 dictionary = (from kna in Ia.Ftn.Cl.Models.Data.Service.KuwaitFtnAreaList
 1055:                               select new { kna.Id, kna.NameArabicName }).ToDictionary(u => u.Id, u => u.NameArabicName);
 1056:  
 1057:                 return dictionary;
 1058:             }
 1059:         }
 1060:  
 1061:         ////////////////////////////////////////////////////////////////////////////
 1062:  
 1063:         /// <summary>
 1064:         ///
 1065:         /// </summary>
 1066:         public static Dictionary<int, int> AreaIdToSiteIdDictionary
 1067:         {
 1068:             get
 1069:             {
 1070:                 Dictionary<int, int> dictionary;
 1071:  
 1072:                 dictionary = (from kna in Ia.Ftn.Cl.Models.Data.Service.KuwaitFtnAreaList
 1073:                               where kna.SiteList.Count > 0
 1074:                               select new { kna.Id, SiteId = kna.SiteList.FirstOrDefault().Id }).ToDictionary(u => u.Id, u => u.SiteId);
 1075:  
 1076:                 return dictionary;
 1077:             }
 1078:         }
 1079:  
 1080:         ////////////////////////////////////////////////////////////////////////////
 1081:         ////////////////////////////////////////////////////////////////////////////
 1082:  
 1083:         /// <summary>
 1084:         ///
 1085:         /// </summary>
 1086:         public static List<int> DomainList
 1087:         {
 1088:             get
 1089:             {
 1090:                 if (domainList == null || domainList.Count == 0)
 1091:                 {
 1092:                     lock (objectLock)
 1093:                     {
 1094:                         domainList = Ia.Ftn.Cl.Models.Data.Service._DomainList;
 1095:                     }
 1096:                 }
 1097:  
 1098:                 return domainList;
 1099:             }
 1100:         }
 1101:  
 1102:         ////////////////////////////////////////////////////////////////////////////
 1103:  
 1104:         /// <summary>
 1105:         ///
 1106:         /// </summary>
 1107:         private static List<int> _DomainList
 1108:         {
 1109:             get
 1110:             {
 1111:                 var routerList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList;
 1112:  
 1113:                 var list = (from r in routerList select r).SelectMany(r => r.DomainList).ToList();
 1114:  
 1115:                 if (list.Distinct().Count() != list.Count())
 1116:                 {
 1117:                     throw new Exception("domainList has duplicate entries");
 1118:                 }
 1119:  
 1120:                 list.Sort();
 1121:  
 1122:                 return list;
 1123:             }
 1124:         }
 1125:  
 1126:         ////////////////////////////////////////////////////////////////////////////
 1127:         ////////////////////////////////////////////////////////////////////////////
 1128:  
 1129:         /// <summary>
 1130:         ///
 1131:         /// </summary>
 1132:         public static List<int> PstnDomainList
 1133:         {
 1134:             get
 1135:             {
 1136:                 if (pstnDomainList == null || pstnDomainList.Count == 0)
 1137:                 {
 1138:                     lock (objectLock)
 1139:                     {
 1140:                         pstnDomainList = Ia.Ftn.Cl.Models.Data.Service._PstnDomainList;
 1141:                     }
 1142:                 }
 1143:  
 1144:                 return pstnDomainList;
 1145:             }
 1146:         }
 1147:  
 1148:         ////////////////////////////////////////////////////////////////////////////
 1149:  
 1150:         /// <summary>
 1151:         ///
 1152:         /// </summary>
 1153:         private static List<int> _PstnDomainList
 1154:         {
 1155:             get
 1156:             {
 1157:                 pstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 1158:                                   select p).SelectMany(r => r.DomainList).ToList();
 1159:  
 1160:                 if (pstnDomainList.Distinct().Count() != pstnDomainList.Count())
 1161:                 {
 1162:                     throw new Exception("pstnDomainList has duplicate entries");
 1163:                 }
 1164:  
 1165:                 pstnDomainList.Sort();
 1166:  
 1167:                 return pstnDomainList;
 1168:             }
 1169:         }
 1170:  
 1171:         ////////////////////////////////////////////////////////////////////////////
 1172:  
 1173:         /// <summary>
 1174:         ///
 1175:         /// </summary>
 1176:         public static List<int> PstnThatUsesNpServerDomainList
 1177:         {
 1178:             get
 1179:             {
 1180:                 var list = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 1181:                             where p.UsesNpServer == true
 1182:                             select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1183:  
 1184:                 list.Sort();
 1185:  
 1186:                 return list;
 1187:             }
 1188:         }
 1189:  
 1190:         ////////////////////////////////////////////////////////////////////////////
 1191:  
 1192:         /// <summary>
 1193:         ///
 1194:         /// </summary>
 1195:         public static List<int> PstnAndMsanDomainList
 1196:         {
 1197:             get
 1198:             {
 1199:                 var list = Ia.Ftn.Cl.Models.Data.Service.PstnDomainList.Intersect(Ia.Ftn.Cl.Models.Data.Service.MsanDomainList).ToList();
 1200:  
 1201:                 list.Sort();
 1202:  
 1203:                 return list;
 1204:             }
 1205:         }
 1206:  
 1207:         /////////////////////////////////////////////////////////////////////////////
 1208:  
 1209:         /// <summary>
 1210:         ///
 1211:         /// </summary>
 1212:         public static bool ServiceIsWithinPstnThatUsesNpServerDomainList(string service)
 1213:         {
 1214:             return PstnThatUsesNpServerDomainList.Any(u => service.StartsWith(u.ToString()));
 1215:         }
 1216:  
 1217:         ////////////////////////////////////////////////////////////////////////////
 1218:  
 1219:         /// <summary>
 1220:         ///
 1221:         /// </summary>
 1222:         public static bool ServiceListHasANumberThatIsWithinPstnThatUsesNpServerDomainList(List<string> serviceList)
 1223:         {
 1224:             var b = false;
 1225:  
 1226:             foreach (var service in serviceList)
 1227:             {
 1228:                 b = Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinPstnThatUsesNpServerDomainList(service);
 1229:  
 1230:                 if (b) break;
 1231:             }
 1232:  
 1233:             return b;
 1234:         }
 1235:  
 1236:         ////////////////////////////////////////////////////////////////////////////
 1237:         ////////////////////////////////////////////////////////////////////////////
 1238:  
 1239:         /// <summary>
 1240:         ///
 1241:         /// </summary>
 1242:         public static List<int> LegacyPstnDomainList
 1243:         {
 1244:             get
 1245:             {
 1246:                 if (legacyPstnDomainList == null || legacyPstnDomainList.Count == 0)
 1247:                 {
 1248:                     lock (objectLock)
 1249:                     {
 1250:                         legacyPstnDomainList = Ia.Ftn.Cl.Models.Data.Service._LegacyPstnDomainList;
 1251:                     }
 1252:                 }
 1253:  
 1254:                 return legacyPstnDomainList;
 1255:             }
 1256:         }
 1257:  
 1258:         ////////////////////////////////////////////////////////////////////////////
 1259:  
 1260:         /// <summary>
 1261:         ///
 1262:         /// </summary>
 1263:         private static List<int> _LegacyPstnDomainList
 1264:         {
 1265:             get
 1266:             {
 1267:                 legacyPstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1268:  
 1269:                 legacyPstnDomainList.Sort();
 1270:  
 1271:                 return legacyPstnDomainList;
 1272:             }
 1273:         }
 1274:  
 1275:         ////////////////////////////////////////////////////////////////////////////
 1276:  
 1277:         /// <summary>
 1278:         ///
 1279:         /// </summary>
 1280:         public static List<int> ImsAndLegacyDomainList
 1281:         {
 1282:             get
 1283:             {
 1284:                 var domainList = Ia.Ftn.Cl.Models.Data.Service.DomainList;
 1285:                 var legacyPstnDomainList = Ia.Ftn.Cl.Models.Data.Service.LegacyPstnDomainList;
 1286:  
 1287:                 var list = domainList.Union(legacyPstnDomainList).ToList();
 1288:  
 1289:                 list.Sort();
 1290:  
 1291:                 return list;
 1292:             }
 1293:         }
 1294:  
 1295:         ////////////////////////////////////////////////////////////////////////////
 1296:  
 1297:         /// <summary>
 1298:         ///
 1299:         /// </summary>
 1300:         public static List<Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain> HundredsSubdomainListWithinImsAndLegacyList
 1301:         {
 1302:             get
 1303:             {
 1304:                 var list = new List<Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain>();
 1305:  
 1306:                 var routerList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList;
 1307:  
 1308:                 foreach (var router in routerList)
 1309:                 {
 1310:                     var subdomainList = HundredsSubdomainListWithinImsRouter(router);
 1311:  
 1312:                     foreach (var subdomain in subdomainList)
 1313:                     {
 1314:                         list.Add(new Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain(router, subdomain));
 1315:                     }
 1316:                 }
 1317:  
 1318:  
 1319:                 var legacyPstnList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList;
 1320:  
 1321:                 foreach (var legacyPstn in legacyPstnList)
 1322:                 {
 1323:                     var subdomainList = HundredsSubdomainListWithinLegacyPstn(legacyPstn);
 1324:  
 1325:                     foreach (var subdomain in subdomainList)
 1326:                     {
 1327:                         list.Add(new Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain(legacyPstn, subdomain));
 1328:                     }
 1329:                 }
 1330:  
 1331:                 return list.Distinct().ToList();
 1332:             }
 1333:         }
 1334:  
 1335:         ////////////////////////////////////////////////////////////////////////////
 1336:  
 1337:         /// <summary>
 1338:         ///
 1339:         /// </summary>
 1340:         public static List<Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain> HundredsSubdomainListWithinImsList
 1341:         {
 1342:             get
 1343:             {
 1344:                 var list = new List<Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain>();
 1345:  
 1346:                 var routerList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList;
 1347:  
 1348:                 foreach (var router in routerList)
 1349:                 {
 1350:                     var subdomainList = HundredsSubdomainListWithinImsRouter(router);
 1351:  
 1352:                     foreach (var subdomain in subdomainList)
 1353:                     {
 1354:                         list.Add(new Ia.Ftn.Cl.Models.Business.Service.HundredsSubdomain(router, subdomain));
 1355:                     }
 1356:                 }
 1357:  
 1358:                 return list.Distinct().ToList();
 1359:             }
 1360:         }
 1361:  
 1362:         ////////////////////////////////////////////////////////////////////////////
 1363:  
 1364:         /// <summary>
 1365:         ///
 1366:         /// </summary>
 1367:         public static List<int> HundredsSubdomainListWithinLegacyPstn(string pstnName)
 1368:         {
 1369:             int n, length;
 1370:             string s;
 1371:  
 1372:             var domainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 1373:                               where p.Name == pstnName
 1374:                               select p).SelectMany(r => r.DomainList).ToList();
 1375:  
 1376:             var list = new List<int>(100 * domainList.Count);
 1377:  
 1378:             foreach (int domain in domainList)
 1379:             {
 1380:                 s = domain.ToString();
 1381:  
 1382:                 length = s.Length;
 1383:  
 1384:                 if (length == 4)
 1385:                 {
 1386:                     for (int i = 0; i < 100; i++)
 1387:                     {
 1388:                         n = domain * 100 + i;
 1389:  
 1390:                         list.Add(n);
 1391:                     }
 1392:                 }
 1393:                 else if (length == 5)
 1394:                 {
 1395:                     for (int p = 0; p < 10; p++)
 1396:                     {
 1397:                         n = domain * 10 + p;
 1398:  
 1399:                         list.Add(n);
 1400:                     }
 1401:                 }
 1402:                 else
 1403:                 {
 1404:                     throw new Exception("length " + length + " is unknown");
 1405:                 }
 1406:             }
 1407:  
 1408:             list.Sort();
 1409:  
 1410:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 1411:         }
 1412:  
 1413:         ////////////////////////////////////////////////////////////////////////////
 1414:  
 1415:         /// <summary>
 1416:         ///
 1417:         /// </summary>
 1418:         public static List<int> HundredsSubdomainListWithinLegacyPstn(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pstn pstn)
 1419:         {
 1420:             int n, length;
 1421:             string s;
 1422:  
 1423:             var domainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 1424:                               where p == pstn
 1425:                               select p).SelectMany(r => r.DomainList).ToList();
 1426:  
 1427:             domainList = domainList.Distinct().ToList();
 1428:  
 1429:             var list = new List<int>(100 * domainList.Count);
 1430:  
 1431:             foreach (int domain in domainList)
 1432:             {
 1433:                 s = domain.ToString();
 1434:  
 1435:                 length = s.Length;
 1436:  
 1437:                 if (length == 4)
 1438:                 {
 1439:                     for (int i = 0; i < 100; i++)
 1440:                     {
 1441:                         n = domain * 100 + i;
 1442:  
 1443:                         list.Add(n);
 1444:                     }
 1445:                 }
 1446:                 else if (length == 5)
 1447:                 {
 1448:                     for (int p = 0; p < 10; p++)
 1449:                     {
 1450:                         n = domain * 10 + p;
 1451:  
 1452:                         list.Add(n);
 1453:                     }
 1454:                 }
 1455:                 else
 1456:                 {
 1457:                     throw new Exception("length " + length + " is unknown");
 1458:                 }
 1459:             }
 1460:  
 1461:             list.Sort();
 1462:  
 1463:             return list.OrderBy(u => u).ToList();
 1464:         }
 1465:  
 1466:         ////////////////////////////////////////////////////////////////////////////
 1467:  
 1468:         /// <summary>
 1469:         ///
 1470:         /// </summary>
 1471:         public static List<int> HundredsSubdomainListWithinImsRouter(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Router router)
 1472:         {
 1473:             int n, length;
 1474:             string s;
 1475:  
 1476:             var domainList = (from r in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList
 1477:                               where r == router
 1478:                               select r).SelectMany(r => r.DomainList).ToList();
 1479:  
 1480:             domainList = domainList.Distinct().ToList();
 1481:  
 1482:             var list = new List<int>(100 * domainList.Count);
 1483:  
 1484:             foreach (int domain in domainList)
 1485:             {
 1486:                 s = domain.ToString();
 1487:  
 1488:                 length = s.Length;
 1489:  
 1490:                 if (length == 4)
 1491:                 {
 1492:                     for (int i = 0; i < 100; i++)
 1493:                     {
 1494:                         n = domain * 100 + i;
 1495:  
 1496:                         list.Add(n);
 1497:                     }
 1498:                 }
 1499:                 else if (length == 5)
 1500:                 {
 1501:                     for (int p = 0; p < 10; p++)
 1502:                     {
 1503:                         n = domain * 10 + p;
 1504:  
 1505:                         list.Add(n);
 1506:                     }
 1507:                 }
 1508:                 else
 1509:                 {
 1510:                     throw new Exception("length " + length + " is unknown");
 1511:                 }
 1512:             }
 1513:  
 1514:             list.Sort();
 1515:  
 1516:             return list.OrderBy(u => u).ToList();
 1517:         }
 1518:  
 1519:         ////////////////////////////////////////////////////////////////////////////
 1520:  
 1521:         /// <summary>
 1522:         ///
 1523:         /// </summary>
 1524:         public static List<int> HundredsSubdomainList
 1525:         {
 1526:             get
 1527:             {
 1528:                 int n, length;
 1529:                 string s;
 1530:  
 1531:                 var domainList = Ia.Ftn.Cl.Models.Data.Service.ImsAndLegacyDomainList;
 1532:  
 1533:                 domainList = domainList.Distinct().ToList();
 1534:  
 1535:                 var list = new List<int>(100 * domainList.Count);
 1536:  
 1537:                 foreach (int domain in domainList)
 1538:                 {
 1539:                     s = domain.ToString();
 1540:  
 1541:                     length = s.Length;
 1542:  
 1543:                     if (length == 4)
 1544:                     {
 1545:                         for (int i = 0; i < 100; i++)
 1546:                         {
 1547:                             n = domain * 100 + i;
 1548:  
 1549:                             list.Add(n);
 1550:                         }
 1551:                     }
 1552:                     else if (length == 5)
 1553:                     {
 1554:                         for (int p = 0; p < 10; p++)
 1555:                         {
 1556:                             n = domain * 10 + p;
 1557:  
 1558:                             list.Add(n);
 1559:                         }
 1560:                     }
 1561:                     else
 1562:                     {
 1563:                         throw new Exception("length " + length + " is unknown");
 1564:                     }
 1565:                 }
 1566:  
 1567:                 list.Sort();
 1568:  
 1569:                 return list.OrderBy(u => u).ToList();
 1570:             }
 1571:         }
 1572:  
 1573:         ////////////////////////////////////////////////////////////////////////////
 1574:  
 1575:         /// <summary>
 1576:         ///
 1577:         /// </summary>
 1578:         public static List<int> HundredsSubdomainListWithinIms
 1579:         {
 1580:             get
 1581:             {
 1582:                 int n, length;
 1583:                 string s;
 1584:  
 1585:                 var domainList = Ia.Ftn.Cl.Models.Data.Service.DomainList;
 1586:  
 1587:                 domainList = domainList.Distinct().ToList();
 1588:  
 1589:                 var list = new List<int>(100 * domainList.Count);
 1590:  
 1591:                 foreach (int domain in domainList)
 1592:                 {
 1593:                     s = domain.ToString();
 1594:  
 1595:                     length = s.Length;
 1596:  
 1597:                     if (length == 4)
 1598:                     {
 1599:                         for (int i = 0; i < 100; i++)
 1600:                         {
 1601:                             n = domain * 100 + i;
 1602:  
 1603:                             list.Add(n);
 1604:                         }
 1605:                     }
 1606:                     else if (length == 5)
 1607:                     {
 1608:                         for (int p = 0; p < 10; p++)
 1609:                         {
 1610:                             n = domain * 10 + p;
 1611:  
 1612:                             list.Add(n);
 1613:                         }
 1614:                     }
 1615:                     else
 1616:                     {
 1617:                         throw new Exception("length " + length + " is unknown");
 1618:                     }
 1619:                 }
 1620:  
 1621:                 list.Sort();
 1622:  
 1623:                 return list.OrderBy(u => u).ToList();
 1624:             }
 1625:         }
 1626:  
 1627:         ////////////////////////////////////////////////////////////////////////////
 1628:         ////////////////////////////////////////////////////////////////////////////
 1629:  
 1630:         /// <summary>
 1631:         ///
 1632:         /// </summary>
 1633:         public static List<int> AxePstnDomainList
 1634:         {
 1635:             get
 1636:             {
 1637:                 if (axePstnDomainList == null || axePstnDomainList.Count == 0)
 1638:                 {
 1639:                     lock (objectLock)
 1640:                     {
 1641:                         axePstnDomainList = Ia.Ftn.Cl.Models.Data.Service._AxePstnDomainList;
 1642:                     }
 1643:                 }
 1644:  
 1645:                 return axePstnDomainList;
 1646:             }
 1647:         }
 1648:  
 1649:         ////////////////////////////////////////////////////////////////////////////
 1650:  
 1651:         /// <summary>
 1652:         ///
 1653:         /// </summary>
 1654:         private static List<int> _AxePstnDomainList
 1655:         {
 1656:             get
 1657:             {
 1658:                 axePstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 1659:                                      where p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe
 1660:                                      select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1661:  
 1662:                 axePstnDomainList.Sort();
 1663:  
 1664:                 return axePstnDomainList;
 1665:             }
 1666:         }
 1667:  
 1668:         ////////////////////////////////////////////////////////////////////////////
 1669:         ////////////////////////////////////////////////////////////////////////////
 1670:  
 1671:         /// <summary>
 1672:         ///
 1673:         /// </summary>
 1674:         public static List<int> LegacyAxePstnDomainList
 1675:         {
 1676:             get
 1677:             {
 1678:                 if (legacyAxePstnDomainList == null || legacyAxePstnDomainList.Count == 0)
 1679:                 {
 1680:                     lock (objectLock)
 1681:                     {
 1682:                         legacyAxePstnDomainList = Ia.Ftn.Cl.Models.Data.Service._LegacyAxePstnDomainList;
 1683:                     }
 1684:                 }
 1685:  
 1686:                 return legacyAxePstnDomainList;
 1687:             }
 1688:         }
 1689:  
 1690:         ////////////////////////////////////////////////////////////////////////////
 1691:  
 1692:         /// <summary>
 1693:         ///
 1694:         /// </summary>
 1695:         private static List<int> _LegacyAxePstnDomainList
 1696:         {
 1697:             get
 1698:             {
 1699:                 legacyAxePstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 1700:                                            where p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe
 1701:                                            select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1702:  
 1703:                 legacyAxePstnDomainList.Sort();
 1704:  
 1705:                 return legacyAxePstnDomainList;
 1706:             }
 1707:         }
 1708:  
 1709:         ////////////////////////////////////////////////////////////////////////////
 1710:         ////////////////////////////////////////////////////////////////////////////
 1711:  
 1712:         /// <summary>
 1713:         ///
 1714:         /// </summary>
 1715:         public static List<int> EwsdPstnDomainList
 1716:         {
 1717:             get
 1718:             {
 1719:                 if (ewsdPstnDomainList == null || ewsdPstnDomainList.Count == 0)
 1720:                 {
 1721:                     lock (objectLock)
 1722:                     {
 1723:                         ewsdPstnDomainList = Ia.Ftn.Cl.Models.Data.Service._EwsdPstnDomainList;
 1724:                     }
 1725:                 }
 1726:  
 1727:                 return ewsdPstnDomainList;
 1728:             }
 1729:         }
 1730:  
 1731:         ////////////////////////////////////////////////////////////////////////////
 1732:  
 1733:         /// <summary>
 1734:         ///
 1735:         /// </summary>
 1736:         private static List<int> _EwsdPstnDomainList
 1737:         {
 1738:             get
 1739:             {
 1740:                 ewsdPstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 1741:                                       where p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd
 1742:                                       select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1743:  
 1744:                 ewsdPstnDomainList.Sort();
 1745:  
 1746:                 return ewsdPstnDomainList;
 1747:             }
 1748:         }
 1749:  
 1750:         ////////////////////////////////////////////////////////////////////////////
 1751:         ////////////////////////////////////////////////////////////////////////////
 1752:  
 1753:         /// <summary>
 1754:         ///
 1755:         /// </summary>
 1756:         public static List<int> LegacyEwsdPstnDomainList
 1757:         {
 1758:             get
 1759:             {
 1760:                 if (legacyEwsdPstnDomainList == null || legacyEwsdPstnDomainList.Count == 0)
 1761:                 {
 1762:                     lock (objectLock)
 1763:                     {
 1764:                         legacyEwsdPstnDomainList = Ia.Ftn.Cl.Models.Data.Service._LegacyEwsdPstnDomainList;
 1765:                     }
 1766:                 }
 1767:  
 1768:                 return legacyEwsdPstnDomainList;
 1769:             }
 1770:         }
 1771:  
 1772:         ////////////////////////////////////////////////////////////////////////////
 1773:  
 1774:         /// <summary>
 1775:         ///
 1776:         /// </summary>
 1777:         private static List<int> _LegacyEwsdPstnDomainList
 1778:         {
 1779:             get
 1780:             {
 1781:                 legacyEwsdPstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 1782:                                             where p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd
 1783:                                             select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1784:  
 1785:                 legacyEwsdPstnDomainList.Sort();
 1786:  
 1787:                 return legacyEwsdPstnDomainList;
 1788:             }
 1789:         }
 1790:  
 1791:         ////////////////////////////////////////////////////////////////////////////
 1792:         ////////////////////////////////////////////////////////////////////////////
 1793:  
 1794:         /// <summary>
 1795:         ///
 1796:         /// </summary>
 1797:         public static List<int> LegacyMrdPstnDomainList
 1798:         {
 1799:             get
 1800:             {
 1801:                 if (legacyMrdPstnDomainList == null || legacyMrdPstnDomainList.Count == 0)
 1802:                 {
 1803:                     lock (objectLock)
 1804:                     {
 1805:                         legacyMrdPstnDomainList = Ia.Ftn.Cl.Models.Data.Service._LegacyMrdPstnDomainList;
 1806:                     }
 1807:                 }
 1808:  
 1809:                 return legacyMrdPstnDomainList;
 1810:             }
 1811:         }
 1812:  
 1813:         ////////////////////////////////////////////////////////////////////////////
 1814:  
 1815:         /// <summary>
 1816:         ///
 1817:         /// </summary>
 1818:         private static List<int> _LegacyMrdPstnDomainList
 1819:         {
 1820:             get
 1821:             {
 1822:                 legacyMrdPstnDomainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 1823:                                            where p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.NortelMeridian
 1824:                                            select p).SelectMany(r => r.DomainList).Distinct().ToList();
 1825:  
 1826:                 legacyMrdPstnDomainList.Sort();
 1827:  
 1828:                 return legacyMrdPstnDomainList;
 1829:             }
 1830:         }
 1831:  
 1832:         ////////////////////////////////////////////////////////////////////////////
 1833:         ////////////////////////////////////////////////////////////////////////////
 1834:  
 1835:         /// <summary>
 1836:         ///
 1837:         /// </summary>
 1838:         public static List<int> MigrationDomainList
 1839:         {
 1840:             get
 1841:             {
 1842:                 if (migrationDomainList == null || migrationDomainList.Count == 0)
 1843:                 {
 1844:                     lock (objectLock)
 1845:                     {
 1846:                         migrationDomainList = Ia.Ftn.Cl.Models.Data.Service._MigrationDomainList;
 1847:                     }
 1848:                 }
 1849:  
 1850:                 return migrationDomainList;
 1851:             }
 1852:         }
 1853:  
 1854:         ////////////////////////////////////////////////////////////////////////////
 1855:  
 1856:         /// <summary>
 1857:         ///
 1858:         /// </summary>
 1859:         private static List<int> _MigrationDomainList
 1860:         {
 1861:             get
 1862:             {
 1863:                 var allowedToBeMigratedOltIdList = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedOltIdList;
 1864:  
 1865:                 var list = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 1866:                             where allowedToBeMigratedOltIdList.Contains(o.Id)
 1867:                             select o.Odf.Router).SelectMany(r => r.DomainList).Distinct().ToList();
 1868:  
 1869:                 list.Sort();
 1870:  
 1871:                 return list;
 1872:             }
 1873:         }
 1874:  
 1875:         ////////////////////////////////////////////////////////////////////////////
 1876:  
 1877:         /// <summary>
 1878:         ///
 1879:         /// </summary>
 1880:         public static List<int> NokiaSwitchDomainList
 1881:         {
 1882:             get
 1883:             {
 1884:                 if (nokiaSwitchDomainList == null || nokiaSwitchDomainList.Count == 0)
 1885:                 {
 1886:                     lock (objectLock)
 1887:                     {
 1888:                         nokiaSwitchDomainList = Ia.Ftn.Cl.Models.Data.Service._NokiaSwitchDomainList;
 1889:                     }
 1890:                 }
 1891:  
 1892:                 return nokiaSwitchDomainList;
 1893:             }
 1894:         }
 1895:  
 1896:         ////////////////////////////////////////////////////////////////////////////
 1897:  
 1898:         /// <summary>
 1899:         ///
 1900:         /// </summary>
 1901:         private static List<int> _NokiaSwitchDomainList
 1902:         {
 1903:             get
 1904:             {
 1905:                 return DomainListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia);
 1906:             }
 1907:         }
 1908:  
 1909:         ////////////////////////////////////////////////////////////////////////////
 1910:  
 1911:         /// <summary>
 1912:         ///
 1913:         /// </summary>
 1914:         public static List<int> HuaweiSwitchDomainList
 1915:         {
 1916:             get
 1917:             {
 1918:                 if (huaweiSwitchDomainList == null || huaweiSwitchDomainList.Count == 0)
 1919:                 {
 1920:                     lock (objectLock)
 1921:                     {
 1922:                         huaweiSwitchDomainList = Ia.Ftn.Cl.Models.Data.Service._HuaweiSwitchDomainList;
 1923:                     }
 1924:                 }
 1925:  
 1926:                 return huaweiSwitchDomainList;
 1927:             }
 1928:         }
 1929:  
 1930:         ////////////////////////////////////////////////////////////////////////////
 1931:  
 1932:         /// <summary>
 1933:         ///
 1934:         /// </summary>
 1935:         private static List<int> _HuaweiSwitchDomainList
 1936:         {
 1937:             get
 1938:             {
 1939:                 return Ia.Ftn.Cl.Models.Data.Service.DomainListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei);
 1940:             }
 1941:         }
 1942:  
 1943:         ////////////////////////////////////////////////////////////////////////////
 1944:         ////////////////////////////////////////////////////////////////////////////
 1945:  
 1946:         /// <summary>
 1947:         ///
 1948:         /// </summary>
 1949:         public static List<int> MsanDomainList
 1950:         {
 1951:             get
 1952:             {
 1953:                 if (msanDomainList == null || msanDomainList.Count == 0)
 1954:                 {
 1955:                     lock (objectLock)
 1956:                     {
 1957:                         msanDomainList = Ia.Ftn.Cl.Models.Data.Service._MsanDomainList;
 1958:                     }
 1959:                 }
 1960:  
 1961:                 return msanDomainList;
 1962:             }
 1963:         }
 1964:  
 1965:         ////////////////////////////////////////////////////////////////////////////
 1966:  
 1967:         /// <summary>
 1968:         ///
 1969:         /// </summary>
 1970:         private static List<int> _MsanDomainList
 1971:         {
 1972:             get
 1973:             {
 1974:                 msanDomainList = (from m in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.MsanList
 1975:                                   where m.DomainList != null
 1976:                                   select m).SelectMany(u => u.DomainList).ToList();
 1977:  
 1978:                 if (msanDomainList.Distinct().Count() != msanDomainList.Count())
 1979:                 {
 1980:                     throw new Exception("msanDomainList has duplicate entries");
 1981:                 }
 1982:  
 1983:                 msanDomainList.Sort();
 1984:  
 1985:                 return msanDomainList;
 1986:             }
 1987:         }
 1988:  
 1989:         ////////////////////////////////////////////////////////////////////////////
 1990:  
 1991:         /// <summary>
 1992:         ///
 1993:         /// </summary>
 1994:         private static List<int> MsanDomainListBySiteId(int siteId)
 1995:         {
 1996:             msanDomainList = (from m in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.MsanList
 1997:                               where m.Site.Id == siteId && m.DomainList != null
 1998:                               select m).SelectMany(u => u.DomainList).Distinct().ToList();
 1999:  
 2000:             msanDomainList.Sort();
 2001:  
 2002:             return msanDomainList;
 2003:         }
 2004:  
 2005:         ////////////////////////////////////////////////////////////////////////////
 2006:         /////////////////////////////////////////////////////////////////////////////
 2007:  
 2008:         /// <summary>
 2009:         ///
 2010:         /// </summary>
 2011:         public static bool ServiceIsWithinNokiaSwitchDomainList(string service)
 2012:         {
 2013:             bool b;
 2014:  
 2015:             if (!string.IsNullOrEmpty(service))
 2016:             {
 2017:                 b = Ia.Ftn.Cl.Models.Data.Service.NokiaSwitchDomainList.Any(u => service.StartsWith(u.ToString()));
 2018:             }
 2019:             else b = false;
 2020:  
 2021:             return b;
 2022:         }
 2023:  
 2024:         /////////////////////////////////////////////////////////////////////////////
 2025:  
 2026:         /// <summary>
 2027:         ///
 2028:         /// </summary>
 2029:         public static bool ServiceIsWithinHuaweiSwitchDomainList(string service)
 2030:         {
 2031:             bool b;
 2032:  
 2033:             if (!string.IsNullOrEmpty(service))
 2034:             {
 2035:                 b = Ia.Ftn.Cl.Models.Data.Service.HuaweiSwitchDomainList.Any(u => service.StartsWith(u.ToString()));
 2036:             }
 2037:             else b = false;
 2038:  
 2039:             return b;
 2040:         }
 2041:  
 2042:         /////////////////////////////////////////////////////////////////////////////
 2043:  
 2044:         /// <summary>
 2045:         ///
 2046:         /// </summary>
 2047:         public static bool ServiceIsWithinAxePstnDomainList(string service)
 2048:         {
 2049:             bool b;
 2050:  
 2051:             if (!string.IsNullOrEmpty(service))
 2052:             {
 2053:                 b = Ia.Ftn.Cl.Models.Data.Service.AxePstnDomainList.Any(u => service.StartsWith(u.ToString()));
 2054:             }
 2055:             else b = false;
 2056:  
 2057:             return b;
 2058:         }
 2059:  
 2060:         /////////////////////////////////////////////////////////////////////////////
 2061:  
 2062:         /// <summary>
 2063:         ///
 2064:         /// </summary>
 2065:         public static bool ServiceIsWithinLegacyAxePstnDomainList(string service)
 2066:         {
 2067:             bool b;
 2068:  
 2069:             if (!string.IsNullOrEmpty(service))
 2070:             {
 2071:                 b = Ia.Ftn.Cl.Models.Data.Service.LegacyAxePstnDomainList.Any(u => service.StartsWith(u.ToString()));
 2072:             }
 2073:             else b = false;
 2074:  
 2075:             return b;
 2076:         }
 2077:  
 2078:         /////////////////////////////////////////////////////////////////////////////
 2079:  
 2080:         /// <summary>
 2081:         ///
 2082:         /// </summary>
 2083:         public static bool ServiceIsWithinEwsdPstnDomainList(string service)
 2084:         {
 2085:             bool b;
 2086:  
 2087:             if (!string.IsNullOrEmpty(service))
 2088:             {
 2089:                 b = Ia.Ftn.Cl.Models.Data.Service.EwsdPstnDomainList.Any(u => service.StartsWith(u.ToString()));
 2090:             }
 2091:             else b = false;
 2092:  
 2093:             return b;
 2094:         }
 2095:  
 2096:         /////////////////////////////////////////////////////////////////////////////
 2097:  
 2098:         /// <summary>
 2099:         ///
 2100:         /// </summary>
 2101:         public static bool ServiceIsWithinLegacyEwsdPstnDomainList(string service)
 2102:         {
 2103:             bool b;
 2104:  
 2105:             if (!string.IsNullOrEmpty(service))
 2106:             {
 2107:                 b = Ia.Ftn.Cl.Models.Data.Service.LegacyEwsdPstnDomainList.Any(u => service.StartsWith(u.ToString()));
 2108:             }
 2109:             else b = false;
 2110:  
 2111:             return b;
 2112:         }
 2113:  
 2114:         /////////////////////////////////////////////////////////////////////////////
 2115:  
 2116:         /// <summary>
 2117:         ///
 2118:         /// </summary>
 2119:         public static bool ServiceIsWithinLegacyMrdPstnDomainList(string service)
 2120:         {
 2121:             bool b;
 2122:  
 2123:             if (!string.IsNullOrEmpty(service))
 2124:             {
 2125:                 b = Ia.Ftn.Cl.Models.Data.Service.LegacyMrdPstnDomainList.Any(u => service.StartsWith(u.ToString()));
 2126:             }
 2127:             else b = false;
 2128:  
 2129:             return b;
 2130:         }
 2131:  
 2132:         /////////////////////////////////////////////////////////////////////////////
 2133:         /////////////////////////////////////////////////////////////////////////////
 2134:  
 2135:         /// <summary>
 2136:         ///
 2137:         /// </summary>
 2138:         public static bool ServiceIsWithinSoftXDomainList(string service)
 2139:         {
 2140:             bool b;
 2141:  
 2142:             if (!string.IsNullOrEmpty(service))
 2143:             {
 2144:                 b = Ia.Ftn.Cl.Models.Data.Service.SoftXDomainList.Any(u => service.StartsWith(u.ToString()));
 2145:             }
 2146:             else b = false;
 2147:  
 2148:             return b;
 2149:         }
 2150:  
 2151:         ////////////////////////////////////////////////////////////////////////////
 2152:  
 2153:         /// <summary>
 2154:         ///
 2155:         /// </summary>
 2156:         public static bool ServiceListHasANumberThatIsWithinSoftXServer(List<string> serviceList)
 2157:         {
 2158:             var b = false;
 2159:  
 2160:             foreach (var service in serviceList)
 2161:             {
 2162:                 b = Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinSoftXDomainList(service);
 2163:  
 2164:                 if (b) break;
 2165:             }
 2166:  
 2167:             return b;
 2168:         }
 2169:  
 2170:         ////////////////////////////////////////////////////////////////////////////
 2171:  
 2172:         /// <summary>
 2173:         ///
 2174:         /// </summary>
 2175:         public static List<int> SoftXDomainList
 2176:         {
 2177:             get
 2178:             {
 2179:                 if (softxDomainList == null || softxDomainList.Count == 0)
 2180:                 {
 2181:                     lock (objectLock)
 2182:                     {
 2183:                         softxDomainList = Ia.Ftn.Cl.Models.Data.Service._SoftXDomainList;
 2184:                     }
 2185:                 }
 2186:  
 2187:                 return softxDomainList;
 2188:             }
 2189:         }
 2190:  
 2191:         ////////////////////////////////////////////////////////////////////////////
 2192:  
 2193:         /// <summary>
 2194:         ///
 2195:         /// </summary>
 2196:         private static List<int> _SoftXDomainList
 2197:         {
 2198:             get
 2199:             {
 2200:                 softxDomainList = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SoftXList
 2201:                                    where s.DomainList != null
 2202:                                    select s).SelectMany(u => u.DomainList).ToList();
 2203:  
 2204:                 if (softxDomainList.Distinct().Count() != softxDomainList.Count())
 2205:                 {
 2206:                     throw new Exception("softxDomainList has duplicate entries");
 2207:                 }
 2208:  
 2209:                 softxDomainList.Sort();
 2210:  
 2211:                 return softxDomainList;
 2212:             }
 2213:         }
 2214:  
 2215:         /////////////////////////////////////////////////////////////////////////////
 2216:         /////////////////////////////////////////////////////////////////////////////
 2217:  
 2218:         /// <summary>
 2219:         ///
 2220:         /// </summary>
 2221:         public static bool ServiceIsWithinSpsDomainList(string service)
 2222:         {
 2223:             bool b;
 2224:  
 2225:             if (!string.IsNullOrEmpty(service))
 2226:             {
 2227:                 b = Ia.Ftn.Cl.Models.Data.Service.SpsDomainList.Any(u => service.StartsWith(u.ToString()));
 2228:             }
 2229:             else b = false;
 2230:  
 2231:             return b;
 2232:         }
 2233:  
 2234:         ////////////////////////////////////////////////////////////////////////////
 2235:  
 2236:         /// <summary>
 2237:         ///
 2238:         /// </summary>
 2239:         public static bool ServiceListHasANumberThatIsWithinSpsServer(List<string> serviceList)
 2240:         {
 2241:             var b = false;
 2242:  
 2243:             foreach (var service in serviceList)
 2244:             {
 2245:                 b = Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinSpsDomainList(service);
 2246:  
 2247:                 if (b) break;
 2248:             }
 2249:  
 2250:             return b;
 2251:         }
 2252:  
 2253:         ////////////////////////////////////////////////////////////////////////////
 2254:  
 2255:         /// <summary>
 2256:         ///
 2257:         /// </summary>
 2258:         public static List<int> SpsDomainList
 2259:         {
 2260:             get
 2261:             {
 2262:                 if (spsDomainList == null || spsDomainList.Count == 0)
 2263:                 {
 2264:                     lock (objectLock)
 2265:                     {
 2266:                         spsDomainList = Ia.Ftn.Cl.Models.Data.Service._SpsDomainList;
 2267:                     }
 2268:                 }
 2269:  
 2270:                 return spsDomainList;
 2271:             }
 2272:         }
 2273:  
 2274:         ////////////////////////////////////////////////////////////////////////////
 2275:  
 2276:         /// <summary>
 2277:         ///
 2278:         /// </summary>
 2279:         private static List<int> _SpsDomainList
 2280:         {
 2281:             get
 2282:             {
 2283:                 spsDomainList = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 2284:                                  where s.UsesNpServer == true && s.DomainList != null
 2285:                                  select s).SelectMany(u => u.DomainList).ToList();
 2286:  
 2287:                 if (spsDomainList.Distinct().Count() != spsDomainList.Count())
 2288:                 {
 2289:                     throw new Exception("spsDomainList has duplicate entries");
 2290:                 }
 2291:  
 2292:                 spsDomainList.Sort();
 2293:  
 2294:                 return spsDomainList;
 2295:             }
 2296:         }
 2297:  
 2298:         /////////////////////////////////////////////////////////////////////////////
 2299:         ////////////////////////////////////////////////////////////////////////////
 2300:  
 2301:         /// <summary>
 2302:         ///
 2303:         /// </summary>
 2304:         public static List<int> NokiaSwitchNokiaAccessDomainList
 2305:         {
 2306:             get
 2307:             {
 2308:                 if (nokiaSwitchNokiaAccessDomainList == null || nokiaSwitchNokiaAccessDomainList.Count == 0)
 2309:                 {
 2310:                     lock (objectLock)
 2311:                     {
 2312:                         var oltIdList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.NokiaRouterNokiaAccessOltIdList;
 2313:  
 2314:                         nokiaSwitchNokiaAccessDomainList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 2315:                                                             where oltIdList.Contains(o.Id)
 2316:                                                             select o.Odf.Router).SelectMany(r => r.DomainList).Distinct().ToList();
 2317:  
 2318:                         nokiaSwitchNokiaAccessDomainList.Sort();
 2319:                     }
 2320:                 }
 2321:  
 2322:                 return nokiaSwitchNokiaAccessDomainList;
 2323:             }
 2324:         }
 2325:  
 2326:         /////////////////////////////////////////////////////////////////////////////
 2327:  
 2328:         /// <summary>
 2329:         ///
 2330:         /// </summary>
 2331:         public static bool ServiceIsWithinNokiaSwitchNokiaAccessDomainList(string service)
 2332:         {
 2333:             bool b;
 2334:  
 2335:             if (!string.IsNullOrEmpty(service))
 2336:             {
 2337:                 b = NokiaSwitchNokiaAccessDomainList.Any(u => service.StartsWith(u.ToString()));
 2338:             }
 2339:             else b = false;
 2340:  
 2341:             return b;
 2342:         }
 2343:  
 2344:         ////////////////////////////////////////////////////////////////////////////
 2345:  
 2346:         /// <summary>
 2347:         ///
 2348:         /// </summary>
 2349:         public static List<int> HuaweiSwitchNokiaAccessDomainList
 2350:         {
 2351:             get
 2352:             {
 2353:                 if (huaweiSwitchNokiaAccessDomainList == null || huaweiSwitchNokiaAccessDomainList.Count == 0)
 2354:                 {
 2355:                     lock (objectLock)
 2356:                     {
 2357:                         var oltIdList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.HuaweiRouterNokiaAccessOltIdList;
 2358:  
 2359:                         huaweiSwitchNokiaAccessDomainList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 2360:                                                              where oltIdList.Contains(o.Id)
 2361:                                                              select o.Odf.Router).SelectMany(r => r.DomainList).Distinct().ToList();
 2362:  
 2363:                         huaweiSwitchNokiaAccessDomainList.Sort();
 2364:                     }
 2365:                 }
 2366:  
 2367:                 return huaweiSwitchNokiaAccessDomainList;
 2368:             }
 2369:         }
 2370:  
 2371:         /////////////////////////////////////////////////////////////////////////////
 2372:  
 2373:         /// <summary>
 2374:         ///
 2375:         /// </summary>
 2376:         public static bool ServiceIsWithinHuaweiSwitchNokiaAccessDomainList(string service)
 2377:         {
 2378:             bool b;
 2379:  
 2380:             if (!string.IsNullOrEmpty(service))
 2381:             {
 2382:                 b = HuaweiSwitchNokiaAccessDomainList.Any(u => service.StartsWith(u.ToString()));
 2383:             }
 2384:             else b = false;
 2385:  
 2386:             return b;
 2387:         }
 2388:  
 2389:         ////////////////////////////////////////////////////////////////////////////
 2390:         ////////////////////////////////////////////////////////////////////////////
 2391:  
 2392:         /// <summary>
 2393:         ///
 2394:         /// </summary>
 2395:         public static List<int> HuaweiAccessDomainList
 2396:         {
 2397:             get
 2398:             {
 2399:                 if (huaweiAccessDomainList == null || huaweiAccessDomainList.Count == 0)
 2400:                 {
 2401:                     lock (objectLock)
 2402:                     {
 2403:                         var oltIdList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.HuaweiOltIdList();
 2404:  
 2405:                         huaweiAccessDomainList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 2406:                                                   where oltIdList.Contains(o.Id)
 2407:                                                   select o.Odf.Router).SelectMany(r => r.DomainList).Distinct().ToList();
 2408:  
 2409:                         huaweiAccessDomainList.Sort();
 2410:                     }
 2411:                 }
 2412:  
 2413:                 return huaweiAccessDomainList;
 2414:             }
 2415:         }
 2416:  
 2417:         /////////////////////////////////////////////////////////////////////////////
 2418:  
 2419:         /// <summary>
 2420:         ///
 2421:         /// </summary>
 2422:         public static bool ServiceIsWithinHuaweiAccessDomainList(string service)
 2423:         {
 2424:             bool b;
 2425:  
 2426:             if (!string.IsNullOrEmpty(service))
 2427:             {
 2428:                 b = HuaweiAccessDomainList.Any(u => service.StartsWith(u.ToString()));
 2429:             }
 2430:             else b = false;
 2431:  
 2432:             return b;
 2433:         }
 2434:  
 2435:         ////////////////////////////////////////////////////////////////////////////
 2436:         ////////////////////////////////////////////////////////////////////////////
 2437:  
 2438:         /// <summary>
 2439:         ///
 2440:         /// </summary>
 2441:         public static bool ServiceListHasANumberThatIsWithinHuaweiSwitchNokiaAccessDomainList(List<string> serviceList)
 2442:         {
 2443:             var b = false;
 2444:  
 2445:             foreach (var service in serviceList)
 2446:             {
 2447:                 b = Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinHuaweiSwitchNokiaAccessDomainList(service);
 2448:  
 2449:                 if (b) break;
 2450:             }
 2451:  
 2452:             return b;
 2453:         }
 2454:  
 2455:         ////////////////////////////////////////////////////////////////////////////
 2456:  
 2457:         /// <summary>
 2458:         ///
 2459:         /// </summary>
 2460:         private static List<int> DomainListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor vendor)
 2461:         {
 2462:             List<int> list;
 2463:  
 2464:             list = (from d in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList
 2465:                     where d.Vendor == vendor
 2466:                     select d).SelectMany(r => r.DomainList).Distinct().ToList();
 2467:  
 2468:             list.Sort();
 2469:  
 2470:             return list;
 2471:         }
 2472:  
 2473:         ////////////////////////////////////////////////////////////////////////////
 2474:  
 2475:         /// <summary>
 2476:         ///
 2477:         /// 
 2478:         /// </summary>
 2479:         private static List<int> DomainListWithinAccessVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor vendor)
 2480:         {
 2481:             List<int> list;
 2482:  
 2483:             list = (from d in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OdfList
 2484:                     where d.Vendor == vendor
 2485:                     select d.Router).SelectMany(r => r.DomainList).ToList();
 2486:  
 2487:             list.Sort();
 2488:  
 2489:             return list;
 2490:         }
 2491:  
 2492:         ////////////////////////////////////////////////////////////////////////////
 2493:  
 2494:         /// <summary>
 2495:         ///
 2496:         /// </summary>
 2497:         public static List<int> AllPossibleServiceNumberList
 2498:         {
 2499:             get
 2500:             {
 2501:                 int n, length;
 2502:                 string s;
 2503:                 List<int> list;
 2504:  
 2505:                 list = new List<int>(10000 * Ia.Ftn.Cl.Models.Data.Service.DomainList.Count);
 2506:  
 2507:                 foreach (int d in Ia.Ftn.Cl.Models.Data.Service.DomainList)
 2508:                 {
 2509:                     s = d.ToString();
 2510:  
 2511:                     length = s.Length;
 2512:  
 2513:                     if (length == 4)
 2514:                     {
 2515:                         for (int i = 0; i < 10000; i++)
 2516:                         {
 2517:                             n = d * 10000 + i;
 2518:  
 2519:                             list.Add(n);
 2520:                         }
 2521:                     }
 2522:                     else if (length == 5)
 2523:                     {
 2524:                         for (int p = 0; p < 1000; p++)
 2525:                         {
 2526:                             n = d * 1000 + p;
 2527:  
 2528:                             list.Add(n);
 2529:                         }
 2530:                     }
 2531:                     else
 2532:                     {
 2533:                         throw new Exception("length " + length + " is unknown");
 2534:                     }
 2535:                 }
 2536:  
 2537:                 return list;
 2538:             }
 2539:         }
 2540:  
 2541:         ////////////////////////////////////////////////////////////////////////////
 2542:  
 2543:         /// <summary>
 2544:         ///
 2545:         /// </summary>
 2546:         public static List<int> AllPossiblePstnServiceNumberList
 2547:         {
 2548:             get
 2549:             {
 2550:                 int n, length;
 2551:                 string s;
 2552:                 List<int> list;
 2553:  
 2554:                 list = new List<int>(10000 * Ia.Ftn.Cl.Models.Data.Service.PstnDomainList.Count);
 2555:  
 2556:                 foreach (int d in Ia.Ftn.Cl.Models.Data.Service.PstnDomainList)
 2557:                 {
 2558:                     s = d.ToString();
 2559:  
 2560:                     length = s.Length;
 2561:  
 2562:                     if (length == 4)
 2563:                     {
 2564:                         for (int i = 0; i < 10000; i++)
 2565:                         {
 2566:                             n = d * 10000 + i;
 2567:  
 2568:                             list.Add(n);
 2569:                         }
 2570:                     }
 2571:                     else if (length == 5)
 2572:                     {
 2573:                         for (int p = 0; p < 1000; p++)
 2574:                         {
 2575:                             n = d * 1000 + p;
 2576:  
 2577:                             list.Add(n);
 2578:                         }
 2579:                     }
 2580:                     else
 2581:                     {
 2582:                         throw new Exception("length " + length + " is unknown");
 2583:                     }
 2584:                 }
 2585:  
 2586:                 return list;
 2587:             }
 2588:         }
 2589:  
 2590:         ////////////////////////////////////////////////////////////////////////////
 2591:  
 2592:         /// <summary>
 2593:         ///
 2594:         /// </summary>
 2595:         public static List<int> AllPossibleMsanServiceNumberList
 2596:         {
 2597:             get
 2598:             {
 2599:                 int n, length;
 2600:                 string s;
 2601:                 List<int> list;
 2602:  
 2603:                 list = new List<int>(10000 * Ia.Ftn.Cl.Models.Data.Service.MsanDomainList.Count);
 2604:  
 2605:                 foreach (int d in Ia.Ftn.Cl.Models.Data.Service.MsanDomainList)
 2606:                 {
 2607:                     s = d.ToString();
 2608:  
 2609:                     length = s.Length;
 2610:  
 2611:                     if (length == 4)
 2612:                     {
 2613:                         for (int i = 0; i < 10000; i++)
 2614:                         {
 2615:                             n = d * 10000 + i;
 2616:  
 2617:                             list.Add(n);
 2618:                         }
 2619:                     }
 2620:                     else if (length == 5)
 2621:                     {
 2622:                         for (int p = 0; p < 1000; p++)
 2623:                         {
 2624:                             n = d * 1000 + p;
 2625:  
 2626:                             list.Add(n);
 2627:                         }
 2628:                     }
 2629:                     else
 2630:                     {
 2631:                         throw new Exception("length " + length + " is unknown");
 2632:                     }
 2633:                 }
 2634:  
 2635:                 return list;
 2636:             }
 2637:         }
 2638:  
 2639:         ////////////////////////////////////////////////////////////////////////////
 2640:  
 2641:         /// <summary>
 2642:         ///
 2643:         /// </summary>
 2644:         public static List<int> AllPossibleLegacyPstnServiceNumberList
 2645:         {
 2646:             get
 2647:             {
 2648:                 int n, length;
 2649:                 string s;
 2650:                 List<int> list;
 2651:  
 2652:                 list = new List<int>(10000 * Ia.Ftn.Cl.Models.Data.Service.LegacyPstnDomainList.Count);
 2653:  
 2654:                 foreach (int d in Ia.Ftn.Cl.Models.Data.Service.LegacyPstnDomainList)
 2655:                 {
 2656:                     s = d.ToString();
 2657:  
 2658:                     length = s.Length;
 2659:  
 2660:                     if (length == 4)
 2661:                     {
 2662:                         for (int i = 0; i < 10000; i++)
 2663:                         {
 2664:                             n = d * 10000 + i;
 2665:  
 2666:                             list.Add(n);
 2667:                         }
 2668:                     }
 2669:                     else if (length == 5)
 2670:                     {
 2671:                         for (int p = 0; p < 1000; p++)
 2672:                         {
 2673:                             n = d * 1000 + p;
 2674:  
 2675:                             list.Add(n);
 2676:                         }
 2677:                     }
 2678:                     else
 2679:                     {
 2680:                         throw new Exception("length " + length + " is unknown");
 2681:                     }
 2682:                 }
 2683:  
 2684:                 return list;
 2685:             }
 2686:         }
 2687:  
 2688:         ////////////////////////////////////////////////////////////////////////////
 2689:  
 2690:         /// <summary>
 2691:         ///
 2692:         /// </summary>
 2693:         public static List<int> AllPossibleServiceNumberListWithinDomain(int domain)
 2694:         {
 2695:             int n, length;
 2696:             string s;
 2697:             List<int> list;
 2698:  
 2699:             s = domain.ToString();
 2700:  
 2701:             length = s.Length;
 2702:  
 2703:             list = new List<int>(10000);
 2704:  
 2705:             if (length == 4)
 2706:             {
 2707:                 for (int i = 0; i < 10000; i++)
 2708:                 {
 2709:                     n = domain * 10000 + i;
 2710:  
 2711:                     list.Add(n);
 2712:                 }
 2713:             }
 2714:             else if (length == 5)
 2715:             {
 2716:                 for (int p = 0; p < 1000; p++)
 2717:                 {
 2718:                     n = domain * 1000 + p;
 2719:  
 2720:                     list.Add(n);
 2721:                 }
 2722:             }
 2723:             else
 2724:             {
 2725:                 throw new Exception("length " + length + " is unknown");
 2726:             }
 2727:  
 2728:             return list;
 2729:         }
 2730:  
 2731:         ////////////////////////////////////////////////////////////////////////////
 2732:  
 2733:         /// <summary>
 2734:         ///
 2735:         /// </summary>
 2736:         public static void FirstAndLastServiceNumbersWithinDomain(int domain, out int firstServiceNumber, out int lastServiceNumber)
 2737:         {
 2738:             var s = domain.ToString();
 2739:  
 2740:             var length = s.Length;
 2741:  
 2742:             if (length == 4)
 2743:             {
 2744:                 firstServiceNumber = domain * 10000;
 2745:                 lastServiceNumber = domain * 10000 + 9999;
 2746:             }
 2747:             else if (length == 5)
 2748:             {
 2749:                 firstServiceNumber = domain * 1000;
 2750:                 lastServiceNumber = domain * 1000 + 999;
 2751:             }
 2752:             else if (length == 6)
 2753:             {
 2754:                 firstServiceNumber = domain * 100;
 2755:                 lastServiceNumber = domain * 100 + 99;
 2756:             }
 2757:             else
 2758:             {
 2759:                 firstServiceNumber = 0;
 2760:                 lastServiceNumber = 0;
 2761:  
 2762:                 //throw new Exception("length " + length + " is undefined.");
 2763:             }
 2764:         }
 2765:  
 2766:         ////////////////////////////////////////////////////////////////////////////
 2767:  
 2768:         /// <summary>
 2769:         ///
 2770:         /// </summary>
 2771:         public static List<int> AllPossibleServiceNumberListWithinHundredsSubdomain(int hundredsSubdomain)
 2772:         {
 2773:             int n, length;
 2774:             string s;
 2775:             List<int> list;
 2776:  
 2777:             s = hundredsSubdomain.ToString();
 2778:  
 2779:             length = s.Length;
 2780:  
 2781:             list = new List<int>(10000);
 2782:  
 2783:             if (length == 6) // 6 digits in 8 digit number divided by 100
 2784:             {
 2785:                 for (int i = 0; i < 100; i++)
 2786:                 {
 2787:                     n = hundredsSubdomain * 100 + i;
 2788:  
 2789:                     list.Add(n);
 2790:                 }
 2791:             }
 2792:             else
 2793:             {
 2794:                 throw new Exception("length " + length + " is unknown");
 2795:             }
 2796:  
 2797:             return list;
 2798:         }
 2799:  
 2800:         ////////////////////////////////////////////////////////////////////////////
 2801:  
 2802:         /// <summary>
 2803:         ///
 2804:         /// </summary>
 2805:         public static int NumberOfPossibleServicesWithinDomainList(List<int> list)
 2806:         {
 2807:             int n, length;
 2808:  
 2809:             n = 0;
 2810:  
 2811:             foreach (int domain in list)
 2812:             {
 2813:                 length = domain.ToString().Length;
 2814:  
 2815:                 if (length == 4) n += 10000;
 2816:                 else if (length == 5) n += 1000;
 2817:                 else
 2818:                 {
 2819:                     throw new Exception("length " + length + " is unknown");
 2820:                 }
 2821:             }
 2822:  
 2823:             return n;
 2824:         }
 2825:  
 2826:         ////////////////////////////////////////////////////////////////////////////
 2827:  
 2828:         /// <summary>
 2829:         ///
 2830:         /// </summary>
 2831:         public static List<int> AllPossibleServiceNumberListWithinNokiaSwitch
 2832:         {
 2833:             get
 2834:             {
 2835:                 List<int> list;
 2836:  
 2837:                 list = AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia);
 2838:  
 2839:                 return list;
 2840:             }
 2841:         }
 2842:  
 2843:         ////////////////////////////////////////////////////////////////////////////
 2844:  
 2845:         /// <summary>
 2846:         ///
 2847:         /// </summary>
 2848:         public static List<int> AllPossibleServiceNumberListWithinHuaweiSwitch
 2849:         {
 2850:             get
 2851:             {
 2852:                 List<int> list;
 2853:  
 2854:                 list = AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei);
 2855:  
 2856:                 return list;
 2857:             }
 2858:         }
 2859:  
 2860:         ////////////////////////////////////////////////////////////////////////////
 2861:  
 2862:         /// <summary>
 2863:         ///
 2864:         /// </summary>
 2865:         private static List<int> AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor vendor)
 2866:         {
 2867:             int n, length;
 2868:             string s;
 2869:             List<int> list;
 2870:             List<int> domainListWithinSwitchVendor;
 2871:  
 2872:             domainListWithinSwitchVendor = Ia.Ftn.Cl.Models.Data.Service.DomainListWithinSwitchVendor(vendor);
 2873:  
 2874:             list = new List<int>(10000 * domainListWithinSwitchVendor.Count);
 2875:  
 2876:             foreach (int domain in domainListWithinSwitchVendor)
 2877:             {
 2878:                 s = domain.ToString();
 2879:  
 2880:                 length = s.Length;
 2881:  
 2882:                 if (length == 4)
 2883:                 {
 2884:                     for (int i = 0; i < 10000; i++)
 2885:                     {
 2886:                         n = domain * 10000 + i;
 2887:  
 2888:                         list.Add(n);
 2889:                     }
 2890:                 }
 2891:                 else if (length == 5)
 2892:                 {
 2893:                     for (int p = 0; p < 1000; p++)
 2894:                     {
 2895:                         n = domain * 1000 + p;
 2896:  
 2897:                         list.Add(n);
 2898:                     }
 2899:                 }
 2900:                 else
 2901:                 {
 2902:                     throw new Exception("length " + length + " is unknown");
 2903:                 }
 2904:             }
 2905:  
 2906:             return list;
 2907:         }
 2908:  
 2909:         ////////////////////////////////////////////////////////////////////////////    
 2910:         ////////////////////////////////////////////////////////////////////////////
 2911:  
 2912:         /// <summary>
 2913:         ///
 2914:         /// </summary>
 2915:         public static List<int> AllPossibleServiceNumberWithinAHuaweiSwitchRouterThatHasANokiaAccessOlt()
 2916:         {
 2917:             int n, length;
 2918:             string s;
 2919:  
 2920:             var domainList = HuaweiSwitchNokiaAccessDomainList;
 2921:  
 2922:             var list = new List<int>(10000 * domainList.Count);
 2923:  
 2924:             foreach (int domain in domainList)
 2925:             {
 2926:                 s = domain.ToString();
 2927:  
 2928:                 length = s.Length;
 2929:  
 2930:                 if (length == 4)
 2931:                 {
 2932:                     for (int i = 0; i < 10000; i++)
 2933:                     {
 2934:                         n = domain * 10000 + i;
 2935:  
 2936:                         list.Add(n);
 2937:                     }
 2938:                 }
 2939:                 else if (length == 5)
 2940:                 {
 2941:                     for (int p = 0; p < 1000; p++)
 2942:                     {
 2943:                         n = domain * 1000 + p;
 2944:  
 2945:                         list.Add(n);
 2946:                     }
 2947:                 }
 2948:                 else
 2949:                 {
 2950:                     throw new Exception("length " + length + " is unknown");
 2951:                 }
 2952:             }
 2953:  
 2954:             list.Sort();
 2955:  
 2956:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 2957:         }
 2958:  
 2959:         ////////////////////////////////////////////////////////////////////////////
 2960:  
 2961:         /// <summary>
 2962:         ///
 2963:         /// </summary>
 2964:         public static List<int> AllPossibleServiceNumberWithinSoftX()
 2965:         {
 2966:             int n, length;
 2967:             string s;
 2968:  
 2969:             var domainList = SoftXDomainList;
 2970:  
 2971:             var list = new List<int>(10000 * domainList.Count);
 2972:  
 2973:             foreach (int domain in domainList)
 2974:             {
 2975:                 s = domain.ToString();
 2976:  
 2977:                 length = s.Length;
 2978:  
 2979:                 if (length == 4)
 2980:                 {
 2981:                     for (int i = 0; i < 10000; i++)
 2982:                     {
 2983:                         n = domain * 10000 + i;
 2984:  
 2985:                         list.Add(n);
 2986:                     }
 2987:                 }
 2988:                 else if (length == 5)
 2989:                 {
 2990:                     for (int p = 0; p < 1000; p++)
 2991:                     {
 2992:                         n = domain * 1000 + p;
 2993:  
 2994:                         list.Add(n);
 2995:                     }
 2996:                 }
 2997:                 else
 2998:                 {
 2999:                     throw new Exception("length " + length + " is unknown");
 3000:                 }
 3001:             }
 3002:  
 3003:             list.Sort();
 3004:  
 3005:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 3006:         }
 3007:  
 3008:         ////////////////////////////////////////////////////////////////////////////
 3009:  
 3010:         /// <summary>
 3011:         ///
 3012:         /// </summary>
 3013:         public static List<int> AllPossibleServiceNumbersWithinSite(string siteName)
 3014:         {
 3015:             int n, length;
 3016:             string s;
 3017:  
 3018:             var domainList = (from r in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList
 3019:                               where r.Site.Name == siteName
 3020:                               select r).SelectMany(r => r.DomainList).ToList();
 3021:  
 3022:             var list = new List<int>(10000 * domainList.Count);
 3023:  
 3024:             foreach (int domain in domainList)
 3025:             {
 3026:                 s = domain.ToString();
 3027:  
 3028:                 length = s.Length;
 3029:  
 3030:                 if (length == 4)
 3031:                 {
 3032:                     for (int i = 0; i < 10000; i++)
 3033:                     {
 3034:                         n = domain * 10000 + i;
 3035:  
 3036:                         list.Add(n);
 3037:                     }
 3038:                 }
 3039:                 else if (length == 5)
 3040:                 {
 3041:                     for (int p = 0; p < 1000; p++)
 3042:                     {
 3043:                         n = domain * 1000 + p;
 3044:  
 3045:                         list.Add(n);
 3046:                     }
 3047:                 }
 3048:                 else
 3049:                 {
 3050:                     throw new Exception("length " + length + " is unknown");
 3051:                 }
 3052:             }
 3053:  
 3054:             list.Sort();
 3055:  
 3056:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 3057:         }
 3058:  
 3059:         ////////////////////////////////////////////////////////////////////////////
 3060:  
 3061:         /// <summary>
 3062:         ///
 3063:         /// </summary>
 3064:         public static List<int> AllPossibleServiceNumbersWithinPstn(string pstnName)
 3065:         {
 3066:             int n, length;
 3067:             string s;
 3068:  
 3069:             var domainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 3070:                               where p.Name == pstnName
 3071:                               select p).SelectMany(r => r.DomainList).ToList();
 3072:  
 3073:             var list = new List<int>(10000 * domainList.Count);
 3074:  
 3075:             foreach (int domain in domainList)
 3076:             {
 3077:                 s = domain.ToString();
 3078:  
 3079:                 length = s.Length;
 3080:  
 3081:                 if (length == 4)
 3082:                 {
 3083:                     for (int i = 0; i < 10000; i++)
 3084:                     {
 3085:                         n = domain * 10000 + i;
 3086:  
 3087:                         list.Add(n);
 3088:                     }
 3089:                 }
 3090:                 else if (length == 5)
 3091:                 {
 3092:                     for (int p = 0; p < 1000; p++)
 3093:                     {
 3094:                         n = domain * 1000 + p;
 3095:  
 3096:                         list.Add(n);
 3097:                     }
 3098:                 }
 3099:                 else
 3100:                 {
 3101:                     throw new Exception("length " + length + " is unknown");
 3102:                 }
 3103:             }
 3104:  
 3105:             list.Sort();
 3106:  
 3107:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 3108:         }
 3109:  
 3110:         ////////////////////////////////////////////////////////////////////////////
 3111:  
 3112:         /// <summary>
 3113:         ///
 3114:         /// </summary>
 3115:         public static List<int> AllPossibleServiceNumbersWithinLegacyPstn(string pstnName)
 3116:         {
 3117:             int n, length;
 3118:             string s;
 3119:  
 3120:             var domainList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList
 3121:                               where p.Name == pstnName
 3122:                               select p).SelectMany(r => r.DomainList).ToList();
 3123:  
 3124:             var list = new List<int>(10000 * domainList.Count);
 3125:  
 3126:             foreach (int domain in domainList)
 3127:             {
 3128:                 s = domain.ToString();
 3129:  
 3130:                 length = s.Length;
 3131:  
 3132:                 if (length == 4)
 3133:                 {
 3134:                     for (int i = 0; i < 10000; i++)
 3135:                     {
 3136:                         n = domain * 10000 + i;
 3137:  
 3138:                         list.Add(n);
 3139:                     }
 3140:                 }
 3141:                 else if (length == 5)
 3142:                 {
 3143:                     for (int p = 0; p < 1000; p++)
 3144:                     {
 3145:                         n = domain * 1000 + p;
 3146:  
 3147:                         list.Add(n);
 3148:                     }
 3149:                 }
 3150:                 else
 3151:                 {
 3152:                     throw new Exception("length " + length + " is unknown");
 3153:                 }
 3154:             }
 3155:  
 3156:             list.Sort();
 3157:  
 3158:             return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
 3159:         }
 3160:  
 3161:         ////////////////////////////////////////////////////////////////////////////
 3162:  
 3163:         /// <summary>
 3164:         ///
 3165:         /// </summary>
 3166:         public static List<string> SiteDomainList(string siteName)
 3167:         {
 3168:             List<int> list;
 3169:             List<string> sList;
 3170:  
 3171:             list = (from r in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList
 3172:                     where r.Site.Name == siteName
 3173:                     select r).SelectMany(r => r.DomainList).ToList();
 3174:  
 3175:             list.Sort();
 3176:  
 3177:             sList = (from n in list select n.ToString()).ToList<string>();
 3178:  
 3179:             return sList;
 3180:         }
 3181:  
 3182:         ////////////////////////////////////////////////////////////////////////////
 3183:  
 3184:         /// <summary>
 3185:         ///
 3186:         /// </summary>
 3187:         public static List<string> SitePstnDomainList(string siteName)
 3188:         {
 3189:             List<int> list;
 3190:             List<string> sList;
 3191:  
 3192:             list = (from r in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 3193:                     where r.Site.Name == siteName
 3194:                     select r).SelectMany(r => r.DomainList).ToList();
 3195:  
 3196:             list.Sort();
 3197:  
 3198:             sList = (from n in list select n.ToString()).ToList<string>();
 3199:  
 3200:             return sList;
 3201:         }
 3202:  
 3203:         ////////////////////////////////////////////////////////////////////////////
 3204:  
 3205:         /// <summary>
 3206:         ///
 3207:         /// </summary>
 3208:         public static bool ServiceListIsWithinSitePstnDomainList(string siteName, List<string> serviceList)
 3209:         {
 3210:             bool b;
 3211:  
 3212:             if (serviceList.Count > 0)
 3213:             {
 3214:                 b = Ia.Ftn.Cl.Models.Data.Service.SitePstnDomainList(siteName).Any(u => serviceList.Any(v => v.StartsWith(u)));
 3215:             }
 3216:             else b = false;
 3217:  
 3218:             return b;
 3219:         }
 3220:  
 3221:         ////////////////////////////////////////////////////////////////////////////
 3222:  
 3223:         /// <summary>
 3224:         ///
 3225:         /// </summary>
 3226:         public static bool ServiceIsWithinPstnDomainList(string service)
 3227:         {
 3228:             bool b;
 3229:  
 3230:             if (!string.IsNullOrEmpty(service))
 3231:             {
 3232:                 b = Ia.Ftn.Cl.Models.Data.Service.PstnDomainList.Any(u => service.StartsWith(u.ToString()));
 3233:             }
 3234:             else b = false;
 3235:  
 3236:             return b;
 3237:         }
 3238:  
 3239:         ////////////////////////////////////////////////////////////////////////////
 3240:  
 3241:         /// <summary>
 3242:         ///
 3243:         /// </summary>
 3244:         public static bool ServiceIsWithinLegacyPstnDomainList(string service)
 3245:         {
 3246:             bool b;
 3247:  
 3248:             if (!string.IsNullOrEmpty(service))
 3249:             {
 3250:                 b = Ia.Ftn.Cl.Models.Data.Service.LegacyPstnDomainList.Any(u => service.StartsWith(u.ToString()));
 3251:             }
 3252:             else b = false;
 3253:  
 3254:             return b;
 3255:         }
 3256:  
 3257:         ////////////////////////////////////////////////////////////////////////////
 3258:  
 3259:         /// <summary>
 3260:         ///
 3261:         /// </summary>
 3262:         public static bool ServiceIsWithinMsanDomainList(string service)
 3263:         {
 3264:             bool b;
 3265:  
 3266:             if (!string.IsNullOrEmpty(service))
 3267:             {
 3268:                 b = Ia.Ftn.Cl.Models.Data.Service.MsanDomainList.Any(u => service.StartsWith(u.ToString()));
 3269:             }
 3270:             else b = false;
 3271:  
 3272:             return b;
 3273:         }
 3274:  
 3275:         ////////////////////////////////////////////////////////////////////////////
 3276:  
 3277:         /// <summary>
 3278:         ///
 3279:         /// </summary>
 3280:         public static bool ServiceListHasANumberThatIsWithinMsanDomainList(List<string> serviceList)
 3281:         {
 3282:             var b = false;
 3283:  
 3284:             foreach (var service in serviceList)
 3285:             {
 3286:                 if (!string.IsNullOrEmpty(service))
 3287:                 {
 3288:                     b = Ia.Ftn.Cl.Models.Data.Service.MsanDomainList.Any(u => service.StartsWith(u.ToString()));
 3289:  
 3290:                     if (b) break;
 3291:                 }
 3292:             }
 3293:  
 3294:             return b;
 3295:         }
 3296:  
 3297:         ////////////////////////////////////////////////////////////////////////////
 3298:  
 3299:         /// <summary>
 3300:         ///
 3301:         /// </summary>
 3302:         public static bool ServiceListHasANumberThatIsWithinPstnDomainList(List<string> serviceList)
 3303:         {
 3304:             bool b;
 3305:  
 3306:             if (serviceList.Count > 0)
 3307:             {
 3308:                 b = Ia.Ftn.Cl.Models.Data.Service.PstnDomainList.Any(u => serviceList.Any(v => v.StartsWith(u.ToString())));
 3309:             }
 3310:             else b = false;
 3311:  
 3312:             return b;
 3313:         }
 3314:  
 3315:         ////////////////////////////////////////////////////////////////////////////
 3316:  
 3317:         /// <summary>
 3318:         ///
 3319:         /// </summary>
 3320:         public static bool ServiceListHasANumberThatIsWithinAxePstnDomainList(List<string> serviceList)
 3321:         {
 3322:             bool b;
 3323:  
 3324:             if (serviceList.Count > 0)
 3325:             {
 3326:                 b = Ia.Ftn.Cl.Models.Data.Service.AxePstnDomainList.Any(u => serviceList.Any(v => v.StartsWith(u.ToString())));
 3327:             }
 3328:             else b = false;
 3329:  
 3330:             return b;
 3331:         }
 3332:  
 3333:         ////////////////////////////////////////////////////////////////////////////
 3334:  
 3335:         /// <summary>
 3336:         ///
 3337:         /// </summary>
 3338:         public static bool ServiceListHasANumberThatIsWithinEwsdPstnDomainList(List<string> serviceList)
 3339:         {
 3340:             bool b;
 3341:  
 3342:             if (serviceList.Count > 0)
 3343:             {
 3344:                 b = Ia.Ftn.Cl.Models.Data.Service.EwsdPstnDomainList.Any(u => serviceList.Any(v => v.StartsWith(u.ToString())));
 3345:             }
 3346:             else b = false;
 3347:  
 3348:             return b;
 3349:         }
 3350:  
 3351:         ////////////////////////////////////////////////////////////////////////////    
 3352:         ////////////////////////////////////////////////////////////////////////////    
 3353:  
 3354:         /// <summary>
 3355:         ///
 3356:         /// </summary>
 3357:         public static List<string> ActiveServiceRequestServiceNumbersWithinDomainList(string domain)
 3358:         {
 3359:             List<string> list;
 3360:  
 3361:             using (var db = new Ia.Ftn.Cl.Db())
 3362:             {
 3363:                 list = (from srs in db.ServiceRequestServices
 3364:                         where /*srs.ServiceType == 1 &&*/ srs.Service.StartsWith(domain) && srs.Provisioned == true
 3365:                         select srs.Service).AsNoTracking().ToList();
 3366:             }
 3367:  
 3368:             return list;
 3369:         }
 3370:  
 3371:         ////////////////////////////////////////////////////////////////////////////    
 3372:  
 3373:         /// <summary>
 3374:         ///
 3375:         /// </summary>
 3376:         public static List<string> ActiveServiceNumbersWithinDomainList(string domain)
 3377:         {
 3378:             List<string> list;
 3379:  
 3380:             using (var db = new Ia.Ftn.Cl.Db())
 3381:             {
 3382:                 list = (from s in db.Service2
 3383:                             //where /*s.ServiceType == Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService &&*/ s.Service.StartsWith(domain)
 3384:                         select s.Service).AsNoTracking().ToList();
 3385:             }
 3386:  
 3387:             return list;
 3388:         }
 3389:  
 3390:         ////////////////////////////////////////////////////////////////////////////
 3391:  
 3392:         /// <summary>
 3393:         ///
 3394:         /// </summary>
 3395:         public static List<string> InactiveServiceRequestServiceNumbersWithinDomainList(string domain)
 3396:         {
 3397:             List<int> possibleServiceList;
 3398:             List<string> serviceList, inactiveServiceList;
 3399:  
 3400:             serviceList = ActiveServiceRequestServiceNumbersWithinDomainList(domain);
 3401:  
 3402:             possibleServiceList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 3403:  
 3404:             inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 3405:  
 3406:             // below: extract numbers within possible but not in serviceList
 3407:             foreach (int i in possibleServiceList)
 3408:             {
 3409:                 if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 3410:             }
 3411:  
 3412:             return inactiveServiceList;
 3413:         }
 3414:  
 3415:         ////////////////////////////////////////////////////////////////////////////
 3416:  
 3417:         /// <summary>
 3418:         ///
 3419:         /// </summary>
 3420:         public static List<string> InactiveServiceNumbersWithinDomainList(string domain)
 3421:         {
 3422:             List<int> possibleServiceList;
 3423:             List<string> serviceList, inactiveServiceList;
 3424:  
 3425:             serviceList = ActiveServiceNumbersWithinDomainList(domain);
 3426:  
 3427:             possibleServiceList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 3428:  
 3429:             inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 3430:  
 3431:             // below: extract numbers within possible but not in serviceList
 3432:             foreach (int i in possibleServiceList)
 3433:             {
 3434:                 if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 3435:             }
 3436:  
 3437:             return inactiveServiceList;
 3438:         }
 3439:  
 3440:         ////////////////////////////////////////////////////////////////////////////
 3441:  
 3442:         /// <summary>
 3443:         ///
 3444:         /// </summary>
 3445:         public static List<string> ServicePbxList
 3446:         {
 3447:             get
 3448:             {
 3449:                 List<string> list, nokiaPbxList, huaweiPbxList;
 3450:  
 3451:                 nokiaPbxList = Ia.Ftn.Cl.Models.Data.Nokia.SubParty.ServicePbxList();
 3452:                 huaweiPbxList = Ia.Ftn.Cl.Models.Data.Huawei.Sbr.ServicePbxList();
 3453:  
 3454:                 list = nokiaPbxList.Concat(huaweiPbxList).ToList();
 3455:  
 3456:                 return list;
 3457:             }
 3458:         }
 3459:  
 3460:         ////////////////////////////////////////////////////////////////////////////
 3461:         ////////////////////////////////////////////////////////////////////////////
 3462:  
 3463:         /// <summary>
 3464:         ///
 3465:         /// </summary>
 3466:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt> AllowedToBeProvisionedOltList
 3467:         {
 3468:             get
 3469:             {
 3470:                 return Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.GreenFieldOltList.Union(AllowedToBeMigratedOltList).ToList();
 3471:             }
 3472:         }
 3473:  
 3474:         ////////////////////////////////////////////////////////////////////////////
 3475:  
 3476:         /// <summary>
 3477:         ///
 3478:         /// </summary>
 3479:         public static List<int> AllowedToBeProvisionedOltIdList
 3480:         {
 3481:             get
 3482:             {
 3483:                 return Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.GreenFieldOltIdList.Union(AllowedToBeMigratedOltIdList).ToList();
 3484:             }
 3485:         }
 3486:  
 3487:         ////////////////////////////////////////////////////////////////////////////
 3488:  
 3489:         /// <summary>
 3490:         ///
 3491:         /// </summary>
 3492:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt> AllowedToBeProvisionedSipOltList
 3493:         {
 3494:             get
 3495:             {
 3496:                 return Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.GreenFieldSipOltList.Union(AllowedToBeMigratedSipOltList).ToList();
 3497:             }
 3498:         }
 3499:  
 3500:         ////////////////////////////////////////////////////////////////////////////
 3501:  
 3502:         /// <summary>
 3503:         ///
 3504:         /// </summary>
 3505:         public static List<int> AllowedToBeProvisionedSipOltIdList
 3506:         {
 3507:             get
 3508:             {
 3509:                 return Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.GreenFieldSipOltIdList.Union(AllowedToBeMigratedSipOltIdList).ToList();
 3510:             }
 3511:         }
 3512:  
 3513:         ////////////////////////////////////////////////////////////////////////////
 3514:         ////////////////////////////////////////////////////////////////////////////
 3515:  
 3516:         /// <summary>
 3517:         ///
 3518:         /// </summary>
 3519:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt> AllowedToBeMigratedOltList
 3520:         {
 3521:             get
 3522:             {
 3523:                 return (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 3524:                         where Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) || Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => o.PonGroupList.Any(pg => pg.Symbol == u))
 3525:                         select o).ToList();
 3526:             }
 3527:         }
 3528:  
 3529:         ////////////////////////////////////////////////////////////////////////////
 3530:  
 3531:         /// <summary>
 3532:         ///
 3533:         /// </summary>
 3534:         public static List<int> AllowedToBeMigratedOltIdList
 3535:         {
 3536:             get
 3537:             {
 3538:                 return (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 3539:                         where Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) || Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => o.PonGroupList.Any(pg => pg.Symbol == u))
 3540:                         select o.Id).ToList();
 3541:             }
 3542:         }
 3543:  
 3544:         ////////////////////////////////////////////////////////////////////////////
 3545:  
 3546:         /// <summary>
 3547:         ///
 3548:         /// </summary>
 3549:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt> AllowedToBeMigratedSipOltList
 3550:         {
 3551:             get
 3552:             {
 3553:                 return (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 3554:                         where o.IsSip == true && (Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) || Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => o.PonGroupList.Any(pg => pg.Symbol == u)))
 3555:                         select o).ToList();
 3556:             }
 3557:         }
 3558:  
 3559:         ////////////////////////////////////////////////////////////////////////////
 3560:  
 3561:         /// <summary>
 3562:         ///
 3563:         /// </summary>
 3564:         public static List<int> AllowedToBeMigratedSipOltIdList
 3565:         {
 3566:             get
 3567:             {
 3568:                 return (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
 3569:                         where o.IsSip == true && (Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) || Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => o.PonGroupList.Any(pg => pg.Symbol == u)))
 3570:                         select o.Id).ToList();
 3571:             }
 3572:         }
 3573:  
 3574:         ////////////////////////////////////////////////////////////////////////////
 3575:  
 3576:         /// <summary>
 3577:         ///
 3578:         /// </summary>
 3579:         public static Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> AllowedToBeMigratedAccessIdToOntDictionary
 3580:         {
 3581:             get
 3582:             {
 3583:                 Dictionary<string, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> dictionary;
 3584:  
 3585:                 var list = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntList
 3586:                             where Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Pon.PonGroup.Olt.Symbol) || Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Pon.PonGroup.Symbol)
 3587:                             select o).ToList();
 3588:  
 3589:                 dictionary = list.ToDictionary(u => u.Access.Id, u => u);
 3590:  
 3591:                 return dictionary;
 3592:             }
 3593:         }
 3594:  
 3595:         ////////////////////////////////////////////////////////////////////////////
 3596:  
 3597:         /// <summary>
 3598:         ///
 3599:         /// </summary>
 3600:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pstn> AllowedToBeMigratedAxePstnList
 3601:         {
 3602:             get
 3603:             {
 3604:                 var list = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 3605:                             join o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList on p.Site equals o.Odf.Router.Site
 3606:                             where Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) && p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe
 3607:                             select p).Distinct().ToList();
 3608:  
 3609:                 return list;
 3610:             }
 3611:         }
 3612:  
 3613:         ////////////////////////////////////////////////////////////////////////////
 3614:  
 3615:         /// <summary>
 3616:         ///
 3617:         /// </summary>
 3618:         public static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pstn> AllowedToBeMigratedEwsdPstnList
 3619:         {
 3620:             get
 3621:             {
 3622:                 var list = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList
 3623:                             join o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList on p.Site equals o.Odf.Router.Site
 3624:                             where Ia.Ftn.Cl.Models.Business.Service.AllowedToBeMigratedOltSymbolList.Any(u => u == o.Symbol) && p.PstnExchangeType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd
 3625:                             select p).Distinct().ToList();
 3626:  
 3627:                 return list;
 3628:             }
 3629:         }
 3630:  
 3631:         ////////////////////////////////////////////////////////////////////////////
 3632:         ////////////////////////////////////////////////////////////////////////////
 3633:  
 3634:         /// <summary>
 3635:         ///
 3636:         /// </summary>
 3637:         public static List<string> ServiceNotInServiceRequestServiceList()
 3638:         {
 3639:             string s;
 3640:             List<string> list;
 3641:  
 3642:             var allPossibleServiceNumberList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberList;
 3643:  
 3644:             var serviceRequestServiceServiceDictionary = Ia.Ftn.Cl.Models.Data.ServiceRequestService.ServiceDictionary();
 3645:  
 3646:             list = new List<string>(allPossibleServiceNumberList.Count);
 3647:  
 3648:             foreach (var i in allPossibleServiceNumberList)
 3649:             {
 3650:                 s = i.ToString();
 3651:  
 3652:                 if (!serviceRequestServiceServiceDictionary.ContainsKey(s))
 3653:                 {
 3654:                     /*if (i > Ia.Ftn.Cl.Model.Business.Service.TemporaryProcedureToIndicateWhereTheLastReadNumberFromOracleDatabaseBecauseListIsTooLongToRepeatHahaha)*/
 3655:                     list.Add(s);
 3656:                 }
 3657:             }
 3658:  
 3659:             return list.OrderBy(u => u).ToList();
 3660:         }
 3661:  
 3662:         ////////////////////////////////////////////////////////////////////////////    
 3663:  
 3664:         /// <summary>
 3665:         ///
 3666:         /// </summary>
 3667:         public static string SequentialAllPossibleServiceNumberList(ref int referenceIndex, out int itemIndex, out int listCount)
 3668:         {
 3669:             int service;
 3670:  
 3671:             if (serviceList.JustStartedOrRolledOver())
 3672:             {
 3673:                 serviceList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberList;
 3674:  
 3675:                 // below: temp to quickly go through specific domains
 3676:                 /*
 3677:                 serviceList = (from s in serviceList
 3678:                                where s.ToString().StartsWith("2361") || s.ToString().StartsWith("2362") || s.ToString().StartsWith("2391") || s.ToString().StartsWith("2392")
 3679:                                select s).ToList();
 3680:                 */
 3681:             }
 3682:  
 3683:             service = serviceList.Next(ref referenceIndex, out itemIndex, out listCount);
 3684:  
 3685:             return service.ToString();
 3686:         }
 3687:  
 3688:         ////////////////////////////////////////////////////////////////////////////    
 3689:  
 3690:         /// <summary>
 3691:         ///
 3692:         /// </summary>
 3693:         public static List<string> NumbersWithinEmsOntSipInfoAndEmsVoipPstnUserThatDoNotBelongToListOfAllPossibleNetworkNumbers()
 3694:         {
 3695:             var allPossibleServiceNumberList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberList;
 3696:             //var s2 = Ia.Ftn.Cl.Model.Data.Service.AllPossiblePstnServiceNumberList;
 3697:             //var s3 = Ia.Ftn.Cl.Model.Data.Service.AllPossibleMsanServiceNumberList;
 3698:  
 3699:             //var v = allPossibleServiceNumberList;//.Union(s2).Union(s3).ToList();
 3700:             var allPossibleServiceList = allPossibleServiceNumberList.ConvertAll(delegate (int i) { return i.ToString(); });
 3701:  
 3702:             var ontSipInfoServiceList = Ia.Ftn.Cl.Models.Data.Huawei.OntSipInfo.ServiceList();
 3703:             var voipPstnUserServiceList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ServiceList();
 3704:             var ontSipInfoAndVoipPstnUserServiceList = ontSipInfoServiceList.Union(voipPstnUserServiceList).ToList();
 3705:  
 3706:             var list = ontSipInfoAndVoipPstnUserServiceList.Except(allPossibleServiceList).ToList();
 3707:  
 3708:             return list;
 3709:         }
 3710:  
 3711:         ////////////////////////////////////////////////////////////////////////////
 3712:         ////////////////////////////////////////////////////////////////////////////
 3713:  
 3714:         /// <summary>
 3715:         ///
 3716:         /// </summary>
 3717:         public static Ia.Ftn.Cl.Models.Business.Service.ServiceType ServiceType(int typeId)
 3718:         {
 3719:             return (from s in Ia.Ftn.Cl.Models.Data.Service.ServiceTypeList where s.Id == typeId select s).SingleOrDefault();
 3720:         }
 3721:  
 3722:         ////////////////////////////////////////////////////////////////////////////
 3723:  
 3724:         /// <summary>
 3725:         ///
 3726:         /// </summary>
 3727:         public static string ServiceTypeNameFromId(int id)
 3728:         {
 3729:             return (from s in Ia.Ftn.Cl.Models.Data.Service.ServiceTypeList where s.Id == id select s.Name).SingleOrDefault();
 3730:         }
 3731:  
 3732:         ////////////////////////////////////////////////////////////////////////////
 3733:  
 3734:         /// <summary>
 3735:         ///
 3736:         /// </summary>
 3737:         public static List<Ia.Ftn.Cl.Models.Business.Service.ServiceType> ServiceTypeList
 3738:         {
 3739:             get
 3740:             {
 3741:                 if (serviceTypeList == null || serviceTypeList.Count == 0)
 3742:                 {
 3743:                     serviceTypeList = new List<Ia.Ftn.Cl.Models.Business.Service.ServiceType>();
 3744:  
 3745:                     serviceTypeList = new List<Ia.Ftn.Cl.Models.Business.Service.ServiceType>
 3746:                     {
 3747:                         // DO NOT CHANGE "Ims" and "Pstn" values, they will effect class ServiceType values
 3748:                         new Ia.Ftn.Cl.Models.Business.Service.ServiceType(0, "Undefined", "Undefined (غير معرف)", "red"),
 3749:                         new Ia.Ftn.Cl.Models.Business.Service.ServiceType(1, "Ims", "Digital (رقمي)", "fiber-blue"),
 3750:                         new Ia.Ftn.Cl.Models.Business.Service.ServiceType(2, "Pstn", "Copper (نحاس)", "copper-brown"),
 3751:                     };
 3752:  
 3753:                     /*
 3754:                     /// 0:IMSSIPUE(IMSSIPUSER): The subscriber is an IMS SIP-UE subscriber.
 3755:                     /// 1:POTS(POTSUSER): The subscriber is a SIP subscriber connected to the SIPIAD of the AGCF.
 3756:                     /// 4:G/U(GUUSER): The subscriber is a G/U subscriber.
 3757:                     /// 5:CDMA(CDMAUSER): The subscriber is a CDMA subscriber.
 3758:                     /// 6:PSTN(PSTNUSER): The subscriber is a PSTN subscriber.
 3759: 
 3760:                     <type id="0" name="?"/>
 3761:                     <type id="1" name="DN" Idlike="25212254:1:965"/>
 3762:                     <type id="2" name="HSI" Idlike="SLA.82.13.1.2:2:965 SLA.PON.ONT.CARD.PORT"/>
 3763:                     <type id="3" name="CDMA"/>
 3764:                     <type id="4" name="G/U"/>
 3765:                     <type id="5" name="POTS"/>
 3766:                     <type id="6" name="PSTN"/>
 3767:                      */
 3768:                 }
 3769:  
 3770:                 return serviceTypeList.ToList();
 3771:             }
 3772:         }
 3773:  
 3774:         ////////////////////////////////////////////////////////////////////////////
 3775:  
 3776:         /// <summary>
 3777:         /// 
 3778:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 3779:         /// 
 3780:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 3781:         /// 2. Add "using System.Reflection".
 3782:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
 3783:         /// 
 3784:         /// </summary>
 3785:  
 3786:         private static XDocument XDocument
 3787:         {
 3788:             get
 3789:             {
 3790:                 if (xDocument == null)
 3791:                 {
 3792:                     lock (objectLock)
 3793:                     {
 3794:                         Assembly assembly;
 3795:                         StreamReader streamReader;
 3796:  
 3797:                         assembly = Assembly.GetExecutingAssembly();
 3798:                         streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Ftn.Cl.Models.Data.service.xml"));
 3799:  
 3800:                         try
 3801:                         {
 3802:                             if (streamReader.Peek() != -1)
 3803:                             {
 3804:                                 xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 3805:                             }
 3806:                         }
 3807:                         catch (Exception)
 3808:                         {
 3809:                         }
 3810:                         finally
 3811:                         {
 3812:                         }
 3813:                     }
 3814:                 }
 3815:  
 3816:                 return xDocument;
 3817:             }
 3818:         }
 3819:  
 3820:         ////////////////////////////////////////////////////////////////////////////    
 3821:         ////////////////////////////////////////////////////////////////////////////
 3822:     }
 3823:  
 3824:     ////////////////////////////////////////////////////////////////////////////
 3825:     ////////////////////////////////////////////////////////////////////////////   
 3826: }