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

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

Service support class of Fixed Telecommunications Network (FTN) business model.

    1: using Microsoft.EntityFrameworkCore.Metadata.Internal;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.Linq;
    5: using System.Runtime.Serialization;
    6: using System.Text.RegularExpressions;
    7:  
    8: namespace Ia.Ftn.Cl.Models.Business
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Service support class of Fixed Telecommunications Network (FTN) business model.
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   18:     /// </remarks> 
   19:     public class Service
   20:     {
   21:         private static int sequentialQueueOriginalCount;
   22:         private static Queue<string> sequentialQueue = new Queue<string>();
   23:  
   24:         //public static readonly int TemporaryProcedureToIndicateWhereTheLastReadNumberFromOracleDatabaseBecauseListIsTooLongToRepeatHahaha = 25667698;
   25:  
   26:         /// <summary/>
   27:         public static int CountryCode { get { return 965; } }
   28:  
   29:         /// <summary/>
   30:         public static List<string> SymbolDomainSameSwitchVendorButDifferentSiteExceptionList
   31:         {
   32:             get
   33:             {
   34:                 var list = new List<string>() { "2390@FNT", "2521@SMC", "2522@SMC", "2523@SMC", "2524@SMC", "2371@ABH", "2372@ABH" };
   35:  
   36:                 return list;
   37:             }
   38:         }
   39:  
   40:         /// <summary/>
   41:         public static List<string> AllowedToBeMigratedOltSymbolList
   42:         {
   43:             get
   44:             {
   45:                 var list = new List<string>() { "EGL", "SAB", "COB", "FNT", "BYN", "MSF", "MBA", "MHL", "MAH", "SSB", "MGF", "ADN", "QSR", "MUB", "QRN", "SMC", "WAH", "NAS", "AGI", "FHH", "ABH" };
   46:  
   47:                 list.Sort();
   48:  
   49:                 return list;
   50:             }
   51:         }
   52:  
   53:         /// <summary/>
   54:         public enum SupplementaryService
   55:         {
   56:             // see SupplementaryServiceArabicDictionary
   57:             CallerId = 1, InternationalCalling, InternationalCallingUserControlled, CallForwarding, CallWaiting, ConferenceCall, WakeupCall, AbbriviatedCalling, ServiceSuspension
   58:         };
   59:  
   60:         /// <summary/>
   61:         public static Dictionary<SupplementaryService, string> SupplementaryServiceArabicDictionary = new Dictionary<SupplementaryService, string>()
   62:         {
   63:             // see SupplementaryService
   64:             { SupplementaryService.CallerId, "كاشف"},
   65:             { SupplementaryService.InternationalCalling, "صفر دولي"},
   66:             { SupplementaryService.InternationalCallingUserControlled, "تحكم بصفر دولي"},
   67:             { SupplementaryService.CallForwarding, "تحويل"},
   68:             { SupplementaryService.CallWaiting, "انتظار"},
   69:             { SupplementaryService.ConferenceCall, "ثلاثي"},
   70:             { SupplementaryService.WakeupCall, "إيقاظ"},
   71:             { SupplementaryService.AbbriviatedCalling, "اختصار"},
   72:             { SupplementaryService.ServiceSuspension, "إيقاف"},
   73:  
   74:         };
   75:  
   76:         /// <summary/>
   77:         public struct HundredsSubdomain
   78:         {
   79:             /// <summary/>
   80:             public HundredsSubdomain(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Router router, int subdomain)
   81:             {
   82:                 this.Id = router.Id.ToString() + "-" + subdomain.ToString();
   83:                 this.RouterId = router.Id;
   84:                 this.PstnId = 0;
   85:                 this.Subdomain = subdomain;
   86:  
   87:                 Ia.Ftn.Cl.Models.Data.Service.FirstAndLastServiceNumbersWithinDomain(subdomain, out int firstServiceNumber, out int lastServiceNumber);
   88:  
   89:                 this.FirstServiceNumber = firstServiceNumber;
   90:                 this.LastServiceNumber = lastServiceNumber;
   91:             }
   92:  
   93:             /// <summary/>
   94:             public HundredsSubdomain(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pstn pstn, int subdomain)
   95:             {
   96:                 this.Id = pstn.Id.ToString() + "-" + subdomain.ToString();
   97:  
   98:                 this.RouterId = 0;
   99:                 this.PstnId = pstn.Id;
  100:                 this.Subdomain = subdomain;
  101:  
  102:                 Ia.Ftn.Cl.Models.Data.Service.FirstAndLastServiceNumbersWithinDomain(subdomain, out int firstServiceNumber, out int lastServiceNumber);
  103:  
  104:                 this.FirstServiceNumber = firstServiceNumber;
  105:                 this.LastServiceNumber = lastServiceNumber;
  106:             }
  107:  
  108:             /// <summary/>
  109:             public HundredsSubdomain(string service)
  110:             {
  111:                 this.Id = string.Empty;
  112:                 this.RouterId = 0;
  113:                 this.PstnId = 0;
  114:                 this.Subdomain = 0;
  115:                 this.FirstServiceNumber = 0;
  116:                 this.LastServiceNumber = 0;
  117:  
  118:                 if (!string.IsNullOrEmpty(service))
  119:                 {
  120:                     if (int.TryParse(service, out int number))
  121:                     {
  122:                         var routerList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList;
  123:                         this.RouterId = (from r in routerList where r.DomainList.Any(u => service.StartsWith(u.ToString())) select r.Id).FirstOrDefault();
  124:  
  125:                         var legacyPstnList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.LegacyPstnList;
  126:                         this.PstnId = (from o in legacyPstnList where o.DomainList.Any(u => service.StartsWith(u.ToString())) select o.Id).FirstOrDefault();
  127:  
  128:                         var subdomainList = Ia.Ftn.Cl.Models.Data.Service.HundredsSubdomainList;
  129:                         var subdomain = (from s in subdomainList where service.StartsWith(s.ToString()) select s).FirstOrDefault();
  130:  
  131:                         this.Subdomain = subdomain;
  132:  
  133:                         Ia.Ftn.Cl.Models.Data.Service.FirstAndLastServiceNumbersWithinDomain(subdomain, out int firstServiceNumber, out int lastServiceNumber);
  134:  
  135:                         this.FirstServiceNumber = firstServiceNumber;
  136:                         this.LastServiceNumber = lastServiceNumber;
  137:                     }
  138:                 }
  139:             }
  140:  
  141:             /// <summary/>
  142:             public string Id { get; }
  143:  
  144:             /// <summary/>
  145:             public int RouterId { get; }
  146:  
  147:             /// <summary/>
  148:             public int PstnId { get; }
  149:  
  150:             /// <summary/>
  151:             public int Subdomain { get; }
  152:  
  153:             /// <summary/>
  154:             public int FirstServiceNumber { get; }
  155:  
  156:             /// <summary/>
  157:             public int LastServiceNumber { get; }
  158:  
  159:             /// <summary/>
  160:             public Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Router Router
  161:             {
  162:                 get
  163:                 {
  164:                     var routerId = this.RouterId;
  165:  
  166:                     var router = (from r in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.RouterList where r.Id == routerId select r).SingleOrDefault();
  167:  
  168:                     return router;
  169:                 }
  170:             }
  171:  
  172:             /// <summary/>
  173:             public Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pstn Pstn
  174:             {
  175:                 get
  176:                 {
  177:                     var pstnId = this.PstnId;
  178:  
  179:                     var pstn = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PstnList where p.Id == pstnId select p).SingleOrDefault();
  180:  
  181:                     return pstn;
  182:                 }
  183:             }
  184:  
  185:         }
  186:  
  187:         ////////////////////////////////////////////////////////////////////////////
  188:  
  189:         /// <summary>
  190:         ///
  191:         /// </summary>
  192:         public class ServiceSupplementaryService
  193:         {
  194:             /// <summary/>
  195:             public int Service { get; set; }
  196:  
  197:             /// <summary/>
  198:             public string Pin { get; set; }
  199:  
  200:             /// <summary/>
  201:             public bool SubscriberHasPin { get; set; }
  202:  
  203:             /// <summary/>
  204:             public bool InternationalCallingUserControlledActivated { get; set; }
  205:  
  206:             /// <summary/>
  207:             public bool ServiceAdministrativelySuspendedByBillingDepartment { get; set; }
  208:  
  209:             /// <summary/>
  210:             public bool ServiceAdministrativelySuspendedForOtherReasons { get; set; }
  211:  
  212:             /// <summary/>
  213:             public bool IsPbx { get; set; }
  214:  
  215:             /// <summary/>
  216:             public List<Ia.Ftn.Cl.Models.Business.Service.SupplementaryService> SupplementaryServiceList { get; set; }
  217:  
  218:             /// <summary/>
  219:             public ServiceSupplementaryService()
  220:             {
  221:                 this.Service = 0;
  222:                 this.Pin = string.Empty;
  223:                 this.SubscriberHasPin = false;
  224:                 this.InternationalCallingUserControlledActivated = false;
  225:                 this.ServiceAdministrativelySuspendedByBillingDepartment = false;
  226:                 this.ServiceAdministrativelySuspendedForOtherReasons = false;
  227:                 this.IsPbx = false;
  228:  
  229:                 this.SupplementaryServiceList = new List<Ia.Ftn.Cl.Models.Business.Service.SupplementaryService>();
  230:             }
  231:         }
  232:  
  233:         ////////////////////////////////////////////////////////////////////////////
  234:  
  235:         /// <summary>
  236:         ///
  237:         /// </summary>
  238:         public class ServiceType
  239:         {
  240:             /// <summary/>
  241:             public int Id { get; set; }
  242:  
  243:             /// <summary/>
  244:             public string Name { get; set; }
  245:  
  246:             /// <summary/>
  247:             public string NameArabicName { get; set; }
  248:  
  249:             /// <summary/>
  250:             public string Color { get; set; }
  251:  
  252:             /// <summary/>
  253:             public ServiceType(int id, string name, string nameArabicName, string color)
  254:             {
  255:                 this.Id = id;
  256:                 this.Name = name;
  257:                 this.NameArabicName = nameArabicName;
  258:                 this.Color = color;
  259:             }
  260:  
  261:             /// <summary/>
  262:             public string ColoredNameArabicName
  263:             {
  264:                 get
  265:                 {
  266:                     return @"<span class=""" + this.Color + @""">" + this.NameArabicName + @"</span>";
  267:                 }
  268:             }
  269:  
  270:             /// <summary/>
  271:             public static int ImsService
  272:             {
  273:                 get
  274:                 {
  275:                     return (from s in Ia.Ftn.Cl.Models.Data.Service.ServiceTypeList where s.Name == "Ims" select s.Id).Single();
  276:                 }
  277:             }
  278:  
  279:             /// <summary/>
  280:             public static int PstnService
  281:             {
  282:                 get
  283:                 {
  284:                     return (from s in Ia.Ftn.Cl.Models.Data.Service.ServiceTypeList where s.Name == "Pstn" select s.Id).Single();
  285:                 }
  286:             }
  287:  
  288:             ////////////////////////////////////////////////////////////////////////////
  289:             ////////////////////////////////////////////////////////////////////////////
  290:         }
  291:  
  292:         ////////////////////////////////////////////////////////////////////////////
  293:  
  294:         /// <summary>
  295:         ///
  296:         /// </summary>
  297:         public Service() { }
  298:  
  299:         ////////////////////////////////////////////////////////////////////////////
  300:  
  301:         /// <summary>
  302:         ///
  303:         /// </summary>
  304:         public static string ServiceName(string service, int serviceType)
  305:         {
  306:             string name;
  307:  
  308:             name = service;
  309:  
  310:             if (name == "0") name = string.Empty;
  311:  
  312:             return name;
  313:         }
  314:  
  315:         ////////////////////////////////////////////////////////////////////////////
  316:  
  317:         /// <summary>
  318:         ///
  319:         /// </summary>
  320:         public static string ServiceIdToService(string serviceId)
  321:         {
  322:             string service;
  323:  
  324:             service = serviceId.Substring(0, serviceId.IndexOf(":"));
  325:  
  326:             return service;
  327:         }
  328:  
  329:         ////////////////////////////////////////////////////////////////////////////
  330:  
  331:         /// <summary>
  332:         ///
  333:         /// </summary>
  334:         public static string ServiceToServiceId(string service, int serviceType)
  335:         {
  336:             string serviceId;
  337:  
  338:             serviceId = service + ":" + serviceType + ":" + Ia.Ftn.Cl.Models.Business.Service.CountryCode;
  339:  
  340:             return serviceId;
  341:         }
  342:  
  343:         ////////////////////////////////////////////////////////////////////////////
  344:  
  345:         /// <summary>
  346:         ///
  347:         /// </summary>
  348:         public static int ServiceIdToServiceType(string serviceId)
  349:         {
  350:             int serviceType;
  351:  
  352:             serviceType = int.Parse(serviceId.Substring(serviceId.IndexOf(":") + 1, 1));
  353:  
  354:             return serviceType;
  355:         }
  356:  
  357:         ////////////////////////////////////////////////////////////////////////////   
  358:  
  359:         /// <summary>
  360:         /// 
  361:         /// </summary>
  362:         public static List<string> ServiceListToServiceIdListForAllServiceTypes(List<string> serviceList)
  363:         {
  364:             List<string> serviceIdList;
  365:  
  366:             if (serviceList.Count > 0)
  367:             {
  368:                 serviceIdList = new List<string>();
  369:  
  370:                 foreach (var service in serviceList)
  371:                 {
  372:                     // I will add serviceIds for both IMS and PSTN version of the number
  373:                     var serviceId = Ia.Ftn.Cl.Models.Business.Service2.ServiceId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
  374:                     serviceIdList.Add(serviceId);
  375:  
  376:                     serviceId = Ia.Ftn.Cl.Models.Business.Service2.ServiceId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.PstnService);
  377:                     serviceIdList.Add(serviceId);
  378:                 }
  379:             }
  380:             else serviceIdList = new List<string>();
  381:  
  382:             return serviceIdList.Distinct().ToList();
  383:         }
  384:  
  385:         ////////////////////////////////////////////////////////////////////////////
  386:  
  387:         /// <summary>
  388:         ///
  389:         /// </summary>
  390:         public static bool ServiceHasEightDigits(string service)
  391:         {
  392:             bool isValid;
  393:  
  394:             if (!string.IsNullOrEmpty(service))
  395:             {
  396:                 isValid = Regex.IsMatch(service, @"^\d{8}$");
  397:             }
  398:             else isValid = false;
  399:  
  400:             return isValid;
  401:         }
  402:  
  403:         ////////////////////////////////////////////////////////////////////////////
  404:  
  405:         /// <summary>
  406:         ///
  407:         /// </summary>
  408:         [DataContract(IsReference = true, Namespace = "kw.com.ia.ftn.api.service", Name = "KuwaitFtnArea")]
  409:         public class KuwaitFtnArea
  410:         {
  411:             /// <summary/>
  412:             public KuwaitFtnArea() { }
  413:  
  414:             /// <summary/>
  415:             public KuwaitFtnArea(string name, string arabicName)
  416:             {
  417:                 this.Name = name;
  418:                 this.ArabicName = arabicName;
  419:             }
  420:  
  421:             /// <summary/>
  422:             [DataMember]
  423:             public int Id { get; set; }
  424:  
  425:             /// <summary/>
  426:             [DataMember]
  427:             public string Name { get; set; }
  428:  
  429:             /// <summary/>
  430:             [DataMember]
  431:             public string ArabicName { get; set; }
  432:  
  433:             /// <summary/>
  434:             [DataMember]
  435:             public string NameArabicName
  436:             {
  437:                 get
  438:                 {
  439:                     return Name + " (" + ArabicName + ")";
  440:                 }
  441:             }
  442:  
  443:             /// <summary/>
  444:             [DataMember]
  445:             public string Symbol { get; set; }
  446:  
  447:             /// <summary/>
  448:             [DataMember]
  449:             public string ServiceRequestAddressProvinceAreaName { get; set; }
  450:  
  451:             /// <summary/>
  452:             public virtual List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site> SiteList { get; set; }
  453:         }
  454:  
  455:         ////////////////////////////////////////////////////////////////////////////
  456:  
  457:         /// <summary>
  458:         ///
  459:         /// </summary>
  460:         public static List<int> SelectListOfNumbersWithinAllowedDomainList(List<int> inNumberList)
  461:         {
  462:             string numberString;
  463:             List<int> numberList;
  464:  
  465:             if (inNumberList.Count > 0)
  466:             {
  467:                 numberList = new List<int>(inNumberList.Count);
  468:  
  469:                 foreach (int i in inNumberList)
  470:                 {
  471:                     numberString = i.ToString();
  472:  
  473:                     if (ServiceHasEightDigitsAndIsWithinAllowedDomainList(numberString)) numberList.Add(i);
  474:                 }
  475:             }
  476:             else numberList = new List<int>();
  477:  
  478:             return numberList;
  479:         }
  480:  
  481:         ////////////////////////////////////////////////////////////////////////////
  482:  
  483:         /// <summary>
  484:         ///
  485:         /// </summary>
  486:         public static bool OltIsWithinAllowedToBeProvisionedOltList(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  487:         {
  488:             return Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt);
  489:         }
  490:  
  491:         ////////////////////////////////////////////////////////////////////////////
  492:  
  493:         /// <summary>
  494:         ///
  495:         /// </summary>
  496:         public static bool OltIsWithinAllowedToBeMigratedOltList(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  497:         {
  498:             return Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
  499:         }
  500:  
  501:         ////////////////////////////////////////////////////////////////////////////
  502:  
  503:         /// <summary>
  504:         ///
  505:         /// </summary>
  506:         public static bool OltIdIsWithinAllowedToBeMigratedOltList(int oltId)
  507:         {
  508:             return Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedOltIdList.Contains(oltId);
  509:         }
  510:  
  511:         ////////////////////////////////////////////////////////////////////////////
  512:  
  513:         /// <summary>
  514:         ///
  515:         /// </summary>
  516:         public static bool OltIsWithinAllowedToBeProvisionedOrMigratedOltList(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  517:         {
  518:             return Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt) || Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
  519:         }
  520:  
  521:         ////////////////////////////////////////////////////////////////////////////
  522:  
  523:         /// <summary>
  524:         ///
  525:         /// </summary>
  526:         public static bool AreaSymbolIsWithinAnAllowedOltToBeProvisionedDomainList(string areaSymbol)
  527:         {
  528:             bool b;
  529:  
  530:             if (!string.IsNullOrEmpty(areaSymbol))
  531:             {
  532:                 b = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.Site.AreaSymbolList.Any(u => areaSymbol == u));
  533:             }
  534:             else
  535:             {
  536:                 b = false;
  537:             }
  538:  
  539:             return b;
  540:         }
  541:  
  542:         ////////////////////////////////////////////////////////////////////////////
  543:  
  544:         /// <summary>
  545:         ///
  546:         /// </summary>
  547:         public static bool NumberIsWithinAnAllowedOltToBeProvisionedDomainList(string service)
  548:         {
  549:             bool b;
  550:  
  551:             if (!string.IsNullOrEmpty(service))
  552:             {
  553:                 b = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString())));
  554:             }
  555:             else
  556:             {
  557:                 b = false;
  558:             }
  559:  
  560:             return b;
  561:         }
  562:  
  563:         ////////////////////////////////////////////////////////////////////////////
  564:  
  565:         /// <summary>
  566:         ///
  567:         /// </summary>
  568:         public static List<int> AllowedToBeProvisionedDomainList
  569:         {
  570:             get
  571:             {
  572:                 var list = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltList.SelectMany(v => v.Odf.Router.DomainList).Distinct().ToList();
  573:  
  574:                 list.Sort();
  575:  
  576:                 return list;
  577:             }
  578:         }
  579:  
  580:         ////////////////////////////////////////////////////////////////////////////
  581:  
  582:         /// <summary>
  583:         ///
  584:         /// </summary>
  585:         public static List<int> AllowedToBeMigratedDomainList
  586:         {
  587:             get
  588:             {
  589:                 var list = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedOltList.SelectMany(v => v.Odf.Router.DomainList).Distinct().ToList();
  590:  
  591:                 list.Sort();
  592:  
  593:                 return list;
  594:             }
  595:         }
  596:  
  597:         ////////////////////////////////////////////////////////////////////////////
  598:  
  599:         /// <summary>
  600:         ///
  601:         /// </summary>
  602:         public static List<string> AllowedToBeProvisionedOltSymbolList
  603:         {
  604:             get
  605:             {
  606:                 var allowedToBeProvisionedOltIdList = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedOltIdList;
  607:  
  608:                 var l1 = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  609:                           where allowedToBeProvisionedOltIdList.Contains(o.Id)
  610:                           select o.Symbol).ToList();
  611:  
  612:                 var l2 = (from pg in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PonGroupList
  613:                           where allowedToBeProvisionedOltIdList.Contains(pg.Olt.Id)
  614:                           select pg.Symbol).ToList();
  615:  
  616:                 var list = l1.Union(l1).Distinct().ToList();
  617:  
  618:                 return list;
  619:             }
  620:         }
  621:  
  622:         ////////////////////////////////////////////////////////////////////////////
  623:  
  624:         /// <summary>
  625:         ///
  626:         /// </summary>
  627:         public static bool NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont, string service)
  628:         {
  629:             bool b;
  630:  
  631:             if (ont != null)
  632:             {
  633:                 b = ont.Pon.PonGroup.Olt.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString()));
  634:  
  635:                 if (!b)
  636:                 {
  637:                     var list = Ia.Ftn.Cl.Models.Business.Service.SymbolDomainSameSwitchVendorButDifferentSiteExceptionList;
  638:  
  639:                     var domain = service.Substring(0, 4);
  640:                     var symbol = ont.Pon.PonGroup.Symbol;
  641:  
  642:                     b = list.Contains(domain + "@" + symbol);
  643:  
  644:                     if (!b)
  645:                     {
  646:                         domain = service.Substring(0, 5);
  647:  
  648:                         b = list.Contains(domain + "@" + symbol);
  649:                     }
  650:                 }
  651:             }
  652:             else b = false;
  653:  
  654:             return b;
  655:         }
  656:  
  657:         ////////////////////////////////////////////////////////////////////////////
  658:  
  659:         /// <summary>
  660:         ///
  661:         /// </summary>
  662:         public static bool ServiceHasEightDigitsAndIsWithinAllowedDomainList(long number)
  663:         {
  664:             string service;
  665:  
  666:             service = number.ToString();
  667:  
  668:             return ServiceHasEightDigitsAndIsWithinAllowedDomainList(service);
  669:         }
  670:  
  671:         ////////////////////////////////////////////////////////////////////////////
  672:  
  673:         /// <summary>
  674:         ///
  675:         /// </summary>
  676:         public static bool ServiceHasEightDigitsAndIsWithinAllowedDomainList(string service)
  677:         {
  678:             bool isWithinAllowed;
  679:  
  680:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigits(service))
  681:             {
  682:                 var domainList = Ia.Ftn.Cl.Models.Data.Service.DomainList;
  683:  
  684:                 if (domainList.Any(u => service.StartsWith(u.ToString()))) isWithinAllowed = true;
  685:                 else isWithinAllowed = false;
  686:             }
  687:             else isWithinAllowed = false;
  688:  
  689:             return isWithinAllowed;
  690:         }
  691:  
  692:         ////////////////////////////////////////////////////////////////////////////
  693:  
  694:         /// <summary>
  695:         ///
  696:         /// </summary>
  697:         public static bool ServiceHasEightDigitsAndIsWithinKuwaitLandlineDomainList(int number)
  698:         {
  699:             string numberString;
  700:  
  701:             numberString = number.ToString();
  702:  
  703:             return ServiceHasEightDigitsAndIsWithinKuwaitLandlineDomainList(numberString);
  704:         }
  705:  
  706:         ////////////////////////////////////////////////////////////////////////////
  707:  
  708:         /// <summary>
  709:         ///
  710:         /// </summary>
  711:         public static bool ServiceHasEightDigitsAndIsWithinKuwaitLandlineDomainList(string service)
  712:         {
  713:             bool isWithinAllowed;
  714:  
  715:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigits(service))
  716:             {
  717:                 isWithinAllowed = Ia.Ftn.Cl.Models.Business.Default.IsKuwaitLandlineService(service);
  718:             }
  719:             else isWithinAllowed = false;
  720:  
  721:             return isWithinAllowed;
  722:         }
  723:  
  724:         ////////////////////////////////////////////////////////////////////////////
  725:  
  726:         /// <summary>
  727:         ///
  728:         /// </summary>
  729:         public static bool NumberIsWithinAllowedNokiaSwitchDomainList(long number)
  730:         {
  731:             string numberString;
  732:  
  733:             numberString = number.ToString();
  734:  
  735:             return NumberIsWithinAllowedNokiaSwitchDomainList(numberString);
  736:         }
  737:  
  738:         ////////////////////////////////////////////////////////////////////////////
  739:  
  740:         /// <summary>
  741:         ///
  742:         /// </summary>
  743:         public static bool NumberIsWithinAllowedNokiaSwitchDomainList(string number)
  744:         {
  745:             bool isWithinAllowedDomains;
  746:  
  747:             if (ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  748:             {
  749:                 if (Ia.Ftn.Cl.Models.Data.Service.NokiaSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
  750:                 else isWithinAllowedDomains = false;
  751:             }
  752:             else isWithinAllowedDomains = false;
  753:  
  754:             return isWithinAllowedDomains;
  755:         }
  756:  
  757:         ////////////////////////////////////////////////////////////////////////////
  758:  
  759:         /// <summary>
  760:         ///
  761:         /// </summary>
  762:         public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(long number)
  763:         {
  764:             string numberString;
  765:  
  766:             numberString = number.ToString();
  767:  
  768:             return NumberIsWithinAllowedHuaweiSwitchDomainList(numberString);
  769:         }
  770:  
  771:         ////////////////////////////////////////////////////////////////////////////
  772:  
  773:         /// <summary>
  774:         ///
  775:         /// </summary>
  776:         public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(string number)
  777:         {
  778:             bool isWithinAllowedDomains;
  779:  
  780:             if (ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  781:             {
  782:                 if (Ia.Ftn.Cl.Models.Data.Service.HuaweiSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
  783:                 else isWithinAllowedDomains = false;
  784:             }
  785:             else isWithinAllowedDomains = false;
  786:  
  787:             return isWithinAllowedDomains;
  788:         }
  789:  
  790:         ////////////////////////////////////////////////////////////////////////////
  791:  
  792:         /// <summary>
  793:         ///
  794:         /// </summary>
  795:         public static bool NumberIsWithinAllowedEricssonAxeSwitchDomainList(long number)
  796:         {
  797:             string numberString;
  798:  
  799:             numberString = number.ToString();
  800:  
  801:             return NumberIsWithinAllowedEricssonAxeSwitchDomainList(numberString);
  802:         }
  803:  
  804:         ////////////////////////////////////////////////////////////////////////////
  805:  
  806:         /// <summary>
  807:         ///
  808:         /// </summary>
  809:         public static bool NumberIsWithinAllowedEricssonAxeSwitchDomainList(string number)
  810:         {
  811:             bool isWithinAllowedDomains;
  812:  
  813:             if (ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  814:             {
  815:                 if (Ia.Ftn.Cl.Models.Data.Service.AxePstnDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
  816:                 else isWithinAllowedDomains = false;
  817:             }
  818:             else isWithinAllowedDomains = false;
  819:  
  820:             return isWithinAllowedDomains;
  821:         }
  822:  
  823:         ////////////////////////////////////////////////////////////////////////////
  824:  
  825:         /// <summary>
  826:         ///
  827:         /// </summary>
  828:         public static bool NumberIsWithinAllowedSiemensEwsdSwitchDomainList(long number)
  829:         {
  830:             string numberString;
  831:  
  832:             numberString = number.ToString();
  833:  
  834:             return NumberIsWithinAllowedSiemensEwsdSwitchDomainList(numberString);
  835:         }
  836:  
  837:         ////////////////////////////////////////////////////////////////////////////
  838:  
  839:         /// <summary>
  840:         ///
  841:         /// </summary>
  842:         public static bool NumberIsWithinAllowedSiemensEwsdSwitchDomainList(string number)
  843:         {
  844:             bool isWithinAllowedDomains;
  845:  
  846:             if (ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  847:             {
  848:                 if (Ia.Ftn.Cl.Models.Data.Service.EwsdPstnDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
  849:                 else isWithinAllowedDomains = false;
  850:             }
  851:             else isWithinAllowedDomains = false;
  852:  
  853:             return isWithinAllowedDomains;
  854:         }
  855:  
  856:         ////////////////////////////////////////////////////////////////////////////
  857:         ////////////////////////////////////////////////////////////////////////////
  858:  
  859:         /// <summary>
  860:         ///
  861:         /// </summary>
  862:         public static Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor SwitchVendor(string service)
  863:         {
  864:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor vendor;
  865:  
  866:             if (NumberIsWithinAllowedNokiaSwitchDomainList(service))
  867:             {
  868:                 vendor = Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia;
  869:             }
  870:             else if (NumberIsWithinAllowedHuaweiSwitchDomainList(service))
  871:             {
  872:                 vendor = Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei;
  873:             }
  874:             else vendor = Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Undefined;
  875:  
  876:             return vendor;
  877:         }
  878:  
  879:         ////////////////////////////////////////////////////////////////////////////
  880:  
  881:         /// <summary>
  882:         ///
  883:         /// </summary>
  884:         public static Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor AccessVendor(string accessName)
  885:         {
  886:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor vendor;
  887:  
  888:             vendor = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessVendorByAccessName(accessName);
  889:  
  890:             if (vendor == null) vendor = Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Undefined;
  891:  
  892:             return vendor;
  893:         }
  894:  
  895:         ////////////////////////////////////////////////////////////////////////////
  896:  
  897:         /// <summary>
  898:         ///
  899:         /// </summary>
  900:         public static int ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(int flatTermId)
  901:         {
  902:             /*
  903:              * - All Nokia ONTs (SFUs and MDUs) start at port position 1
  904:              * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
  905:              * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
  906:              */
  907:  
  908:             // -1 because it has a Huawei MDU. See above.
  909:  
  910:             return flatTermId - 1;
  911:         }
  912:  
  913:         ////////////////////////////////////////////////////////////////////////////    
  914:  
  915:         /// <summary>
  916:         ///
  917:         /// </summary>
  918:         public static string SequentialServiceNotInServiceRequestServiceManager(out int sequentialQueueCount, out string progressCounterString)
  919:         {
  920:             string service;
  921:  
  922:             if (sequentialQueue.Count == 0)
  923:             {
  924:                 var list = Ia.Ftn.Cl.Models.Data.Service.ServiceNotInServiceRequestServiceList();
  925:                 sequentialQueue = new Queue<string>(list);
  926:  
  927:                 sequentialQueueOriginalCount = sequentialQueue.Count;
  928:             }
  929:  
  930:             if (sequentialQueue.Count > 0) service = sequentialQueue.Dequeue();
  931:             else service = string.Empty;
  932:  
  933:             progressCounterString = "(" + sequentialQueue.Count + "/" + sequentialQueueOriginalCount + ")";
  934:  
  935:             sequentialQueueCount = sequentialQueue.Count;
  936:  
  937:             return service;
  938:         }
  939:  
  940:         ////////////////////////////////////////////////////////////////////////////    
  941:         ////////////////////////////////////////////////////////////////////////////
  942:     }
  943:  
  944:     ////////////////////////////////////////////////////////////////////////////
  945:  
  946:     /// <summary>
  947:     ///
  948:     /// </summary>
  949:     public static class ServiceExtension
  950:     {
  951:         ////////////////////////////////////////////////////////////////////////////
  952:  
  953:         /// <summary>
  954:         /// 
  955:         /// <see cref="http://stackoverflow.com/questions/8910588/how-to-override-contains"/>
  956:         /// </summary>
  957:         public static bool Contains(this List<Ia.Ftn.Cl.Models.Business.ServiceRequest.NumberSerial> sourceList, int number, int serial)
  958:         {
  959:             return ((from n in sourceList where n.Number == number && n.Serial == serial select n) != null);
  960:         }
  961:  
  962:         ////////////////////////////////////////////////////////////////////////////    
  963:  
  964:         /// <summary>
  965:         ///
  966:         /// </summary>
  967:         public static List<long> IdList(this List<Ia.Ftn.Cl.Models.Business.ServiceRequest.NumberSerial> sourceList)
  968:         {
  969:             return ((from n in sourceList select (long)((long)n.Number * 100 + n.Serial)).ToList());
  970:         }
  971:  
  972:         ////////////////////////////////////////////////////////////////////////////
  973:         ////////////////////////////////////////////////////////////////////////////
  974:     }
  975:  
  976:     ////////////////////////////////////////////////////////////////////////////
  977:     ////////////////////////////////////////////////////////////////////////////   
  978: }