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

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

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

    1: using System;
    2: using System.Collections;
    3: using System.Collections.Generic;
    4: using System.Data;
    5: using System.Linq;
    6: using System.Text.RegularExpressions;
    7:  
    8: namespace Ia.Ftn.Cl.Model.Business
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Provision support class of Fixed Telecommunications Network (FTN) business model.
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2006-2022 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 Provision
   30:     {
   31:         private static int imsServiceRequestAdministrativeIssueQueueOriginalCount, axePstnServiceSuspensionQueueOriginalCount, ewsdPstnServiceSuspensionQueueOriginalCount, aperiodicQueueOriginalCount;
   32:         private static int discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueueOriginalCount;
   33:  
   34:         private static Queue<KeyValuePair<string, string>> discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue = new Queue<KeyValuePair<string, string>>();
   35:         private static Queue<string> imsServiceRequestAdministrativeIssueQueue = new Queue<string>();
   36:         private static Queue<string> axePstnServiceSuspensionQueue = new Queue<string>();
   37:         private static Queue<string> ewsdPstnServiceSuspensionQueue = new Queue<string>();
   38:         private static Queue<string> aperiodicQueue = new Queue<string>();
   39:  
   40:         ////////////////////////////////////////////////////////////////////////////
   41:  
   42:         /// <summary>
   43:         ///
   44:         /// </summary>
   45:         public Provision() { }
   46:  
   47:         ////////////////////////////////////////////////////////////////////////////
   48:  
   49:         /// <summary>
   50:         ///
   51:         /// </summary>
   52:         public static bool CreateReadNokiaSwitchSubscriber(Ia.Ftn.Cl.Model.Client.Nokia.Ims ims, string accessName, string service, int port, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
   53:         {
   54:             bool executed, isSip;
   55:             int gatewayId;
   56:             string r;
   57:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
   58:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
   59:             Ia.Ftn.Cl.Model.Ont ont;
   60:             Ia.Ftn.Cl.Model.Huawei.EmsOnt emsOnt;
   61:  
   62:             executed = false;
   63:             result = string.Empty;
   64:  
   65:             switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
   66:  
   67:             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
   68:             {
   69:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
   70:                 {
   71:                     nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
   72:  
   73:                     if (nddOnt != null)
   74:                     {
   75:                         if (protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
   76:                         else isSip = protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.Sip;
   77:  
   78:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service) || overrideRouterDomainRestriction)
   79:                         {
   80:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
   81:  
   82:                             if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
   83:                             {
   84:                                 ont = Ia.Ftn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
   85:  
   86:                                 if (ont != null)
   87:                                 {
   88:                                     if (!isSip) // if H.248
   89:                                     {
   90:                                         gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
   91:  
   92:                                         if (gatewayId > 0)
   93:                                         {
   94:                                             port = (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ftn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
   95:  
   96:                                             if (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
   97:                                             {
   98:                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
   99:                                                 result += r + ",";
  100:  
  101:                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  102:                                                 result += r + ",";
  103:  
  104:                                                 executed = true;
  105:                                             }
  106:                                             else
  107:                                             {
  108:                                                 result += "port is invalid or does not exist,";
  109:                                             }
  110:                                         }
  111:                                         else
  112:                                         {
  113:                                             result += "gatewayId is invalid or does not exist,";
  114:                                         }
  115:                                     }
  116:                                     else // if IsSip == true
  117:                                     {
  118:                                         result += "No procedure defined for a SIP Nokia-Nokia IMS-Access setting,";
  119:                                     }
  120:                                 }
  121:                                 else
  122:                                 {
  123:                                     result += "ONT is null for access:" + nddOnt.Access.Name + ",";
  124:                                 }
  125:                             }
  126:                             else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  127:                             {
  128:                                 emsOnt = Ia.Ftn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
  129:  
  130:                                 if (emsOnt != null)
  131:                                 {
  132:                                     if (!isSip) // if H.248
  133:                                     {
  134:                                         gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  135:  
  136:                                         if (gatewayId > 0)
  137:                                         {
  138:                                             port = (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ftn.Cl.Model.Data.Default.NextVacantFlatTermIdForHuaweiEmsOntEquipmentTypeIdAndNokiaGatewayId(emsOnt.EquipmentType, gatewayId);
  139:  
  140:                                             if (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
  141:                                             {
  142:                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
  143:                                                 result += r + ",";
  144:  
  145:                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  146:                                                 result += r + ",";
  147:  
  148:                                                 executed = true;
  149:                                             }
  150:                                             else
  151:                                             {
  152:                                                 result += "port is invalid or does not exist,";
  153:                                             }
  154:                                         }
  155:                                         else
  156:                                         {
  157:                                             result += "gatewayId is invalid or does not exist,";
  158:                                         }
  159:                                     }
  160:                                     else // if IsSip == true
  161:                                     {
  162:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.CreateSipSubscriber(ims, service, nddOnt, out r);
  163:                                         result += r + ",";
  164:  
  165:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(ims, service, nddOnt, out r);
  166:                                         result += r + ",";
  167:  
  168:                                         executed = true;
  169:                                     }
  170:                                 }
  171:                                 else
  172:                                 {
  173:                                     result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
  174:                                 }
  175:                             }
  176:                             else
  177:                             {
  178:                                 throw new Exception("accessVendor is unknown. ");
  179:                             }
  180:                         }
  181:                         else result += "Service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
  182:                     }
  183:                     else result += "nddOnt is null, does not exist for access:" + accessName + ",";
  184:                 }
  185:                 else result += "service number does not belong to a Nokia switch.";
  186:             }
  187:             else
  188:             {
  189:                 throw new Exception("switchVendor is null or not Nokia. ");
  190:             }
  191:  
  192:             return executed;
  193:         }
  194:  
  195:         ////////////////////////////////////////////////////////////////////////////
  196:  
  197:         /// <summary>
  198:         ///
  199:         /// </summary>
  200:         public static bool DeleteReadNokiaSwitchSubscriber(Ia.Ftn.Cl.Model.Client.Nokia.Ims ims, string accessName, string service, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
  201:         {
  202:             bool executed, isSip;
  203:             int gatewayId;
  204:             string r;
  205:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  206:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  207:             Ia.Ftn.Cl.Model.Ont ont;
  208:  
  209:             executed = false;
  210:             result = string.Empty;
  211:  
  212:             switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
  213:  
  214:             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  215:             {
  216:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
  217:                 {
  218:                     nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
  219:  
  220:                     if (nddOnt != null)
  221:                     {
  222:                         if (protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
  223:                         else isSip = protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.Sip;
  224:  
  225:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service) || overrideRouterDomainRestriction)
  226:                         {
  227:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  228:  
  229:                             if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  230:                             {
  231:                                 ont = Ia.Ftn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  232:  
  233:                                 if (ont != null)
  234:                                 {
  235:                                     if (!isSip) // if H.248
  236:                                     {
  237:                                         gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  238:  
  239:                                         if (gatewayId > 0)
  240:                                         {
  241:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
  242:                                             result += r + ",";
  243:  
  244:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  245:                                             result += r + ",";
  246:  
  247:                                             executed = true;
  248:                                         }
  249:                                         else
  250:                                         {
  251:                                             result += "gatewayId is invalid or does not exist,";
  252:                                         }
  253:                                     }
  254:                                     else // if IsSip == true
  255:                                     {
  256:                                         result += "No procedure defined for a SIP Nokia-Nokia IMS-Access setting,";
  257:                                     }
  258:                                 }
  259:                                 else
  260:                                 {
  261:                                     result += "ont is null for access:" + nddOnt.Access.Name + ",";
  262:                                 }
  263:                             }
  264:                             else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  265:                             {
  266:                                 if (!isSip) // if H.248
  267:                                 {
  268:                                     gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  269:  
  270:                                     if (gatewayId > 0)
  271:                                     {
  272:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
  273:                                         result += r + ",";
  274:  
  275:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  276:                                         result += r + ",";
  277:  
  278:                                         executed = true;
  279:                                     }
  280:                                     else
  281:                                     {
  282:                                         result += "gatewayId is invalid or does not exist,";
  283:                                     }
  284:                                 }
  285:                                 else // if IsSip == true
  286:                                 {
  287:                                     Ia.Ftn.Cl.Model.Data.Nokia.Ims.DeleteSipSubscriber(ims, service, nddOnt, out r);
  288:                                     result += r + ",";
  289:  
  290:                                     Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(ims, service, nddOnt, out r);
  291:                                     result += r + ",";
  292:                                 }
  293:                             }
  294:                             else
  295:                             {
  296:                                 throw new Exception("accessVendor is unknown. ");
  297:                             }
  298:                         }
  299:                         else
  300:                         {
  301:                             result += "Service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
  302:                         }
  303:                     }
  304:                     else
  305:                     {
  306:                         result += "nddOnt is null, does not exist for access:" + accessName + ",";
  307:                     }
  308:                 }
  309:                 else result += "service number does not belong to a Nokia switch.";
  310:             }
  311:             else
  312:             {
  313:                 throw new Exception("switchVendor is null or not Nokia. ");
  314:             }
  315:  
  316:             return executed;
  317:         }
  318:  
  319:         ////////////////////////////////////////////////////////////////////////////
  320:         ////////////////////////////////////////////////////////////////////////////
  321:  
  322:         /// <summary>
  323:         ///
  324:         /// </summary>
  325:         public static bool DeleteReadNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(Ia.Ftn.Cl.Model.Client.Nokia.Ims ims, string service, out string result)
  326:         {
  327:             bool executed;
  328:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
  329:  
  330:             executed = false;
  331:             result = string.Empty;
  332:  
  333:             if (Ia.Ftn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  334:             {
  335:                 switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
  336:  
  337:                 if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  338:                 {
  339:                     if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
  340:                     {
  341:                         foreach (Ia.Ftn.Cl.Model.Business.Nokia.Ims.ImsBasicService ibs in Ia.Ftn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
  342:                         {
  343:                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, ibs.PrimarySwitch, ibs.Fsdb, out string r);
  344:                             result += r + ",";
  345:  
  346:                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadSubPartyAndSubscriber(ims, service, ibs.PrimarySwitch, ibs.Fsdb, ibs.Service, out r);
  347:                             result += r + ",";
  348:                         }
  349:  
  350:                         executed = true;
  351:                     }
  352:                     else result += "Error: service number does not belong to a valid Nokia switch. ";
  353:                 }
  354:                 else result += "Error: switchVendor is null or not Nokia. ";
  355:             }
  356:             else result += "Error: service \"" + service + "\" does not belong to the network.";
  357:  
  358:             return executed;
  359:         }
  360:  
  361:         ////////////////////////////////////////////////////////////////////////////
  362:         ////////////////////////////////////////////////////////////////////////////
  363:  
  364:         /// <summary>
  365:         ///
  366:         /// </summary>
  367:         public static bool ModifyReadNokiaSwitchSubscriberH248ToSip(Ia.Ftn.Cl.Model.Client.Nokia.Ims ims, string service, Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, out string result)
  368:         {
  369:             bool executed;
  370:             int gatewayId;
  371:             string r;
  372:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  373:             Ia.Ftn.Cl.Model.Ont ont;
  374:             Ia.Ftn.Cl.Model.Huawei.EmsOnt emsOnt;
  375:  
  376:             executed = false;
  377:             result = string.Empty;
  378:  
  379:             switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
  380:  
  381:             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  382:             {
  383:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
  384:                 {
  385:                     if (nddOnt != null)
  386:                     {
  387:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service))
  388:                         {
  389:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  390:  
  391:                             if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  392:                             {
  393:                                 ont = Ia.Ftn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  394:  
  395:                                 if (ont != null)
  396:                                 {
  397:                                     if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
  398:                                     {
  399:                                         gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  400:  
  401:                                         if (gatewayId > 0)
  402:                                         {
  403:                                             //Ia.Ftn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndAgcfEndpointToSip(ims, gatewayId, service, nddOnt, out r);
  404:                                             //result += r + ",";
  405:  
  406:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  407:                                             result += r + ",";
  408:  
  409:                                             executed = true;
  410:                                         }
  411:                                         else
  412:                                         {
  413:                                             result += "gatewayId is invalid or does not exist,";
  414:                                         }
  415:                                     }
  416:                                     else // if IsSip == true
  417:                                     {
  418:                                         result += "error: OLT is already SIP,";
  419:                                     }
  420:                                 }
  421:                                 else
  422:                                 {
  423:                                     result += "ONT is null for access:" + nddOnt.Access.Name + ",";
  424:                                 }
  425:                             }
  426:                             else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  427:                             {
  428:                                 emsOnt = Ia.Ftn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
  429:  
  430:                                 if (emsOnt != null)
  431:                                 {
  432:                                     if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
  433:                                     {
  434:                                         gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  435:  
  436:                                         if (gatewayId > 0)
  437:                                         {
  438:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndDeleteAgcfEndpointToSip(ims, service, nddOnt, out r);
  439:                                             result += r + ",";
  440:  
  441:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  442:                                             result += r + ",";
  443:  
  444:                                             executed = true;
  445:                                         }
  446:                                         else
  447:                                         {
  448:                                             result += "gatewayId is invalid or does not exist,";
  449:                                         }
  450:                                     }
  451:                                     else // if IsSip == true
  452:                                     {
  453:                                         result += "error: OLT is already SIP,";
  454:                                     }
  455:                                 }
  456:                                 else
  457:                                 {
  458:                                     result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
  459:                                 }
  460:                             }
  461:                             else
  462:                             {
  463:                                 throw new Exception("accessVendor is unknown. ");
  464:                             }
  465:                         }
  466:                         else
  467:                         {
  468:                             result += "Service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
  469:                         }
  470:                     }
  471:                     else
  472:                     {
  473:                         result += "nddOnt is null,";
  474:                     }
  475:                 }
  476:                 else result += "service number does not belong to a Nokia switch.";
  477:             }
  478:             else
  479:             {
  480:                 throw new Exception("switchVendor is null or not Nokia. ");
  481:             }
  482:  
  483:             return executed;
  484:         }
  485:  
  486:         ////////////////////////////////////////////////////////////////////////////
  487:         ////////////////////////////////////////////////////////////////////////////
  488:  
  489:         /// <summary>
  490:         ///
  491:         /// </summary>
  492:         public static bool CreateReadHuaweiSwitchSubscriber(Ia.Ftn.Cl.Model.Client.Huawei.Ims ims, string accessName, string service, int port, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
  493:         {
  494:             bool executed, created, isSip;
  495:             string r;
  496:             Ia.Ftn.Cl.Model.Business.Huawei.Default.FnSnPnPort fnSnPnPort;
  497:             Ia.Ftn.Cl.Model.Business.Huawei.Dev.MduDev mdu;
  498:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  499:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  500:             Ia.Ftn.Cl.Model.Huawei.EmsOnt emsOnt;
  501:             Ia.Ftn.Cl.Model.Ont ont;
  502:  
  503:             executed = false;
  504:             result = string.Empty;
  505:  
  506:             switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
  507:  
  508:             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  509:             {
  510:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
  511:                 {
  512:                     nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
  513:  
  514:                     if (nddOnt != null)
  515:                     {
  516:                         if (protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
  517:                         else isSip = protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.Sip;
  518:  
  519:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service) || overrideRouterDomainRestriction)
  520:                         {
  521:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  522:  
  523:                             if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  524:                             {
  525:                                 ont = Ia.Ftn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  526:  
  527:                                 if (ont != null)
  528:                                 {
  529:                                     if (isSip) // if SIP
  530:                                     {
  531:                                         result += "No procedure defined for a SIP Huawei-Nokia IMS-Access setting,";
  532:                                     }
  533:                                     else // if fsSip == false
  534:                                     {
  535:                                         port = (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ftn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
  536:  
  537:                                         if (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
  538:                                         {
  539:                                             Ia.Ftn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
  540:                                             result += r + ",";
  541:  
  542:                                             Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(ims, service, out r);
  543:                                             result += r + ",";
  544:  
  545:                                             // other commands will be issued through NCE NBI to configure H.248 in SKB and TEC softswitch
  546:  
  547:                                             executed = true;
  548:                                         }
  549:                                         else
  550:                                         {
  551:                                             result += "Port is invalid or does not exist,";
  552:                                         }
  553:                                     }
  554:                                 }
  555:                                 else
  556:                                 {
  557:                                     result += "Ont is null, does not exist for access:" + nddOnt.Access.Name + ",";
  558:                                 }
  559:                             }
  560:                             else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  561:                             {
  562:                                 emsOnt = Ia.Ftn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
  563:  
  564:                                 if (emsOnt != null)
  565:                                 {
  566:                                     if (isSip)
  567:                                     {
  568:                                         if (emsOnt.FamilyType == Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
  569:                                         {
  570:                                             var accessNameToMduDevDictionary = Ia.Ftn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
  571:  
  572:                                             if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  573:                                             {
  574:                                                 var pn = port;
  575:  
  576:                                                 mdu = accessNameToMduDevDictionary[nddOnt.Access.Name];
  577:  
  578:                                                 var vacantFnSnPnList = Ia.Ftn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mdu, emsOnt);
  579:  
  580:                                                 if (pn != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) fnSnPnPort = vacantFnSnPnList.Where(f => f.Pn == pn).SingleOrDefault();
  581:                                                 else fnSnPnPort = Ia.Ftn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mdu, emsOnt);
  582:  
  583:                                                 if (fnSnPnPort != null)
  584:                                                 {
  585:                                                     port = (port < 0) ? fnSnPnPort.Pn : port;
  586:  
  587:                                                     created = Ia.Ftn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
  588:  
  589:                                                     result += r + ",";
  590:                                                 }
  591:                                                 else result += "MDU sn and/or tel is invalid or does not exist. ";
  592:                                             }
  593:                                             else result += "emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name;
  594:                                         }
  595:                                         else // if not MDU
  596:                                         {
  597:                                             port = (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ftn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
  598:  
  599:                                             if (port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
  600:                                             {
  601:                                                 created = Ia.Ftn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
  602:  
  603:                                                 result += r + ",";
  604:                                             }
  605:                                             else result += "Port is invalid or does not exist,";
  606:                                         }
  607:                                     }
  608:                                     else // if H.248
  609:                                     {
  610:                                         result += "No procedure defined for an H.248 non-SIP Huawei-Huawei IMS-Access setting,";
  611:                                     }
  612:                                 }
  613:                                 else
  614:                                 {
  615:                                     result += "emsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
  616:                                 }
  617:  
  618:                                 Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt.Access.Id, out r);
  619:                                 result += r + ",";
  620:                             }
  621:                             else
  622:                             {
  623:                                 throw new Exception("accessVendor is unknown. ");
  624:                             }
  625:                         }
  626:                         else
  627:                         {
  628:                             result += "Service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
  629:                         }
  630:                     }
  631:                     else
  632:                     {
  633:                         Ia.Ftn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
  634:                         result += r + ",";
  635:  
  636:                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(ims, service, out r);
  637:                         result += r + ",";
  638:  
  639:                         executed = true;
  640:                     }
  641:                 }
  642:                 else result += "service number does not belong to a Huawei switch.";
  643:             }
  644:             else
  645:             {
  646:                 throw new Exception("switchVendor is null or not Huawei. ");
  647:             }
  648:  
  649:             return executed;
  650:         }
  651:  
  652:         ////////////////////////////////////////////////////////////////////////////
  653:  
  654:         /// <summary>
  655:         ///
  656:         /// </summary>
  657:         public static bool DeleteReadHuaweiSwitchSubscriber(Ia.Ftn.Cl.Model.Client.Huawei.Ims ims, string accessName, string service, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
  658:         {
  659:             bool executed, isSip;
  660:             string r;
  661:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  662:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  663:             Ia.Ftn.Cl.Model.Ont ont;
  664:  
  665:             executed = false;
  666:             result = string.Empty;
  667:  
  668:             switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
  669:  
  670:             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  671:             {
  672:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
  673:                 {
  674:                     nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
  675:  
  676:                     if (nddOnt != null)
  677:                     {
  678:                         if (protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
  679:                         else isSip = protocol == Ia.Ftn.Cl.Model.Business.Default.Protocol.Sip;
  680:  
  681:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service) || overrideRouterDomainRestriction)
  682:                         {
  683:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  684:  
  685:                             if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  686:                             {
  687:                                 ont = Ia.Ftn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  688:  
  689:                                 if (ont != null)
  690:                                 {
  691:                                     if (isSip)
  692:                                     {
  693:                                         result += "No procedure defined for a SIP Huawei-Nokia IMS-Access setting,";
  694:                                     }
  695:                                     else // if H.248
  696:                                     {
  697:                                         Ia.Ftn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
  698:                                         result += r + ",";
  699:  
  700:                                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt.Access.Id, out r);
  701:                                         result += r + ",";
  702:  
  703:                                         // other commands will be issued through NCE NBI to configure H.248 in SKB and TEC softswitch
  704:                                     }
  705:                                 }
  706:                                 else
  707:                                 {
  708:                                     result += "ont is null,";
  709:                                 }
  710:                             }
  711:                             else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  712:                             {
  713:                                 if (isSip)
  714:                                 {
  715:                                     Ia.Ftn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
  716:                                     result += r + ",";
  717:  
  718:                                     Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt.Access.Id, out r);
  719:                                     result += r + ",";
  720:                                 }
  721:                                 else // if H.248
  722:                                 {
  723:                                     result += "No procedure defined for an H.248 non-SIP Huawei-Huawei IMS-Access setting,";
  724:                                 }
  725:                             }
  726:                             else
  727:                             {
  728:                                 throw new Exception("accessVendor is unknown. ");
  729:                             }
  730:                         }
  731:                         else
  732:                         {
  733:                             result += "Service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
  734:                         }
  735:                     }
  736:                     else
  737:                     {
  738:                         Ia.Ftn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
  739:                         result += r + ",";
  740:  
  741:                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, string.Empty, out r);
  742:                         result += r + ",";
  743:                     }
  744:                 }
  745:                 else result += "service number does not belong to a Huawei switch.";
  746:             }
  747:             else
  748:             {
  749:                 throw new Exception("switchVendor is null or not Huawei. ");
  750:             }
  751:  
  752:             return executed;
  753:         }
  754:  
  755:         ////////////////////////////////////////////////////////////////////////////
  756:         ////////////////////////////////////////////////////////////////////////////
  757:  
  758:         /// <summary>
  759:         ///
  760:         /// </summary>
  761:         public static string ImsServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceListItem(out int serviceRequestAdministrativeIssueQueueCount, out string progressCounterString)
  762:         {
  763:             string service;
  764:  
  765:             if (imsServiceRequestAdministrativeIssueQueue.Count == 0)
  766:             {
  767:                 imsServiceRequestAdministrativeIssueQueue = new Queue<string>(Ia.Ftn.Cl.Model.Data.Provision.ImsServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList());
  768:  
  769:                 imsServiceRequestAdministrativeIssueQueueOriginalCount = imsServiceRequestAdministrativeIssueQueue.Count;
  770:             }
  771:  
  772:             if (imsServiceRequestAdministrativeIssueQueue.Count > 0) service = imsServiceRequestAdministrativeIssueQueue.Dequeue();
  773:             else service = null;
  774:  
  775:             progressCounterString = "(" + imsServiceRequestAdministrativeIssueQueue.Count + "/" + imsServiceRequestAdministrativeIssueQueueOriginalCount + ") ";
  776:  
  777:             serviceRequestAdministrativeIssueQueueCount = imsServiceRequestAdministrativeIssueQueue.Count;
  778:  
  779:             return service;
  780:         }
  781:  
  782:         /*
  783:         ////////////////////////////////////////////////////////////////////////////
  784: 
  785:         /// <summary>
  786:         ///
  787:         /// </summary>
  788:         public static string SequentialEricssonAxePstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(out int serviceSuspensionQueueCount, out string result)
  789:         {
  790:             string service;
  791: 
  792:             if (axePstnServiceSuspensionQueue.Count == 0)
  793:             {
  794:                 axePstnServiceSuspensionQueue = new Queue<string>(Ia.Ftn.Cl.Model.Data.Provision.EricssonAxePstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList());
  795: 
  796:                 axePstnServiceSuspensionQueueOriginalCount = axePstnServiceSuspensionQueue.Count;
  797:             }
  798: 
  799:             if (axePstnServiceSuspensionQueue.Count > 0) service = axePstnServiceSuspensionQueue.Dequeue();
  800:             else service = null;
  801: 
  802:             result = "(" + axePstnServiceSuspensionQueue.Count + "/" + axePstnServiceSuspensionQueueOriginalCount + ") ";
  803: 
  804:             serviceSuspensionQueueCount = axePstnServiceSuspensionQueue.Count;
  805: 
  806:             return service;
  807:         }
  808: 
  809:         ////////////////////////////////////////////////////////////////////////////
  810: 
  811:         /// <summary>
  812:         ///
  813:         /// </summary>
  814:         public static string SequentialSiemensEwsdPstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList(out int serviceSuspensionQueueCount, out string result)
  815:         {
  816:             string service;
  817: 
  818:             if (ewsdPstnServiceSuspensionQueue.Count == 0)
  819:             {
  820:                 ewsdPstnServiceSuspensionQueue = new Queue<string>(Ia.Ftn.Cl.Model.Data.Provision.SiemensEwsdPstnServiceSuspensionMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceList());
  821: 
  822:                 ewsdPstnServiceSuspensionQueueOriginalCount = ewsdPstnServiceSuspensionQueue.Count;
  823:             }
  824: 
  825:             if (ewsdPstnServiceSuspensionQueue.Count > 0) service = ewsdPstnServiceSuspensionQueue.Dequeue();
  826:             else service = null;
  827: 
  828:             result = "(" + ewsdPstnServiceSuspensionQueue.Count + "/" + ewsdPstnServiceSuspensionQueueOriginalCount + ") ";
  829: 
  830:             serviceSuspensionQueueCount = ewsdPstnServiceSuspensionQueue.Count;
  831: 
  832:             return service;
  833:         }
  834:         */
  835:  
  836:         ////////////////////////////////////////////////////////////////////////////
  837:         ////////////////////////////////////////////////////////////////////////////
  838:  
  839:         /// <summary>
  840:         ///
  841:         /// </summary>
  842:         public static KeyValuePair<string, string> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceItem(Ia.Ftn.Cl.Model.Business.Default.Procedure procedure, out int discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceQueueCount, out string progressCounterString)
  843:         {
  844:             return DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceItem(procedure, 0, out discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceQueueCount, out progressCounterString);
  845:         }
  846:  
  847:         ////////////////////////////////////////////////////////////////////////////
  848:  
  849:         /// <summary>
  850:         ///
  851:         /// </summary>
  852:         public static KeyValuePair<string, string> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceItem(Ia.Ftn.Cl.Model.Business.Default.Procedure procedure, int provisionWithinLastNDays, out int discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount, out string progressCounterString)
  853:         {
  854:             KeyValuePair<string, string> serviceIdAccessId;
  855:  
  856:             if (discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Count == 0 && procedure == Ia.Ftn.Cl.Model.Business.Default.Procedure.InitializeOrIterate)
  857:             {
  858:                 var dictionary1 = DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdAccessIdDictionary(provisionWithinLastNDays);
  859:                 var dictionary2 = DiscrepancyBetweenServiceRequestServiceAndServiceServiceIdDictionary(provisionWithinLastNDays);
  860:  
  861:                 var dictionary = new Dictionary<string, string>();
  862:  
  863:                 foreach (var kvp in dictionary1) dictionary[kvp.Key] = kvp.Value;
  864:  
  865:                 foreach (var kvp in dictionary2)
  866:                 {
  867:                     if (!dictionary.ContainsKey(kvp.Key))
  868:                     {
  869:                         dictionary[kvp.Key] = kvp.Value;
  870:                     }
  871:                 }
  872:  
  873:                 discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue = new Queue<KeyValuePair<string, string>>(dictionary);
  874:  
  875:                 discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueueOriginalCount = discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Count;
  876:             }
  877:  
  878:             if (discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Count > 0) serviceIdAccessId = discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Dequeue();
  879:             else serviceIdAccessId = new KeyValuePair<string, string>();
  880:  
  881:             progressCounterString = "(" + discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Count + "/" + discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueueOriginalCount + ")";
  882:  
  883:             discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount = discrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceQueue.Count;
  884:  
  885:             return serviceIdAccessId;
  886:         }
  887:  
  888:         ////////////////////////////////////////////////////////////////////////////
  889:  
  890:         /// <summary>
  891:         ///
  892:         /// </summary>
  893:         public static Dictionary<string, string> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdAccessIdDictionary(int provisionWithinLastNDays)
  894:         {
  895:             Ia.Ftn.Cl.Model.Data.Provision.ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary);
  896:  
  897:             var dictionary = new Dictionary<string, string>();
  898:  
  899:             foreach (KeyValuePair<string, string> s in serviceToUpdateServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
  900:             foreach (KeyValuePair<string, string> s in serviceToCreateServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
  901:             foreach (KeyValuePair<string, string> s in serviceToDeleteServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
  902:  
  903:             return dictionary;
  904:         }
  905:  
  906:         ////////////////////////////////////////////////////////////////////////////
  907:  
  908:         /// <summary>
  909:         ///
  910:         /// </summary>
  911:         public static Dictionary<string, string> DiscrepancyBetweenServiceRequestServiceAndServiceServiceIdDictionary(int provisionWithinLastNDays)
  912:         {
  913:             Ia.Ftn.Cl.Model.Data.Provision.ServiceToCreateServiceIdDictionary_ServiceToDeleteServiceIdDictionary(provisionWithinLastNDays, out Dictionary<string, string> serviceToCreateServiceIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdDictionary);
  914:  
  915:             var dictionary = new Dictionary<string, string>();
  916:  
  917:             foreach (KeyValuePair<string, string> s in serviceToCreateServiceIdDictionary) dictionary.Add(s.Key, s.Value);
  918:             foreach (KeyValuePair<string, string> s in serviceToDeleteServiceIdDictionary) dictionary.Add(s.Key, s.Value);
  919:  
  920:             //return dictionary.Where(u => u.Key.StartsWith("2390")).ToDictionary(u => u.Key, u => u.Value); // to work with || s.Name == "RKK"
  921:             return dictionary;
  922:         }
  923:  
  924:         ////////////////////////////////////////////////////////////////////////////
  925:  
  926:         /// <summary>
  927:         ///
  928:         /// </summary>
  929:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(int provisioningWithinPastNHours, List<string> priorityServiceList)
  930:         {
  931:             DateTime pastNHoursDateTime;
  932:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList, laterProcessList;
  933:  
  934:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
  935:             laterProcessList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
  936:  
  937:             pastNHoursDateTime = (provisioningWithinPastNHours > 0) ? DateTime.UtcNow.AddHours(3).AddHours(-provisioningWithinPastNHours) : DateTime.MinValue;
  938:  
  939:             Ia.Ftn.Cl.Model.Business.Provision.ServiceOntToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceOntToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList);
  940:  
  941:             foreach (var serviceOnt in serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList)
  942:             {
  943:                 if (serviceOnt.CreatedDateTime >= pastNHoursDateTime || priorityServiceList.Contains(serviceOnt.Service))
  944:                 {
  945:                     var p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Create, DateTime = serviceOnt.CreatedDateTime };
  946:                     processList.Add(p);
  947:  
  948:                     p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime };
  949:                     processList.Add(p);
  950:                     laterProcessList.Add(p);
  951:                 }
  952:             }
  953:  
  954:             foreach (var serviceOnt in serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
  955:             {
  956:                 if (serviceOnt.CreatedDateTime >= pastNHoursDateTime || priorityServiceList.Contains(serviceOnt.Service))
  957:                 {
  958:                     var p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Delete, DateTime = serviceOnt.CreatedDateTime };
  959:                     processList.Add(p);
  960:  
  961:                     p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime };
  962:                     processList.Add(p);
  963:                     laterProcessList.Add(p);
  964:                 }
  965:             }
  966:  
  967:             processList = processList.OrderByDescending(l => l.DateTime).ToList();
  968:  
  969:             processList.AddRange(laterProcessList);
  970:  
  971:             return processList;
  972:         }
  973:  
  974:         ////////////////////////////////////////////////////////////////////////////
  975:  
  976:         /// <summary>
  977:         ///
  978:         /// </summary>
  979:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> _ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(int provisioningWithinPastNHours, List<string> priorityServiceList)
  980:         {
  981:             DateTime pastNHoursDateTime;
  982:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList, laterProcessList;
  983:  
  984:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
  985:             laterProcessList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
  986:  
  987:             pastNHoursDateTime = (provisioningWithinPastNHours > 0) ? DateTime.UtcNow.AddHours(3).AddHours(-provisioningWithinPastNHours) : DateTime.MinValue;
  988:  
  989:             /*
  990:             Ia.Ftn.Cl.Model.Business.Provision.ServiceOntToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceOntToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList);
  991: 
  992:             foreach (var serviceOnt in serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList)
  993:             {
  994:                 if (serviceOnt.CreatedDateTime >= pastNHoursDateTime || priorityServiceList.Contains(serviceOnt.Service))
  995:                 {
  996:                     var p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Create, DateTime = serviceOnt.CreatedDateTime };
  997:                     processList.Add(p);
  998: 
  999:                     p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime };
 1000:                     processList.Add(p);
 1001:                     laterProcessList.Add(p);
 1002:                 }
 1003:             }
 1004: 
 1005:             foreach (var serviceOnt in serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 1006:             {
 1007:                 if (serviceOnt.CreatedDateTime >= pastNHoursDateTime || priorityServiceList.Contains(serviceOnt.Service))
 1008:                 {
 1009:                     var p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Delete, DateTime = serviceOnt.CreatedDateTime };
 1010:                     processList.Add(p);
 1011: 
 1012:                     p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime };
 1013:                     processList.Add(p);
 1014:                     laterProcessList.Add(p);
 1015:                 }
 1016:             }
 1017: 
 1018:             processList = processList.OrderByDescending(l => l.DateTime).ToList();
 1019: 
 1020:             processList.AddRange(laterProcessList);
 1021:             */
 1022:  
 1023:             return processList;
 1024:         }
 1025:  
 1026:         ////////////////////////////////////////////////////////////////////////////
 1027:  
 1028:         /// <summary>
 1029:         ///
 1030:         /// </summary>
 1031:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> MsanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceList()
 1032:         {
 1033:             string dn;
 1034:             List<string> serviceExemptionList;
 1035:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList, laterProcessList;
 1036:  
 1037:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1038:             laterProcessList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1039:  
 1040:             var list1 = Ia.Ftn.Cl.Model.Business.Provision.MsanServicesThatHaveProvisionedImsServiceExceptWhereEmsOntSipInfoEmsOntIsOfflineOrDeviceOfflineErrorAndExceptWhereEmsVoipPstnUserEmsDevHasDeviceOfflineErrorAndIgnoringNonSipNokiaOntList();
 1041:             var list2 = Ia.Ftn.Cl.Model.Business.Provision.MsanServiceInVoipPstnUserThatHaveNoEquivalentInServiceList();
 1042:  
 1043:             var list = list1.Union(list2).ToList();
 1044:  
 1045:             // will exclude exempt numbers
 1046:             serviceExemptionList = Ia.Ftn.Cl.Model.Data.Provision.ServiceOfServiceExemptFromProvisionProcessingList();
 1047:  
 1048:             foreach (string service in serviceExemptionList) list.Remove(service);
 1049:  
 1050:             var voipPstnUserDidFnSnPnDnMsanList = Ia.Ftn.Cl.Model.Data.Huawei.VoipPstnUser.DidFnSnPnDnMsanList();
 1051:  
 1052:             foreach (var service in list)
 1053:             {
 1054:                 dn = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ImpuAid(service);
 1055:  
 1056:                 var voipPstnUserDidFnSnPnDnMsan = (from vpudfspdm in voipPstnUserDidFnSnPnDnMsanList
 1057:                                                    where vpudfspdm.Dn == dn
 1058:                                                    select vpudfspdm).FirstOrDefault();
 1059:  
 1060:                 if (voipPstnUserDidFnSnPnDnMsan != null)
 1061:                 {
 1062:                     var p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = service, EmsVoipPstnUserDidFnSnPnDn = voipPstnUserDidFnSnPnDnMsan, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Delete };
 1063:                     processList.Add(p);
 1064:  
 1065:                     p = new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = service, EmsVoipPstnUserDidFnSnPnDn = voipPstnUserDidFnSnPnDnMsan, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read };
 1066:                     processList.Add(p);
 1067:                     laterProcessList.Add(p);
 1068:                 }
 1069:             }
 1070:  
 1071:             processList = processList.OrderByDescending(l => l.DateTime).ToList();
 1072:  
 1073:             processList.AddRange(laterProcessList);
 1074:  
 1075:             return processList;
 1076:         }
 1077:  
 1078:         ////////////////////////////////////////////////////////////////////////////
 1079:  
 1080:         /// <summary>
 1081:         ///
 1082:         /// </summary>
 1083:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> ServiceOntToAddAndToRemoveInAsbrList()
 1084:         {
 1085:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList;
 1086:  
 1087:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1088:  
 1089:             Ia.Ftn.Cl.Model.Business.Provision.ServiceOntToAddToAsbrList_ServiceOntToRemoveFromAsbrList(out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToAddToAsbrList, out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToRemoveFromAsbrList);
 1090:  
 1091:             // issue read, execute, then read again commands
 1092:             foreach (var serviceOnt in serviceOntToAddToAsbrList)
 1093:             {
 1094:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Create, DateTime = serviceOnt.CreatedDateTime });
 1095:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime });
 1096:             }
 1097:  
 1098:             foreach (var serviceOnt in serviceOntToRemoveFromAsbrList)
 1099:             {
 1100:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Delete, DateTime = serviceOnt.CreatedDateTime });
 1101:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime });
 1102:             }
 1103:  
 1104:             return processList;
 1105:         }
 1106:  
 1107:         ////////////////////////////////////////////////////////////////////////////
 1108:  
 1109:         /// <summary>
 1110:         /// Find the provisioned services within SIP OLTs that do not have equivalent OntSipInfo or VoipPstnUser records, and all OntSipInfo and VoipPstnUser records that do note have equivalent services within SIP OLTs.
 1111:         /// </summary>
 1112:         private static void ServiceOntToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceOntToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 1113:         {
 1114:             Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated serviceOnt2;
 1115:             List<string> serviceIdExemptionList;
 1116:             List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList;
 1117:             List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList, voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList;
 1118:  
 1119:             serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList = new List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated>();
 1120:             serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList = new List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated>();
 1121:  
 1122:             serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ftn.Cl.Model.Data.Service2.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList;
 1123:             serviceOntList = Ia.Ftn.Cl.Model.Data.Service2.ServiceOntList;
 1124:             ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ftn.Cl.Model.Data.Huawei.OntSipInfo.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList();
 1125:             voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ftn.Cl.Model.Data.Huawei.VoipPstnUser.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList();
 1126:  
 1127:             foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 1128:             {
 1129:                 if (!ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)
 1130:                     && !voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId))
 1131:                 {
 1132:                     if (!serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1133:                     {
 1134:                         serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Add(serviceOnt);
 1135:                     }
 1136:                 }
 1137:             }
 1138:  
 1139:  
 1140:             // In serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList I must make sure that serviceId does not belong to any current service in serviceOntList
 1141:             // this is to allow NCE and POTS to Access migration without interruption or feedback from the vendor. Any number deleted from IMS will be deleted from NCE.
 1142:  
 1143:             foreach (var ontSipInfoServiceOnt in ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 1144:             {
 1145:                 if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1146:                 {
 1147:                     if (!serviceOntList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 1148:                     {
 1149:                         if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1150:                         {
 1151:                             serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(ontSipInfoServiceOnt);
 1152:                         }
 1153:                     }
 1154:                 }
 1155:                 /*
 1156:                 else if (serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.CreatedDateTime > ontSipInfoServiceOnt.CreatedDateTime))
 1157:                 {
 1158:                     // below: we will check for and add all NCE records that were created *before* the IMS records
 1159: 
 1160:                     if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId))
 1161:                     {
 1162:                         serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(ontSipInfoServiceOnt);
 1163:                     }
 1164:                 }
 1165:                 */
 1166:             }
 1167:  
 1168:             foreach (var voipPstnUserServiceOnt in voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 1169:             {
 1170:                 if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1171:                 {
 1172:                     if (!serviceOntList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 1173:                     {
 1174:                         if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1175:                         {
 1176:                             serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(voipPstnUserServiceOnt);
 1177:                         }
 1178:                     }
 1179:                 }
 1180:                 /*
 1181:                 else if (serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.CreatedDateTime > voipPstnUserServiceOnt.CreatedDateTime))
 1182:                 {
 1183:                     // below: we will check for and add all NCE records that were created *before* the IMS records
 1184: 
 1185:                     if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId))
 1186:                     {
 1187:                         serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(voipPstnUserServiceOnt);
 1188:                     }
 1189:                 }
 1190:                 */
 1191:             }
 1192:  
 1193:             // will exclude exempt numbers
 1194:             serviceIdExemptionList = Ia.Ftn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
 1195:             foreach (string serviceId in serviceIdExemptionList)
 1196:             {
 1197:                 serviceOnt2 = serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.SingleOrDefault(u => u.ServiceId == serviceId);
 1198:                 if (serviceOnt2 != null) serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Remove(serviceOnt2);
 1199:  
 1200:                 serviceOnt2 = serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.SingleOrDefault(u => u.ServiceId == serviceId);
 1201:                 if (serviceOnt2 != null) serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Remove(serviceOnt2);
 1202:             }
 1203:         }
 1204:  
 1205:         ////////////////////////////////////////////////////////////////////////////
 1206:  
 1207:         /// <summary>
 1208:         ///
 1209:         /// </summary>
 1210:         public static List<string> MsanServicesThatHaveProvisionedImsServiceExceptWhereEmsOntSipInfoEmsOntIsOfflineOrDeviceOfflineErrorAndExceptWhereEmsVoipPstnUserEmsDevHasDeviceOfflineErrorAndIgnoringNonSipNokiaOntList()
 1211:         {
 1212:             var serviceList = Ia.Ftn.Cl.Model.Data.Service2.ImsServiceInAllowedToBeMigratedOltList;
 1213:             var msanServiceList = Ia.Ftn.Cl.Model.Data.Service2.MsanServiceList;
 1214:  
 1215:             var serviceWhereEmsOntIsOfflineList = Ia.Ftn.Cl.Model.Data.Huawei.OntSipInfo.ServiceWithinEmsOntSipInfoWhereEmsOntResultCodeOntIsOfflineOrDeviceOfflineErrorList();
 1216:             var serviceWhereEmsDevDeviceOfflineError = Ia.Ftn.Cl.Model.Data.Huawei.VoipPstnUser.ServiceWithinEmsVoipPstnUserWhereEmsDevResultCodeDeviceOfflineError();
 1217:  
 1218:             //var serviceWhereOntIsOfflineList = Ia.Ftn.Cl.Model.Data.Nokia.Ont.ServiceWhereOntIsOfflineList();
 1219:  
 1220:             var list = msanServiceList.Intersect(serviceList).ToList();
 1221:  
 1222:             list = list.Except(serviceWhereEmsOntIsOfflineList).ToList();
 1223:             list = list.Except(serviceWhereEmsDevDeviceOfflineError).ToList();
 1224:  
 1225:             return list;
 1226:         }
 1227:  
 1228:         ////////////////////////////////////////////////////////////////////////////
 1229:  
 1230:         /// <summary>
 1231:         ///
 1232:         /// </summary>
 1233:         public static List<string> MsanServiceInVoipPstnUserThatHaveNoEquivalentInServiceList()
 1234:         {
 1235:             List<string> list;
 1236:  
 1237:             var serviceList = Ia.Ftn.Cl.Model.Data.Service2.ServiceList;
 1238:             var msanServiceList = Ia.Ftn.Cl.Model.Data.Huawei.VoipPstnUser.MsanServiceList;
 1239:  
 1240:             list = msanServiceList.Except(serviceList).ToList();
 1241:  
 1242:             return list;
 1243:         }
 1244:  
 1245:         ////////////////////////////////////////////////////////////////////////////
 1246:  
 1247:         /// <summary>
 1248:         ///
 1249:         /// </summary>
 1250:         public static void ServiceOntToAddToAsbrList_ServiceOntToRemoveFromAsbrList(out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> addList, out List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> removeList)
 1251:         {
 1252:             Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated serviceOnt2;
 1253:             List<string> serviceIdExemptionList;
 1254:             List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList;
 1255:             List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated> asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList;
 1256:  
 1257:             addList = new List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated>();
 1258:             removeList = new List<Ia.Ftn.Cl.Model.Business.ServiceAccessIpOntCreated>();
 1259:  
 1260:             //List<string> list;
 1261:  
 1262:             /*
 1263: select s.Service from Service2 s
 1264: inner join ServiceRequestServices srs on s.Id = srs.Id
 1265: inner join Accesses a on a.Id = srs.Access_Id
 1266: inner join Sbrs sb on 'sip:+965'+ s.Service +'@ims.moc.kw' = sb.IMPU
 1267: left outer join Asbrs asb on sb.IMPU = asb.PUI
 1268: where (a.Olt = 102010101 or a.Olt = 102010201) -- OLT ids MUB:102010101 QRN:102010201
 1269: and srs.Provisioned = 1
 1270: and asb.Id is null
 1271: order by s.Service
 1272:              */
 1273:  
 1274:             /*
 1275:             // for oltId intersect AllowedToBeMigrated with Hu-No OLTs
 1276:             var oltIdList = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaAccessOltIdList;
 1277: 
 1278:             //var i = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
 1279: 
 1280:             using (var db = new Ia.Ftn.Cl.Model.Ftn())
 1281:             {
 1282:                 var list = (from s in db.Service2s
 1283:                             join srs in db.ServiceRequestServices on s.Id equals srs.Id
 1284:                             join a in db.Accesses on srs.Access.Id equals a.Id
 1285:                             //join sbr in db.Sbrs on "sip:+965" + s.Service + "@ims.moc.kw" equals sbr.IMPU
 1286:                             //join asbr in db.Asbrs on sbr.IMPU equals asbr.PUI into gj
 1287:                             //from u in gj.DefaultIfEmpty()
 1288:                             where oltIdList.Contains(a.Olt) && srs.Provisioned == true //&& u == null
 1289:                             orderby s.Service
 1290:                             select new { s.Service, AccessId = a.Id }).ToList();
 1291: 
 1292:                 //var l = (from a in list select i[a.AccessId]).Distinct().ToList();
 1293:                 var l = (from a in list select a.AccessId).Distinct().ToList();
 1294:             }
 1295: 
 1296: 
 1297:             //return list;
 1298:             */
 1299:  
 1300:             serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList = Ia.Ftn.Cl.Model.Data.Service2.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList();
 1301:             serviceOntList = Ia.Ftn.Cl.Model.Data.Service2.ServiceOntList;
 1302:             asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList = Ia.Ftn.Cl.Model.Data.Huawei.Asbr.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList();
 1303:  
 1304:             foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList)
 1305:             {
 1306:                 if (!asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId))
 1307:                 {
 1308:                     if (!addList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1309:                     {
 1310:                         addList.Add(serviceOnt);
 1311:                     }
 1312:                 }
 1313:             }
 1314:  
 1315:             foreach (var serviceOnt in asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList)
 1316:             {
 1317:                 if (!serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1318:                 {
 1319:                     if (!serviceOntList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 1320:                     {
 1321:                         if (!removeList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 1322:                         {
 1323:                             removeList.Add(serviceOnt);
 1324:                         }
 1325:                     }
 1326:                 }
 1327:                 else if (serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/ && u.CreatedDateTime > serviceOnt.CreatedDateTime))
 1328:                 {
 1329:                     // below: we will check for and add all NCE records that were created *before* the IMS records
 1330:  
 1331:                     if (!removeList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/))
 1332:                     {
 1333:                         removeList.Add(serviceOnt);
 1334:                     }
 1335:                 }
 1336:             }
 1337:  
 1338:             // will exclude exempt numbers
 1339:             serviceIdExemptionList = Ia.Ftn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
 1340:             foreach (string serviceId in serviceIdExemptionList)
 1341:             {
 1342:                 serviceOnt2 = addList.SingleOrDefault(u => u.ServiceId == serviceId);
 1343:                 if (serviceOnt2 != null) addList.Remove(serviceOnt2);
 1344:  
 1345:                 serviceOnt2 = removeList.SingleOrDefault(u => u.ServiceId == serviceId);
 1346:                 if (serviceOnt2 != null) removeList.Remove(serviceOnt2);
 1347:             }
 1348:         }
 1349:  
 1350:         /*
 1351:         ////////////////////////////////////////////////////////////////////////////
 1352:         ////////////////////////////////////////////////////////////////////////////
 1353: 
 1354:         /// <summary>
 1355:         ///
 1356:         /// </summary>
 1357:         public static List<string> ServiceSuspendedInServiceRequestServiceButNotInServiceStringNumberList
 1358:         {
 1359:             get
 1360:             {
 1361:                 List<string> list, sList, srsList;
 1362:                 SortedList sl;
 1363: 
 1364:                 sList = Ia.Ftn.Cl.Model.Data.Service2.ServiceSuspensionIsTrueStringNumberList;
 1365:                 srsList = Ia.Ftn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueAndProvisionedIsTrueStringNumberList;
 1366: 
 1367:                 if (sList != null && sList.Count > 0)
 1368:                 {
 1369:                     if (srsList != null && srsList.Count > 0)
 1370:                     {
 1371:                         list = new List<string>(sList.Count);
 1372: 
 1373:                         sl = new SortedList(sList.ToDictionary(s => s));
 1374: 
 1375:                         foreach (string s in srsList)
 1376:                         {
 1377:                             if (!sl.ContainsKey(s)) list.Add(s);
 1378:                         }
 1379:                     }
 1380:                     else
 1381:                     {
 1382:                         list = new List<string>();
 1383:                     }
 1384:                 }
 1385:                 else
 1386:                 {
 1387:                     if (srsList != null && srsList.Count > 0) list = sList;
 1388:                     else list = new List<string>();
 1389:                 }
 1390: 
 1391:                 return list;
 1392:             }
 1393:         }
 1394:         */
 1395:  
 1396:         /*
 1397:         ////////////////////////////////////////////////////////////////////////////
 1398: 
 1399:         /// <summary>
 1400:         ///
 1401:         /// </summary>
 1402:         public static List<string> ServiceActiveInServiceRequestServiceButNotInServiceStringNumberList
 1403:         {
 1404:             get
 1405:             {
 1406:                 List<string> list, sList, srsList;
 1407:                 SortedList sl;
 1408: 
 1409:                 sList = Ia.Ftn.Cl.Model.Data.Service2.ServiceSuspensionIsFalseStringNumberList;
 1410:                 srsList = Ia.Ftn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsFalseStringNumberList;
 1411: 
 1412:                 if (sList != null && sList.Count > 0)
 1413:                 {
 1414:                     if (srsList != null && srsList.Count > 0)
 1415:                     {
 1416:                         list = new List<string>(sList.Count);
 1417: 
 1418:                         sl = new SortedList(sList.ToDictionary(s => s));
 1419: 
 1420:                         foreach (string s in srsList)
 1421:                         {
 1422:                             if (!sl.ContainsKey(s)) list.Add(s);
 1423:                         }
 1424:                     }
 1425:                     else
 1426:                     {
 1427:                         list = new List<string>();
 1428:                     }
 1429:                 }
 1430:                 else
 1431:                 {
 1432:                     if (srsList != null && srsList.Count > 0) list = sList;
 1433:                     else list = new List<string>();
 1434:                 }
 1435: 
 1436:                 return list;
 1437:             }
 1438:         }
 1439:         */
 1440:  
 1441:         ////////////////////////////////////////////////////////////////////////////
 1442:  
 1443:         /// <summary>
 1444:         ///
 1445:         /// </summary>
 1446:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> EmsOntToBeUpdatedFromH248ToSipList()
 1447:         {
 1448:             List<string> oltSymbolList;
 1449:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList;
 1450:  
 1451:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1452:  
 1453:             oltSymbolList = Ia.Ftn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
 1454:  
 1455:             var list = Ia.Ftn.Cl.Model.Data.Default.DistinctNddOntWhereVaprofIsNotAluSipBAndIgnoreMduForOltSymbolListList(oltSymbolList);
 1456:  
 1457:             foreach (var l in list)
 1458:             {
 1459:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Update });
 1460:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read });
 1461:             }
 1462:  
 1463:             return processList;
 1464:         }
 1465:  
 1466:         ////////////////////////////////////////////////////////////////////////////
 1467:  
 1468:         /// <summary>
 1469:         ///
 1470:         /// </summary>
 1471:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList()
 1472:         {
 1473:             int pn;
 1474:             List<string> oltSymbolList;
 1475:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList;
 1476:  
 1477:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1478:  
 1479:             oltSymbolList = Ia.Ftn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
 1480:  
 1481:             var list = Ia.Ftn.Cl.Model.Data.Default.ServiceAndNddOntAndEmsOntFamilyTypeAndPortWhereAgcfEndpointPortIsNot0AndVaprofIsAluSipBAndSfuEmsOntSipInfoTelDoesNotExistOrMduEmsVagIsSipAndMduEmsVoipPstnUserPnDoesNotExistForOltSymbolListList(oltSymbolList);
 1482:  
 1483:             /*
 1484:              * All Nokia ONTs (SFUs and MDUs) start at port position 1.
 1485:              * Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0.
 1486:              */
 1487:  
 1488:             // issue update then read commands
 1489:             foreach (var l in list)
 1490:             {
 1491:                 if (l.EmsOntFamilyType == Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu)
 1492:                 {
 1493:                     processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu, Port = l.Port, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Update });
 1494:                     processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu, Port = l.Port, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read });
 1495:                 }
 1496:                 else if (l.EmsOntFamilyType == Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 1497:                 {
 1498:                     pn = Ia.Ftn.Cl.Model.Business.Service.ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(l.Port);
 1499:  
 1500:                     processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu, Port = pn, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Update });
 1501:                     processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ftn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu, Port = pn, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.Read });
 1502:                 }
 1503:                 else
 1504:                 {
 1505:                     throw new Exception("EmsOntFamilyType is not concedered. ");
 1506:                 }
 1507:             }
 1508:  
 1509:             return processList;
 1510:         }
 1511:  
 1512:         ////////////////////////////////////////////////////////////////////////////
 1513:  
 1514:         /// <summary>
 1515:         ///
 1516:         /// </summary>
 1517:         public static List<Ia.Ftn.Cl.Model.Business.Procedure.Process> NokiaImsSubscriberToBeUpdatedFromH248ToSipList()
 1518:         {
 1519:             List<string> oltSymbolList;
 1520:             List<Ia.Ftn.Cl.Model.Business.Procedure.Process> processList;
 1521:  
 1522:             processList = new List<Ia.Ftn.Cl.Model.Business.Procedure.Process>();
 1523:  
 1524:             oltSymbolList = Ia.Ftn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
 1525:  
 1526:             var list = Ia.Ftn.Cl.Model.Data.Default.ServiceAndNddOntWherePrimaryPuidcpeProfileNumberIsNot10AndEmsOntVaprofIsAluSipBAndSfuEmsOntSipInfoTelExistsOrAndMduEmsOntVagIsSipAndMduEmsVoipPstnUserPnExistsForOltSymbolListList(oltSymbolList);
 1527:  
 1528:             // issue delete then create commands
 1529:             foreach (var l in list)
 1530:             {
 1531:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Protocol = Ia.Ftn.Cl.Model.Business.Default.Protocol.H248, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.DeleteRead });
 1532:  
 1533:                 processList.Add(new Ia.Ftn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Protocol = Ia.Ftn.Cl.Model.Business.Default.Protocol.Sip, Type = Ia.Ftn.Cl.Model.Business.Procedure.ProcessType.CreateRead });
 1534:             }
 1535:  
 1536:             return processList;
 1537:         }
 1538:  
 1539:         ////////////////////////////////////////////////////////////////////////////    
 1540:         ////////////////////////////////////////////////////////////////////////////    
 1541:  
 1542:         /// <summary>
 1543:         ///
 1544:         /// </summary>
 1545:         public static void ReadService(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms, string input, out Ia.Cl.Models.Result result)
 1546:         {
 1547:             int gatewayId, port;
 1548:             long number;
 1549:             string partyId, r;
 1550:             string accessId, service;
 1551:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1552:             Ia.Ftn.Cl.Model.Service2 service2;
 1553:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 1554:  
 1555:             result = new Ia.Cl.Models.Result();
 1556:  
 1557:             if (!string.IsNullOrEmpty(input))
 1558:             {
 1559:                 input = input.Trim();
 1560:                 //input = input.ToLower();
 1561:  
 1562:                 number = long.Parse(input);
 1563:  
 1564:                 if (Ia.Ftn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
 1565:                 {
 1566:                     service = number.ToString();
 1567:  
 1568:                     result.AddSuccess("Service: " + service + " ");
 1569:  
 1570:                     /*
 1571:                      * Note that in find.aspx (Ia.Ftn.Cl.Model.Ui.Default) I actually hide access name if port is undefined.
 1572:                      * case "service2AccessNameHyperLink":
 1573:                      * {
 1574:                      *   if (service2.AccessName != null && service2.Port != Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 1575:                      *   {
 1576:                      *     hl.Text = service2.AccessName;
 1577:                      *     hl.NavigateUrl = Ia.Ftn.Cl.Model.Business.Maintenance.Find.Url(service2.AccessName);
 1578:                      *   }
 1579:                      *   break;
 1580:                      * }
 1581: 
 1582:                      */
 1583:  
 1584:                     Ia.Ftn.Cl.Model.Data.Service.AccessIdAndPortByService(service, out accessId, out port);
 1585:  
 1586:                     // below: I should remove the whole section within if(){} below
 1587:                     if (string.IsNullOrEmpty(accessId))
 1588:                     {
 1589:                         var serviceType = Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService;
 1590:                         var serviceId = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 1591:  
 1592:                         // attempt a read from Service2
 1593:                         service2 = Ia.Ftn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
 1594:  
 1595:                         if (service2 != null && service2.Access != null) accessId = service2.Access.Id;
 1596:                         else
 1597:                         {
 1598:                             // attempt a read from ServiceRequestService
 1599:                             var serviceRequestService = Ia.Ftn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
 1600:  
 1601:                             if (serviceRequestService != null && serviceRequestService.Access != null) accessId = serviceRequestService.Access.Id;
 1602:                             else accessId = string.Empty;
 1603:                         }
 1604:                     }
 1605:  
 1606:                     if (!string.IsNullOrEmpty(accessId))
 1607:                     {
 1608:                         // get service information using accessId
 1609:  
 1610:                         nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(accessId);
 1611:  
 1612:                         if (nddOnt != null)
 1613:                         {
 1614:                             switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
 1615:                             accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 1616:  
 1617:                             try
 1618:                             {
 1619:                                 if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1620:                                 {
 1621:                                     partyId = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.PartyId(service);
 1622:                                     gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromPartyId(partyId);
 1623:  
 1624:                                     if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1625:                                     {
 1626:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 1627:                                         {
 1628:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
 1629:  
 1630:                                             result.AddSuccess(r);
 1631:                                         }
 1632:                                         else // if IsSip == true
 1633:                                         {
 1634:                                             result.AddSuccess("SIP process is undefined for No/No");
 1635:                                         }
 1636:                                     }
 1637:                                     else if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1638:                                     {
 1639:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 1640:                                         {
 1641:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
 1642:                                         }
 1643:                                         else // if IsSip == true
 1644:                                         {
 1645:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r);
 1646:                                         }
 1647:  
 1648:                                         result.AddSuccess(r);
 1649:                                     }
 1650:                                     else throw new Exception("AccessVendor is undefined");
 1651:                                 }
 1652:                                 else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1653:                                 {
 1654:                                     Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out string readHuaweiResult);
 1655:  
 1656:                                     result.AddSuccess(readHuaweiResult);
 1657:  
 1658:                                     if (accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia || accessVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1659:                                     {
 1660:                                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, accessId, out r);
 1661:  
 1662:                                         result.AddSuccess(r);
 1663:                                     }
 1664:                                     else throw new Exception("accessVendor is undefined");
 1665:                                 }
 1666:                                 else throw new Exception("switchVendor is undefined");
 1667:                             }
 1668:                             catch (Exception ex)
 1669:                             {
 1670:                                 result.AddError("Exception: " + ex.ToString());
 1671:                             }
 1672:                         }
 1673:                         else result.AddError("NDD ONT is null, does not exist for service: " + service);
 1674:                     }
 1675:                     else
 1676:                     {
 1677:                         // get service without knowing accessId
 1678:  
 1679:                         if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
 1680:                         {
 1681:                             /*
 1682:                             partyId = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.PartyId(service);
 1683:                             gatewayId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromPartyId(partyId);
 1684: 
 1685:                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
 1686:                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, null, out r);
 1687:                             */
 1688:  
 1689:                             result.AddError("(Service2 is null or service.Access is null) and (serviceRequestService is null or serviceRequestService.Access is null) and (number is not within allowed Huawei switch domain list) for service: " + service);
 1690:                         }
 1691:                         else if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
 1692:                         {
 1693:                             Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out r);
 1694:  
 1695:                             result.AddSuccess(r);
 1696:                         }
 1697:                         else
 1698:                         {
 1699:                             throw new Exception("switchVendor is undefined");
 1700:                         }
 1701:                     }
 1702:  
 1703:                     // this is a sensitive issue. later I will allow storing empty accessId
 1704:                     Ia.Ftn.Cl.Model.Data.Service.AccessIdAndPortByService(service, out accessId, out port);
 1705:  
 1706:                     //if (!string.IsNullOrEmpty(accessId))
 1707:                     //{
 1708:                     Ia.Ftn.Cl.Model.Data.Service2.UpdateImsServiceAccessAndPort(service, accessId, port, string.Empty, out Ia.Cl.Models.Result updateServiceAccessResult);
 1709:  
 1710:                     result.AddResult(updateServiceAccessResult);
 1711:                     //}
 1712:                 }
 1713:                 else result.AddError("Number \"" + number + "\" does not belong to the network.");
 1714:             }
 1715:             else result.AddError("No input was entered.");
 1716:         }
 1717:  
 1718:         ////////////////////////////////////////////////////////////////////////////    
 1719:  
 1720:         /// <summary>
 1721:         ///
 1722:         /// </summary>
 1723:         public static void UpdateReadSupplementaryService(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms, string input, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService supplementaryService, bool supplementaryServiceState, out Ia.Cl.Models.Result result)
 1724:         {
 1725:             long number;
 1726:             string r, r0, r2;
 1727:             string accessId, service;
 1728:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1729:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 1730:  
 1731:             result = new Ia.Cl.Models.Result();
 1732:  
 1733:             if (!string.IsNullOrEmpty(input))
 1734:             {
 1735:                 input = input.Trim();
 1736:                 //input = input.ToLower();
 1737:  
 1738:                 number = long.Parse(input);
 1739:  
 1740:                 if (Ia.Ftn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
 1741:                 {
 1742:                     service = number.ToString();
 1743:  
 1744:                     switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
 1745:  
 1746:                     result.AddSuccess("Service: " + service + " ");
 1747:  
 1748:                     Ia.Ftn.Cl.Model.Data.Service.AccessIdAndPortByService(service, out accessId, out int port);
 1749:  
 1750:                     if (!string.IsNullOrEmpty(accessId))
 1751:                     {
 1752:                         nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary.ContainsKey(accessId) ? Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary[accessId] : null;
 1753:  
 1754:                         if (nddOnt != null)
 1755:                         {
 1756:                             switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
 1757:  
 1758:                             try
 1759:                             {
 1760:                                 if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1761:                                 {
 1762:                                     Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, supplementaryService, supplementaryServiceState, out r);
 1763:  
 1764:                                     result.AddSuccess(r);
 1765:  
 1766:                                     if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 1767:                                     {
 1768:                                         var gwId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 1769:  
 1770:                                         if (gwId > 0)
 1771:                                         {
 1772:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms/*, sNddOnt*/, gwId, out r2);
 1773:                                         }
 1774:                                         else
 1775:                                         {
 1776:                                             r2 = "gwId: zero";
 1777:                                         }
 1778:                                     }
 1779:                                     else // if IsSip == true
 1780:                                     {
 1781:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r2);
 1782:                                     }
 1783:  
 1784:                                     result.AddSuccess("updated:" + r + ", read:" + r2);
 1785:                                 }
 1786:                                 else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1787:                                 {
 1788:                                     Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, supplementaryService, supplementaryServiceState, out r);
 1789:  
 1790:                                     Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out r2);
 1791:  
 1792:                                     result.AddSuccess("updated:" + r + ", read:" + r2);
 1793:                                 }
 1794:                                 else
 1795:                                 {
 1796:                                     throw new Exception("switchVendor is undefined.");
 1797:                                 }
 1798:                             }
 1799:                             catch (Exception ex)
 1800:                             {
 1801:                                 result.AddError("Exception: " + ex.ToString());
 1802:                             }
 1803:                         }
 1804:                         else result.AddError("NDD ONT is null, does not exist for service: " + service);
 1805:                     }
 1806:                     else
 1807:                     {
 1808:                         if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1809:                         {
 1810:                             Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, supplementaryService, supplementaryServiceState, out r);
 1811:  
 1812:                             Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out r2);
 1813:  
 1814:                             result.AddSuccess("updated:" + r + ", read:" + r2);
 1815:                         }
 1816:                         else
 1817:                         {
 1818:                             result.AddError("AccessId is null and switchVendor is not Huawei for service: " + service);
 1819:                         }
 1820:                     }
 1821:                 }
 1822:                 else result.AddError("Number \"" + number + "\" does not belong to the network");
 1823:             }
 1824:             else result.AddError("No input was entered");
 1825:         }
 1826:  
 1827:         ////////////////////////////////////////////////////////////////////////////
 1828:  
 1829:         /// <summary>
 1830:         ///
 1831:         /// </summary>
 1832:         public static Ia.Cl.Models.Result ManageServiceProvisioning(Ia.Ftn.Cl.Model.Business.Default.Procedure procedure, Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms)
 1833:         {
 1834:             int number;
 1835:             string r0, r1, r2, r3, service;
 1836:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 1837:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 1838:  
 1839:             r0 = r1 = r2 = r3 = string.Empty;
 1840:             var result = new Ia.Cl.Models.Result();
 1841:  
 1842:             var kvp = Ia.Ftn.Cl.Model.Business.Provision.DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceItem(procedure, out int serviceQueueCount, out string progressCounterString);
 1843:  
 1844:             var serviceId = kvp.Key;
 1845:  
 1846:             var serviceRequestAdministrativeIssueType = Ia.Ftn.Cl.Model.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueTypeByDisconnectionType(Ia.Ftn.Cl.Model.Business.ServiceRequestAdministrativeIssue.DisconnectionType.None);
 1847:  
 1848:             if (!string.IsNullOrEmpty(serviceId))
 1849:             {
 1850:                 var synchronized = false;
 1851:  
 1852:                 r0 = "service: " + serviceId.Replace(":1:965", "") + " " + progressCounterString + ": ";
 1853:  
 1854:                 service = Ia.Ftn.Cl.Model.Business.Service.ServiceIdToService(serviceId);
 1855:  
 1856:                 if (Ia.Ftn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
 1857:                 {
 1858:                     var service2 = Ia.Ftn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
 1859:                     var serviceRequestService = Ia.Ftn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
 1860:  
 1861:                     try
 1862:                     {
 1863:                         if (serviceRequestService != null)
 1864:                         {
 1865:                             service = serviceRequestService.Service;
 1866:  
 1867:                             if (serviceRequestService.Provisioned)
 1868:                             {
 1869:                                 if (int.TryParse(service, out number))
 1870:                                 {
 1871:                                     switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
 1872:  
 1873:                                     if (service2 == null)
 1874:                                     {
 1875:                                         // create service
 1876:                                         r0 += "create: ";
 1877:  
 1878:                                         nddOnt = (serviceRequestService.Access != null) ? Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(serviceRequestService.Access.Id) : null;
 1879:  
 1880:                                         if (nddOnt != null)
 1881:                                         {
 1882:                                             if (Ia.Ftn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
 1883:                                             {
 1884:                                                 if (switchVendor == nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor)
 1885:                                                 {
 1886:                                                     if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service))
 1887:                                                     {
 1888:                                                         if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1889:                                                         {
 1890:                                                             r0 += "Nokia: ";
 1891:  
 1892:                                                             // make sure the number is not suspended before creating it
 1893:                                                             Ia.Ftn.Cl.Model.Data.ServiceRequestAdministrativeIssue.Update(service, serviceRequestAdministrativeIssueType, false, out _);
 1894:  
 1895:                                                             Ia.Ftn.Cl.Model.Business.Provision.CreateReadNokiaSwitchSubscriber(nokiaIms, nddOnt.Access.Name, service, Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 1896:  
 1897:                                                             synchronized = true;
 1898:  
 1899:                                                             r0 += r1 + ",";
 1900:                                                         }
 1901:                                                         else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1902:                                                         {
 1903:                                                             r0 += "Huawei: ";
 1904:  
 1905:                                                             // make sure the number is not suspend before creating it
 1906:                                                             Ia.Ftn.Cl.Model.Data.ServiceRequestAdministrativeIssue.Update(service, serviceRequestAdministrativeIssueType, false, out _);
 1907:  
 1908:                                                             // I will completely remove any existing number before installing it again to make sure it installs fresh
 1909:                                                             // maybe I shouldn't
 1910:                                                             // Ia.Ftn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, nddOnt.Access.Name, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 1911:  
 1912:                                                             Ia.Ftn.Cl.Model.Business.Provision.CreateReadHuaweiSwitchSubscriber(huaweiIms, nddOnt.Access.Name, service, Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r2);
 1913:  
 1914:                                                             synchronized = true;
 1915:  
 1916:                                                             r0 += r1 + "," + r2 + ",";
 1917:                                                         }
 1918:                                                         else
 1919:                                                         {
 1920:                                                             throw new Exception("switchVendor is undefined.");
 1921:                                                         }
 1922:                                                     }
 1923:                                                     else r0 += "service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
 1924:                                                 }
 1925:                                                 else r0 += "switchVendor of service " + service + " is not equal to switch vendor of access " + nddOnt.Access.Name + ".";
 1926:                                             }
 1927:                                             else r0 += "Access is not in an allowed to be provisioned OLT. ";
 1928:                                         }
 1929:                                         else
 1930:                                         {
 1931:                                             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 1932:                                             {
 1933:                                                 // see above
 1934:                                                 r0 += "Huawei: ";
 1935:  
 1936:                                                 // make sure the number is not suspend before creating it
 1937:                                                 Ia.Ftn.Cl.Model.Data.ServiceRequestAdministrativeIssue.Update(service, serviceRequestAdministrativeIssueType, false, out _);
 1938:  
 1939:                                                 // I will completely remove any existing number before installing it again to make sure it installs fresh
 1940:                                                 // maybe I shouldn't
 1941:                                                 //Ia.Ftn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, string.Empty, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 1942:  
 1943:                                                 Ia.Ftn.Cl.Model.Business.Provision.CreateReadHuaweiSwitchSubscriber(huaweiIms, string.Empty, service, Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r2);
 1944:  
 1945:                                                 synchronized = true;
 1946:  
 1947:                                                 //r0 += r4.Message + "," + r1 + "," + r2 + ","; too much info
 1948:                                                 r0 += r2 + ",";
 1949:                                             }
 1950:                                             else r0 += "serviceNddOnt is null and switchVendor is not Huawei. ";
 1951:                                         }
 1952:                                     }
 1953:                                     else
 1954:                                     {
 1955:                                         // update service
 1956:                                         r0 += "update: ";
 1957:  
 1958:                                         if (service2.Access != null) nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(service2.Access.Id);
 1959:                                         else if (serviceRequestService.Access != null) nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(serviceRequestService.Access.Id);
 1960:                                         else nddOnt = null;
 1961:  
 1962:                                         if (nddOnt != null)
 1963:                                         {
 1964:                                             if (Ia.Ftn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
 1965:                                             {
 1966:                                                 if (switchVendor == nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor)
 1967:                                                 {
 1968:                                                     // To make things easier, I will skip checking for NumberIsWithinAllowedRouterDomainList in updates because it is already checked when the number is installed
 1969:                                                     //if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service))
 1970:                                                     //{
 1971:                                                     r0 += "service: ";
 1972:  
 1973:                                                     if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 1974:                                                     {
 1975:                                                         r0 += "Nokia: ";
 1976:  
 1977:                                                         // below: send change command to IMS
 1978:                                                         if (service2.CallerId != serviceRequestService.CallerId) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallerId, serviceRequestService.CallerId, out r2);
 1979:                                                         else if (service2.CallForwarding != serviceRequestService.CallForwarding) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallForwarding, serviceRequestService.CallForwarding, out r2);
 1980:                                                         else if (service2.ConferenceCall != serviceRequestService.ConferenceCall) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall, serviceRequestService.ConferenceCall, out r2);
 1981:                                                         else if (service2.AlarmCall != serviceRequestService.AlarmCall) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.AlarmCall, out r2); // do not change
 1982:                                                         else if (service2.WakeupCall != serviceRequestService.WakeupCall) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.WakeupCall, out r2);
 1983:                                                         else if (service2.AbbriviatedCalling != serviceRequestService.AbbriviatedCalling) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling, serviceRequestService.AbbriviatedCalling, out r2);
 1984:                                                         else if (service2.InternationalCalling != serviceRequestService.InternationalCalling) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, serviceRequestService.InternationalCalling, out r2);
 1985:                                                         else if (service2.InternationalCallingUserControlled != serviceRequestService.InternationalCallingUserControlled) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled, serviceRequestService.InternationalCallingUserControlled, out r2);
 1986:  
 1987:                                                         // below: CallWaiting is not provisioned for PBX keys. It is placed last in the execution logic so that it does not prevention the flow of logic to other services
 1988:                                                         else if (service2.CallWaiting != serviceRequestService.CallWaiting) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallWaiting, serviceRequestService.CallWaiting, out r2);
 1989:  
 1990:                                                         //else if (Ia.Ftn.Cl.Model.Business.Administration.ServiceSuspensionIsEnabled && service2.ServiceSuspension != serviceRequestService.CallBarring) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ServiceSuspension, serviceRequestService.CallBarring, out r2);
 1991:                                                         else r2 = "no difference in services. ";
 1992:  
 1993:                                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 1994:                                                         {
 1995:                                                             var gwId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 1996:  
 1997:                                                             if (gwId > 0)
 1998:                                                             {
 1999:                                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms/*, sNddOnt*/, gwId, out r3);
 2000:  
 2001:                                                                 r0 += r2 + "," + r3 + ",";
 2002:                                                             }
 2003:                                                             else r0 += "gwId: 0," + r2 + "," + r3 + ",";
 2004:                                                         }
 2005:                                                         else // if IsSip == true
 2006:                                                         {
 2007:                                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r3);
 2008:  
 2009:                                                             r0 += r2 + "," + r3 + ",";
 2010:                                                         }
 2011:                                                     }
 2012:                                                     else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2013:                                                     {
 2014:                                                         r0 += "Huawei: ";
 2015:  
 2016:                                                         // See below
 2017:                                                         if (service2.CallerId != serviceRequestService.CallerId) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallerId, serviceRequestService.CallerId, out r2);
 2018:                                                         else if (service2.CallForwarding != serviceRequestService.CallForwarding) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallForwarding, serviceRequestService.CallForwarding, out r2);
 2019:                                                         else if (service2.CallWaiting != serviceRequestService.CallWaiting) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallWaiting, serviceRequestService.CallWaiting, out r2);
 2020:                                                         else if (service2.ConferenceCall != serviceRequestService.ConferenceCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall, serviceRequestService.ConferenceCall, out r2);
 2021:                                                         else if (service2.AlarmCall != serviceRequestService.AlarmCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.AlarmCall, out r2); // do not change
 2022:                                                         else if (service2.WakeupCall != serviceRequestService.WakeupCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.WakeupCall, out r2);
 2023:                                                         else if (service2.AbbriviatedCalling != serviceRequestService.AbbriviatedCalling) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling, serviceRequestService.AbbriviatedCalling, out r2);
 2024:                                                         else if (service2.InternationalCalling != serviceRequestService.InternationalCalling) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, serviceRequestService.InternationalCalling, out r2);
 2025:                                                         else if (service2.InternationalCallingUserControlled != serviceRequestService.InternationalCallingUserControlled) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled, serviceRequestService.InternationalCallingUserControlled, out r2);
 2026:  
 2027:                                                         //else if (Ia.Ftn.Cl.Model.Business.Administration.ServiceSuspensionIsEnabled && service2.ServiceSuspension != serviceRequestService.CallBarring) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ServiceSuspension, serviceRequestService.CallBarring, out r2);
 2028:  
 2029:                                                         else r2 = "no difference in services. ";
 2030:  
 2031:                                                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, nddOnt.Access.Id, out r3);
 2032:  
 2033:                                                         r0 += r2 + "," + r3 + ",";
 2034:                                                     }
 2035:                                                     else
 2036:                                                     {
 2037:                                                         throw new Exception("switchVendor is undefined.");
 2038:                                                     }
 2039:                                                     //}
 2040:                                                     //else
 2041:                                                     //{
 2042:                                                     //    r0 += "service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
 2043:                                                     //}
 2044:                                                 }
 2045:                                                 else r0 += "Access is not in an allowed to be provisioned OLT. ";
 2046:                                             }
 2047:                                             else r0 += "switchVendor of service " + service + " is not equal to switch vendor of access " + nddOnt.Access.Name + ".";
 2048:                                         }
 2049:                                         else
 2050:                                         {
 2051:                                             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2052:                                             {
 2053:                                                 r0 += "Huawei: ";
 2054:  
 2055:                                                 // See above
 2056:                                                 if (service2.CallerId != serviceRequestService.CallerId) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallerId, serviceRequestService.CallerId, out r2);
 2057:                                                 else if (service2.CallForwarding != serviceRequestService.CallForwarding) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallForwarding, serviceRequestService.CallForwarding, out r2);
 2058:                                                 else if (service2.CallWaiting != serviceRequestService.CallWaiting) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallWaiting, serviceRequestService.CallWaiting, out r2);
 2059:                                                 else if (service2.ConferenceCall != serviceRequestService.ConferenceCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall, serviceRequestService.ConferenceCall, out r2);
 2060:                                                 else if (service2.AlarmCall != serviceRequestService.AlarmCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.AlarmCall, out r2); // do not change
 2061:                                                 else if (service2.WakeupCall != serviceRequestService.WakeupCall) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.WakeupCall, out r2);
 2062:                                                 else if (service2.AbbriviatedCalling != serviceRequestService.AbbriviatedCalling) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling, serviceRequestService.AbbriviatedCalling, out r2);
 2063:  
 2064:                                                 else if (service2.InternationalCalling != serviceRequestService.InternationalCalling) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, serviceRequestService.InternationalCalling, out r2);
 2065:                                                 else if (service2.InternationalCallingUserControlled != serviceRequestService.InternationalCallingUserControlled) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled, serviceRequestService.InternationalCallingUserControlled, out r2);
 2066:  
 2067:                                                 //else if (Ia.Ftn.Cl.Model.Business.Administration.ServiceSuspensionIsEnabled && service2.ServiceSuspension != serviceRequestService.CallBarring) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ServiceSuspension, serviceRequestService.CallBarring, out r2);
 2068:  
 2069:                                                 else r2 = "no difference in services. ";
 2070:  
 2071:                                                 Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out r3);
 2072:  
 2073:                                                 r0 += r2 + "," + r3 + ",";
 2074:                                             }
 2075:                                             else r0 += "serviceNddOnt is null and switchVendor is not Huawei. ";
 2076:                                         }
 2077:                                     }
 2078:                                 }
 2079:                                 else r0 += "service is not a valid number. ";
 2080:                             }
 2081:                             else
 2082:                             {
 2083:                                 if (int.TryParse(service, out number))
 2084:                                 {
 2085:                                     switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
 2086:  
 2087:                                     if (service2 != null)
 2088:                                     {
 2089:                                         // delete service
 2090:                                         r0 += "delete: ";
 2091:  
 2092:                                         nddOnt = (service2.Access != null) ? Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(service2.Access.Id) : null;
 2093:  
 2094:                                         if (nddOnt != null)
 2095:                                         {
 2096:                                             if (Ia.Ftn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
 2097:                                             {
 2098:                                                 if (switchVendor == nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor)
 2099:                                                 {
 2100:                                                     if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service))
 2101:                                                     {
 2102:                                                         if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 2103:                                                         {
 2104:                                                             r0 += "Nokia: ";
 2105:  
 2106:                                                             Ia.Ftn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(nokiaIms, nddOnt.Access.Name, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 2107:  
 2108:                                                             synchronized = true;
 2109:  
 2110:                                                             r0 += r1;
 2111:                                                         }
 2112:                                                         else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2113:                                                         {
 2114:                                                             r0 += "Huawei: ";
 2115:  
 2116:                                                             Ia.Ftn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, nddOnt.Access.Name, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 2117:  
 2118:                                                             synchronized = true;
 2119:  
 2120:                                                             r0 += r1;
 2121:                                                         }
 2122:                                                         else
 2123:                                                         {
 2124:                                                             throw new Exception("switchVendor is undefined.");
 2125:                                                         }
 2126:                                                     }
 2127:                                                     else r0 += "service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.";
 2128:                                                 }
 2129:                                                 else r0 += "switchVendor of service " + service + " is not equal to switch vendor of access " + nddOnt.Access.Name + ".";
 2130:                                             }
 2131:                                             else r0 += "Access is not in an allowed to be provisioned OLT. ";
 2132:                                         }
 2133:                                         else
 2134:                                         {
 2135:                                             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 2136:                                             {
 2137:                                                 r0 += "Nokia: ";
 2138:  
 2139:                                                 //Ia.Ftn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(nokiaIms, string.Empty, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 2140:                                                 //r0 += "serviceNddOnt is null and switchVendor is not Huawei. ";
 2141:  
 2142:                                                 Ia.Ftn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(nokiaIms, service, out r1);
 2143:  
 2144:                                                 synchronized = true;
 2145:  
 2146:                                                 r0 += r1;
 2147:                                             }
 2148:                                             else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2149:                                             {
 2150:                                                 // see above
 2151:                                                 r0 += "Huawei: ";
 2152:  
 2153:                                                 Ia.Ftn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, string.Empty, service, Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r1);
 2154:  
 2155:                                                 synchronized = true;
 2156:  
 2157:                                                 r0 += r1;
 2158:                                             }
 2159:                                             else
 2160:                                             {
 2161:                                                 throw new Exception("switchVendor is undefined.");
 2162:                                             }
 2163:                                         }
 2164:                                     }
 2165:                                     else
 2166:                                     {
 2167:                                         throw new Exception("service2 is null. ");
 2168:                                     }
 2169:                                 }
 2170:                                 else r0 += "service is not a valid number. ";
 2171:                             }
 2172:                         }
 2173:                         else r0 += "serviceRequestService is null. ";
 2174:                     }
 2175:                     catch (Exception ex)
 2176:                     {
 2177:                         r0 += "Exception: " + ex.ToString();
 2178:                     }
 2179:  
 2180:                     if (synchronized) Ia.Ftn.Cl.Model.Data.Msmq.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Model.Business.Msmq.Application.ProvisionApplication, Ia.Ftn.Cl.Model.Business.Msmq.Process.SynchronizeCompleted, serviceRequestService.Service);
 2181:                 }
 2182:                 else r0 += "The service number " + service + " does not have eight digits and/or is not within allowed domain list.";
 2183:             }
 2184:             else r0 = "No numbers in service discrepancy and complementary service mismatch list. ";
 2185:  
 2186:             result.AddSuccess(r0);
 2187:  
 2188:             return result;
 2189:         }
 2190:  
 2191:         ////////////////////////////////////////////////////////////////////////////
 2192:  
 2193:         /// <summary>
 2194:         ///
 2195:         /// </summary>
 2196:         public static Ia.Cl.Models.Result ManageServiceRequestAdministrativeIssue(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms)
 2197:         {
 2198:             string r2, r3;
 2199:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 2200:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 2201:  
 2202:             var result = new Ia.Cl.Models.Result();
 2203:  
 2204:             if (Ia.Ftn.Cl.Model.Business.Administration.ServiceSuspensionIsEnabled)
 2205:             {
 2206:                 var programmedAccountingDisconnectionType = Ia.Ftn.Cl.Model.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedAccounting;
 2207:                 var programmedInternationalCallingDisconnectionType = Ia.Ftn.Cl.Model.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedInternationalCalling;
 2208:  
 2209:                 //var ontAccessIdToOntDictionary = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
 2210:  
 2211:                 var service = Ia.Ftn.Cl.Model.Business.Provision.ImsServiceMismatchBetweenServiceRequestAdministrativeIssueAndServiceServiceListItem(out int serviceRequestAdministrativeIssueQueueCount, out string progressCounterString);
 2212:  
 2213:                 var serviceType = Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService;
 2214:                 var serviceId = Ia.Ftn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 2215:  
 2216:                 if (!string.IsNullOrEmpty(service))
 2217:                 {
 2218:                     result.AddSuccess("service: " + service + " " + progressCounterString);
 2219:                     r2 = serviceId;
 2220:  
 2221:                     var service2 = Ia.Ftn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
 2222:                     var serviceRequestService = Ia.Ftn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
 2223:                     var serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Model.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
 2224:  
 2225:                     if (service2 != null)
 2226:                     {
 2227:                         switchVendor = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorByService(service);
 2228:  
 2229:                         if (service2.Access != null) nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(service2.Access.Id);
 2230:                         else if (serviceRequestService.Access != null) nddOnt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(serviceRequestService.Access.Id);
 2231:                         else nddOnt = null;
 2232:  
 2233:                         if (nddOnt != null)
 2234:                         {
 2235:                             if (Ia.Ftn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
 2236:                             {
 2237:                                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainListOrIsWithinSymbolDomainSameSwitchVendorButDifferentSiteExceptionList(nddOnt, service))
 2238:                                 {
 2239:                                     var accessId = nddOnt.Access.Id;
 2240:  
 2241:                                     result.AddSuccess("service: ");
 2242:  
 2243:                                     if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 2244:                                     {
 2245:                                         /*
 2246:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 2247:                                         {
 2248:                                             var gwId = Ia.Ftn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 2249: 
 2250:                                             if (gwId > 0)
 2251:                                             {
 2252:                                                 if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedAccountingDisconnectionType && service2.ServiceSuspension == false) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
 2253:                                                 else if (serviceRequestAdministrativeIssue == null && service2.ServiceSuspension == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, false, out r2);
 2254:                                                 else if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedInternationalCallingDisconnectionType && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, false, out r2);
 2255:                                                 else if (serviceRequestAdministrativeIssue == null && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == false) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, true, out r2);
 2256:                                                 else result.AddError("unrecognized serviceRequestAdministrativeIssue");
 2257: 
 2258:                                                 Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out r3);
 2259: 
 2260:                                                 result.AddSuccess(r2 + "," + r3);
 2261:                                             }
 2262:                                             else result.AddError("gwId is 0.");
 2263:                                         }
 2264:                                         else // if IsSip == true
 2265:                                         {
 2266:                                             if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedAccountingDisconnectionType && service2.ServiceSuspension == false) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
 2267:                                             else if (serviceRequestAdministrativeIssue == null && service2.ServiceSuspension == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, false, out r2);
 2268:                                             else if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedInternationalCallingDisconnectionType && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, false, out r2);
 2269:                                             else if (serviceRequestAdministrativeIssue == null && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, true, out r2);
 2270:                                             else result.AddError("unrecognized serviceRequestAdministrativeIssue");
 2271: 
 2272:                                             Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r3);
 2273: 
 2274:                                             result.AddSuccess(r2 + "," + r3);
 2275:                                         }
 2276:                                         */
 2277:  
 2278:                                         if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedAccountingDisconnectionType && service2.ServiceSuspension == false) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
 2279:                                         else if (serviceRequestAdministrativeIssue == null && service2.ServiceSuspension == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, false, out r2);
 2280:                                         else if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedInternationalCallingDisconnectionType && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, false, out r2);
 2281:                                         else if (serviceRequestAdministrativeIssue == null && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == false) Ia.Ftn.Cl.Model.Data.Nokia.Ims.UpdateSupplementaryService(nokiaIms, service, nddOnt, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, true, out r2);
 2282:                                         else result.AddError("unrecognized serviceRequestAdministrativeIssue");
 2283:  
 2284:                                         Ia.Ftn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r3);
 2285:  
 2286:                                         result.AddSuccess(r2 + "," + r3);
 2287:                                     }
 2288:                                     else if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2289:                                     {
 2290:                                         if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedAccountingDisconnectionType && service2.ServiceSuspension == false) Ia.Ftn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
 2291:                                         else if (serviceRequestAdministrativeIssue == null && service2.ServiceSuspension == true) Ia.Ftn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
 2292:                                         else if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedInternationalCallingDisconnectionType && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, false, out r2);
 2293:                                         else if (serviceRequestAdministrativeIssue == null && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == false) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, true, out r2);
 2294:                                         else result.AddError("unrecognized serviceRequestAdministrativeIssue.");
 2295:  
 2296:                                         Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out r3);
 2297:  
 2298:                                         result.AddSuccess(r2 + "," + r3);
 2299:                                     }
 2300:                                     else result.AddError("switchVendor is undefined.");
 2301:                                 }
 2302:                                 else result.AddError("service " + service + " is not within allowed router domain list for access " + nddOnt.Access.Name + ". To override restrictions contact department.");
 2303:                             }
 2304:                             else result.AddError("access is not in an allowed to be provisioned OLT.");
 2305:                         }
 2306:                         else
 2307:                         {
 2308:                             if (switchVendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 2309:                             {
 2310:                                 if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedAccountingDisconnectionType && service2.ServiceSuspension == false) Ia.Ftn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
 2311:                                 else if (serviceRequestAdministrativeIssue == null && service2.ServiceSuspension == true) Ia.Ftn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
 2312:                                 else if (serviceRequestAdministrativeIssue != null && serviceRequestAdministrativeIssue.Type == (int)programmedInternationalCallingDisconnectionType && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == true) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, false, out r2);
 2313:                                 else if (serviceRequestAdministrativeIssue == null && serviceRequestService.InternationalCalling == true && service2.InternationalCalling == false) Ia.Ftn.Cl.Model.Data.Huawei.Ims.UpdateSupplementaryService(huaweiIms, service, Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, true, out r2);
 2314:                                 else result.AddError("unrecognized serviceRequestAdministrativeIssue.");
 2315:  
 2316:                                 Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out r3);
 2317:  
 2318:                                 result.AddSuccess(r2 + "," + r3);
 2319:                             }
 2320:                             else result.AddError("nddOnt is null and switchVendor is not Huawei.");
 2321:                         }
 2322:                     }
 2323:                     else result.AddError("service2 is null.");
 2324:                 }
 2325:                 else result.AddWarning("No numbers in service request administrative issue mismatch list.");
 2326:             }
 2327:             else result.AddWarning("service request administrative issue is disabled.");
 2328:  
 2329:             return result;
 2330:         }
 2331:  
 2332:         ////////////////////////////////////////////////////////////////////////////
 2333:  
 2334:         /// <summary>
 2335:         ///
 2336:         /// </summary>
 2337:         public static Ia.Cl.Models.Result ManageMsmqQueue(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms)
 2338:         {
 2339:             string r;
 2340:  
 2341:             var result = new Ia.Cl.Models.Result();
 2342:  
 2343:             var queueCount = Ia.Ftn.Cl.Model.Data.Msmq.ProvisionApplication.Count;
 2344:  
 2345:             if (queueCount > 0)
 2346:             {
 2347:                 var message = Ia.Ftn.Cl.Model.Data.Msmq.ProvisionApplication.Dequeue;
 2348:  
 2349:                 if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.ServiceRequestAndOrServiceRequestTypeUpdated)
 2350:                 {
 2351:                     if (Ia.Ftn.Cl.Model.Business.Administration.NowIsOfficialWorkingTime)
 2352:                     {
 2353:                         var r2 = Ia.Ftn.Cl.Model.Business.Provision.ManageServiceProvisioning(Ia.Ftn.Cl.Model.Business.Default.Procedure.InitializeOrIterate, nokiaIms, huaweiIms);
 2354:  
 2355:                         result.AddSuccess("Provision service: " + r2.MessageWithoutCaption);
 2356:                     }
 2357:                     else
 2358:                     {
 2359:                     }
 2360:                 }
 2361:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.Synchronize)
 2362:                 {
 2363:                     if (Ia.Ftn.Cl.Model.Business.Administration.NowIsOfficialWorkingTime)
 2364:                     {
 2365:                         var r2 = Ia.Ftn.Cl.Model.Business.Provision.ManageServiceProvisioning(Ia.Ftn.Cl.Model.Business.Default.Procedure.InitializeOrIterate, nokiaIms, huaweiIms);
 2366:  
 2367:                         result.AddSuccess("Provision (from sync) service: " + r2.MessageWithoutCaption);
 2368:                     }
 2369:                     else
 2370:                     {
 2371:                     }
 2372:                 }
 2373:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.CreateReadServiceAccessPort)
 2374:                 {
 2375:                     var service = message.Service;
 2376:                     var accessName = message.AccessName;
 2377:                     var port = (message.Port > 0) ? message.Port : Ia.Ftn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 2378:                     var overrideRouterDomainRestriction = message.OverrideRouterDomainRestriction;
 2379:  
 2380:                     var protocol = Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd;
 2381:  
 2382:                     Ia.Ftn.Cl.Model.Business.Provision.CreateReadService(nokiaIms, huaweiIms, accessName, service, port, protocol, overrideRouterDomainRestriction, out r);
 2383:  
 2384:                     result.AddSuccess("Create/Read: " + service + "|" + accessName + "|" + port + ": " + r);
 2385:                 }
 2386:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.DeleteReadServiceAccess)
 2387:                 {
 2388:                     var service = message.Service;
 2389:                     var accessName = message.AccessName;
 2390:                     var overrideRouterDomainRestriction = message.OverrideRouterDomainRestriction;
 2391:  
 2392:                     var protocol = Ia.Ftn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd;
 2393:  
 2394:                     Ia.Ftn.Cl.Model.Business.Provision.DeleteReadService(nokiaIms, huaweiIms, accessName, service, protocol, overrideRouterDomainRestriction, out r);
 2395:  
 2396:                     result.AddSuccess("Delete/Read: " + service + "|" + accessName + ": " + r);
 2397:                 }
 2398:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.UpdateReadServiceSupplementaryService)
 2399:                 {
 2400:                     var service = message.Service;
 2401:                     var serviceSupplementaryService = message.ServiceSupplementaryService;
 2402:                     var serviceSupplementaryServiceState = message.ServiceSupplementaryServiceState;
 2403:  
 2404:                     Ia.Ftn.Cl.Model.Business.Provision.UpdateReadSupplementaryService(nokiaIms, huaweiIms, service, serviceSupplementaryService, serviceSupplementaryServiceState, out Ia.Cl.Models.Result r2);
 2405:  
 2406:                     result.AddSuccess("Set/Reset/Read Service Supplementary Service: " + service + ": " + r2.Message);
 2407:                 }
 2408:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.AccessCreated)
 2409:                 {
 2410:                     Ia.Ftn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionaryReset();
 2411:  
 2412:                     var result0 = Ia.Ftn.Cl.Model.Business.Nokia.Ims.CreateMissingAgcfGatewayRecordForNokiaSwitchOntInNonSipOlt(nokiaIms);
 2413:  
 2414:                     result.AddSuccess("Access created: AccessNameToMduDevDictionary reset. CreateMissingAgcfGatewayRecordForNokiaSwitchOntInNonSipOlt(): " + result0.Message);
 2415:                 }
 2416:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.ServiceInServiceRequestAdministrativeIssuesUpdated)
 2417:                 {
 2418:                     var r1 = Ia.Ftn.Cl.Model.Business.Provision.ManageServiceRequestAdministrativeIssue(nokiaIms, huaweiIms);
 2419:  
 2420:                     result.AddResult("Manage Service Request Administrative Issue: ", r1);
 2421:                 }
 2422:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.ActiveApplicationRunningPermissionState)
 2423:                 {
 2424:                     Ia.Ftn.Cl.Model.Business.Default.PermitActiveApplicationsToRun = message.State;
 2425:  
 2426:                     result.AddSuccess("PermitActiveApplicationsToRun: " + message.State);
 2427:                 }
 2428:                 else
 2429:                 {
 2430:                     throw new ArgumentOutOfRangeException("MSMQ process " + message.Process.ToString() + " is undefined");
 2431:                 }
 2432:             }
 2433:  
 2434:             return result;
 2435:         }
 2436:  
 2437:         ////////////////////////////////////////////////////////////////////////////
 2438:  
 2439:         /// <summary>
 2440:         ///
 2441:         /// </summary>
 2442:         public static Ia.Cl.Models.Result ManageAperiodicProcedure(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms)
 2443:         {
 2444:             int aperiodicQueueCount;
 2445:             string service;
 2446:  
 2447:             var result = new Ia.Cl.Models.Result();
 2448:  
 2449:             if (aperiodicQueue.Count == 0)
 2450:             {
 2451:                 List<string> list;
 2452:  
 2453:                 using (var db = new Ia.Ftn.Cl.Model.Db())
 2454:                 {
 2455:                     list = (from s in db.Service2
 2456:                             where s.Service.StartsWith("24825") || s.Service.StartsWith("24826") || s.Service.StartsWith("24827") || s.Service.StartsWith("24828") || s.Service.StartsWith("24829")
 2457:                             select s.Service).ToList();
 2458:                 }
 2459:  
 2460:                 aperiodicQueue = new Queue<string>(list);
 2461:  
 2462:                 aperiodicQueueOriginalCount = aperiodicQueue.Count;
 2463:             }
 2464:  
 2465:             if (aperiodicQueue.Count > 0) service = aperiodicQueue.Dequeue();
 2466:             else service = string.Empty;
 2467:  
 2468:             if (!string.IsNullOrEmpty(service))
 2469:             {
 2470:                 Ia.Ftn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(huaweiIms, service, out string deleteString);
 2471:                 Ia.Ftn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out string readString);
 2472:  
 2473:                 result.AddSuccess(service + " (" + aperiodicQueue.Count + "/" + aperiodicQueueOriginalCount + "): delete:" + deleteString + ", read:" + readString);
 2474:             }
 2475:             else
 2476:             {
 2477:                 result.AddSuccess("service is null");
 2478:             }
 2479:  
 2480:             aperiodicQueueCount = aperiodicQueue.Count;
 2481:  
 2482:             return result;
 2483:         }
 2484:  
 2485:         ////////////////////////////////////////////////////////////////////////////
 2486:         ////////////////////////////////////////////////////////////////////////////
 2487:  
 2488:         /// <summary>
 2489:         ///
 2490:         /// </summary>
 2491:         public static void CreateReadService(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms, string accessName, string service, int port, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
 2492:         {
 2493:             if (!string.IsNullOrEmpty(service))
 2494:             {
 2495:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
 2496:                 {
 2497:                     if (!string.IsNullOrEmpty(accessName))
 2498:                     {
 2499:                         Ia.Ftn.Cl.Model.Business.Provision.CreateReadNokiaSwitchSubscriber(nokiaIms, accessName, service, port, protocol, overrideRouterDomainRestriction, out result);
 2500:                     }
 2501:                     else result = "Error: Can't create a Nokia service without an access. AccessName is null or empty. ";
 2502:                 }
 2503:                 else if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
 2504:                 {
 2505:                     Ia.Ftn.Cl.Model.Business.Provision.CreateReadHuaweiSwitchSubscriber(huaweiIms, accessName, service, port, protocol, overrideRouterDomainRestriction, out result);
 2506:                 }
 2507:                 else result = "Error: service number does not belong to a valid vendor switch. ";
 2508:             }
 2509:             else result = "Error: service null or empty. ";
 2510:         }
 2511:  
 2512:         ////////////////////////////////////////////////////////////////////////////
 2513:  
 2514:         /// <summary>
 2515:         ///
 2516:         /// </summary>
 2517:         public static void DeleteReadService(Ia.Ftn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ftn.Cl.Model.Client.Huawei.Ims huaweiIms, string accessName, string service, Ia.Ftn.Cl.Model.Business.Default.Protocol protocol, bool overrideRouterDomainRestriction, out string result)
 2518:         {
 2519:             bool b;
 2520:  
 2521:             if (!string.IsNullOrEmpty(service))
 2522:             {
 2523:                 if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
 2524:                 {
 2525:                     if (!string.IsNullOrEmpty(accessName))
 2526:                     {
 2527:                         b = Ia.Ftn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(nokiaIms, accessName, service, protocol, overrideRouterDomainRestriction, out result);
 2528:                     }
 2529:                     else
 2530:                     {
 2531:                         b = Ia.Ftn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(nokiaIms, service, out result);
 2532:                     }
 2533:                 }
 2534:                 else if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
 2535:                 {
 2536:                     b = Ia.Ftn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, accessName, service, protocol, overrideRouterDomainRestriction, out result);
 2537:                 }
 2538:                 else result = "Error: service number does not belong to a valid vendor switch. ";
 2539:             }
 2540:             else
 2541:             {
 2542:                 result = "Error: service null or empty. ";
 2543:             }
 2544:         }
 2545:  
 2546:         ////////////////////////////////////////////////////////////////////////////
 2547:         ////////////////////////////////////////////////////////////////////////////    
 2548:     }
 2549:  
 2550:     ////////////////////////////////////////////////////////////////////////////
 2551:     ////////////////////////////////////////////////////////////////////////////   
 2552: }