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