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