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

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

Signaling Service Processing System (SPS) support class for Huawei's Fixed Telecommunications Network (FTN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Configuration;
    4: using System.Data;
    5: using System.Linq;
    6:  
    7: namespace Ia.Ftn.Cl.Model.Business.Huawei
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// Signaling Service Processing System (SPS) support class for Huawei's Fixed Telecommunications Network (FTN) business model.
   13:     /// </summary>
   14:  
   15:     /// <remarks> 
   16:     /// Copyright © 2018-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     ///
   18:     /// 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
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     public class Sps
   29:     {
   30:         private static List<string> properlySelectedSpsCommandList = new List<string>();
   31:         private static Queue<ProvisioningWorkflow> synchronizationCommandQueue = new Queue<ProvisioningWorkflow>();
   32:  
   33:         private static Ia.Ftn.Cl.Model.Client.Huawei.Sps sps = new Cl.Model.Client.Huawei.Sps();
   34:  
   35:         /// <summary/>
   36:         public enum SpsOpcode { LstSeruattr, ModSeruattr }
   37:  
   38:         /// <summary/>
   39:         public enum Mode { NUM = 0, IMSINUM = 1 };
   40:  
   41:         /// <summary/>
   42:         public enum Servattr { OMNP = 0 };
   43:  
   44:         /// <summary/>
   45:         public enum NumType { TYPE0 = 0, TYPE1 = 1, TYPE2 = 2, TYPE3 = 3, TYPE4 = 4, TYPE5 = 5, TYPE8 = 8, TYPE9 = 9 };
   46:  
   47:         /// <summary/>
   48:         public class FieldIdNameExplanation
   49:         {
   50:             public int Id;
   51:             public string FieldName;
   52:             public string FieldExplanation;
   53:         }
   54:  
   55:         /// <summary/>
   56:         public static FieldIdNameExplanation[] NumTypeFieldIdExplanationList =
   57:            {
   58:             new FieldIdNameExplanation {Id = (int)NumType.TYPE0, FieldExplanation="In local network" },
   59:             new FieldIdNameExplanation {Id = (int)NumType.TYPE1, FieldExplanation="Moved out of local network" },
   60:             new FieldIdNameExplanation {Id = (int)NumType.TYPE2, FieldExplanation="Moved in from external network" },
   61:             new FieldIdNameExplanation {Id = (int)NumType.TYPE3, FieldExplanation="Moved to another non-local number" },
   62:             new FieldIdNameExplanation {Id = (int)NumType.TYPE4, FieldExplanation="Flexible number" },
   63:             new FieldIdNameExplanation {Id = (int)NumType.TYPE5, FieldExplanation="Moved from GSM to CDMA network" },
   64:             new FieldIdNameExplanation {Id = (int)NumType.TYPE8, FieldExplanation="Moved from CDMA to GSM network" },
   65:             new FieldIdNameExplanation {Id = (int)NumType.TYPE9, FieldExplanation="Local fixed network" }
   66:         };
   67:  
   68:         /// <summary/>
   69:         public enum RnidxType { HLR = 0, RN = 1, ALL = 2 };
   70:  
   71:         /// <summary/>
   72:         public static FieldIdNameExplanation[] RnidxTypeFieldIdExplanationList =
   73:            {
   74:             new FieldIdNameExplanation { Id = (int)RnidxType.HLR,FieldExplanation="HLR number index" },
   75:             new FieldIdNameExplanation { Id = (int)RnidxType.RN,FieldExplanation="Route number index" },
   76:             new FieldIdNameExplanation { Id = (int)RnidxType.ALL,FieldExplanation="HLR+RN" },
   77:         };
   78:  
   79:         /// <summary/>
   80:         public static FieldIdNameExplanation[] ParameterFieldNameExplanationList =
   81:            {
   82:             new FieldIdNameExplanation { FieldName = "USRNUM",FieldExplanation="MSISDN" },
   83:             new FieldIdNameExplanation { FieldName = "SERVATTR",FieldExplanation="Whether enable Related services" },
   84:             new FieldIdNameExplanation { FieldName = "IMSINUM",FieldExplanation="User IMSI number" },
   85:             new FieldIdNameExplanation { FieldName = "NUMTYPE",FieldExplanation="Number type" },
   86:             new FieldIdNameExplanation { FieldName = "RNIDXTYPE",FieldExplanation="Route index type" },
   87:             new FieldIdNameExplanation { FieldName = "HLRIDX",FieldExplanation="HLR address index" },
   88:             new FieldIdNameExplanation { FieldName = "RNIDX",FieldExplanation="NP route index" },
   89:             new FieldIdNameExplanation { FieldName = "RNIDX2",FieldExplanation="Routing Number Index" },
   90:             new FieldIdNameExplanation { FieldName = "RN",FieldExplanation="Routing number" },
   91:             new FieldIdNameExplanation { FieldName = "DESC",FieldExplanation="Description" }
   92:         };
   93:  
   94:         /// <summary/>
   95:         public class ProvisioningWorkflow
   96:         {
   97:             /// <summary/>
   98:             public string Service { get; set; }
   99:  
  100:             /// <summary/>
  101:             public string ReadCommand { get; set; }
  102:  
  103:             /// <summary/>
  104:             public string UpdateCommand { get; set; }
  105:  
  106:             /// <summary/>
  107:             public ProvisioningWorkflow()
  108:             {
  109:  
  110:             }
  111:         }
  112:  
  113:         /// <summary/>
  114:         public static string Host { get { return ConfigurationManager.AppSettings["spsHuaweiServerHost"].ToString(); } }
  115:  
  116:         /// <summary/>
  117:         public static int Port { get { return int.Parse(ConfigurationManager.AppSettings["spsHuaweiServerPort"].ToString()); } }
  118:  
  119:         /// <summary/>
  120:         public static string LoginUser { get { return ConfigurationManager.AppSettings["spsHuaweiServerLoginUser"].ToString(); } }
  121:  
  122:         /// <summary/>
  123:         public static string LogoutUser { get { return ConfigurationManager.AppSettings["spsHuaweiServerLogoutUser"].ToString(); } }
  124:  
  125:         /// <summary/>
  126:         public static string SemiColon { get { return ";"; } }
  127:  
  128:         ////////////////////////////////////////////////////////////////////////////
  129:  
  130:         /// <summary>
  131:         /// Response class of NCE TL1 NBI following the "10.3 Response Format Description standard" in iManager NCE Unified Network Management System Guide.
  132:         /// </summary>
  133:         public class Response
  134:         {
  135:             /// <summary/>
  136:             public bool IsSuccess { get { return ReturnCode == Ia.Ftn.Cl.Model.Client.Huawei.Sps.ResultCode.OperationIsSuccessful; } }
  137:  
  138:             /// <summary/>
  139:             public Ia.Ftn.Cl.Model.Client.Huawei.Sps.ResultCode ReturnCode { get; set; }
  140:  
  141:             /// <summary/>
  142:             public string CodeExplanation { get; set; }
  143:  
  144:             /// <summary/>
  145:             public string CommandString { get; set; }
  146:  
  147:             /// <summary/>
  148:             public int Count { get; set; }
  149:  
  150:             /// <summary/>
  151:             public Dictionary<string, string> QueryDictionary { get; set; }
  152:  
  153:             /// <summary/>
  154:             public Response() { }
  155:         }
  156:  
  157:         ////////////////////////////////////////////////////////////////////////////
  158:  
  159:         /// <summary>
  160:         ///
  161:         /// </summary>
  162:         public Sps() { }
  163:  
  164:         ////////////////////////////////////////////////////////////////////////////
  165:  
  166:         /// <summary>
  167:         ///
  168:         /// </summary>
  169:         public static Ia.Cl.Models.Result Connect()
  170:         {
  171:             var result = new Ia.Cl.Models.Result();
  172:  
  173:             if (sps != null && !sps.IsConnected)
  174:             {
  175:                 sps.Connect(out result);
  176:             }
  177:             else
  178:             {
  179:                 result.AddWarning("SPS is already connected.");
  180:             }
  181:  
  182:             return result;
  183:         }
  184:  
  185:         ////////////////////////////////////////////////////////////////////////////
  186:  
  187:         /// <summary>
  188:         ///
  189:         /// </summary>
  190:         public static Ia.Cl.Models.Result Disconnect()
  191:         {
  192:             var result = new Ia.Cl.Models.Result();
  193:  
  194:             if (sps != null && sps.IsConnected)
  195:             {
  196:                 sps.Disconnect(out result);
  197:             }
  198:             else
  199:             {
  200:                 result.AddWarning("SPS is already disconnected.");
  201:             }
  202:  
  203:             return result;
  204:         }
  205:  
  206:         ////////////////////////////////////////////////////////////////////////////
  207:  
  208:         /// <summary>
  209:         ///
  210:         /// </summary>
  211:         public static void Login()
  212:         {
  213:             sps.Login();
  214:         }
  215:  
  216:         ////////////////////////////////////////////////////////////////////////////
  217:  
  218:         /// <summary>
  219:         ///
  220:         /// </summary>
  221:         public static void Logout()
  222:         {
  223:             sps.Logout();
  224:         }
  225:  
  226:         ////////////////////////////////////////////////////////////////////////////
  227:  
  228:         /// <summary>
  229:         ///
  230:         /// </summary>
  231:         public static Queue<string> ReceiveQueue
  232:         {
  233:             get
  234:             {
  235:                 return sps.ReceiveQueue;
  236:             }
  237:         }
  238:  
  239:         ////////////////////////////////////////////////////////////////////////////
  240:  
  241:         /// <summary>
  242:         ///
  243:         /// </summary>
  244:         public static Queue<string> SendQueue
  245:         {
  246:             get
  247:             {
  248:                 return sps.SendQueue;
  249:             }
  250:         }
  251:  
  252:         ////////////////////////////////////////////////////////////////////////////
  253:  
  254:         /// <summary>
  255:         ///
  256:         /// </summary>
  257:         public static bool IsConnected
  258:         {
  259:             get
  260:             {
  261:                 return sps != null && sps.IsConnected;
  262:             }
  263:         }
  264:  
  265:         ////////////////////////////////////////////////////////////////////////////
  266:  
  267:         /// <summary>
  268:         ///
  269:         /// </summary>
  270:         public static void ManageReceiveQueue(out Ia.Cl.Models.Result result)
  271:         {
  272:             string rowString, formattedString;
  273:  
  274:             result = new Ia.Cl.Models.Result();
  275:  
  276:             try
  277:             {
  278:                 while (sps.ReceiveQueue.Count > 0)
  279:                 {
  280:                     rowString = sps.ReceiveQueue.Dequeue();
  281:  
  282:                     //Debug.WriteLine("ManageReceiveQueue(): rowString: " + rowString);
  283:  
  284:                     formattedString = rowString;
  285:  
  286:                     sps.Update(formattedString, ref sps, out result);
  287:                 }
  288:             }
  289:             catch (Exception ex)
  290:             {
  291:                 result.AddError("ManageReceiveQueue: Exception: " + ex.Message);
  292:             }
  293:         }
  294:  
  295:         ////////////////////////////////////////////////////////////////////////////
  296:  
  297:         /// <summary>
  298:         ///
  299:         /// </summary>
  300:         public static string ManageSendQueue(out Ia.Cl.Models.Result result)
  301:         {
  302:             string command;
  303:  
  304:             command = string.Empty;
  305:             result = new Ia.Cl.Models.Result();
  306:  
  307:             try
  308:             {
  309:                 if (sps.SendQueue.Count > 0)
  310:                 {
  311:                     command = sps.SendQueue.Dequeue();
  312:  
  313:                     //Debug.WriteLine("ManageSendQueue(): command: " + command);
  314:  
  315:                     sps.Send(command, out Ia.Cl.Models.Result r);
  316:  
  317:                     if (r.IsSuccessful) result.AddSuccess(r.Message);
  318:                     else result.AddError(r.Message);
  319:                 }
  320:             }
  321:             catch (Exception ex)
  322:             {
  323:                 result.AddError("ManageSendQueue: Exception: " + ex.Message);
  324:             }
  325:  
  326:             return result.IsSuccessful ? command : string.Empty;
  327:         }
  328:  
  329:         ////////////////////////////////////////////////////////////////////////////
  330:  
  331:         /// <summary>
  332:         ///
  333:         /// </summary>
  334:         public static Ia.Cl.Models.Result ManageUpdate(string service, int rnidx)
  335:         {
  336:             string command;
  337:             var result = new Ia.Cl.Models.Result();
  338:  
  339:             command = Ia.Ftn.Cl.Model.Business.Huawei.Sps.UpdateCommand(service, rnidx);
  340:  
  341:             sps.SendQueue.Enqueue(command);
  342:  
  343:             result.AddSuccess("service: " + service + ", rnidx: " + rnidx + ", sent: " + command);
  344:  
  345:             return result;
  346:         }
  347:  
  348:         ////////////////////////////////////////////////////////////////////////////
  349:  
  350:         /// <summary>
  351:         ///
  352:         /// </summary>
  353:         public static string KeepAliveShakeHandCommand
  354:         {
  355:             get
  356:             {
  357:                 return "SHK HND:;";
  358:             }
  359:         }
  360:  
  361:         ////////////////////////////////////////////////////////////////////////////
  362:  
  363:         /// <summary>
  364:         ///
  365:         /// </summary>
  366:         public static string ManageProperly(ref int properlySelectedSpsCommandListIndex)
  367:         {
  368:             var command = Ia.Ftn.Cl.Model.Business.Huawei.Sps.ProperlySelectedSingleSpsCommandQueueCommand(ref properlySelectedSpsCommandListIndex, out int itemIndex, out int listCount);
  369:  
  370:             sps.SendQueue.Enqueue(command);
  371:  
  372:             var r = command + " (" + itemIndex + "/" + listCount + ")";
  373:  
  374:             return r;
  375:         }
  376:  
  377:         ////////////////////////////////////////////////////////////////////////////
  378:  
  379:         /// <summary>
  380:         ///
  381:         /// </summary>
  382:         public static Ia.Cl.Models.Result ManageMsmqQueue()
  383:         {
  384:             string command;
  385:  
  386:             var result = new Ia.Cl.Models.Result();
  387:  
  388:             var queueCount = Ia.Ftn.Cl.Model.Data.Msmq.SpsApplication.Count;
  389:  
  390:             if (queueCount > 0)
  391:             {
  392:                 var message = Ia.Ftn.Cl.Model.Data.Msmq.SpsApplication.Dequeue;
  393:  
  394:                 if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.ReadService)
  395:                 {
  396:                     if (Ia.Ftn.Cl.Model.Data.Service.ServiceIsWithinPstnThatUsesNpServerDomainList(message.Service))
  397:                     {
  398:                         command = Ia.Ftn.Cl.Model.Business.Huawei.Sps.ReadCommand(message.Service);
  399:  
  400:                         sps.SendQueue.Enqueue(command);
  401:  
  402:                         result.AddSuccess(message.Service);
  403:                     }
  404:                     else result.AddError("Service: " + message.Service + " is not within SPS server.");
  405:                 }
  406:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.Synchronize)
  407:                 {
  408:                     var r0 = ManageSynchronization(Ia.Ftn.Cl.Model.Business.Default.Procedure.InitializeOrIterate);
  409:  
  410:                     result.AddSuccess("Synchronize: InitializeOrIterate: " + r0.Message);
  411:                 }
  412:                 else if (message.Process == Ia.Ftn.Cl.Model.Business.Msmq.Process.ActiveApplicationRunningPermissionState)
  413:                 {
  414:                     Ia.Ftn.Cl.Model.Business.Default.PermitActiveApplicationsToRun = message.State;
  415:  
  416:                     result.AddSuccess("PermitActiveApplicationsToRun: " + message.State);
  417:                 }
  418:                 else
  419:                 {
  420:                     throw new ArgumentOutOfRangeException("MSMQ process " + message.Process.ToString() + " is undefined");
  421:                 }
  422:             }
  423:             else
  424:             {
  425:             }
  426:  
  427:             return result;
  428:         }
  429:  
  430:         ////////////////////////////////////////////////////////////////////////////
  431:  
  432:         /// <summary>
  433:         ///
  434:         /// </summary>
  435:         public static Ia.Cl.Models.Result ManageSynchronization(Ia.Ftn.Cl.Model.Business.Default.Procedure procedure)
  436:         {
  437:             Ia.Ftn.Cl.Model.Business.Huawei.Sps.ProvisioningWorkflow provisioningWorkflow;
  438:  
  439:             var result = new Ia.Cl.Models.Result();
  440:  
  441:             provisioningWorkflow = Ia.Ftn.Cl.Model.Business.Huawei.Sps.SynchronizeSpsServiceRnidxRouteToMatchImsServiceRouterVendorQueueCommand(procedure);
  442:  
  443:             if (provisioningWorkflow != null)
  444:             {
  445:                 sps.SendQueue.Enqueue(provisioningWorkflow.UpdateCommand);
  446:                 sps.SendQueue.Enqueue(provisioningWorkflow.ReadCommand);
  447:  
  448:                 // no easy access to send here Ia.Ftn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(Ia.Ftn.Cl.Model.Data.Msmq.AccessNameQueue.Process.ResetAccess, provisioningWorkflow input);
  449:  
  450:                 Ia.Ftn.Cl.Model.Data.Msmq.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Model.Business.Msmq.Application.SpsApplication, Ia.Ftn.Cl.Model.Business.Msmq.Process.SynchronizeCompleted, provisioningWorkflow.Service);
  451:  
  452:                 result.AddSuccess("Update: " + provisioningWorkflow.UpdateCommand + ", Read: " + provisioningWorkflow.ReadCommand);
  453:             }
  454:             else
  455:             {
  456:                 result.AddWarning("No rerouting. ");
  457:             }
  458:  
  459:             return result;
  460:         }
  461:  
  462:         ////////////////////////////////////////////////////////////////////////////
  463:  
  464:         /// <summary>
  465:         ///
  466:         /// </summary>
  467:         public static Ia.Cl.Models.Result ManageKeepAliveShakeHand()
  468:         {
  469:             var result = new Ia.Cl.Models.Result();
  470:  
  471:             var c = Ia.Ftn.Cl.Model.Business.Huawei.Sps.KeepAliveShakeHandCommand;
  472:  
  473:             sps.SendQueue.Enqueue(c);
  474:  
  475:             result.AddSuccess(c);
  476:  
  477:             return result;
  478:         }
  479:  
  480:         ////////////////////////////////////////////////////////////////////////////
  481:  
  482:         /// <summary>
  483:         ///
  484:         /// </summary>
  485:         public static string ProperlySelectedSingleSpsCommandQueueCommand(ref int referenceIndex, out int itemIndex, out int listCount)
  486:         {
  487:             if (properlySelectedSpsCommandList.JustStartedOrRolledOver())
  488:             {
  489:                 properlySelectedSpsCommandList = SpsCommandToRetrieveAllPossiblePstnServiceNumbersPreferablyNotInSpsTableWithinPstn();
  490:             }
  491:  
  492:             var command = properlySelectedSpsCommandList.Next(ref referenceIndex, out itemIndex, out listCount);
  493:  
  494:             return command;
  495:         }
  496:  
  497:         ////////////////////////////////////////////////////////////////////////////
  498:  
  499:         /// <summary>
  500:         ///
  501:         /// </summary>
  502:         public static ProvisioningWorkflow SynchronizeSpsServiceRnidxRouteToMatchImsServiceRouterVendorQueueCommand(Ia.Ftn.Cl.Model.Business.Default.Procedure procedure)
  503:         {
  504:             ProvisioningWorkflow provisioningWorkflow;
  505:             List<ProvisioningWorkflow> list;
  506:  
  507:             provisioningWorkflow = null;
  508:  
  509:             if (synchronizationCommandQueue.Count == 0 && procedure == Ia.Ftn.Cl.Model.Business.Default.Procedure.InitializeOrIterate)
  510:             {
  511:                 list = ModifyAndReadTwoCommandItemOfSpsServiceRnidxRouteToMatchImsServiceRouterVendorList();
  512:  
  513:                 synchronizationCommandQueue = new Queue<ProvisioningWorkflow>(list); // don't shuffle because a modify command is followed by a read .Shuffle());
  514:             }
  515:  
  516:             if (synchronizationCommandQueue.Count > 0) provisioningWorkflow = synchronizationCommandQueue.Dequeue();
  517:  
  518:             return provisioningWorkflow;
  519:         }
  520:  
  521:         ////////////////////////////////////////////////////////////////////////////
  522:  
  523:         /// <summary>
  524:         ///
  525:         /// </summary>
  526:         public static List<ProvisioningWorkflow> ModifyAndReadTwoCommandItemOfSpsServiceRnidxRouteToMatchImsServiceRouterVendorList()
  527:         {
  528:             int rnidxRoute;
  529:             string service;
  530:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
  531:             Ia.Ftn.Cl.Model.Business.Default.SwitchRoute pstnSwitchRoute, switchRouteToMigratedRouterVendor;
  532:             ProvisioningWorkflow provisioningWorkflow;
  533:             List<ProvisioningWorkflow> provisioningWorkflowList;
  534:  
  535:             provisioningWorkflowList = new List<ProvisioningWorkflow>();
  536:  
  537:             //var imsServiceToRouterVendorDictionary = Ia.Ftn.Cl.Model.Data.Service.ImsServiceToOntRouterVendorInAllowedToBeMigratedOltDictionary;
  538:             var imsServiceToRouterVendorDictionary = Ia.Ftn.Cl.Model.Data.Service.ImsServiceToOntAndMsanRouterVendorInAllowedToBeMigratedOltAndDomainDictionary;
  539:  
  540:             var pstnServiceToSwitchRouteDictionary = Ia.Ftn.Cl.Model.Data.Huawei.Seruattr.PstnThatUsesNpServerServiceToSwitchRouteDictionary();
  541:  
  542:             // will exclude exempt numbers
  543:             var serviceExemptionList = Ia.Ftn.Cl.Model.Data.Provision.ServiceOfServiceExemptFromProvisionProcessingList();
  544:  
  545:             foreach (KeyValuePair<string, Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor> kvp in imsServiceToRouterVendorDictionary)
  546:             {
  547:                 service = kvp.Key;
  548:                 vendor = kvp.Value;
  549:  
  550:                 if (pstnServiceToSwitchRouteDictionary.ContainsKey(service))
  551:                 {
  552:                     pstnSwitchRoute = pstnServiceToSwitchRouteDictionary[service];
  553:  
  554:                     if (vendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) switchRouteToMigratedRouterVendor = Ia.Ftn.Cl.Model.Business.Default.SwitchRoute.NokiaIms;
  555:                     else if (vendor == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei) switchRouteToMigratedRouterVendor = Ia.Ftn.Cl.Model.Business.Default.SwitchRoute.HuaweiIms;
  556:                     else switchRouteToMigratedRouterVendor = Ia.Ftn.Cl.Model.Business.Default.SwitchRoute.Unknown;
  557:  
  558:                     if (pstnSwitchRoute != switchRouteToMigratedRouterVendor && switchRouteToMigratedRouterVendor != Ia.Ftn.Cl.Model.Business.Default.SwitchRoute.Unknown)
  559:                     {
  560:                         if (!serviceExemptionList.Contains(service))
  561:                         {
  562:                             provisioningWorkflow = new ProvisioningWorkflow();
  563:  
  564:                             rnidxRoute = Ia.Ftn.Cl.Model.Business.Huawei.Seruattr.SwitchRouteToRnidxRoute(switchRouteToMigratedRouterVendor);
  565:  
  566:                             provisioningWorkflow.Service = service;
  567:                             provisioningWorkflow.UpdateCommand = UpdateCommand(service, rnidxRoute);
  568:                             provisioningWorkflow.ReadCommand = ReadCommand(service);
  569:  
  570:                             provisioningWorkflowList.Add(provisioningWorkflow);
  571:                         }
  572:                     }
  573:                 }
  574:             }
  575:  
  576:             return provisioningWorkflowList;
  577:         }
  578:  
  579:         ////////////////////////////////////////////////////////////////////////////
  580:         ////////////////////////////////////////////////////////////////////////////
  581:  
  582:         /// <summary>
  583:         ///
  584:         /// </summary>
  585:         public static string ReadCommand(string service)
  586:         {
  587:             return FormatSpsLstCommand(SpsOpcode.LstSeruattr, service);
  588:         }
  589:  
  590:         ////////////////////////////////////////////////////////////////////////////
  591:  
  592:         /// <summary>
  593:         ///
  594:         /// </summary>
  595:         public static string UpdateCommand(string service, int rnidxRoute)
  596:         {
  597:             return FormatSpsModCommand(SpsOpcode.ModSeruattr, service, rnidxRoute);
  598:         }
  599:  
  600:         ////////////////////////////////////////////////////////////////////////////
  601:         ////////////////////////////////////////////////////////////////////////////
  602:  
  603:         /// <summary>
  604:         ///
  605:         /// </summary>
  606:         private static string FormatSpsLstCommand(SpsOpcode amsOpcode, string service)
  607:         {
  608:             string command;
  609:  
  610:             if (amsOpcode == SpsOpcode.LstSeruattr)
  611:             {
  612:                 command = @"LST SERUATTR:MODE=NUM,USRNUM=""" + service + @""";";
  613:             }
  614:             else command = string.Empty;
  615:  
  616:             return command;
  617:         }
  618:  
  619:         ////////////////////////////////////////////////////////////////////////////
  620:  
  621:         /// <summary>
  622:         ///
  623:         /// </summary>
  624:         private static string FormatSpsModCommand(SpsOpcode amsOpcode, string service, int rnidxRoute)
  625:         {
  626:             string command;
  627:  
  628:             if (amsOpcode == SpsOpcode.ModSeruattr)
  629:             {
  630:                 command = @"MOD SERUATTR:MODE=NUM,USRNUM=""" + service + @""",RNIDXTYPE=RN,RNIDX=" + rnidxRoute + ";";
  631:             }
  632:             else command = string.Empty;
  633:  
  634:             return command;
  635:         }
  636:  
  637:         ////////////////////////////////////////////////////////////////////////////
  638:  
  639:         /// <summary>
  640:         ///
  641:         /// </summary>
  642:         public static List<string> SpsCommandToRetrieveAllPossiblePstnServiceNumbersPreferablyNotInSpsTableWithinPstn()
  643:         {
  644:             HashSet<string> hashSet;
  645:  
  646:             var list0 = new List<int>();
  647:  
  648:             var siteList = (from o in Ia.Ftn.Cl.Model.Data.Service.AllowedToBeMigratedOltList
  649:                             select o.Odf.Router.Site).Distinct().ToList();
  650:  
  651:             var pstnNameList = (from p in Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.PstnThatUsesNpServerList
  652:                                 where siteList.Contains(p.Site)
  653:                                 select p.Name).ToList();
  654:  
  655:             hashSet = new HashSet<string>();
  656:  
  657:             foreach (string pstnName in pstnNameList)
  658:             {
  659:                 list0.AddRange(Ia.Ftn.Cl.Model.Data.Service.AllPossibleServiceNumbersWithinPstn(pstnName));
  660:             }
  661:  
  662:             var usrnumList = Ia.Ftn.Cl.Model.Data.Huawei.Seruattr.UsrnumList();
  663:  
  664:             var list = list0.Except(usrnumList).ToList();
  665:  
  666:             // if list is empty then will use the all list
  667:             //if (list.Count == 0) list = list0;
  668:             if (list.Count < 6) list = list0; // bug with some hanging numbers 25382383, 25392538
  669:  
  670:             var servicelist = list.ConvertAll<string>(u => u.ToString());
  671:  
  672:             var commandList = new List<string>();
  673:  
  674:             foreach (string s in servicelist)
  675:             {
  676:                 commandList.Add(Ia.Ftn.Cl.Model.Business.Huawei.Sps.FormatSpsLstCommand(SpsOpcode.LstSeruattr, s));
  677:             }
  678:  
  679:             hashSet.UnionWith(new HashSet<string>(commandList));
  680:  
  681:             return hashSet.OrderBy(u => u).ToList();
  682:         }
  683:  
  684:         ////////////////////////////////////////////////////////////////////////////    
  685:         ////////////////////////////////////////////////////////////////////////////    
  686:     }
  687:  
  688:     ////////////////////////////////////////////////////////////////////////////
  689:     ////////////////////////////////////////////////////////////////////////////   
  690: }