شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة ش.ش.و.

Integrated Applications Programming Company

Skip Navigation Links

Public general use code classes and xml files that we've compiled and used over the years:

Signaling Service Processing System (SPS) support class for Huawei's Next Generation Network (NGN) business model.

   1:  using System.Collections.Generic;
   2:  using System.Configuration;
   3:  using System.Data;
   4:  using System.Linq;
   5:   
   6:  namespace Ia.Ngn.Cl.Model.Business.Huawei
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// Signaling Service Processing System (SPS) support class for Huawei's Next Generation Network (NGN) business model.
  12:      /// </summary>
  13:   
  14:      /// <remarks> 
  15:      /// Copyright © 2018-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  16:      ///
  17:      /// 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
  18:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  19:      ///
  20:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  21:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  22:      /// 
  23:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  24:      /// 
  25:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  26:      /// </remarks> 
  27:      public partial class Sps
  28:      {
  29:          private static Queue<string> commandQueue = new Queue<string>();
  30:          private static Queue<ProvisioningWorkflow> synchronizationCommandQueue = new Queue<ProvisioningWorkflow>();
  31:   
  32:          /// <summary/>
  33:          public enum SpsOpcode { LstSeruattr, ModSeruattr }
  34:   
  35:          /// <summary/>
  36:          public enum Mode { NUM = 0, IMSINUM = 1 };
  37:   
  38:          /// <summary/>
  39:          public enum Servattr { OMNP = 0 };
  40:   
  41:          /// <summary/>
  42:          public enum NumType { TYPE0 = 0, TYPE1 = 1, TYPE2 = 2, TYPE3 = 3, TYPE4 = 4, TYPE5 = 5, TYPE8 = 8, TYPE9 = 9 };
  43:   
  44:          /// <summary/>
  45:          public class FieldIdNameExplanation
  46:          {
  47:              public int Id;
  48:              public string FieldName;
  49:              public string FieldExplanation;
  50:          }
  51:   
  52:          /// <summary/>
  53:          public static FieldIdNameExplanation[] NumTypeFieldIdExplanationList =
  54:             {
  55:              new FieldIdNameExplanation {Id = (int)NumType.TYPE0, FieldExplanation="In local network" },
  56:              new FieldIdNameExplanation {Id = (int)NumType.TYPE1, FieldExplanation="Moved out of local network" },
  57:              new FieldIdNameExplanation {Id = (int)NumType.TYPE2, FieldExplanation="Moved in from external network" },
  58:              new FieldIdNameExplanation {Id = (int)NumType.TYPE3, FieldExplanation="Moved to another non-local number" },
  59:              new FieldIdNameExplanation {Id = (int)NumType.TYPE4, FieldExplanation="Flexible number" },
  60:              new FieldIdNameExplanation {Id = (int)NumType.TYPE5, FieldExplanation="Moved from GSM to CDMA network" },
  61:              new FieldIdNameExplanation {Id = (int)NumType.TYPE8, FieldExplanation="Moved from CDMA to GSM network" },
  62:              new FieldIdNameExplanation {Id = (int)NumType.TYPE9, FieldExplanation="Local fixed network" }
  63:          };
  64:   
  65:          /// <summary/>
  66:          public enum RnidxType { HLR = 0, RN = 1, ALL = 2 };
  67:   
  68:          /// <summary/>
  69:          public static FieldIdNameExplanation[] RnidxTypeFieldIdExplanationList =
  70:             {
  71:              new FieldIdNameExplanation { Id = (int)RnidxType.HLR,FieldExplanation="HLR number index" },
  72:              new FieldIdNameExplanation { Id = (int)RnidxType.RN,FieldExplanation="Route number index" },
  73:              new FieldIdNameExplanation { Id = (int)RnidxType.ALL,FieldExplanation="HLR+RN" },
  74:          };
  75:   
  76:          /// <summary/>
  77:          public static FieldIdNameExplanation[] ParameterFieldNameExplanationList =
  78:             {
  79:              new FieldIdNameExplanation { FieldName = "USRNUM",FieldExplanation="MSISDN" },
  80:              new FieldIdNameExplanation { FieldName = "SERVATTR",FieldExplanation="Whether enable Related services" },
  81:              new FieldIdNameExplanation { FieldName = "IMSINUM",FieldExplanation="User IMSI number" },
  82:              new FieldIdNameExplanation { FieldName = "NUMTYPE",FieldExplanation="Number type" },
  83:              new FieldIdNameExplanation { FieldName = "RNIDXTYPE",FieldExplanation="Route index type" },
  84:              new FieldIdNameExplanation { FieldName = "HLRIDX",FieldExplanation="HLR address index" },
  85:              new FieldIdNameExplanation { FieldName = "RNIDX",FieldExplanation="NP route index" },
  86:              new FieldIdNameExplanation { FieldName = "RNIDX2",FieldExplanation="Routing Number Index" },
  87:              new FieldIdNameExplanation { FieldName = "RN",FieldExplanation="Routing number" },
  88:              new FieldIdNameExplanation { FieldName = "DESC",FieldExplanation="Description" }
  89:          };
  90:   
  91:          /// <summary/>
  92:          public class ProvisioningWorkflow
  93:          {
  94:              /// <summary/>
  95:              public string ReadCommand { get; set; }
  96:              /// <summary/>
  97:              public string UpdateCommand { get; set; }
  98:   
  99:              /// <summary/>
 100:              public ProvisioningWorkflow()
 101:              {
 102:   
 103:              }
 104:          }
 105:   
 106:          /// <summary/>
 107:          public static string Host { get { return ConfigurationManager.AppSettings["spsHuaweiServerHost"].ToString(); } }
 108:   
 109:          /// <summary/>
 110:          public static int Port { get { return int.Parse(ConfigurationManager.AppSettings["spsHuaweiServerPort"].ToString()); } }
 111:   
 112:          /// <summary/>
 113:          public static string LoginUser { get { return ConfigurationManager.AppSettings["spsHuaweiServerLoginUser"].ToString(); } }
 114:   
 115:          /// <summary/>
 116:          public static string LogoutUser { get { return ConfigurationManager.AppSettings["spsHuaweiServerLogoutUser"].ToString(); } }
 117:   
 118:          ////////////////////////////////////////////////////////////////////////////
 119:   
 120:          /// <summary>
 121:          /// Response class of U2000 TL1 NBI following the "10.3 Response Format Description standard" in iManager U2000 Unified Network Management System Guide.
 122:          /// </summary>
 123:          public class Response
 124:          {
 125:              /// <summary/>
 126:              public bool IsSuccess { get { return ReturnCode == Ia.Ngn.Cl.Model.Client.Huawei.Sps.ResultCode.OperationIsSuccessful; } }
 127:   
 128:              /// <summary/>
 129:              public Ia.Ngn.Cl.Model.Client.Huawei.Sps.ResultCode ReturnCode { get; set; }
 130:   
 131:              /// <summary/>
 132:              public string CodeExplanation { get; set; }
 133:   
 134:              /// <summary/>
 135:              public string CommandString { get; set; }
 136:   
 137:              /// <summary/>
 138:              public int Count { get; set; }
 139:   
 140:              /// <summary/>
 141:              public Dictionary<string, string> QueryDictionary { get; set; }
 142:   
 143:              /// <summary/>
 144:              public Response() { }
 145:          }
 146:   
 147:          ////////////////////////////////////////////////////////////////////////////
 148:   
 149:          /// <summary>
 150:          ///
 151:          /// </summary>
 152:          public Sps() { }
 153:   
 154:          ////////////////////////////////////////////////////////////////////////////
 155:   
 156:          /// <summary>
 157:          ///
 158:          /// </summary>
 159:          public static string KeepAliveShakeHandCommand
 160:          {
 161:              get
 162:              {
 163:                  return "SHK HND:;";
 164:              }
 165:          }
 166:   
 167:          ////////////////////////////////////////////////////////////////////////////
 168:   
 169:          /// <summary>
 170:          ///
 171:          /// </summary>
 172:          public static string ProperlySelectedSingleSpsCommandQueueCommand()
 173:          {
 174:              string command;
 175:              List<string> list;
 176:   
 177:              command = KeepAliveShakeHandCommand;
 178:   
 179:              if (commandQueue.Count == 0)
 180:              {
 181:                  list = SpsCommandsToRetrieveList();
 182:   
 183:                  commandQueue = new Queue<string>(list.Shuffle());
 184:              }
 185:   
 186:              if (commandQueue.Count > 0) command = commandQueue.Dequeue();
 187:   
 188:              return command;
 189:          }
 190:   
 191:          ////////////////////////////////////////////////////////////////////////////
 192:   
 193:          /// <summary>
 194:          ///
 195:          /// </summary>
 196:          public static ProvisioningWorkflow SynchronizeSpsServiceRnidxRouteToMatchGponServiceRouterVendorQueueCommand
 197:          {
 198:              get
 199:              {
 200:                  ProvisioningWorkflow provisioningWorkflow;
 201:                  List<ProvisioningWorkflow> list;
 202:   
 203:                  provisioningWorkflow = null;
 204:   
 205:                  if (synchronizationCommandQueue.Count == 0)
 206:                  {
 207:                      list = ModifyAndReadTwoCommandItemOfSpsServiceRnidxRouteToMatchGponServiceRouterVendorList();
 208:   
 209:                      synchronizationCommandQueue = new Queue<ProvisioningWorkflow>(list); // don't shuffle because a modify command is followed by a read .Shuffle());
 210:                  }
 211:   
 212:                  if (synchronizationCommandQueue.Count > 0) provisioningWorkflow = synchronizationCommandQueue.Dequeue();
 213:   
 214:                  return provisioningWorkflow;
 215:              }
 216:          }
 217:   
 218:          ////////////////////////////////////////////////////////////////////////////
 219:   
 220:          /// <summary>
 221:          ///
 222:          /// </summary>
 223:          public static List<ProvisioningWorkflow> ModifyAndReadTwoCommandItemOfSpsServiceRnidxRouteToMatchGponServiceRouterVendorList()
 224:          {
 225:              int rnidxRoute;
 226:              string service;
 227:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 228:              Ia.Ngn.Cl.Model.Business.Default.SwitchRoute pstnSwitchRoute, switchRouteToMigratedRouterVendor;
 229:              ProvisioningWorkflow provisioningWorkflow;
 230:              List<ProvisioningWorkflow> provisioningWorkflowList;
 231:   
 232:              provisioningWorkflowList = new List<ProvisioningWorkflow>();
 233:   
 234:              var dictionary = Ia.Ngn.Cl.Model.Data.Service.GponServiceToOntRouterVendorInAllowedToBeMigratedOltDictionary;
 235:   
 236:              var pstnServiceToSwitchRouteDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Seruattr.PstnServiceToSwitchRouteDictionary();
 237:   
 238:              // will exclude exempt numbers
 239:              var serviceExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceOfServiceExemptFromProvisionProcessingList();
 240:   
 241:              foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> kvp in dictionary)
 242:              {
 243:                  service = kvp.Key;
 244:                  vendor = kvp.Value;
 245:   
 246:                  if (pstnServiceToSwitchRouteDictionary.ContainsKey(service))
 247:                  {
 248:                      pstnSwitchRoute = pstnServiceToSwitchRouteDictionary[service];
 249:   
 250:                      if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) switchRouteToMigratedRouterVendor = Ia.Ngn.Cl.Model.Business.Default.SwitchRoute.NokiaIms;
 251:                      else if (vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei) switchRouteToMigratedRouterVendor = Ia.Ngn.Cl.Model.Business.Default.SwitchRoute.HuaweiIms;
 252:                      else switchRouteToMigratedRouterVendor = Ia.Ngn.Cl.Model.Business.Default.SwitchRoute.Unknown;
 253:   
 254:                      if (pstnSwitchRoute != switchRouteToMigratedRouterVendor && switchRouteToMigratedRouterVendor != Ia.Ngn.Cl.Model.Business.Default.SwitchRoute.Unknown)
 255:                      {
 256:                          if (!serviceExemptionList.Contains(service))
 257:                          {
 258:                              provisioningWorkflow = new ProvisioningWorkflow();
 259:   
 260:                              rnidxRoute = Ia.Ngn.Cl.Model.Business.Huawei.Seruattr.SwitchRouteToRnidxRoute(switchRouteToMigratedRouterVendor);
 261:   
 262:                              provisioningWorkflow.UpdateCommand = UpdateCommand(service, rnidxRoute);
 263:                              provisioningWorkflow.ReadCommand = ReadCommand(service);
 264:   
 265:                              provisioningWorkflowList.Add(provisioningWorkflow);
 266:                          }
 267:                      }
 268:                  }
 269:              }
 270:   
 271:              return provisioningWorkflowList;
 272:          }
 273:   
 274:          ////////////////////////////////////////////////////////////////////////////
 275:          ////////////////////////////////////////////////////////////////////////////
 276:   
 277:          /// <summary>
 278:          ///
 279:          /// </summary>
 280:          public static string ReadCommand(string service)
 281:          {
 282:              return FormatSpsLstCommand(SpsOpcode.LstSeruattr, service);
 283:          }
 284:   
 285:          ////////////////////////////////////////////////////////////////////////////
 286:   
 287:          /// <summary>
 288:          ///
 289:          /// </summary>
 290:          public static string UpdateCommand(string service, int rnidxRoute)
 291:          {
 292:              return FormatSpsModCommand(SpsOpcode.ModSeruattr, service, rnidxRoute);
 293:          }
 294:   
 295:          ////////////////////////////////////////////////////////////////////////////
 296:          ////////////////////////////////////////////////////////////////////////////
 297:   
 298:          /// <summary>
 299:          ///
 300:          /// </summary>
 301:          private static string FormatSpsLstCommand(SpsOpcode amsOpcode, string service)
 302:          {
 303:              string command;
 304:   
 305:              if (amsOpcode == SpsOpcode.LstSeruattr)
 306:              {
 307:                  command = @"LST SERUATTR:MODE=NUM,USRNUM=""" + service + @""";";
 308:              }
 309:              else command = string.Empty;
 310:   
 311:              return command;
 312:          }
 313:   
 314:          ////////////////////////////////////////////////////////////////////////////
 315:   
 316:          /// <summary>
 317:          ///
 318:          /// </summary>
 319:          private static string FormatSpsModCommand(SpsOpcode amsOpcode, string service, int rnidxRoute)
 320:          {
 321:              string command;
 322:   
 323:              if (amsOpcode == SpsOpcode.ModSeruattr)
 324:              {
 325:                  command = @"MOD SERUATTR:MODE=NUM,USRNUM=""" + service + @""",RNIDXTYPE=RN,RNIDX=" + rnidxRoute + ";";
 326:              }
 327:              else command = string.Empty;
 328:   
 329:              return command;
 330:          }
 331:   
 332:          ////////////////////////////////////////////////////////////////////////////
 333:   
 334:          /// <summary>
 335:          ///
 336:          /// </summary>
 337:          public static List<string> SpsCommandsToRetrieveList()
 338:          {
 339:              List<string> siteNameList;
 340:              HashSet<string> hashSet, hashSet2;
 341:   
 342:              hashSet = new HashSet<string>();
 343:   
 344:              siteNameList = (from o in Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltList select o.Odf.Router.Site.Name).Distinct().ToList();
 345:   
 346:              foreach (string siteName in siteNameList)
 347:              {
 348:                  hashSet2 = new HashSet<string>(SpsCommandsToRetrieveSeruattrForAllPossiblePstnServiceNumberWithinSiteList(siteName));
 349:   
 350:                  hashSet.UnionWith(hashSet2);
 351:              }
 352:   
 353:              return hashSet.OrderBy(u => u).ToList();
 354:          }
 355:   
 356:          ////////////////////////////////////////////////////////////////////////////
 357:   
 358:          /// <summary>
 359:          ///
 360:          /// </summary>
 361:          public static List<string> SpsCommandsToRetrieveSeruattrForAllPossiblePstnServiceNumberWithinSiteList(string siteName)
 362:          {
 363:              List<string> servicelist;
 364:              List<string> list;
 365:   
 366:              servicelist = Ia.Ngn.Cl.Model.Data.Service.AllPossiblePstnServiceNumbersWithinSite(siteName);
 367:   
 368:              list = new List<string>();
 369:   
 370:              foreach (string s in servicelist)
 371:              {
 372:                  list.Add(Ia.Ngn.Cl.Model.Business.Huawei.Sps.FormatSpsLstCommand(SpsOpcode.LstSeruattr, s));
 373:              }
 374:   
 375:              return list.ToList();
 376:          }
 377:   
 378:          ////////////////////////////////////////////////////////////////////////////    
 379:          ////////////////////////////////////////////////////////////////////////////    
 380:      }
 381:   
 382:      ////////////////////////////////////////////////////////////////////////////
 383:      ////////////////////////////////////////////////////////////////////////////   
 384:  }