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

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

U2020 Northbound Interface IP (SoftX) 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.Diagnostics;
    6: using System.Linq;
    7: using System.Threading.Tasks;
    8:  
    9: namespace Ia.Ftn.Cl.Models.Business.Huawei
   10: {
   11:     ////////////////////////////////////////////////////////////////////////////
   12:  
   13:     /// <summary publish="true">
   14:     /// U2020 Northbound Interface IP (SoftX) support class for Huawei's Fixed Telecommunications Network (FTN) business model.
   15:     /// </summary>
   16:  
   17:     /// <remarks> 
   18:     /// Copyright © 2019-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     /// </remarks> 
   20:     public class SoftX
   21:     {
   22:         /*
   23:          * Add the following settings
   24:     "SoftXHuaweiServerHost": "*******",
   25:     "SoftXHuaweiServerPort": "*******",
   26:     "SoftXHuaweiServerLoginUser": "LGI:OP=&quot;*******&quot;,PWD=&quot;*******&quot;;",
   27:     "SoftXHuaweiServerLogoutUser": "LGO:OP=&quot;*******&quot;;"
   28:         */
   29:  
   30:         private static List<string> properlySelectedSoftXCommandList = new List<string>();
   31:         private static Queue<ProvisioningWorkflow> synchronizationCommandQueue = new Queue<ProvisioningWorkflow>();
   32:         private static readonly Procedure addOrRemoveAsbrSubscriberProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(Ia.Ftn.Cl.Models.Business.Provision.ServiceOntToAddAndToRemoveInAsbrList);
   33:  
   34:         private static Ia.Ftn.Cl.Models.Client.Huawei.SoftX tecSoftX;
   35:         private static Ia.Ftn.Cl.Models.Client.Huawei.SoftX skbSoftX;
   36:  
   37:         /// <summary/>
   38:         public const int RemotePort = 2944;
   39:  
   40:         /// <summary/>
   41:         public enum SoftXOpcode
   42:         {
   43:             /// <summary/>
   44:             LstMgw,
   45:  
   46:             /// <summary/>
   47:             LstAsbr,
   48:  
   49:             /// <summary/>
   50:             AddMgw,
   51:  
   52:             /// <summary/>
   53:             AddAsbr,
   54:  
   55:             /// <summary/>
   56:             RemoveAsbr
   57:         }
   58:  
   59:         /// <summary/>
   60:         //public enum Mode { NUM = 0, IMSINUM = 1 };
   61:  
   62:         /// <summary/>
   63:         //public enum Servattr { OMNP = 0 };
   64:  
   65:         /// <summary/>
   66:         //public enum NumType { TYPE0 = 0, TYPE1 = 1, TYPE2 = 2, TYPE3 = 3, TYPE4 = 4, TYPE5 = 5, TYPE8 = 8, TYPE9 = 9 };
   67:  
   68:         /// <summary/>
   69:         public class NetworkElement
   70:         {
   71:             public string Symbol;
   72:             public string Domain;
   73:             public string NetId;
   74:             public string Ip;
   75:             public string La;
   76:         }
   77:  
   78:         /// <summary/>
   79:         public static NetworkElement[] NetworkElementList =
   80:         {
   81:             new NetworkElement {Symbol = "TEC", Domain = "tec.agcf01", NetId = "tec-agcf-vnid", Ip="10.10.11.20", La="10.10.9.10" },
   82:             new NetworkElement {Symbol = "SKB", Domain = "skb.agcf01", NetId = "skb-agcf-vnid", Ip="10.10.15.20", La="10.10.13.10" },
   83:         };
   84:  
   85:         /// <summary/>
   86:         public static NetworkElement SkbNetworkElement
   87:         {
   88:             get
   89:             {
   90:                 return (from n in NetworkElementList where n.Symbol == "SKB" select n).Single();
   91:             }
   92:         }
   93:  
   94:         /// <summary/>
   95:         public static NetworkElement TecNetworkElement
   96:         {
   97:             get
   98:             {
   99:                 return (from n in NetworkElementList where n.Symbol == "TEC" select n).Single();
  100:             }
  101:         }
  102:  
  103:         /// <summary/>
  104:         public class FieldIdNameExplanation
  105:         {
  106:             public int Id;
  107:             public string FieldName;
  108:             public string FieldExplanation;
  109:         }
  110:  
  111:         /*
  112:         /// <summary/>
  113:         public static FieldIdNameExplanation[] NumTypeFieldIdExplanationList =
  114:            {
  115:             new FieldIdNameExplanation {Id = (int)NumType.TYPE0, FieldExplanation="In local network" },
  116:             new FieldIdNameExplanation {Id = (int)NumType.TYPE1, FieldExplanation="Moved out of local network" },
  117:             new FieldIdNameExplanation {Id = (int)NumType.TYPE2, FieldExplanation="Moved in from external network" },
  118:             new FieldIdNameExplanation {Id = (int)NumType.TYPE3, FieldExplanation="Moved to another non-local number" },
  119:             new FieldIdNameExplanation {Id = (int)NumType.TYPE4, FieldExplanation="Flexible number" },
  120:             new FieldIdNameExplanation {Id = (int)NumType.TYPE5, FieldExplanation="Moved from GSM to CDMA network" },
  121:             new FieldIdNameExplanation {Id = (int)NumType.TYPE8, FieldExplanation="Moved from CDMA to GSM network" },
  122:             new FieldIdNameExplanation {Id = (int)NumType.TYPE9, FieldExplanation="Local fixed network" }
  123:         };
  124:         */
  125:  
  126:         /// <summary/>
  127:         //public enum RnidxType { HLR = 0, RN = 1, ALL = 2 };
  128:  
  129:         /*
  130:         /// <summary/>
  131:         public static FieldIdNameExplanation[] RnidxTypeFieldIdExplanationList =
  132:            {
  133:             new FieldIdNameExplanation { Id = (int)RnidxType.HLR,FieldExplanation="HLR number index" },
  134:             new FieldIdNameExplanation { Id = (int)RnidxType.RN,FieldExplanation="Route number index" },
  135:             new FieldIdNameExplanation { Id = (int)RnidxType.ALL,FieldExplanation="HLR+RN" },
  136:         };
  137:         */
  138:  
  139:         /// <summary/>
  140:         public static FieldIdNameExplanation[] ParameterFieldNameExplanationList =
  141:            {
  142:             new FieldIdNameExplanation { FieldName = "TID",FieldExplanation="Termination ID" },
  143:             new FieldIdNameExplanation { FieldName = "PUI",FieldExplanation="PublicUser Id" },
  144:             new FieldIdNameExplanation { FieldName = "PRI",FieldExplanation="PrivateUser Id" },
  145:             new FieldIdNameExplanation { FieldName = "RGN",FieldExplanation="IMS Registration Group Name" },
  146:             new FieldIdNameExplanation { FieldName = "TET",FieldExplanation="Terminal Equipment Type" },
  147:             new FieldIdNameExplanation { FieldName = "MN",FieldExplanation="Module number" },
  148:             new FieldIdNameExplanation { FieldName = "DID",FieldExplanation="Port type" },
  149:             new FieldIdNameExplanation { FieldName = "PLF",FieldExplanation="Priority Line flag" },
  150:             new FieldIdNameExplanation { FieldName = "TS",FieldExplanation="Termination Status" },
  151:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="New Service Right" },
  152:             new FieldIdNameExplanation { FieldName = "DT",FieldExplanation="Default Dial Tone" },
  153:             new FieldIdNameExplanation { FieldName = "HNID",FieldExplanation="Home Network ID" },
  154:             new FieldIdNameExplanation { FieldName = "NETID",FieldExplanation="Visited Network ID" },
  155:             new FieldIdNameExplanation { FieldName = "NETINFO",FieldExplanation="Access Network Info" },
  156:             new FieldIdNameExplanation { FieldName = "PHNCON",FieldExplanation="Phone Context Index" },
  157:             new FieldIdNameExplanation { FieldName = "DIGMAP",FieldExplanation="Initial DigitMap Index" },
  158:             new FieldIdNameExplanation { FieldName = "GLOBDMAPIDX",FieldExplanation="Global DigitMap Index" },
  159:             new FieldIdNameExplanation { FieldName = "PWD",FieldExplanation="Password" },
  160:             new FieldIdNameExplanation { FieldName = "SGN",FieldExplanation="SCC Group Name" },
  161:             new FieldIdNameExplanation { FieldName = "SOCGN",FieldExplanation="SOC Group Number" },
  162:             new FieldIdNameExplanation { FieldName = "DP",FieldExplanation="Download Profile Flag" },
  163:             new FieldIdNameExplanation { FieldName = "DR",FieldExplanation="Send Registration Subscription Flag" },
  164:             new FieldIdNameExplanation { FieldName = "EMGCN",FieldExplanation="Emergency Call Group Name" },
  165:             new FieldIdNameExplanation { FieldName = "CONF",FieldExplanation="Conference URI index" },
  166:             new FieldIdNameExplanation { FieldName = "CLIPMD",FieldExplanation="CLIP/R Mode" },
  167:             new FieldIdNameExplanation { FieldName = "IFMIMN",FieldExplanation="IFMI Module Number" },
  168:             new FieldIdNameExplanation { FieldName = "CODEC",FieldExplanation="Codec prefer" },
  169:             new FieldIdNameExplanation { FieldName = "CGP",FieldExplanation="Gate Proprity" },
  170:             new FieldIdNameExplanation { FieldName = "EID",FieldExplanation="Equipment ID" },
  171:             new FieldIdNameExplanation { FieldName = "MGWID",FieldExplanation="MGW ID" },           
  172:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Global MGW index" },           
  173:             new FieldIdNameExplanation { FieldName = "MGWDESC",FieldExplanation="MGW description" },
  174:             new FieldIdNameExplanation { FieldName = "MGWGROUPNO",FieldExplanation="MGW Group Number" },
  175:             new FieldIdNameExplanation { FieldName = "CP",FieldExplanation="Audio codec prefer" },           
  176:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="MGW Group Name" },           
  177:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Session Border Control" },           
  178:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Session Border Control Description" },           
  179:             new FieldIdNameExplanation { FieldName = "GWTP",FieldExplanation="Gateway type" },           
  180:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Control MID" },           
  181:             new FieldIdNameExplanation { FieldName = "PTYPE",FieldExplanation="Protocol type" },
  182:             new FieldIdNameExplanation { FieldName = "CODETYPE",FieldExplanation="Code type" },
  183:             new FieldIdNameExplanation { FieldName = "TDMIFC1",FieldExplanation="TDM termination ID prefix1" },
  184:             new FieldIdNameExplanation { FieldName = "TDMIFC2",FieldExplanation="TDM termination ID prefix2" },
  185:             new FieldIdNameExplanation { FieldName = "TDMIFC3",FieldExplanation="TDM termination ID prefix3" },
  186:             new FieldIdNameExplanation { FieldName = "TDMIFC4",FieldExplanation="TDM termination ID prefix4" },
  187:             new FieldIdNameExplanation { FieldName = "TDMIFC5",FieldExplanation="TDM termination ID prefix5" },
  188:             new FieldIdNameExplanation { FieldName = "TDMIFC6",FieldExplanation="TDM termination ID prefix6" },
  189:             new FieldIdNameExplanation { FieldName = "TDMIFC7",FieldExplanation="TDM termination ID prefix7" },
  190:             new FieldIdNameExplanation { FieldName = "TDMIFC8",FieldExplanation="TDM termination ID prefix8" },
  191:             new FieldIdNameExplanation { FieldName = "TDMIFC9",FieldExplanation="TDM termination ID prefix9" },
  192:             new FieldIdNameExplanation { FieldName = "TDMIFC10",FieldExplanation="TDM termination ID prefix10" },
  193:             new FieldIdNameExplanation { FieldName = "TDMIFC11",FieldExplanation="TDM termination ID prefix11" },
  194:             new FieldIdNameExplanation { FieldName = "TDMIFC12",FieldExplanation="TDM termination ID prefix12" },
  195:             new FieldIdNameExplanation { FieldName = "TDMIFC13",FieldExplanation="TDM termination ID prefix13" },
  196:             new FieldIdNameExplanation { FieldName = "TDMIFC14",FieldExplanation="TDM termination ID prefix14" },
  197:             new FieldIdNameExplanation { FieldName = "TDMIFC15",FieldExplanation="TDM termination ID prefix15" },
  198:             new FieldIdNameExplanation { FieldName = "TDMIFC16",FieldExplanation="TDM termination ID prefix16" },
  199:             new FieldIdNameExplanation { FieldName = "RTPIFC",FieldExplanation="RTP termination ID prefix" },
  200:             new FieldIdNameExplanation { FieldName = "HAIRPIN",FieldExplanation="Hairpin connection" },
  201:             new FieldIdNameExplanation { FieldName = "MSTYPE",FieldExplanation="Master/Slave type" },
  202:             new FieldIdNameExplanation { FieldName = "MRSCAP",FieldExplanation="Media resource server" },
  203:             new FieldIdNameExplanation { FieldName = "UCATT",FieldExplanation="Special attributes" },
  204:             new FieldIdNameExplanation { FieldName = "UCATTEX",FieldExplanation="Extend Special attributes" },
  205:             new FieldIdNameExplanation { FieldName = "OIPDM",FieldExplanation="Origin IP domain" },
  206:             new FieldIdNameExplanation { FieldName = "E2ET",FieldExplanation="Support E2E trace or not" },
  207:             new FieldIdNameExplanation { FieldName = "TOS",FieldExplanation="TOS Value" },
  208:             new FieldIdNameExplanation { FieldName = "HEARTBEATTIMES",FieldExplanation="Heartbeat Times" },
  209:             new FieldIdNameExplanation { FieldName = "PREMRS1",FieldExplanation="Preference MRS 1" },
  210:             new FieldIdNameExplanation { FieldName = "PREMRS2",FieldExplanation="Preference MRS 2" },
  211:             new FieldIdNameExplanation { FieldName = "PREMRS3",FieldExplanation="Preference MRS 3" },
  212:             new FieldIdNameExplanation { FieldName = "AGID",FieldExplanation="Global AG number" },
  213:             new FieldIdNameExplanation { FieldName = "IMSFLAG",FieldExplanation="IMS flag" },
  214:             new FieldIdNameExplanation { FieldName = "MMFLAG",FieldExplanation="Single AG switch flag" },
  215:             new FieldIdNameExplanation { FieldName = "NOTHWDEV",FieldExplanation="Not Authentication MG" },
  216:             new FieldIdNameExplanation { FieldName = "MIXVOICE",FieldExplanation="Mix voice flag" },
  217:             new FieldIdNameExplanation { FieldName = "VBDCODECMODE",FieldExplanation="VBD code mode" },
  218:             new FieldIdNameExplanation { FieldName = "ET",FieldExplanation="Encryption type" },
  219:             new FieldIdNameExplanation { FieldName = "DYNIP",FieldExplanation="Support dynamic IP address" },
  220:             new FieldIdNameExplanation { FieldName = "KEY",FieldExplanation="Key" },           
  221:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="DH Authentication MGID" },           
  222:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="SPI" },           
  223:             new FieldIdNameExplanation { FieldName = "SUPROOTPKG",FieldExplanation="Root package" },           
  224:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Normal MG execution time" },           
  225:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Normal MGC execution time" },           
  226:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="MG provisional response timer value" },           
  227:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="MGC provisional response timer value" },           
  228:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="MGC originated pending limit" },           
  229:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="MG originated pending limit" },           
  230:             new FieldIdNameExplanation { FieldName = "LA",FieldExplanation="Local IP address" },           
  231:             //new FieldIdNameExplanation { FieldName = "XXXXXX",FieldExplanation="Local port" },           
  232:             new FieldIdNameExplanation { FieldName = "RA1",FieldExplanation="Remote IP address 1" },
  233:             new FieldIdNameExplanation { FieldName = "RA2",FieldExplanation="Remote IP address 2" },
  234:             new FieldIdNameExplanation { FieldName = "RA3",FieldExplanation="Remote IP address 3" },
  235:             new FieldIdNameExplanation { FieldName = "RA4",FieldExplanation="Remote IP address 4" },
  236:             new FieldIdNameExplanation { FieldName = "RA5",FieldExplanation="Remote IP address 5" },
  237:             new FieldIdNameExplanation { FieldName = "RP",FieldExplanation="Remote port" },
  238:             new FieldIdNameExplanation { FieldName = "LISTOFCODEC",FieldExplanation="Codec list" },
  239:             new FieldIdNameExplanation { FieldName = "EC",FieldExplanation="EC" },
  240:             new FieldIdNameExplanation { FieldName = "USRRATE",FieldExplanation="User Rate" },
  241:             new FieldIdNameExplanation { FieldName = "ENVOICEATTR",FieldExplanation="Enhanced Voice Attribute" },
  242:             new FieldIdNameExplanation { FieldName = "MGWFCFLAG",FieldExplanation="Gateway Support H.248.11 Protocol" },
  243:             new FieldIdNameExplanation { FieldName = "OBJRATE",FieldExplanation="OverLoad Object Rate" },
  244:             new FieldIdNameExplanation { FieldName = "PROTCTTM",FieldExplanation="OverLoad Protect time" },
  245:             new FieldIdNameExplanation { FieldName = "IPDOMAIN",FieldExplanation="IPDomain" },
  246:         };
  247:  
  248:         /// <summary/>
  249:         public class ProvisioningWorkflow
  250:         {
  251:             /// <summary/>
  252:             public string ReadCommand { get; set; }
  253:  
  254:             /// <summary/>
  255:             public string TecCreateCommand { get; set; }
  256:  
  257:             /// <summary/>
  258:             public string SkbCreateCommand { get; set; }
  259:  
  260:             /// <summary/>
  261:             public ProvisioningWorkflow()
  262:             {
  263:  
  264:             }
  265:         }
  266:  
  267:         /// <summary/>
  268:         public static string Host { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SoftXHuaweiServerHost"); } }
  269:  
  270:         /// <summary/>
  271:         public static int Port { get { return int.Parse(Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SoftXHuaweiServerPort")); } }
  272:  
  273:         /// <summary/>
  274:         public static string LoginUser { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SoftXHuaweiServerLoginUser"); } }
  275:  
  276:         /// <summary/>
  277:         public static string LogoutUser { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SoftXHuaweiServerLogoutUser"); } }
  278:  
  279:         /// <summary/>
  280:         public static string SemiColon { get { return ";"; } }
  281:  
  282:         ////////////////////////////////////////////////////////////////////////////
  283:  
  284:         /// <summary>
  285:         /// 
  286:         /// </summary>
  287:         public class Response
  288:         {
  289:             /// <summary/>
  290:             public bool IsSuccess { get { return ReturnCode == Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode.OperationSucceeded; } }
  291:  
  292:             /// <summary/>
  293:             public Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode ReturnCode { get; set; }
  294:  
  295:             /// <summary/>
  296:             public string NetworkElement { get; set; }
  297:  
  298:             /// <summary/>
  299:             public string CodeExplanation { get; set; }
  300:  
  301:             /// <summary/>
  302:             public string CommandString { get; set; }
  303:  
  304:             /// <summary/>
  305:             public string Content { get; set; }
  306:  
  307:             /// <summary/>
  308:             public int Count { get; set; }
  309:  
  310:             /// <summary/>
  311:             public Dictionary<string, string> QueryDictionary { get; set; }
  312:  
  313:             /// <summary/>
  314:             public Response() { }
  315:         }
  316:  
  317:         ////////////////////////////////////////////////////////////////////////////
  318:  
  319:         /// <summary>
  320:         ///
  321:         /// </summary>
  322:         public SoftX() { }
  323:  
  324:         ////////////////////////////////////////////////////////////////////////////
  325:  
  326:         /// <summary>
  327:         ///
  328:         /// </summary>
  329:         public static Ia.Cl.Models.Result Connect()
  330:         {
  331:             var result = new Ia.Cl.Models.Result();
  332:  
  333:             tecSoftX = new Cl.Models.Client.Huawei.SoftX();
  334:             skbSoftX = new Cl.Models.Client.Huawei.SoftX();
  335:  
  336:             if (tecSoftX != null && !tecSoftX.IsConnected) result = tecSoftX.Connect();
  337:             else result.AddWarning("TEC SoftX is already connected");
  338:  
  339:             if (skbSoftX != null && !skbSoftX.IsConnected) result = skbSoftX.Connect();
  340:             else result.AddWarning("SKB SoftX is already connected");
  341:  
  342:             return result;
  343:         }
  344:  
  345:         ////////////////////////////////////////////////////////////////////////////
  346:  
  347:         /// <summary>
  348:         ///
  349:         /// </summary>
  350:         public static Ia.Cl.Models.Result Disconnect()
  351:         {
  352:             var result = new Ia.Cl.Models.Result();
  353:  
  354:             if (tecSoftX != null && tecSoftX.IsConnected) result = tecSoftX.Disconnect();
  355:             else result.AddWarning("TEC SoftX is already disconnected");
  356:  
  357:             if (skbSoftX != null && skbSoftX.IsConnected) result = skbSoftX.Disconnect();
  358:             else result.AddWarning("SKB SoftX is already disconnected");
  359:  
  360:             return result;
  361:         }
  362:  
  363:         ////////////////////////////////////////////////////////////////////////////
  364:  
  365:         /// <summary>
  366:         ///
  367:         /// </summary>
  368:         public static void Login()
  369:         {
  370:             tecSoftX.Login();
  371:             skbSoftX.Login();
  372:         }
  373:  
  374:         ////////////////////////////////////////////////////////////////////////////
  375:  
  376:         /// <summary>
  377:         ///
  378:         /// </summary>
  379:         public static void Logout()
  380:         {
  381:             tecSoftX.Logout();
  382:             skbSoftX.Logout();
  383:         }
  384:  
  385:         ////////////////////////////////////////////////////////////////////////////
  386:  
  387:         /// <summary>
  388:         ///
  389:         /// </summary>
  390:         public static void RegisterNe()
  391:         {
  392:             var c = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.RegisterNetworkElementCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.TecNetworkElement);
  393:             tecSoftX.SendQueue.Enqueue(c);
  394:  
  395:             c = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.RegisterNetworkElementCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.SkbNetworkElement);
  396:             skbSoftX.SendQueue.Enqueue(c);
  397:         }
  398:  
  399:         ////////////////////////////////////////////////////////////////////////////
  400:  
  401:         /// <summary>
  402:         ///
  403:         /// </summary>
  404:         public static void UnregisterNe()
  405:         {
  406:             var c = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.UnregisterNetworkElementCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.TecNetworkElement);
  407:             tecSoftX.SendQueue.Enqueue(c);
  408:  
  409:             c = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.UnregisterNetworkElementCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.SkbNetworkElement);
  410:             skbSoftX.SendQueue.Enqueue(c);
  411:         }
  412:  
  413:         ////////////////////////////////////////////////////////////////////////////
  414:  
  415:         /// <summary>
  416:         ///
  417:         /// </summary>
  418:         private static string RegisterNetworkElementCommand(NetworkElement networkElement)
  419:         {
  420:             // REG NE:IP="10.10.11.20";
  421:             return @"REG NE:IP=""" + networkElement.Ip + @""";";
  422:         }
  423:  
  424:         ////////////////////////////////////////////////////////////////////////////
  425:  
  426:         /// <summary>
  427:         ///
  428:         /// </summary>
  429:         private static string UnregisterNetworkElementCommand(NetworkElement networkElement)
  430:         {
  431:             // UNREG NE:IP="10.161.198.243"; 
  432:             return @"UNREG NE:IP=""" + networkElement.Ip + @""";";
  433:         }
  434:  
  435:         ////////////////////////////////////////////////////////////////////////////
  436:  
  437:         /// <summary>
  438:         ///
  439:         /// </summary>
  440:         public static Queue<string> TecReceiveQueue
  441:         {
  442:             get
  443:             {
  444:                 return tecSoftX.ReceiveQueue;
  445:             }
  446:         }
  447:  
  448:         ////////////////////////////////////////////////////////////////////////////
  449:  
  450:         /// <summary>
  451:         ///
  452:         /// </summary>
  453:         public static Queue<string> TecSendQueue
  454:         {
  455:             get
  456:             {
  457:                 return tecSoftX.SendQueue;
  458:             }
  459:         }
  460:  
  461:         ////////////////////////////////////////////////////////////////////////////
  462:  
  463:         /// <summary>
  464:         ///
  465:         /// </summary>
  466:         public static Queue<string> SkbReceiveQueue
  467:         {
  468:             get
  469:             {
  470:                 return skbSoftX.ReceiveQueue;
  471:             }
  472:         }
  473:  
  474:         ////////////////////////////////////////////////////////////////////////////
  475:  
  476:         /// <summary>
  477:         ///
  478:         /// </summary>
  479:         public static Queue<string> SkbSendQueue
  480:         {
  481:             get
  482:             {
  483:                 return skbSoftX.SendQueue;
  484:             }
  485:         }
  486:  
  487:         ////////////////////////////////////////////////////////////////////////////
  488:  
  489:         /// <summary>
  490:         ///
  491:         /// </summary>
  492:         public static bool IsConnected
  493:         {
  494:             get
  495:             {
  496:                 return tecSoftX != null && tecSoftX.IsConnected && skbSoftX != null && skbSoftX.IsConnected;
  497:             }
  498:         }
  499:  
  500:         ////////////////////////////////////////////////////////////////////////////
  501:         ////////////////////////////////////////////////////////////////////////////
  502:  
  503:         /// <summary>
  504:         ///
  505:         /// </summary>
  506:         public static Ia.Cl.Models.Result ManageReceiveQueue()
  507:         {
  508:             string rowString, formattedString;
  509:  
  510:             var result = new Ia.Cl.Models.Result();
  511:             var tecSoftXResult = new Ia.Cl.Models.Result();
  512:             var skbSoftXResult = new Ia.Cl.Models.Result();
  513:  
  514:             try
  515:             {
  516:                 while (tecSoftX.ReceiveQueue.Count > 0)
  517:                 {
  518:                     rowString = tecSoftX.ReceiveQueue.Dequeue();
  519:  
  520:                     Debug.WriteLine("ManageReceiveQueue(): rowString: " + rowString);
  521:  
  522:                     formattedString = rowString;
  523:  
  524:                     tecSoftX.Update(formattedString, ref tecSoftX, out tecSoftXResult);
  525:                 }
  526:  
  527:                 while (skbSoftX.ReceiveQueue.Count > 0)
  528:                 {
  529:                     rowString = skbSoftX.ReceiveQueue.Dequeue();
  530:  
  531:                     Debug.WriteLine("ManageReceiveQueue(): rowString: " + rowString);
  532:  
  533:                     formattedString = rowString;
  534:  
  535:                     skbSoftX.Update(formattedString, ref skbSoftX, out skbSoftXResult);
  536:                 }
  537:  
  538:                 result.AddResult(tecSoftXResult);
  539:                 result.AddResult(skbSoftXResult);
  540:             }
  541:             catch (Exception ex)
  542:             {
  543:                 result.AddError("ManageReceiveQueue: Exception: " + ex.Message);
  544:             }
  545:  
  546:             return result;
  547:         }
  548:  
  549:         ////////////////////////////////////////////////////////////////////////////
  550:  
  551:         /// <summary>
  552:         ///
  553:         /// </summary>
  554:         public static string ManageSendQueue(out Ia.Cl.Models.Result result)
  555:         {
  556:             string command = string.Empty;
  557:             var commandList = new List<string>();
  558:  
  559:             result = new Ia.Cl.Models.Result();
  560:  
  561:             try
  562:             {
  563:                 if (tecSoftX.SendQueue.Count > 0)
  564:                 {
  565:                     command = tecSoftX.SendQueue.Dequeue();
  566:  
  567:                     Debug.WriteLine("ManageSendQueue(): command: " + command);
  568:  
  569:                     var r = tecSoftX.Send(command);
  570:  
  571:                     if (r.HasError) result.AddError(r.Message);
  572:  
  573:                     commandList.Add(command);
  574:                 }
  575:  
  576:                 if (skbSoftX.SendQueue.Count > 0)
  577:                 {
  578:                     command = skbSoftX.SendQueue.Dequeue();
  579:  
  580:                     Debug.WriteLine("ManageSendQueue(): command: " + command);
  581:  
  582:                     var r = skbSoftX.Send(command);
  583:  
  584:                     if (r.HasError) result.AddError(r.Message);
  585:  
  586:                     commandList.Add(command);
  587:                 }
  588:             }
  589:             catch (Exception ex)
  590:             {
  591:                 result.AddError("ManageSendQueue: Exception: " + ex.Message);
  592:             }
  593:  
  594:             return result.HasError ? string.Empty : string.Join(" ", commandList);
  595:         }
  596:  
  597:         ////////////////////////////////////////////////////////////////////////////
  598:  
  599:         /// <summary>
  600:         ///
  601:         /// </summary>
  602:         private static string KeepAliveShakeHandCommand
  603:         {
  604:             get
  605:             {
  606:                 return "SHK HAND:;";
  607:             }
  608:         }
  609:  
  610:         ////////////////////////////////////////////////////////////////////////////
  611:  
  612:         /// <summary>
  613:         ///
  614:         /// </summary>
  615:         private static string ProperlySelectedSingleSoftXCommandQueueCommand(ref int referenceIndex, out int itemIndex, out int listCount)
  616:         {
  617:             if (properlySelectedSoftXCommandList.JustStartedOrRolledOver())
  618:             {
  619:                 //list = new List<string>(); // SoftXCommandToRetrieveAllPossibleMgwsPreferablyNotInMgwTable();
  620:  
  621:                 properlySelectedSoftXCommandList = SoftXCommandToRetrieveAllPossibleAsbrsPreferablyNotInAsbrsTable();
  622:             }
  623:  
  624:             var command = properlySelectedSoftXCommandList.Next(ref referenceIndex, out itemIndex, out listCount);
  625:  
  626:             return command;
  627:         }
  628:  
  629:         ////////////////////////////////////////////////////////////////////////////
  630:  
  631:         /// <summary>
  632:         ///
  633:         /// </summary>
  634:         public static List<string> SoftXCommandToRetrieveAllPossibleMgwsPreferablyNotInMgwTable()
  635:         {
  636:             HashSet<string> hashSet;
  637:  
  638:             hashSet = new HashSet<string>();
  639:  
  640:             //var nddOntInHuaweiSwitchNokiaAccessWithAccessList = Ia.Ftn.Cl.Model.Data.Huawei.Ims.NddOntInHuaweiSwitchNokiaAccessWithAccessList();
  641:             var nddOntInHuaweiSwitchNokiaAccessList = Ia.Ftn.Cl.Models.Data.Huawei.Ims.NddOntInHuaweiSwitchNokiaAccessList();
  642:  
  643:             var ipEidOfnddOntInHuaweiSwitchNokiaAccessWithAccessList = new List<string>();
  644:  
  645:             /*
  646:             foreach (var n in nddOntInHuaweiSwitchNokiaAccessWithAccessList)
  647:             {
  648:                 if (Ia.Cl.Models.Default.IsValidIpv4(n.Ip))
  649:                 {
  650:                     ipEidOfnddOntInHuaweiSwitchNokiaAccessWithAccessList.Add(IpToEid(n.Ip));
  651:                 }
  652:                 else
  653:                 {
  654:                 }
  655:             }
  656:             */
  657:  
  658:             var ipEidOfnddOntInHuaweiSwitchNokiaAccessList = new List<string>();
  659:  
  660:             foreach (var n in nddOntInHuaweiSwitchNokiaAccessList)
  661:             {
  662:                 if (Ia.Cl.Models.Default.IsValidIpv4(n.Ip))
  663:                 {
  664:                     ipEidOfnddOntInHuaweiSwitchNokiaAccessList.Add(IpToEid(n.Ip));
  665:                 }
  666:                 else
  667:                 {
  668:                 }
  669:             }
  670:  
  671:             var eid0List = Ia.Ftn.Cl.Models.Data.Huawei.Mgw.EidList();
  672:             eid0List = eid0List.Distinct().ToList();
  673:  
  674:             //var eidList = ipEidOfnddOntInHuaweiSwitchNokiaAccessWithAccessList.Except(eid0List).ToList();
  675:             var eidList = ipEidOfnddOntInHuaweiSwitchNokiaAccessList.Except(eid0List).ToList();
  676:  
  677:             // if eidList is empty then will use the all list
  678:             //if (eidList.Count == 0) eidList = ipEidOfnddOntInHuaweiSwitchNokiaAccessWithAccessList;
  679:             if (eidList.Count == 0) eidList = ipEidOfnddOntInHuaweiSwitchNokiaAccessList;
  680:  
  681:             var commandList = new List<string>();
  682:  
  683:             foreach (string eid in eidList)
  684:             {
  685:                 commandList.Add(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.FormatSoftXLstCommand(SoftXOpcode.LstMgw, eid));
  686:             }
  687:  
  688:             hashSet.UnionWith(new HashSet<string>(commandList));
  689:  
  690:             return hashSet.OrderBy(u => u).ToList();
  691:         }
  692:  
  693:         ////////////////////////////////////////////////////////////////////////////
  694:  
  695:         /// <summary>
  696:         ///
  697:         /// </summary>
  698:         public static List<string> SoftXCommandToRetrieveAllPossibleAsbrsPreferablyNotInAsbrsTable()
  699:         {
  700:             string pui;
  701:             HashSet<string> hashSet;
  702:  
  703:             hashSet = new HashSet<string>();
  704:  
  705:             var possibleList = Ia.Ftn.Cl.Models.Data.Service.AllPossibleServiceNumberWithinSoftX().ConvertAll<string>(u => u.ToString());
  706:  
  707:             // temp
  708:             //possibleList = possibleList.Where(u => u.StartsWith("254")).ToList();
  709:  
  710:             var existingList = Ia.Ftn.Cl.Models.Data.Huawei.Asbr.ServiceList();
  711:  
  712:             var list = possibleList.Except(existingList).ToList();
  713:  
  714:             // if list is empty then will use the possibleList
  715:             if (list.Count == 0) list = possibleList;
  716:  
  717:             var commandList = new List<string>();
  718:  
  719:             foreach (string service in list)
  720:             {
  721:                 pui = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuSipDomain(service);
  722:  
  723:                 commandList.Add(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.FormatSoftXLstCommand(SoftXOpcode.LstAsbr, pui));
  724:             }
  725:  
  726:             hashSet.UnionWith(new HashSet<string>(commandList));
  727:  
  728:             return hashSet.OrderBy(u => u).ToList();
  729:         }
  730:  
  731:         ////////////////////////////////////////////////////////////////////////////
  732:         ////////////////////////////////////////////////////////////////////////////
  733:  
  734:  
  735:  
  736:         ////////////////////////////////////////////////////////////////////////////
  737:         ////////////////////////////////////////////////////////////////////////////
  738:  
  739:         /// <summary>
  740:         ///
  741:         /// </summary>
  742:         public static Ia.Cl.Models.Result AddAsbr(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, string service, int port)
  743:         {
  744:             string command;
  745:             Ia.Cl.Models.Result result;
  746:  
  747:             result = new Ia.Cl.Models.Result();
  748:  
  749:             var ont = Ia.Ftn.Cl.Models.Data.Nokia.Ont.Read(nddOnt.Id);
  750:  
  751:             if (ont != null)
  752:             {
  753:                 port = (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ftn.Cl.Models.Data.Huawei.Asbr.NextVacantTidForOnt(nddOnt, ont);
  754:  
  755:                 if (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  756:                 {
  757:                     command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.AddAsbrCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.TecNetworkElement, nddOnt, service, port);
  758:                     tecSoftX.SendQueue.Enqueue(command);
  759:  
  760:                     command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.AddAsbrCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.SkbNetworkElement, nddOnt, service, port);
  761:                     skbSoftX.SendQueue.Enqueue(command);
  762:                 }
  763:                 else
  764:                 {
  765:                     result.AddError("Port is invalid or does not exist:" + nddOnt.Access.Name);
  766:                 }
  767:             }
  768:             else
  769:             {
  770:                 result.AddError("Ont is null, does not exist for access:" + nddOnt.Access.Name);
  771:             }
  772:  
  773:             return result;
  774:         }
  775:  
  776:         ////////////////////////////////////////////////////////////////////////////
  777:  
  778:         /// <summary>
  779:         ///
  780:         /// </summary>
  781:         public static void ReadAsbr(string service)
  782:         {
  783:             string command;
  784:  
  785:             command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ReadAsbrCommand(service);
  786:  
  787:             tecSoftX.SendQueue.Enqueue(command);
  788:             skbSoftX.SendQueue.Enqueue(command);
  789:         }
  790:  
  791:         ////////////////////////////////////////////////////////////////////////////
  792:  
  793:         /// <summary>
  794:         ///
  795:         /// </summary>
  796:         public static void RemoveAsbr(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, string service)
  797:         {
  798:             string command;
  799:  
  800:             // try to handle removing a number without knowing the ONT
  801:  
  802:             command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.RemoveAsbrCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.TecNetworkElement, nddOnt, service, 0);
  803:             tecSoftX.SendQueue.Enqueue(command);
  804:  
  805:             command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.RemoveAsbrCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.SkbNetworkElement, nddOnt, service, 0);
  806:             skbSoftX.SendQueue.Enqueue(command);
  807:         }
  808:  
  809:         /*
  810:         ////////////////////////////////////////////////////////////////////////////
  811: 
  812:         /// <summary>
  813:         ///
  814:         /// </summary>
  815:         private static Ia.Cl.Models.Result ManageSynchronizationBetweenHuaweiImsAndNokiaAccess()
  816:         {
  817:             Ia.Ftn.Cl.Model.Business.Huawei.SoftX.ProvisioningWorkflow provisioningWorkflow;
  818: 
  819:             var result = new Ia.Cl.Models.Result();
  820: 
  821:             provisioningWorkflow = Ia.Ftn.Cl.Model.Business.Huawei.SoftX.SynchronizeAsbrServiceToMatchHuaweiSwitchNokiaAccessServiceQueueCommand;
  822: 
  823:             if (provisioningWorkflow != null)
  824:             {
  825:                 tecSoftX.SendQueue.Enqueue(provisioningWorkflow.TecCreateCommand);
  826:                 tecSoftX.SendQueue.Enqueue(provisioningWorkflow.ReadCommand);
  827: 
  828:                 skbSoftX.SendQueue.Enqueue(provisioningWorkflow.SkbCreateCommand);
  829:                 skbSoftX.SendQueue.Enqueue(provisioningWorkflow.ReadCommand);
  830: 
  831:                 result.AddSuccess("Create (TEC): " + provisioningWorkflow.TecCreateCommand + "(SKB): " + provisioningWorkflow.SkbCreateCommand + ", Read: " + provisioningWorkflow.ReadCommand);
  832:             }
  833:             else
  834:             {
  835:                 result.AddWarning("No sync");
  836:             }
  837: 
  838:             return result;
  839:         }
  840:          */
  841:  
  842:         ////////////////////////////////////////////////////////////////////////////
  843:  
  844:         /// <summary>
  845:         ///
  846:         /// </summary>
  847:         public static Ia.Cl.Models.Result ManageSynchronizationBetweenHuaweiImsAndNokiaAccess(Ia.Ftn.Cl.Models.Business.Default.Procedure procedure)
  848:         {
  849:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
  850:  
  851:             var result = new Ia.Cl.Models.Result();
  852:  
  853:             process = addOrRemoveAsbrSubscriberProcedure.NextProcess();
  854:  
  855:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
  856:             {
  857:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Create)
  858:                 {
  859:                     result.AddSuccess("create: " + process.Service + " (" + process.Ont.Access.Name + ") " + addOrRemoveAsbrSubscriberProcedure.ProgressCounterString);
  860:  
  861:                     AddAsbr(process.Ont, process.Service, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown);
  862:  
  863:                     // not suitable causes too many messages
  864:                     //Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Model.Business.MessageQueue.Application.SoftXApplication, Ia.Ftn.Cl.Model.Business.MessageQueue.Process.ReadService, process.Service);
  865:                 }
  866:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
  867:                 {
  868:                     result.AddSuccess("read: " + process.Service + " (" + process.Ont.Access.Name + ") " + addOrRemoveAsbrSubscriberProcedure.ProgressCounterString);
  869:  
  870:                     ReadAsbr(process.Service);
  871:                 }
  872:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Delete)
  873:                 {
  874:                     result.AddSuccess("delete: " + process.Service + " (" + process.Ont.Access.Name + ") " + addOrRemoveAsbrSubscriberProcedure.ProgressCounterString);
  875:  
  876:                     RemoveAsbr(process.Ont, process.Service);
  877:  
  878:                     // not suitable causes too many messages
  879:                     //Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Model.Business.MessageQueue.Application.SoftXApplication, Ia.Ftn.Cl.Model.Business.MessageQueue.Process.ReadService, process.Service);
  880:                 }
  881:                 else result.AddError("sync: undefined procedure");
  882:  
  883:                 Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.SoftXApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.SynchronizeCompleted, process.Service);
  884:             }
  885:             else result.AddWarning("sync: nothing to create or delete");
  886:  
  887:             return result;
  888:         }
  889:  
  890:         ////////////////////////////////////////////////////////////////////////////
  891:         ////////////////////////////////////////////////////////////////////////////
  892:  
  893:  
  894:  
  895:  
  896:  
  897:  
  898:  
  899:  
  900:  
  901:         ////////////////////////////////////////////////////////////////////////////
  902:         ////////////////////////////////////////////////////////////////////////////
  903:  
  904:         /// <summary>
  905:         ///
  906:         /// </summary>
  907:         public static string ManageProperly(ref int properlySelectedSoftXCommandListIndex)
  908:         {
  909:             var command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ProperlySelectedSingleSoftXCommandQueueCommand(ref properlySelectedSoftXCommandListIndex, out int itemIndex, out int listCount);
  910:  
  911:             tecSoftX.SendQueue.Enqueue(command);
  912:             skbSoftX.SendQueue.Enqueue(command);
  913:  
  914:             var r = command + " (" + itemIndex + "/" + listCount + ")";
  915:  
  916:             return r;
  917:         }
  918:  
  919:         ////////////////////////////////////////////////////////////////////////////
  920:  
  921:         /// <summary>
  922:         ///
  923:         /// </summary>
  924:         public static async Task<Ia.Cl.Models.Result> ManageMessageQueue()
  925:         {
  926:             string command;
  927:  
  928:             var result = new Ia.Cl.Models.Result();
  929:  
  930:             var count = await Ia.Ftn.Cl.Models.Data.MessageQueue.SoftXApplication.CountAsync;
  931:  
  932:             if (count > 0)
  933:             {
  934:                 var message = await Ia.Ftn.Cl.Models.Data.MessageQueue.SoftXApplication.DequeueAsync;
  935:  
  936:                 if (message != null)
  937:                 {
  938:                     if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadService)
  939:                     {
  940:                         if (Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinSoftXDomainList(message.Service))
  941:                         {
  942:                             command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ReadAsbrCommand(message.Service);
  943:  
  944:                             tecSoftX.SendQueue.Enqueue(command);
  945:                             skbSoftX.SendQueue.Enqueue(command);
  946:  
  947:                             result.AddSuccess(message.Service);
  948:                         }
  949:                         else result.AddError("Service: " + message.Service + " is not within SoftX server");
  950:                     }
  951:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadAccess)
  952:                     {
  953:                         var accessName = message.AccessName;
  954:  
  955:                         if (!string.IsNullOrEmpty(accessName))
  956:                         {
  957:                             command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ReadMgwCommand(message.AccessName);
  958:  
  959:                             tecSoftX.SendQueue.Enqueue(command);
  960:                             skbSoftX.SendQueue.Enqueue(command);
  961:  
  962:                             result.AddSuccess(message.AccessName);
  963:                         }
  964:                         else result.AddError("AccessName is null or empty");
  965:                     }
  966:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ResetAccess)
  967:                     {
  968:                         result.AddError("Process " + message.Process.ToString() + " undefined");
  969:                     }
  970:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort)
  971:                     {
  972:                         var service = message.Service;
  973:                         var accessName = message.AccessName;
  974:                         var port = message.Port;
  975:  
  976:                         if (Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinSoftXDomainList(service))
  977:                         {
  978:                             var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
  979:  
  980:                             var createResult = AddAsbr(nddOnt, message.Service, port);
  981:  
  982:                             ReadAsbr(service);
  983:  
  984:                             result.AddSuccess("Create/Read: " + service + "|" + accessName + "|" + port + ": " + message.Service + "," + createResult.Message);
  985:                         }
  986:                         else result.AddError("Create/Read: " + service + "|" + accessName + "|" + port + ": Service: " + service + " is not within SoftX server");
  987:                     }
  988:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  989:                     {
  990:                         var service = message.Service;
  991:                         var accessName = message.AccessName;
  992:  
  993:                         if (Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinSoftXDomainList(message.Service))
  994:                         {
  995:                             if (!string.IsNullOrEmpty(accessName))
  996:                             {
  997:                                 var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
  998:  
  999:                                 RemoveAsbr(nddOnt, service);
 1000:  
 1001:                                 ReadAsbr(service);
 1002:  
 1003:                                 result.AddSuccess("Delete/Read: " + service + "|" + accessName + ": " + message.Service);
 1004:                             }
 1005:                             else result.AddError("Delete/Read: " + service + "|" + accessName + ": AccessName is null or empty");
 1006:                         }
 1007:                         else result.AddError("Delete/Read: " + service + "|" + accessName + ": Service " + service + " is not within SoftX server");
 1008:                     }
 1009:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.Synchronize)
 1010:                     {
 1011:                         var r = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ManageSynchronizationBetweenHuaweiImsAndNokiaAccess(Ia.Ftn.Cl.Models.Business.Default.Procedure.InitializeOrIterate);
 1012:  
 1013:                         result.AddSuccess("Synchronize: " + r.Message);
 1014:                     }
 1015:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ActiveApplicationRunningPermissionState)
 1016:                     {
 1017:                         Ia.Ftn.Cl.Models.Business.Default.PermitActiveApplicationsToRun = message.State;
 1018:  
 1019:                         result.AddSuccess("PermitActiveApplicationsToRun: " + message.State);
 1020:                     }
 1021:                     else
 1022:                     {
 1023:                         throw new ArgumentOutOfRangeException("MessageQueue process " + message.Process.ToString() + " is undefined");
 1024:                     }
 1025:                 }
 1026:                 else
 1027:                 {
 1028:                 }
 1029:             }
 1030:             else
 1031:             {
 1032:             }
 1033:  
 1034:             return result;
 1035:         }
 1036:  
 1037:         ////////////////////////////////////////////////////////////////////////////
 1038:  
 1039:         /// <summary>
 1040:         ///
 1041:         /// </summary>
 1042:         public static Ia.Cl.Models.Result ManageCreateMissingMgw()
 1043:         {
 1044:             string command;
 1045:  
 1046:             var result = new Ia.Cl.Models.Result();
 1047:  
 1048:             var nddOnt = Ia.Ftn.Cl.Models.Data.Provision.NddHuaweiSwitchAndNokiaAccessOntWithAccessButNoMgwRecord(out string r0);
 1049:  
 1050:             if (nddOnt != null)
 1051:             {
 1052:                 command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.AddMgwCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.TecNetworkElement, nddOnt);
 1053:                 tecSoftX.SendQueue.Enqueue(command);
 1054:  
 1055:                 command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.AddMgwCommand(Ia.Ftn.Cl.Models.Business.Huawei.SoftX.SkbNetworkElement, nddOnt);
 1056:                 skbSoftX.SendQueue.Enqueue(command);
 1057:  
 1058:                 command = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ReadMgwCommand(nddOnt);
 1059:                 tecSoftX.SendQueue.Enqueue(command);
 1060:                 skbSoftX.SendQueue.Enqueue(command);
 1061:  
 1062:                 result.AddSuccess("Updated: " + nddOnt.Access.Name + " " + r0);
 1063:             }
 1064:             else
 1065:             {
 1066:                 result.AddWarning("There are no missing MGWs in Huawei-Nokia networks");
 1067:             }
 1068:  
 1069:             return result;
 1070:         }
 1071:  
 1072:         ////////////////////////////////////////////////////////////////////////////
 1073:  
 1074:         /// <summary>
 1075:         ///
 1076:         /// </summary>
 1077:         public static Ia.Cl.Models.Result ManageKeepAliveShakeHand()
 1078:         {
 1079:             var result = new Ia.Cl.Models.Result();
 1080:  
 1081:             var c = Ia.Ftn.Cl.Models.Business.Huawei.SoftX.KeepAliveShakeHandCommand;
 1082:  
 1083:             tecSoftX.SendQueue.Enqueue(c);
 1084:             skbSoftX.SendQueue.Enqueue(c);
 1085:  
 1086:             result.AddSuccess(c);
 1087:  
 1088:             return result;
 1089:         }
 1090:  
 1091:         ////////////////////////////////////////////////////////////////////////////
 1092:         ////////////////////////////////////////////////////////////////////////////
 1093:  
 1094:         /// <summary>
 1095:         ///
 1096:         /// </summary>
 1097:         public static bool SpecialBooleanParameterHandling(string parameterName, string parameterValue)
 1098:         {
 1099:             bool b;
 1100:  
 1101:             if (parameterValue == "Yes") b = true;
 1102:             else if (parameterName == "No") b = false;
 1103:             else if (parameterName == "Active") b = true;
 1104:             else b = false;
 1105:  
 1106:             return b;
 1107:         }
 1108:  
 1109:         ////////////////////////////////////////////////////////////////////////////
 1110:  
 1111:         /// <summary>
 1112:         ///
 1113:         /// </summary>
 1114:         public static int SpecialIntegerParameterHandling(string parameterName, string parameterValue)
 1115:         {
 1116:             int i;
 1117:  
 1118:             if (parameterValue == "NULL") i = 0;
 1119:             else i = int.Parse(parameterName);
 1120:  
 1121:             return i;
 1122:         }
 1123:  
 1124:         ////////////////////////////////////////////////////////////////////////////
 1125:         ////////////////////////////////////////////////////////////////////////////
 1126:  
 1127:         /// <summary>
 1128:         ///
 1129:         /// </summary>
 1130:         private static string ReadAsbrCommand(string service)
 1131:         {
 1132:             var pui = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuSipDomain(service);
 1133:  
 1134:             return FormatSoftXLstCommand(SoftXOpcode.LstAsbr, pui);
 1135:         }
 1136:  
 1137:         ////////////////////////////////////////////////////////////////////////////
 1138:  
 1139:         /// <summary>
 1140:         ///
 1141:         /// </summary>
 1142:         private static string ReadMgwCommand(string accessName)
 1143:         {
 1144:             string command;
 1145:  
 1146:             var ip = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntAccessNameToOntIpDictionary[accessName];
 1147:  
 1148:             if (Ia.Cl.Models.Default.IsValidIpv4(ip))
 1149:             {
 1150:                 var eid = IpToEid(ip);
 1151:  
 1152:                 command = FormatSoftXLstCommand(SoftXOpcode.LstMgw, eid);
 1153:             }
 1154:             else command = string.Empty;
 1155:  
 1156:             return command;
 1157:         }
 1158:  
 1159:         ////////////////////////////////////////////////////////////////////////////
 1160:  
 1161:         /// <summary>
 1162:         ///
 1163:         /// </summary>
 1164:         private static string ReadMgwCommand(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont)
 1165:         {
 1166:             string command;
 1167:  
 1168:             if (ont != null)
 1169:             {
 1170:                 var eid = IpToEid(ont.Ip);
 1171:  
 1172:                 command = FormatSoftXLstCommand(SoftXOpcode.LstMgw, eid);
 1173:             }
 1174:             else command = string.Empty;
 1175:  
 1176:             return command;
 1177:         }
 1178:  
 1179:         ////////////////////////////////////////////////////////////////////////////
 1180:  
 1181:         /// <summary>
 1182:         ///
 1183:         /// </summary>
 1184:         private static string AddMgwCommand(NetworkElement networkElement, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont)
 1185:         {
 1186:             string command;
 1187:  
 1188:             if (ont != null)
 1189:             {
 1190:                 command = FormatSoftXCommand(SoftXOpcode.AddMgw, networkElement, ont.Ip, ont.Access.Name);
 1191:             }
 1192:             else command = string.Empty;
 1193:  
 1194:             return command;
 1195:         }
 1196:  
 1197:         ////////////////////////////////////////////////////////////////////////////
 1198:  
 1199:         /// <summary>
 1200:         ///
 1201:         /// </summary>
 1202:         private static string AddAsbrCommand(NetworkElement networkElement, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont, string serivce, int port)
 1203:         {
 1204:             string command;
 1205:  
 1206:             if (ont != null)
 1207:             {
 1208:                 command = FormatSoftXCommand(SoftXOpcode.AddAsbr, networkElement, ont.Ip, ont.Access.Name, serivce, port);
 1209:             }
 1210:             else command = string.Empty;
 1211:  
 1212:             return command;
 1213:         }
 1214:  
 1215:         ////////////////////////////////////////////////////////////////////////////
 1216:  
 1217:         /// <summary>
 1218:         ///
 1219:         /// </summary>
 1220:         private static string RemoveAsbrCommand(NetworkElement networkElement, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont, string serivce, int port)
 1221:         {
 1222:             string command;
 1223:  
 1224:             if (ont != null)
 1225:             {
 1226:                 command = FormatSoftXCommand(SoftXOpcode.RemoveAsbr, networkElement, ont.Ip, ont.Access.Name, serivce, port);
 1227:             }
 1228:             else command = string.Empty;
 1229:  
 1230:             return command;
 1231:         }
 1232:  
 1233:         ////////////////////////////////////////////////////////////////////////////
 1234:         ////////////////////////////////////////////////////////////////////////////
 1235:  
 1236:         /// <summary>
 1237:         ///
 1238:         /// </summary>
 1239:         private static string FormatSoftXLstCommand(SoftXOpcode softXOpcode, string parameter)
 1240:         {
 1241:             string command;
 1242:  
 1243:             if (softXOpcode == SoftXOpcode.LstMgw)
 1244:             {
 1245:                 // LST MGW:EID="10.12.42.190:2944";
 1246:                 command = @"LST MGW:EID=""" + parameter + @""";";
 1247:             }
 1248:             else if (softXOpcode == SoftXOpcode.LstAsbr)
 1249:             {
 1250:                 // LST ASBR: PUI="sip:+96525449809@ims.moc.kw";
 1251:                 command = @"LST ASBR:PUI=""" + parameter + @""";";
 1252:             }
 1253:             else command = string.Empty;
 1254:  
 1255:             return command;
 1256:         }
 1257:  
 1258:         ////////////////////////////////////////////////////////////////////////////
 1259:  
 1260:         /// <summary>
 1261:         ///
 1262:         /// </summary>
 1263:         private static string FormatSoftXCommand(SoftXOpcode softXOpcode, NetworkElement networkElement, string ontIp, string accessName)
 1264:         {
 1265:             return FormatSoftXCommand(softXOpcode, networkElement, ontIp, accessName, null, 0);
 1266:         }
 1267:  
 1268:         ////////////////////////////////////////////////////////////////////////////
 1269:  
 1270:         /// <summary>
 1271:         ///
 1272:         /// </summary>
 1273:         private static string FormatSoftXCommand(SoftXOpcode softXOpcode, NetworkElement networkElement, string ontIp, string accessName, string service, int port)
 1274:         {
 1275:             string command;
 1276:  
 1277:             if (softXOpcode == SoftXOpcode.AddMgw)
 1278:             {
 1279:                 // ADD MGW: EID="ONT IP:2944", GWTP=AG, MGWDESC="ONT IP", MGCMODULENO=22, PTYPE=H248, LA="10.10.9.10", DYNIP=NS, RA1="ONT IP", RP=2944, LISTOFCODEC=PCMA-1&PCMU-1&G7231-0&G729-1&G726-0&T38-0&AMR-0&H261-0&H263-0&MPEG4-0&CLEARMODE-1&G726_40-0&G726_32-0&G726_24-0&G726_16-0&ILBC-0&SPEEX-0&G711A_VBD-0&G711U_VBD-0&GSM_FR-0, EC=TRUE, ET=NO, TDMIFC1=10, RTPIFC=11, OWDYNA=YES, SUPROOTPKG=NS, MGWFCFLAG=FALSE, HEARTBEATTIMES=5;
 1280:                 command = @"ADD MGW:EID=""" + ontIp + @":" + RemotePort + @""", GWTP=AG, MGWDESC=""" + accessName + @""", MGCMODULENO=22, PTYPE=H248, LA=""" + networkElement.La + @""", DYNIP=NS, RA1=""" + ontIp + @""", RP=" + RemotePort + @", LISTOFCODEC=PCMA-1&PCMU-1&G7231-0&G729-1&G726-0&T38-0&AMR-0&H261-0&H263-0&MPEG4-0&CLEARMODE-1&G726_40-0&G726_32-0&G726_24-0&G726_16-0&ILBC-0&SPEEX-0&G711A_VBD-0&G711U_VBD-0&GSM_FR-0, EC=TRUE, ET=NO, TDMIFC1=10, RTPIFC=11, OWDYNA=YES, SUPROOTPKG=NS, MGWFCFLAG=FALSE, HEARTBEATTIMES=5;";
 1281:             }
 1282:             else if (softXOpcode == SoftXOpcode.AddAsbr)
 1283:             {
 1284:                 var pui = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Pui(service);
 1285:                 var pri = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Pri(service);
 1286:                 var tid = port;
 1287:  
 1288:                 // ADD ASBR: PUI="sip:+9652400xxxx@ims.moc.kw", PRI="+9652400xxxx@ims.moc.kw", REGTP=SINGLE, DID=ESL, EID="ONT IP:2944", TID="1", HNID="agcf-hnid", NETID="tec-agcf-vnid", NETINFO="access", PHNCON="Kuwait", DIGMAP=10, PWD="admin", DP=YES;
 1289:                 command = @"ADD ASBR:PUI=""" + pui + @""", PRI=""" + pri + @""", REGTP=SINGLE, DID=ESL, EID=""" + ontIp + @":" + RemotePort + @""", TID=""" + tid + @""", HNID=""agcf-hnid"", NETID=""" + networkElement.NetId + @""", NETINFO=""access"", PHNCON=""Kuwait"", DIGMAP=10, PWD=""admin"", DP=YES;";
 1290:             }
 1291:             else if (softXOpcode == SoftXOpcode.RemoveAsbr)
 1292:             {
 1293:                 var pui = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Pui(service);
 1294:                 var pri = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Pri(service);
 1295:                 var tid = port;
 1296:  
 1297:                 // RMV ASBR: PUI="sip:+556239901189@ims1.gvt.net.br";
 1298:                 command = @"RMV ASBR:PUI=""" + pui + @""";";
 1299:             }
 1300:             else command = string.Empty;
 1301:  
 1302:             return command;
 1303:         }
 1304:  
 1305:         ////////////////////////////////////////////////////////////////////////////
 1306:  
 1307:         /// <summary>
 1308:         ///
 1309:         /// </summary>
 1310:         private static string FormatSoftXModCommand(SoftXOpcode amsOpcode, string service, int rnidxRoute)
 1311:         {
 1312:             string command;
 1313:  
 1314:             if (amsOpcode == SoftXOpcode.LstAsbr)
 1315:             {
 1316:                 command = @"MOD SERUATTR:MODE=NUM,USRNUM=""" + service + @""",RNIDXTYPE=RN,RNIDX=" + rnidxRoute + ";";
 1317:             }
 1318:             else command = string.Empty;
 1319:  
 1320:             return command;
 1321:         }
 1322:  
 1323:         ////////////////////////////////////////////////////////////////////////////
 1324:  
 1325:         /// <summary>
 1326:         ///
 1327:         /// </summary>
 1328:         public static string IpToEid(string ip)
 1329:         {
 1330:             return ip + ":" + RemotePort;
 1331:         }
 1332:  
 1333:         ////////////////////////////////////////////////////////////////////////////    
 1334:         ////////////////////////////////////////////////////////////////////////////    
 1335:     }
 1336:  
 1337:     ////////////////////////////////////////////////////////////////////////////
 1338:     ////////////////////////////////////////////////////////////////////////////   
 1339: }