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