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