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