)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation Links

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