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