)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » SoftX (Ia.Ftn.Cl.Models.Data.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) data model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.Linq;
    5: using System.Text.RegularExpressions;
    6:  
    7: namespace Ia.Ftn.Cl.Models.Data.Huawei
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// U2020 Northbound Interface IP (SoftX) support class for Huawei's Fixed Telecommunications Network (FTN) data model.
   13:     /// </summary>
   14:  
   15:     /// <remarks> 
   16:     /// Copyright © 2019-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     /// </remarks> 
   18:     public class SoftX
   19:     {
   20:         ////////////////////////////////////////////////////////////////////////////
   21:  
   22:         /// <summary>
   23:         ///
   24:         /// </summary>
   25:         public static bool UpdateDatabaseWithSoftXCommandOutput(string rowData, ref Ia.Ftn.Cl.Models.Client.Huawei.SoftX softX, out Ia.Cl.Models.Result result)
   26:         {
   27:             bool b;
   28:             Ia.Ftn.Cl.Models.Business.Huawei.SoftX.Response response;
   29:  
   30:             b = false;
   31:             result = new Ia.Cl.Models.Result();
   32:  
   33:             response = Ia.Ftn.Cl.Models.Data.Huawei.SoftX.ParseResponse(rowData);
   34:  
   35:             if (response != null)
   36:             {
   37:                 if (response.ReturnCode == Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode.OperationSucceeded)
   38:                 {
   39:                     if (response.CommandString.Contains("LST MGW:"))
   40:                     {
   41:                         if (response.Count > 0)
   42:                         {
   43:                             b = Ia.Ftn.Cl.Models.Data.Huawei.Mgw.Update(response, out result);
   44:                         }
   45:                         else result.AddWarning(response.CodeExplanation);
   46:                     }
   47:                     else if (response.CommandString.Contains("LST ASBR:"))
   48:                     {
   49:                         if (response.Count > 0)
   50:                         {
   51:                             b = Ia.Ftn.Cl.Models.Data.Huawei.Asbr.Update(response, out result);
   52:                         }
   53:                         else result.AddWarning(response.CodeExplanation);
   54:                     }
   55:                     else if (response.CommandString.StartsWith("LST NEBYOMC:"))
   56:                     {
   57:                         result.AddSuccess(response.CodeExplanation);
   58:                     }
   59:                     else if (response.CommandString.StartsWith("REG NE:"))
   60:                     {
   61:                         result.AddSuccess(response.CodeExplanation);
   62:                     }
   63:                     else if (response.CommandString.StartsWith("UNREG NE:"))
   64:                     {
   65:                         result.AddSuccess(response.CodeExplanation);
   66:                     }
   67:                     else if (response.CommandString.StartsWith("ADD MGW:"))
   68:                     {
   69:                         result.AddSuccess(response.CodeExplanation);
   70:                     }
   71:                     /*
   72:                     else if (response.CommandString.StartsWith("RMV MGW:")) //?
   73:                     {
   74:                         result.AddSuccess(response.CodeExplanation);
   75:                     }
   76:                     */
   77:                     else if (response.CommandString.StartsWith("ADD ASBR:"))
   78:                     {
   79:                         result.AddSuccess(response.CodeExplanation);
   80:                     }
   81:                     else if (response.CommandString.StartsWith("RMV ASBR:"))
   82:                     {
   83:                         result.AddSuccess(response.CodeExplanation);
   84:                     }
   85:                     else if (response.CommandString.StartsWith("SHK HAND:"))
   86:                     {
   87:                         result.AddSuccess(response.CodeExplanation);
   88:                     }
   89:                     else if (response.CommandString.StartsWith("LGI:"))
   90:                     {
   91:                         softX.IsLoggedIn = true;
   92:  
   93:                         result.AddSuccess(response.CodeExplanation);
   94:                     }
   95:                     else if (response.CommandString.StartsWith("LGO:")) // never reached
   96:                     {
   97:                         softX.IsLoggedIn = false;
   98:  
   99:                         result.AddSuccess(response.CodeExplanation);
  100:                     }
  101:                     else
  102:                     {
  103:                         result.AddWarning("No designated opcode to process");
  104:  
  105:                         b = false;
  106:                     }
  107:                 }
  108:                 else if (response.ReturnCode == Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode.TheUserDoesNotExist)
  109:                 {
  110:                     if (response.CommandString.Contains("LST ASBR:"))
  111:                     {
  112:                         b = Ia.Ftn.Cl.Models.Data.Huawei.Asbr.Update(response, out result);
  113:                     }
  114:                     else if (response.CommandString.Contains("RMV ASBR:"))
  115:                     {
  116:                         result.AddSuccess(response.CodeExplanation);
  117:                     }
  118:                     else
  119:                     {
  120:                         result.AddWarning("No designated opcode to process");
  121:  
  122:                         b = false;
  123:                     }
  124:                 }
  125:                 else if (response.ReturnCode == Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode.InvalidCommand)
  126:                 {
  127:                     // just ignore for now
  128:  
  129:                     b = false;
  130:                 }
  131:                 else if (response.ReturnCode == Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode.InsufficientAuthority)
  132:                 {
  133:                     result.AddWarning(response.CodeExplanation);
  134:  
  135:                     b = false;
  136:                 }
  137:                 else
  138:                 {
  139:                     result.AddWarning(response.CodeExplanation);
  140:  
  141:                     b = false;
  142:                 }
  143:             }
  144:             else
  145:             {
  146:                 result.AddError("Response is null");
  147:  
  148:                 b = false;
  149:             }
  150:  
  151:  
  152:             return b;
  153:         }
  154:  
  155:         ////////////////////////////////////////////////////////////////////////////
  156:  
  157:         /// <summary>
  158:         /// Parse response according to HUAWEI SoftX3000 MML Command Protocol
  159:         /// </summary>
  160:         public static Ia.Ftn.Cl.Models.Business.Huawei.SoftX.Response ParseResponse(string rowData)
  161:         {
  162:             int count;
  163:             string networkElement, returnCodeString, content, identifier, commandString, key, value;
  164:             DateTime dateTime;
  165:             Dictionary<string, string> fieldNameExplanationToValueDictionary, fieldNameToValueDictionary;
  166:             Match match;
  167:             MatchCollection matchCollection;
  168:             Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode returnCode;
  169:             Ia.Ftn.Cl.Models.Business.Huawei.SoftX.Response response;
  170:             List<string> attributeList;
  171:             List<List<string>> valueListList;
  172:  
  173:             response = new Ia.Ftn.Cl.Models.Business.Huawei.SoftX.Response();
  174:  
  175:             attributeList = new List<string>(100);
  176:             valueListList = new List<List<string>>(100);
  177:  
  178:             /*
  179: +++    tec.agcf01        2020-11-03 11:27:42+03:00
  180: O&M    #18293403
  181: %%LST ASBR: PUI="sip:+96525449809@ims.moc.kw";%%
  182: RETCODE = 0  Operation succeeded
  183: 
  184:  ESL User Physical Location
  185: ---------------------------
  186:      Equipment ID  =  10.12.42.190:2944
  187:   MGW description  =  10.12.42.190
  188:            MGW ID  =  NULL
  189:    Termination ID  =  3
  190: Master/Slave type  =  Master
  191: 
  192: (Number of results = 1)
  193: 
  194: AGCF Users
  195: ----------
  196:                       PublicUser Id  =  sip:+96525449809@ims.moc.kw
  197:                      PrivateUser Id  =  +96525449809@ims.moc.kw
  198:                       Register Type  =  Single
  199:         IMS Registration Group Name  =  NULL
  200:             Terminal Equipment Type  =  Normal Terminal
  201:                       Module number  =  22
  202:                           Port type  =  ESL subscriber
  203:                  Priority Line flag  =  False
  204:                  Termination Status  =  Active
  205:                   New Service Right  =  NULL
  206:                   Default Dial Tone  =  Standard
  207:                     Home Network ID  =  ims.moc.kw
  208:                  Visited Network ID  =  tec.agcf01.ims.moc.kw
  209:                 Access Network Info  =  access
  210:                 Phone Context Index  =  0
  211:              Initial DigitMap Index  =  10
  212:               Global DigitMap Index  =  65535
  213:                            Password  =  ********
  214:                      SCC Group Name  =  NULL
  215:                    SOC Group Number  =  65534
  216:               Download Profile Flag  =  Explicit Subscription
  217: Send Registration Subscription Flag  =  No Subscription
  218:           Emergency Call Group Name  =  default
  219:                Conference URI index  =  255
  220:                         CLIP/R Mode  =  ATS mode
  221:                  IFMI Module Number  =  255
  222:                        Codec prefer  =  None
  223:                       Gate Proprity  =  Normal
  224: 
  225: (Number of results = 1)
  226: 
  227: ---    END             */
  228:  
  229:             /*
  230: +++     NMS SERVER        2020-11-19 08:56:17
  231: O&M     #2304
  232: %%LGI:OP="MOC_NBI", PWD="*****";%%
  233: RETCODE = 0  Success
  234: 
  235: Success
  236: 
  237: ---    END
  238:             */
  239:  
  240:             /*
  241: +++     NMS SERVER        2020-11-19 09:30:56
  242: O&M     #2304
  243: %%SHK HAND:;%%
  244: RETCODE = 0  Success
  245: 
  246: Success
  247: 
  248: ---    END
  249:             */
  250:  
  251:             /*
  252: +++    tec.agcf01        2020-12-17 19:03:16+03:00
  253: O&M    #20143962
  254: %%/ *229931* /LST ASBR: PUI="sip:+96525410007@ims.moc.kw";%%
  255: RETCODE = 96013  The user does not exist
  256: 
  257: ---    END             */
  258:  
  259:             match = Regex.Match(rowData, @"\+\+\+\s+(.+?)\s+(\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}).*?\r\nO\&M\s+#(.+?)\r\n%%(.+?)%%\r\nRETCODE = (\d+?)  (.+?)\r\n(.+?)---\s+END", RegexOptions.Singleline);
  260:  
  261:             if (match.Success)
  262:             {
  263:                 networkElement = match.Groups[1].Value;
  264:                 dateTime = DateTime.Parse(match.Groups[2].Value);
  265:                 identifier = match.Groups[3].Value;
  266:  
  267:                 commandString = match.Groups[4].Value;
  268:                 // remove the /*...*/ %%/*22*/LST MGW: EID="10.11.96.22:2944";%%
  269:                 commandString = Regex.Replace(commandString, @"/\*.*\*/", "");
  270:  
  271:                 returnCode = (Ia.Ftn.Cl.Models.Client.Huawei.SoftX.ResultCode)int.Parse(match.Groups[5].Value);
  272:                 returnCodeString = match.Groups[6].Value;
  273:  
  274:                 content = match.Groups[7].Value;
  275:  
  276:                 fieldNameExplanationToValueDictionary = new Dictionary<string, string>();
  277:                 fieldNameToValueDictionary = new Dictionary<string, string>();
  278:  
  279:                 if (!string.IsNullOrEmpty(content))
  280:                 {
  281:                     // remove () from (Number of results = 1)
  282:  
  283:                     content = Regex.Replace(content, @"\(Number of results = (\d+)\)", "Number of results = $1");
  284:  
  285:                     //content = content.Trim(); do not trim content or you will loose last entry
  286:  
  287:                     matchCollection = Regex.Matches(content, @"(.+?)\s+?=\s+?(.+)\r\n", RegexOptions.Multiline);
  288:  
  289:                     if (matchCollection.Count > 0)
  290:                     {
  291:                         foreach (Match m in matchCollection)
  292:                         {
  293:                             key = m.Groups[1].Value.Trim();
  294:                             value = m.Groups[2].Value.Trim();
  295:  
  296:                             if (!string.IsNullOrEmpty(key))
  297:                             {
  298:                                 fieldNameExplanationToValueDictionary[key] = value;
  299:                             }
  300:                         }
  301:                     }
  302:                 }
  303:  
  304:                 count = fieldNameExplanationToValueDictionary.ContainsKey("Number of results") ? int.Parse(fieldNameExplanationToValueDictionary["Number of results"]) : 0;
  305:  
  306:                 // convert field discriptions to field names, and enumerated values to actual values
  307:                 foreach (KeyValuePair<string, string> kvp in fieldNameExplanationToValueDictionary)
  308:                 {
  309:                     key = (from p in Ia.Ftn.Cl.Models.Business.Huawei.SoftX.ParameterFieldNameExplanationList where p.FieldExplanation == kvp.Key select p.FieldName).SingleOrDefault();
  310:  
  311:                     if (!string.IsNullOrEmpty(key))
  312:                     {
  313:                         /*
  314:                         if (key == "NUMTYPE") value = (from n in Ia.Ftn.Cl.Model.Business.Huawei.SoftX.NumTypeFieldIdExplanationList where n.FieldExplanation == kvp.Value select n.Id).SingleOrDefault().ToString();
  315:                         else if (key == "RNIDXTYPE") value = (from r in Ia.Ftn.Cl.Model.Business.Huawei.SoftX.RnidxTypeFieldIdExplanationList where r.FieldExplanation == kvp.Value select r.Id).SingleOrDefault().ToString();
  316:                         else if (key == "SERVATTR") value = "0";
  317:                         else*/
  318:                         value = kvp.Value;
  319:  
  320:                         fieldNameToValueDictionary[key] = value;
  321:                     }
  322:                 }
  323:  
  324:                 response.NetworkElement = networkElement;
  325:                 response.CommandString = commandString;
  326:                 response.Content = content;
  327:                 response.ReturnCode = returnCode;
  328:                 response.CodeExplanation = returnCodeString;
  329:                 response.QueryDictionary = fieldNameToValueDictionary;
  330:                 response.Count = count;
  331:             }
  332:             else response = null;
  333:  
  334:             return response;
  335:         }
  336:  
  337:         ////////////////////////////////////////////////////////////////////////////
  338:         ////////////////////////////////////////////////////////////////////////////   
  339:     }
  340:  
  341:     ////////////////////////////////////////////////////////////////////////////
  342:     ////////////////////////////////////////////////////////////////////////////   
  343: }