)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » SoftX (Ia.Ftn.Cl.Model.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.Model.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:     ///
   18:     /// 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
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     public class SoftX
   29:     {
   30:         ////////////////////////////////////////////////////////////////////////////
   31:  
   32:         /// <summary>
   33:         ///
   34:         /// </summary>
   35:         public static bool UpdateDatabaseWithSoftXCommandOutput(string rowData, ref Ia.Ftn.Cl.Model.Client.Huawei.SoftX softX, out Ia.Cl.Models.Result result)
   36:         {
   37:             bool b;
   38:             Ia.Ftn.Cl.Model.Business.Huawei.SoftX.Response response;
   39:  
   40:             b = false;
   41:             result = new Ia.Cl.Models.Result();
   42:  
   43:             response = Ia.Ftn.Cl.Model.Data.Huawei.SoftX.ParseResponse(rowData);
   44:  
   45:             if (response.ReturnCode == Ia.Ftn.Cl.Model.Client.Huawei.SoftX.ResultCode.OperationSucceeded)
   46:             {
   47:                 if (response.CommandString.Contains("LST MGW:"))
   48:                 {
   49:                     if (response.Count > 0)
   50:                     {
   51:                         b = Ia.Ftn.Cl.Model.Data.Huawei.Mgw.Update(response, out result);
   52:                     }
   53:                     else result.AddWarning(response.CodeExplanation);
   54:                 }
   55:                 else if (response.CommandString.Contains("LST ASBR:"))
   56:                 {
   57:                     if (response.Count > 0)
   58:                     {
   59:                         b = Ia.Ftn.Cl.Model.Data.Huawei.Asbr.Update(response, out result);
   60:                     }
   61:                     else result.AddWarning(response.CodeExplanation);
   62:                 }
   63:                 else if (response.CommandString.StartsWith("LST NEBYOMC:"))
   64:                 {
   65:                     result.AddSuccess(response.CodeExplanation);
   66:                 }
   67:                 else if (response.CommandString.StartsWith("REG NE:"))
   68:                 {
   69:                     result.AddSuccess(response.CodeExplanation);
   70:                 }
   71:                 else if (response.CommandString.StartsWith("UNREG NE:"))
   72:                 {
   73:                     result.AddSuccess(response.CodeExplanation);
   74:                 }
   75:                 else if (response.CommandString.StartsWith("ADD MGW:"))
   76:                 {
   77:                     result.AddSuccess(response.CodeExplanation);
   78:                 }
   79:                 /*
   80:                 else if (response.CommandString.StartsWith("RMV MGW:")) //?
   81:                 {
   82:                     result.AddSuccess(response.CodeExplanation);
   83:                 }
   84:                 */
   85:                 else if (response.CommandString.StartsWith("ADD ASBR:"))
   86:                 {
   87:                     result.AddSuccess(response.CodeExplanation);
   88:                 }
   89:                 else if (response.CommandString.StartsWith("RMV ASBR:"))
   90:                 {
   91:                     result.AddSuccess(response.CodeExplanation);
   92:                 }
   93:                 else if (response.CommandString.StartsWith("SHK HAND:"))
   94:                 {
   95:                     result.AddSuccess(response.CodeExplanation);
   96:                 }
   97:                 else if (response.CommandString.StartsWith("LGI:"))
   98:                 {
   99:                     softX.IsLoggedIn = true;
  100:  
  101:                     result.AddSuccess(response.CodeExplanation);
  102:                 }
  103:                 else if (response.CommandString.StartsWith("LGO:")) // never reached
  104:                 {
  105:                     softX.IsLoggedIn = false;
  106:  
  107:                     result.AddSuccess(response.CodeExplanation);
  108:                 }
  109:                 else
  110:                 {
  111:                     result.AddWarning("No designated opcode to process");
  112:  
  113:                     b = false;
  114:                 }
  115:             }
  116:             else if (response.ReturnCode == Ia.Ftn.Cl.Model.Client.Huawei.SoftX.ResultCode.TheUserDoesNotExist)
  117:             {
  118:                 if (response.CommandString.Contains("LST ASBR:"))
  119:                 {
  120:                     b = Ia.Ftn.Cl.Model.Data.Huawei.Asbr.Update(response, out result);
  121:                 }
  122:                 else if (response.CommandString.Contains("RMV ASBR:"))
  123:                 {
  124:                     result.AddSuccess(response.CodeExplanation);
  125:                 }
  126:                 else
  127:                 {
  128:                     result.AddWarning("No designated opcode to process");
  129:  
  130:                     b = false;
  131:                 }
  132:             }
  133:             else if (response.ReturnCode == Ia.Ftn.Cl.Model.Client.Huawei.SoftX.ResultCode.InvalidCommand)
  134:             {
  135:                 // just ignore for now
  136:  
  137:                 b = false;
  138:             }
  139:             else if (response.ReturnCode == Ia.Ftn.Cl.Model.Client.Huawei.SoftX.ResultCode.InsufficientAuthority)
  140:             {
  141:                 result.AddWarning(response.CodeExplanation);
  142:  
  143:                 b = false;
  144:             }
  145:             else
  146:             {
  147:                 result.AddWarning(response.CodeExplanation);
  148:  
  149:                 b = false;
  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.Model.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.Model.Client.Huawei.SoftX.ResultCode returnCode;
  169:             Ia.Ftn.Cl.Model.Business.Huawei.SoftX.Response response;
  170:             List<string> attributeList;
  171:             List<List<string>> valueListList;
  172:  
  173:             response = new Ia.Ftn.Cl.Model.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.Model.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.Model.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: }