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