)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » Provision

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

Provision support class for Optical Fiber Network (OFN) data model.

    1: using Ia.Ngn.Cl.Model.Business;
    2: using Microsoft.EntityFrameworkCore;
    3: using System;
    4: using System.Collections;
    5: using System.Collections.Generic;
    6: using System.Data;
    7: using System.Linq;
    8: using static Ia.Cl.Model.Db.Temp;
    9:  
   10: namespace Ia.Ngn.Cl.Model.Data
   11: {
   12:     ////////////////////////////////////////////////////////////////////////////
   13:  
   14:     /// <summary publish="true">
   15:     /// Provision support class for Optical Fiber Network (OFN) data model.
   16:     /// </summary>
   17:     /// 
   18:     /// <remarks> 
   19:     /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   20:     ///
   21:     /// 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
   22:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   23:     ///
   24:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   25:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   26:     /// 
   27:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   28:     /// 
   29:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   30:     /// </remarks> 
   31:     public class Provision
   32:     {
   33:         private static int nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex, nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex, allPossibleNddOntNotInAgcfGatewayRecordListIndex, allPossibleAgcfGatewayRecordFromWithinOltListIndex, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex, allPossibleAgcfGatewayRecordNoInOntListIndex;
   34:         private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> allPossibleNddOntNotInAgcfGatewayRecordList, nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList, nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList;
   35:         private static List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> allPossibleAgcfGatewayRecordFromWithinOltList, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList, allPossibleAgcfGatewayRecordNoInOntList;
   36:         private static List<string> provisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList;
   37:  
   38:         private static readonly object objectLock = new object();
   39:  
   40:         ////////////////////////////////////////////////////////////////////////////
   41:  
   42:         /// <summary>
   43:         ///
   44:         /// </summary>
   45:         public Provision() { }
   46:  
   47:         ////////////////////////////////////////////////////////////////////////////
   48:  
   49:         /// <summary>
   50:         ///
   51:         /// </summary>
   52:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecord(out string result)
   53:         {
   54:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
   55:  
   56:             if (nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList == null || nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex == 0)
   57:             {
   58:                 nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecordList();//.Where(u=>u.Access.Name.Contains("SLA")).ToList();
   59:  
   60:                 nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex = 0;
   61:             }
   62:  
   63:             if (nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList.Count > 0)
   64:             {
   65:                 ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList[nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex];
   66:  
   67:                 nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList, nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex);
   68:             }
   69:             else ont = null;
   70:  
   71:             result = "(" + nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex + "/" + nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList.Count + ") ";
   72:  
   73:             return ont;
   74:         }
   75:  
   76:         ////////////////////////////////////////////////////////////////////////////
   77:  
   78:         /// <summary>
   79:         ///
   80:         /// </summary>
   81:         public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(out string result)
   82:         {
   83:             Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
   84:  
   85:             if (agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList == null || agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex == 0)
   86:             {
   87:                 agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpointList();
   88:  
   89:                 agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex = 0;
   90:             }
   91:  
   92:             if (agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList.Count > 0)
   93:             {
   94:                 agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList[agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex];
   95:  
   96:                 agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex);
   97:             }
   98:             else agcfGatewayRecord = null;
   99:  
  100:             result = "(" + agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex + "/" + agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList.Count + ") ";
  101:  
  102:             return agcfGatewayRecord;
  103:         }
  104:  
  105:         ////////////////////////////////////////////////////////////////////////////
  106:  
  107:         /// <summary>
  108:         ///
  109:         /// </summary>
  110:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntNotInAgcfGatewayRecordList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, out string result)
  111:         {
  112:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
  113:  
  114:             if (allPossibleNddOntNotInAgcfGatewayRecordList == null || allPossibleNddOntNotInAgcfGatewayRecordListIndex == 0)
  115:             {
  116:                 allPossibleNddOntNotInAgcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.NddOntNotInAgcfGatewayRecordList(olt);
  117:  
  118:                 allPossibleNddOntNotInAgcfGatewayRecordListIndex = 0;
  119:             }
  120:  
  121:             if (allPossibleNddOntNotInAgcfGatewayRecordList.Count > 0)
  122:             {
  123:                 ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)allPossibleNddOntNotInAgcfGatewayRecordList[allPossibleNddOntNotInAgcfGatewayRecordListIndex];
  124:  
  125:                 allPossibleNddOntNotInAgcfGatewayRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleNddOntNotInAgcfGatewayRecordList, allPossibleNddOntNotInAgcfGatewayRecordListIndex);
  126:             }
  127:             else ont = null;
  128:  
  129:             result = "(" + allPossibleNddOntNotInAgcfGatewayRecordListIndex + "/" + allPossibleNddOntNotInAgcfGatewayRecordList.Count + ") ";
  130:  
  131:             return ont;
  132:         }
  133:  
  134:         ////////////////////////////////////////////////////////////////////////////
  135:  
  136:         /// <summary>
  137:         ///
  138:         /// </summary>
  139:         public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordFromWithinOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, out string result)
  140:         {
  141:             Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
  142:  
  143:             if (allPossibleAgcfGatewayRecordFromWithinOltList == null || allPossibleAgcfGatewayRecordFromWithinOltListIndex == 0)
  144:             {
  145:                 allPossibleAgcfGatewayRecordFromWithinOltList = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.List(olt);
  146:  
  147:                 allPossibleAgcfGatewayRecordFromWithinOltListIndex = 0;
  148:             }
  149:  
  150:             if (allPossibleAgcfGatewayRecordFromWithinOltList.Count > 0)
  151:             {
  152:                 agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)allPossibleAgcfGatewayRecordFromWithinOltList[allPossibleAgcfGatewayRecordFromWithinOltListIndex];
  153:  
  154:                 allPossibleAgcfGatewayRecordFromWithinOltListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleAgcfGatewayRecordFromWithinOltList, allPossibleAgcfGatewayRecordFromWithinOltListIndex);
  155:             }
  156:             else agcfGatewayRecord = null;
  157:  
  158:             result = "(" + allPossibleAgcfGatewayRecordFromWithinOltListIndex + "/" + allPossibleAgcfGatewayRecordFromWithinOltList.Count + ") ";
  159:  
  160:             return agcfGatewayRecord;
  161:         }
  162:  
  163:         ////////////////////////////////////////////////////////////////////////////
  164:  
  165:         /// <summary>
  166:         ///
  167:         /// </summary>
  168:         public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordNoInOntList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
  169:         {
  170:             Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
  171:  
  172:             if (allPossibleAgcfGatewayRecordNoInOntList == null || allPossibleAgcfGatewayRecordNoInOntListIndex == 0)
  173:             {
  174:                 allPossibleAgcfGatewayRecordNoInOntList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AllPossibleAgcfGatewayRecordsNoInOntsList(olt);
  175:  
  176:                 allPossibleAgcfGatewayRecordNoInOntListIndex = 0;
  177:             }
  178:  
  179:             agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)allPossibleAgcfGatewayRecordNoInOntList[allPossibleAgcfGatewayRecordNoInOntListIndex];
  180:  
  181:             allPossibleAgcfGatewayRecordNoInOntListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleAgcfGatewayRecordNoInOntList, allPossibleAgcfGatewayRecordNoInOntListIndex);
  182:  
  183:             return agcfGatewayRecord;
  184:         }
  185:  
  186:         ////////////////////////////////////////////////////////////////////////////
  187:         ////////////////////////////////////////////////////////////////////////////
  188:  
  189:         /// <summary>
  190:         ///
  191:         /// </summary>
  192:         public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecord(out string result)
  193:         {
  194:             Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
  195:  
  196:             if (nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList == null || nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex == 0)
  197:             {
  198:                 nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList = Ia.Ngn.Cl.Model.Data.Huawei.Ims.NddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecord();//.Where(u=>u.Access.Name.Contains("SLA")).ToList();
  199:  
  200:                 nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex = 0;
  201:             }
  202:  
  203:             if (nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList.Count > 0)
  204:             {
  205:                 ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList[nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex];
  206:  
  207:                 nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList, nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex);
  208:             }
  209:             else ont = null;
  210:  
  211:             result = "(" + nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordListIndex + "/" + nddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecordList.Count + ") ";
  212:  
  213:             return ont;
  214:         }
  215:  
  216:         /*
  217:         ////////////////////////////////////////////////////////////////////////////
  218: 
  219:         /// <summary>
  220:         ///
  221:         /// </summary>
  222:         public static bool UpdateServiceRequestServiceServiceSuspensionWithNonNullAccess(out string result)
  223:         {
  224:             bool toTrue, toFalse;
  225:             StringBuilder sb;
  226:             List<string> srsCurrentList, toTrueList, toFalseList;
  227: 
  228:             toTrue = toFalse = false;
  229: 
  230:             srsCurrentList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueStringNumberList;
  231: 
  232:             toTrueList = new List<string>(srsCurrentList.Count);
  233:             toFalseList = new List<string>(srsCurrentList.Count);
  234: 
  235:             sb = new StringBuilder(12 * (srsCurrentList.Count));
  236: 
  237:             // below: numbers that should be added to SRS barring
  238:             sb.Append("\r\nNumber(s) to be set in SRS as barred: ");
  239: 
  240:             toTrue = Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspensionAndServiceSuspensionTypeIdToSpecifiedSuspensionStateForAServiceStringList(toTrueList, true, Guid.Empty);
  241:             sb.Append("\r\nNumber(s) set?: " + toTrue.ToString());
  242: 
  243:             // below: numbres that should be removed from SRS barring
  244:             sb.Append("\r\nNumber(s) to be reset in SRS as not barred: ");
  245: 
  246:             toFalse = Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspensionAndServiceSuspensionTypeIdToSpecifiedSuspensionStateForAServiceStringList(toFalseList, false, Guid.Empty);
  247:             sb.Append("\r\nNumber(s) reset?: " + toTrue.ToString());
  248: 
  249:             result = sb.ToString();
  250: 
  251:             return toTrue || toFalse;
  252:         }
  253:         */
  254:  
  255:         ////////////////////////////////////////////////////////////////////////////
  256:  
  257:         /// <summary>
  258:         ///
  259:         /// </summary>
  260:         private static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceWithAccessesWithNullAgcfEndpointList
  261:         {
  262:             get
  263:             {
  264:                 List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
  265:  
  266:                 using (var db = new Ia.Ngn.Cl.Model.Ngn())
  267:                 {
  268:                     serviceRequestServiceList = (from srs in db.ServiceRequestServices
  269:                                                  join e in db.AgcfEndpoints on Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(srs.Service) equals e.PrividUser
  270:                                                  into gj
  271:                                                  from u in gj.DefaultIfEmpty()
  272:                                                  where u == null && srs.Access != null
  273:                                                  select srs).Include(u => u.Access).ToList();
  274:                 }
  275:  
  276:                 return serviceRequestServiceList;
  277:             }
  278:         }
  279:  
  280:         ////////////////////////////////////////////////////////////////////////////
  281:  
  282:         /// <summary>
  283:         ///
  284:         /// </summary>
  285:         public static List<string> ImsServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList()
  286:         {
  287:             return ServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService, out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList);
  288:         }
  289:  
  290:         ////////////////////////////////////////////////////////////////////////////
  291:  
  292:         /// <summary>
  293:         ///
  294:         /// </summary>
  295:         public static List<string> PstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList()
  296:         {
  297:             return ServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService, out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList);
  298:         }
  299:  
  300:         ////////////////////////////////////////////////////////////////////////////
  301:  
  302:         /// <summary>
  303:         ///
  304:         /// </summary>
  305:         public static void EricssonAxePstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList)
  306:         {
  307:             PstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe, out serviceToSuspendList, out serviceToReleaseList, out serviceInternationalCallingToSuspendList, out serviceInternationalCallingToReleaseList);
  308:         }
  309:  
  310:         ////////////////////////////////////////////////////////////////////////////
  311:  
  312:         /// <summary>
  313:         ///
  314:         /// </summary>
  315:         public static void SiemensEwsdPstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList)
  316:         {
  317:             PstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd, out serviceToSuspendList, out serviceToReleaseList, out serviceInternationalCallingToSuspendList, out serviceInternationalCallingToReleaseList);
  318:         }
  319:  
  320:         ////////////////////////////////////////////////////////////////////////////
  321:  
  322:         /// <summary>
  323:         ///
  324:         /// </summary>
  325:         public static void PstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType pstnExchangeType, out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList)
  326:         {
  327:             ServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService, out List<string> serviceToSuspend0List, out List<string> serviceToRelease0List, out List<string> serviceInternationalCallingToSuspend0List, out List<string> serviceInternationalCallingToRelease0List);
  328:  
  329:             serviceToSuspendList = new List<string>();
  330:             serviceToReleaseList = new List<string>();
  331:  
  332:             serviceInternationalCallingToSuspendList = new List<string>();
  333:             serviceInternationalCallingToReleaseList = new List<string>();
  334:  
  335:             if (pstnExchangeType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe)
  336:             {
  337:                 foreach (var s in serviceToSuspend0List)
  338:                 {
  339:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedEricssonAxeSwitchDomainList(s))
  340:                     {
  341:                         serviceToSuspendList.Add(s);
  342:                     }
  343:                 }
  344:  
  345:                 foreach (var s in serviceToRelease0List)
  346:                 {
  347:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedEricssonAxeSwitchDomainList(s))
  348:                     {
  349:                         serviceToReleaseList.Add(s);
  350:                     }
  351:                 }
  352:  
  353:                 foreach (var s in serviceInternationalCallingToSuspend0List)
  354:                 {
  355:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedEricssonAxeSwitchDomainList(s))
  356:                     {
  357:                         serviceInternationalCallingToSuspendList.Add(s);
  358:                     }
  359:                 }
  360:  
  361:                 foreach (var s in serviceInternationalCallingToRelease0List)
  362:                 {
  363:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedEricssonAxeSwitchDomainList(s))
  364:                     {
  365:                         serviceInternationalCallingToReleaseList.Add(s);
  366:                     }
  367:                 }
  368:             }
  369:             else if (pstnExchangeType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd)
  370:             {
  371:                 foreach (var s in serviceToSuspend0List)
  372:                 {
  373:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedSiemensEwsdSwitchDomainList(s))
  374:                     {
  375:                         serviceToSuspendList.Add(s);
  376:                     }
  377:                 }
  378:  
  379:                 foreach (var s in serviceToRelease0List)
  380:                 {
  381:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedSiemensEwsdSwitchDomainList(s))
  382:                     {
  383:                         serviceToReleaseList.Add(s);
  384:                     }
  385:                 }
  386:  
  387:                 foreach (var s in serviceInternationalCallingToSuspend0List)
  388:                 {
  389:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedSiemensEwsdSwitchDomainList(s))
  390:                     {
  391:                         serviceInternationalCallingToSuspendList.Add(s);
  392:                     }
  393:                 }
  394:  
  395:                 foreach (var s in serviceInternationalCallingToRelease0List)
  396:                 {
  397:                     if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedSiemensEwsdSwitchDomainList(s))
  398:                     {
  399:                         serviceInternationalCallingToReleaseList.Add(s);
  400:                     }
  401:                 }
  402:             }
  403:             else throw new ArgumentOutOfRangeException(@"pstnExchangeType " + pstnExchangeType.ToString() + " is unknown.");
  404:         }
  405:  
  406:         ////////////////////////////////////////////////////////////////////////////
  407:  
  408:         /// <summary>
  409:         ///
  410:         /// </summary>
  411:         public static List<string> ServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(int serviceType, out List<string> serviceToSuspendList, out List<string> serviceToReleaseList, out List<string> serviceInternationalCallingToSuspendList, out List<string> serviceInternationalCallingToReleaseList)
  412:         {
  413:             List<string> serviceList;
  414:  
  415:             serviceToSuspendList = new List<string>();
  416:             serviceToReleaseList = new List<string>();
  417:  
  418:             serviceInternationalCallingToSuspendList = new List<string>();
  419:             serviceInternationalCallingToReleaseList = new List<string>();
  420:  
  421:             var programmedAccountingDisconnectionType = Ia.Ngn.Cl.Model.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedAccounting;
  422:             var programmedInternationalCallingDisconnectionType = Ia.Ngn.Cl.Model.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedInternationalCalling;
  423:  
  424:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
  425:             {
  426:                 serviceToSuspendList = (from srai in db.ServiceRequestAdministrativeIssues
  427:                                         join s in db.Service2 on srai.Id equals s.Id
  428:                                         where s.ServiceSuspension != true && s.ServiceType == serviceType && srai.Type == (int)programmedAccountingDisconnectionType
  429:                                         select s.Service).AsNoTracking().ToList();
  430:  
  431:                 serviceToReleaseList = (from s in db.Service2
  432:                                         join srai in db.ServiceRequestAdministrativeIssues on s.Id equals srai.Id into srais
  433:                                         from srai in srais.DefaultIfEmpty()
  434:                                         where srai == null && s.ServiceType == serviceType && s.ServiceSuspension == true
  435:                                         select s.Service).AsNoTracking().ToList();
  436:  
  437:                 serviceInternationalCallingToSuspendList = (from srai in db.ServiceRequestAdministrativeIssues
  438:                                                             join s in db.Service2 on srai.Id equals s.Id
  439:                                                             join srs in db.ServiceRequestServices on srai.Id equals srs.Id
  440:                                                             where s.ServiceType == serviceType && srs.InternationalCalling == true && s.InternationalCalling == true && srai.Type == (int)programmedInternationalCallingDisconnectionType
  441:                                                             select s.Service).AsNoTracking().ToList();
  442:  
  443:                 serviceInternationalCallingToReleaseList = (from s in db.Service2
  444:                                                             join srs in db.ServiceRequestServices on s.Id equals srs.Id
  445:                                                             join srai in db.ServiceRequestAdministrativeIssues on s.Id equals srai.Id into srais
  446:                                                             from srai in srais.DefaultIfEmpty()
  447:                                                             where srai == null && s.ServiceType == serviceType && srs.InternationalCalling == true && s.InternationalCalling == false
  448:                                                             select s.Service).AsNoTracking().ToList();
  449:             }
  450:  
  451:             var serviceExemptionList = ServiceOfServiceExemptFromProvisionProcessingList();
  452:             foreach (string s in serviceExemptionList)
  453:             {
  454:                 serviceToSuspendList.Remove(s);
  455:                 serviceToReleaseList.Remove(s);
  456:  
  457:                 serviceInternationalCallingToSuspendList.Remove(s);
  458:                 serviceInternationalCallingToReleaseList.Remove(s);
  459:             }
  460:  
  461:  
  462:             serviceList = serviceToSuspendList.Union(serviceToReleaseList).Union(serviceInternationalCallingToSuspendList).Union(serviceInternationalCallingToReleaseList).ToList();
  463:  
  464:             // temp until we settle issues with disconnection dept
  465:             var serviceToDeleteList = new List<string>();
  466:             foreach (string s in serviceList)
  467:             {
  468:                 if (!Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(s)) serviceToDeleteList.Add(s);
  469:             }
  470:             foreach (var s in serviceToDeleteList) serviceList.Remove(s);
  471:  
  472:             return serviceList;
  473:         }
  474:  
  475:         ////////////////////////////////////////////////////////////////////////////
  476:  
  477:         /// <summary>
  478:         ///
  479:         /// </summary>
  480:         public static Dictionary<string, string> ComplementaryImsServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(DateTime earliestRequestDateTime)
  481:         {
  482:             return Ia.Ngn.Cl.Model.Data.Provision.ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService, earliestRequestDateTime);
  483:         }
  484:  
  485:         ////////////////////////////////////////////////////////////////////////////
  486:  
  487:         /// <summary>
  488:         ///
  489:         /// </summary>
  490:         public static Dictionary<string, string> ComplementaryPstnServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(DateTime earliestRequestDateTime)
  491:         {
  492:             return Ia.Ngn.Cl.Model.Data.Provision.ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService, earliestRequestDateTime);
  493:         }
  494:  
  495:         ////////////////////////////////////////////////////////////////////////////
  496:  
  497:         /// <summary>
  498:         ///
  499:         /// </summary>
  500:         public static Dictionary<string, string> ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(int serviceType, DateTime earliestRequestDateTime)
  501:         {
  502:             Dictionary<string, string> serviceIdAccessIdDictionary;
  503:  
  504:             var allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
  505:  
  506:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
  507:             {
  508:                 var servicePbxList = Ia.Ngn.Cl.Model.Data.Service.ServicePbxList;
  509:                 //var huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.ConvertAll<string>(u => u.ToString());
  510:  
  511:                 // below: Service different from ServiceRequestService
  512:                 serviceIdAccessIdDictionary = (from s in db.Service2
  513:                                                    //join srs in db.ServiceRequestServices on s.Id equals srs.Id // this is faster, but I need to match Services to account for PSTN numbers
  514:                                                join srs in db.ServiceRequestServices on s.Service equals srs.Service
  515:                                                join srai in db.ServiceRequestAdministrativeIssues on s.Service equals srai.Service into srai2
  516:                                                from srai3 in srai2.DefaultIfEmpty()
  517:                                                where s.ServiceType == serviceType
  518:                                                && srs.Provisioned == true
  519:                                                && srs.LastRequestDateTime >= earliestRequestDateTime
  520:                                                && (s.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt) || s.Access == null)
  521:                                                &&
  522:                                                (
  523:                                                    s.AbbriviatedCalling != srs.AbbriviatedCalling
  524:                                                    || s.AlarmCall != srs.AlarmCall
  525:                                                    || s.WakeupCall != srs.WakeupCall
  526:                                                    || s.CallerId != srs.CallerId
  527:                                                    || s.CallForwarding != srs.CallForwarding
  528:                                                    || s.ConferenceCall != srs.ConferenceCall
  529:                                                    || s.InternationalCallingUserControlled != srs.InternationalCallingUserControlled
  530:                                                    || s.InternationalCalling != srs.InternationalCalling
  531:                                                    || s.SpeedDial != srs.SpeedDial
  532:                                                    //|| (Ia.Ngn.Cl.Model.Business.Administration.ServiceSuspensionIsEnabled && s.ServiceSuspension != srs.CallBarring)
  533:  
  534:                                                    // below: exclude PBX numbers from the Call Waiting service requirement
  535:                                                    || !servicePbxList.Contains(srs.Service) && s.CallWaiting != srs.CallWaiting
  536:  
  537:                                                /*
  538:                                                // below: exclude huawei from barring and service suspension operations
  539:                                                //|| !huaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
  540:                                                || !huaweiSwitchDomainList.Contains(srs.Service.Substring(0, 4)) && !huaweiSwitchDomainList.Contains(srs.Service.Substring(0, 5))
  541:                                                &&
  542:                                                (
  543:                                                    srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
  544:                                                    || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
  545:                                                    || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
  546:                                                    || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
  547:                                                )
  548:                                                */
  549:  
  550:                                                // below: check for numbers in which srs.Access != s.Access when s.Access != null
  551:                                                //|| (s.Access != null && s.Access.Id != srs.Access.Id) // not appropriate to compare s.Access and srs.Access here
  552:                                                )
  553:                                                && srai3.Id == null // srai3.Id == null means no ServiceRequestAdministrativeIssues
  554:                                                select new
  555:                                                {
  556:                                                    s.Id,
  557:                                                    AccessId = (s.Access != null) ? s.Access.Id : string.Empty
  558:                                                }).AsNoTracking().ToDictionary(n => n.Id, n => n.AccessId);
  559:             }
  560:  
  561:             return serviceIdAccessIdDictionary;
  562:         }
  563:  
  564:         ////////////////////////////////////////////////////////////////////////////
  565:  
  566:         /// <summary>
  567:         ///
  568:         /// </summary>
  569:         public static SortedList ProvisionedServiceRequestServiceAndServiceMismatchAccessServiceIdList()
  570:         {
  571:             SortedList serviceRequestServiceAndServiceMismatchAccessServiceIdList;
  572:             Dictionary<string, int> srsIdDictionary, sIdDictionary;
  573:  
  574:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
  575:             {
  576:                 // below: ServiceRequestService dictionary
  577:                 srsIdDictionary = (from srs in db.ServiceRequestServices
  578:                                    join s in db.Service2 on srs.Id equals s.Id
  579:                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && srs.Provisioned == true && srs.Access != null && s.Access != null && srs.Access.Id != s.Access.Id
  580:                                    select srs.Id).ToDictionary(n => n, n => 1);
  581:  
  582:                 // below: Service dictionary
  583:                 sIdDictionary = (from s in db.Service2
  584:                                  join srs in db.ServiceRequestServices on s.Id equals srs.Id
  585:                                  where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && srs.Provisioned == true && s.Access != null && srs.Access != null && s.Access.Id != srs.Access.Id
  586:                                  select s.Id).ToDictionary(n => n, n => 1);
  587:             }
  588:  
  589:             serviceRequestServiceAndServiceMismatchAccessServiceIdList = new SortedList(srsIdDictionary.Count + sIdDictionary.Count);
  590:  
  591:             foreach (KeyValuePair<string, int> kvp in srsIdDictionary)
  592:                 if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
  593:                     serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
  594:  
  595:             foreach (KeyValuePair<string, int> kvp in sIdDictionary)
  596:                 if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
  597:                     serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
  598:  
  599:             return serviceRequestServiceAndServiceMismatchAccessServiceIdList;
  600:         }
  601:  
  602:         ////////////////////////////////////////////////////////////////////////////
  603:  
  604:         /// <summary>
  605:         ///
  606:         /// </summary>
  607:         public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
  608:         {
  609:             ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(0, out serviceToUpdateServiceIdAccessIdDictionary, out serviceToCreateServiceIdAccessIdDictionary, out serviceToDeleteServiceIdAccessIdDictionary);
  610:         }
  611:  
  612:         ////////////////////////////////////////////////////////////////////////////
  613:  
  614:         /// <summary>
  615:         ///
  616:         /// </summary>
  617:         public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(int provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
  618:         {
  619:             string service, serviceId;
  620:             Dictionary<string, string> mismatchServiceIdAccessIdDictionary, serviceRequestServiceProvisionedServiceIdAccessIdDictionary, serviceRequestServiceRemovedServiceIdAccessIdDictionary, serviceIdAccessIdDictionary;
  621:  
  622:             var earliestRequestDateTime = (provisionWithinLastNDays > 0) ? DateTime.UtcNow.AddHours(3).AddDays(-provisionWithinLastNDays) : Ia.Ngn.Cl.Model.Business.Administration.EarliestRequestDateTime;
  623:  
  624:             var allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
  625:  
  626:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
  627:             {
  628:                 // below: ServiceRequestService dictionary
  629:                 serviceRequestServiceProvisionedServiceIdAccessIdDictionary = (from srs in db.ServiceRequestServices
  630:                                                                                where srs.Provisioned == true && srs.LastRequestDateTime >= earliestRequestDateTime
  631:                                                                                && srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)
  632:                                                                                select new { srs.Id, AccessId = srs.Access.Id }).AsNoTracking().ToDictionary(n => n.Id, n => n.AccessId);
  633:  
  634:                 serviceRequestServiceRemovedServiceIdAccessIdDictionary = (from srs in db.ServiceRequestServices
  635:                                                                            where srs.Provisioned == false && srs.LastRequestDateTime >= earliestRequestDateTime
  636:                                                                            /*&& srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)*/
  637:                                                                            select new { srs.Id, AccessId = srs.Access.Id }).AsNoTracking().ToDictionary(n => n.Id, n => n.AccessId);
  638:  
  639:                 serviceIdAccessIdDictionary = (from s in db.Service2
  640:                                                where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
  641:                                                && (s.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt) || s.Access == null)
  642:                                                select new { s.Id, AccessId = s.Access.Id }).AsNoTracking().ToDictionary(n => n.Id, n => n.AccessId);
  643:             }
  644:  
  645:             // services to provision (ServiceRequestService.Provisioned = true and not in Service list)
  646:             serviceToCreateServiceIdAccessIdDictionary = new Dictionary<string, string>();
  647:             foreach (KeyValuePair<string, string> kvp in serviceRequestServiceProvisionedServiceIdAccessIdDictionary)
  648:             {
  649:                 if (!serviceIdAccessIdDictionary.ContainsKey(kvp.Key))
  650:                 {
  651:                     if (!string.IsNullOrEmpty(kvp.Value))
  652:                     {
  653:                         serviceId = kvp.Key;
  654:                         service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
  655:  
  656:                         if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service) && !service.StartsWith("2489"))
  657:                         {
  658:                             serviceToCreateServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
  659:                         }
  660:                     }
  661:                 }
  662:             }
  663:  
  664:             // services to remove (Service has equivalent ServiceRequestService.Provisioned = false)
  665:             serviceToDeleteServiceIdAccessIdDictionary = new Dictionary<string, string>();
  666:             foreach (KeyValuePair<string, string> kvp in serviceIdAccessIdDictionary)
  667:             {
  668:                 if (serviceRequestServiceRemovedServiceIdAccessIdDictionary.ContainsKey(kvp.Key))
  669:                 {
  670:                     //if (!string.IsNullOrEmpty(kvp.Value)) // only delete numbers with accesses, to be removed later
  671:                     //{
  672:                     serviceId = kvp.Key;
  673:                     service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
  674:  
  675:                     if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service) && !service.StartsWith("2489"))
  676:                     {
  677:                         serviceToDeleteServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
  678:                     }
  679:                     //}
  680:                 }
  681:             }
  682:  
  683:  
  684:             mismatchServiceIdAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Provision.ComplementaryImsServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(earliestRequestDateTime);
  685:  
  686:  
  687:             // services to update
  688:             serviceToUpdateServiceIdAccessIdDictionary = new Dictionary<string, string>();
  689:             foreach (KeyValuePair<string, string> kvp in mismatchServiceIdAccessIdDictionary)
  690:             {
  691:                 serviceId = kvp.Key;
  692:                 service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
  693:  
  694:                 if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service) && !service.StartsWith("2489"))
  695:                 {
  696:                     serviceToUpdateServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
  697:                 }
  698:             }
  699:  
  700:             // 3. Update list (order is important behind create and delete lists)
  701:             foreach (KeyValuePair<string, string> kvp in mismatchServiceIdAccessIdDictionary)
  702:             {
  703:                 // I will exclude all numbers from complementary list that are in either serviceToProvision list or serviceToRemove list
  704:                 if (serviceToCreateServiceIdAccessIdDictionary.ContainsKey(kvp.Key) || serviceToDeleteServiceIdAccessIdDictionary.ContainsKey(kvp.Key))
  705:                 {
  706:                     serviceToUpdateServiceIdAccessIdDictionary.Remove(kvp.Key);
  707:                 }
  708:             }
  709:  
  710:             // will exclude exempt numbers
  711:             var serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
  712:             foreach (string s in serviceIdExemptionList)
  713:             {
  714:                 serviceToUpdateServiceIdAccessIdDictionary.Remove(s);
  715:                 serviceToCreateServiceIdAccessIdDictionary.Remove(s);
  716:                 serviceToDeleteServiceIdAccessIdDictionary.Remove(s);
  717:             }
  718:         }
  719:  
  720:         ////////////////////////////////////////////////////////////////////////////
  721:  
  722:         /// <summary>
  723:         ///
  724:         /// </summary>
  725:         public static void ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(out Dictionary<string, string> serviceToCreateServiceIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdDictionary)
  726:         {
  727:             ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(0, out serviceToCreateServiceIdDictionary, out serviceToDeleteServiceIdDictionary);
  728:         }
  729:  
  730:         ////////////////////////////////////////////////////////////////////////////
  731:  
  732:         /// <summary>
  733:         ///
  734:         /// </summary>
  735:         public static void ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(int provisionWithinLastNDays, out Dictionary<string, string> serviceToCreateServiceIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdDictionary)
  736:         {
  737:             /*
  738:             var siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList;
  739: 
  740:             var site0List = (from s in siteList
  741:                              where s.Name == "SLB" || s.Name == "ARD" || s.Name == "QRN" || s.Name == "MSF" || s.Name == "MGF" || s.Name == "JHB" || s.Name == "SKB"
  742:                              select s).ToList();
  743: 
  744:             var msanList = site0List.SelectMany(u => u.Msans).ToList();
  745:             */
  746:  
  747:             var msanList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.MsanList;
  748:  
  749:             ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(msanList, provisionWithinLastNDays, out serviceToCreateServiceIdDictionary, out serviceToDeleteServiceIdDictionary);
  750:         }
  751:  
  752:         ////////////////////////////////////////////////////////////////////////////
  753:  
  754:         /// <summary>
  755:         ///
  756:         /// </summary>
  757:         public static void ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan> msanList, int provisionWithinLastNDays, out Dictionary<string, string> serviceToCreateServiceIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdDictionary)
  758:         {
  759:             string service, serviceId;
  760:             Dictionary<string, string> serviceRequestServiceProvisionedServiceIdDictionary, serviceRequestServiceRemovedServiceIdDictionary;
  761:             Dictionary<string, string> serviceIdDictionary;
  762:  
  763:             var earliestRequestDateTime = (provisionWithinLastNDays > 0) ? DateTime.UtcNow.AddHours(3).AddDays(-provisionWithinLastNDays) : Ia.Ngn.Cl.Model.Business.Administration.EarliestRequestDateTime;
  764:  
  765:             var allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
  766:  
  767:             //var msanDomainList = Ia.Ngn.Cl.Model.Data.Service.MsanDomainList;
  768:             var msanDomainList = msanList.SelectMany(u => u.DomainList).ToList();
  769:  
  770:             var msanDomainStringList = msanDomainList.ConvertAll(delegate (int i) { return i.ToString(); });
  771:  
  772:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
  773:             {
  774:                 var serviceRequestServiceList = (from srs in db.ServiceRequestServices
  775:                                                  where srs.LastRequestDateTime >= earliestRequestDateTime
  776:                                                  && srs.Access == null
  777:                                                  select new { srs.Id, srs.Service, srs.Provisioned }).AsNoTracking().ToList();
  778:  
  779:                 serviceRequestServiceProvisionedServiceIdDictionary = (from l in serviceRequestServiceList
  780:                                                                        where l.Provisioned == true && (msanDomainStringList.Contains(l.Service.Substring(0, 4)) || msanDomainStringList.Contains(l.Service.Substring(0, 5)))
  781:                                                                        select new { l.Id }).ToDictionary(n => n.Id, n => n.Id);
  782:  
  783:                 serviceRequestServiceRemovedServiceIdDictionary = (from l in serviceRequestServiceList
  784:                                                                    where l.Provisioned == false && (msanDomainStringList.Contains(l.Service.Substring(0, 4)) || msanDomainStringList.Contains(l.Service.Substring(0, 5)))
  785:                                                                    select new { l.Id }).ToDictionary(n => n.Id, n => n.Id);
  786:  
  787:                 serviceIdDictionary = (from s in db.Service2
  788:                                        where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
  789:                                        /*&& s.Access == null*/ && (msanDomainStringList.Contains(s.Service.Substring(0, 4)) || msanDomainStringList.Contains(s.Service.Substring(0, 5)))
  790:                                        select new { s.Id }).AsNoTracking().ToDictionary(n => n.Id, n => n.Id);
  791:             }
  792:  
  793:  
  794:             // services to provision (ServiceRequestService.Provisioned = true and not in Service list)
  795:             serviceToCreateServiceIdDictionary = new Dictionary<string, string>();
  796:             foreach (var kvp in serviceRequestServiceProvisionedServiceIdDictionary)
  797:             {
  798:                 if (!serviceIdDictionary.ContainsKey(kvp.Key))
  799:                 {
  800:                     if (!string.IsNullOrEmpty(kvp.Value))
  801:                     {
  802:                         serviceId = kvp.Key;
  803:                         service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
  804:  
  805:                         if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service) && !service.StartsWith("2489"))
  806:                         {
  807:                             serviceToCreateServiceIdDictionary.Add(kvp.Key, kvp.Value);
  808:                         }
  809:                     }
  810:                 }
  811:             }
  812:  
  813:             // If there is an entry in MSAN for number then I will create it on IMS even if it has a PSTN version (which will be deleted by net-manager or axe projects)
  814:             var pstnServiceIdList = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceIdList;
  815:             var msanServiceDictionary = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.MsanServiceDictionary;
  816:  
  817:             foreach (var serviceId0 in pstnServiceIdList)
  818:             {
  819:                 service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId0);
  820:                 var service2Id = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService);
  821:  
  822:                 if (!msanServiceDictionary.ContainsKey(service)) serviceToCreateServiceIdDictionary.Remove(service2Id);
  823:             }
  824:             //serviceToCreateServiceIdDictionary = new Dictionary<string, string>();
  825:  
  826:  
  827:             // services to remove (Service has equivalent ServiceRequestService.Provisioned = false)
  828:             serviceToDeleteServiceIdDictionary = new Dictionary<string, string>();
  829:             foreach (var kvp in serviceIdDictionary)
  830:             {
  831:                 if (serviceRequestServiceRemovedServiceIdDictionary.ContainsKey(kvp.Key))
  832:                 {
  833:                     if (!string.IsNullOrEmpty(kvp.Value)) // only delete numbers with accesses, to be removed later
  834:                     {
  835:                         serviceId = kvp.Key;
  836:                         service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
  837:  
  838:                         if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service) && !service.StartsWith("2489"))
  839:                         {
  840:                             serviceToDeleteServiceIdDictionary.Add(kvp.Key, kvp.Value);
  841:                         }
  842:                     }
  843:                 }
  844:             }
  845:  
  846:             /*
  847:             // temp until I fix changed-to problems
  848:             var changedAndChangedToServiceIdList = Ia.Ngn.Cl.Model.Data.ServiceRequest.ChangedAndChangedToServiceIdList();
  849:             foreach (var serviceId in changedAndChangedToServiceIdList)
  850:             {
  851:                 serviceToCreateServiceIdDictionary.Remove(serviceId);
  852:                 serviceToDeleteServiceIdDictionary.Remove(serviceId);
  853:             }
  854:             */
  855:  
  856:             var serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
  857:             foreach (var serviceId0 in serviceIdExemptionList)
  858:             {
  859:                 serviceToCreateServiceIdDictionary.Remove(serviceId0);
  860:                 serviceToDeleteServiceIdDictionary.Remove(serviceId0);
  861:             }
  862:         }
  863:  
  864:         ////////////////////////////////////////////////////////////////////////////
  865:  
  866:         /// <summary>
  867:         /// List of exempt number ids
  868:         /// </summary>
  869:         public static List<string> ServiceIdOfServiceExemptFromProvisionProcessingList()
  870:         {
  871:             List<string> list;
  872:  
  873:             list = new List<string>();
  874:  
  875:             foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceIdList()) list.Add(u);
  876:  
  877:             return list;
  878:         }
  879:  
  880:         ////////////////////////////////////////////////////////////////////////////
  881:  
  882:         /// <summary>
  883:         /// List of exempt services
  884:         /// </summary>
  885:         public static List<string> ServiceOfServiceExemptFromProvisionProcessingList()
  886:         {
  887:             List<string> list;
  888:  
  889:             list = new List<string>();
  890:  
  891:             foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceList()) list.Add(u);
  892:  
  893:             return list;
  894:         }
  895:  
  896:         ////////////////////////////////////////////////////////////////////////////
  897:         ////////////////////////////////////////////////////////////////////////////
  898:  
  899:         /// <summary>
  900:         ///
  901:         /// </summary>
  902:         public static List<string> ProvisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList(bool reloadData)
  903:         {
  904:             if (reloadData || provisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList == null || provisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList.Count == 0)
  905:             {
  906:                 lock (objectLock)
  907:                 {
  908:                     provisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList = _ProvisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList();
  909:                 }
  910:             }
  911:  
  912:             return provisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList;
  913:         }
  914:  
  915:         ////////////////////////////////////////////////////////////////////////////
  916:  
  917:         /// <summary>
  918:         ///
  919:         /// </summary>
  920:         private static List<string> _ProvisionedImsServiceWithNullAccessNotInPstnNorInNceOntSipInfoNorVoipPstnUserNorMsanWithinMsanDomainListList()
  921:         {
  922:             List<string> list;
  923:  
  924:             var imsServiceWithAccessNullList = Ia.Ngn.Cl.Model.Data.Service2.ImsServiceWithAccessNullList;
  925:             var serviceWithProvisionedTrueAndNullAccessList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceWithProvisionedTrueAndNullAccessList();
  926:  
  927:             var pstnServiceList = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceList;
  928:             var emsOntSipInfoServiceList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ServiceList();
  929:             var emsVoipPstnUserServiceList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ServiceList();
  930:  
  931:             var msanDomainList = Ia.Ngn.Cl.Model.Data.Service.MsanDomainList;
  932:  
  933:             var list0 = imsServiceWithAccessNullList.Intersect(serviceWithProvisionedTrueAndNullAccessList).ToList();
  934:             var list1 = pstnServiceList.Union(emsOntSipInfoServiceList).Union(emsVoipPstnUserServiceList).ToList();
  935:  
  936:             var list2 = list0.Except(list1).ToList();
  937:  
  938:             list = (from l in list2 where msanDomainList.Any(u => l.StartsWith(u.ToString())) select l).ToList();
  939:  
  940:             return list;
  941:         }
  942:  
  943:         ////////////////////////////////////////////////////////////////////////////
  944:         ////////////////////////////////////////////////////////////////////////////    
  945:     }
  946:  
  947:     ////////////////////////////////////////////////////////////////////////////
  948:     ////////////////////////////////////////////////////////////////////////////   
  949: }