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

Integrated Applications Programming Company

Skip Navigation Links

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

Ericsson AXE support class of Next Generation Network'a (NGN's) data model.

   1:  using System;
   2:  using System.Data;
   3:  using System.Diagnostics;
   4:  using System.Linq;
   5:  using System.Text.RegularExpressions;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data.Ericsson
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Ericsson AXE support class of Next Generation Network'a (NGN's) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 Axe
  29:      {
  30:          ////////////////////////////////////////////////////////////////////////////
  31:   
  32:          /// <summary>
  33:          ///
  34:          /// </summary>
  35:          public Axe() { }
  36:   
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public static bool UpdateDatabaseWithAxeCommandOutput(string fileContent, ref Ia.Ngn.Cl.Model.Client.Ericsson.Axe axe, out Ia.Cl.Model.Result result)
  43:          {
  44:              bool b;
  45:              Ia.Ngn.Cl.Model.Business.Ericsson.Axe.Response response;
  46:   
  47:              b = false;
  48:              result = new Ia.Cl.Model.Result();
  49:   
  50:              Debug.WriteLine(" ");
  51:              Debug.WriteLine("============================================");
  52:   
  53:              if (fileContent.StartsWith("WO   "))
  54:              {
  55:                  b = true;
  56:              }
  57:              else
  58:              {
  59:                  response = Ia.Ngn.Cl.Model.Data.Ericsson.Axe.ParseResponse(fileContent);
  60:   
  61:                  if (response.ReturnCode == Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.OperationIsSuccessful
  62:                      || response.ReturnCode == Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.NotAcceptedUnreasonableValue
  63:                      || response.ReturnCode == Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.NotConnected
  64:                      )
  65:                  {
  66:                      if (response.CommandString.StartsWith("SUSCP:"))
  67:                      {
  68:                          b = Ia.Ngn.Cl.Model.Data.Ericsson.Axe.UpdateServiceFromAxeResponse(response, out result);
  69:                      }
  70:                      /*
  71:                      else if (response.CommandString.StartsWith("STSUP:"))
  72:                      {
  73:                          result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
  74:                      }
  75:                      else if (response.CommandString.StartsWith("SULIE:"))
  76:                      {
  77:                          result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
  78:                      }
  79:                      else if (response.CommandString.StartsWith("ALLIP;"))
  80:                      {
  81:                          result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
  82:                      }
  83:                      */
  84:                      else
  85:                      {
  86:                          result.AddError("No designated opcode to process");
  87:   
  88:                          b = false;
  89:                      }
  90:                  }
  91:                  else
  92:                  {
  93:                      result.AddError("Operation failed. ");
  94:   
  95:                      b = false;
  96:                  }
  97:              }
  98:   
  99:              Debug.WriteLine("UpdateDatabaseWithAxeCommandOutput(): " + result.Message);
 100:   
 101:              Debug.WriteLine("============================================");
 102:              Debug.WriteLine(" ");
 103:   
 104:              return b;
 105:          }
 106:   
 107:          ////////////////////////////////////////////////////////////////////////////
 108:   
 109:          /// <summary>
 110:          ///
 111:          /// </summary>
 112:          public static bool UpdateServiceFromAxeResponse(Ia.Ngn.Cl.Model.Business.Ericsson.Axe.Response response, out Ia.Cl.Model.Result result)
 113:          {
 114:              bool insert, update, delete;
 115:              int serviceType;
 116:              string serviceId, service;
 117:              Ia.Ngn.Cl.Model.Service2 service2, newService;
 118:   
 119:              insert = update = delete = false;
 120:              result = new Ia.Cl.Model.Result();
 121:   
 122:              service = response.Service.ToString();
 123:   
 124:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService;
 125:              serviceId = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
 126:   
 127:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 128:              {
 129:                  if (response.IsProvisioned)
 130:                  {
 131:                      newService = new Ia.Ngn.Cl.Model.Service2();
 132:   
 133:                      newService.Id = serviceId;
 134:                      newService.AreaCode = Ia.Ngn.Cl.Model.Business.Service.CountryCode;
 135:                      newService.Service = service;
 136:                      newService.ServiceType = serviceType;
 137:   
 138:                      newService.CallerId = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallerId);
 139:                      newService.AbbriviatedCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling);
 140:                      newService.CallForwarding = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallForwarding);
 141:                      newService.CallWaiting = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallWaiting);
 142:                      newService.ConferenceCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall);
 143:                      newService.InternationalCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling);
 144:                      newService.InternationalCallingUserControlled = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled);
 145:   
 146:                      newService.AlarmCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall);
 147:                      newService.WakeupCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall);
 148:   
 149:                      newService.ServiceSuspension = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.ServiceSuspension);
 150:                      //newService.CallBarring = subParty.ServiceSuspension;
 151:   
 152:                      newService.Pin = int.TryParse(response.ServiceSupplementaryService.Pin, out int i) ? i : 0;
 153:   
 154:                      //if (nddOnt != null) newService.Access = (from a in db.Accesses where a.Id == nddOnt.Access.Id select a).SingleOrDefault();
 155:                      //else
 156:                      newService.Access = null;
 157:   
 158:                      service2 = (from s in db.Service2s
 159:                                  where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Id == newService.Id
 160:                                  select s).SingleOrDefault();
 161:   
 162:                      if (service2 == null)
 163:                      {
 164:                          newService.Created = newService.Updated = DateTime.UtcNow.AddHours(3);
 165:                          db.Service2s.Add(newService);
 166:   
 167:                          insert = true;
 168:                      }
 169:                      else
 170:                      {
 171:                          if (service2.Update(newService))
 172:                          {
 173:                              db.Service2s.Attach(service2);
 174:                              db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
 175:   
 176:                              update = true;
 177:                          }
 178:                          else update = false;
 179:                      }
 180:                  }
 181:                  else
 182:                  {
 183:                      service2 = (from s in db.Service2s
 184:                                  where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Id == serviceId
 185:                                  select s).SingleOrDefault();
 186:   
 187:                      if (service2 != null)
 188:                      {
 189:                          db.Service2s.Remove(service2);
 190:   
 191:                          delete = true;
 192:                      }
 193:                  }
 194:   
 195:                  db.SaveChanges();
 196:              }
 197:   
 198:              result.AddSuccess(service + ": state: " + Ia.Ngn.Cl.Model.Ui.Text.ExpressionOfInsertOrUpdateOrDelete(insert, update, delete));
 199:   
 200:              return insert || update || delete;
 201:          }
 202:   
 203:          ////////////////////////////////////////////////////////////////////////////
 204:   
 205:          /// <summary>
 206:          /// Parse response of Ericsson AXE
 207:          /// </summary>
 208:          private static Ia.Ngn.Cl.Model.Business.Ericsson.Axe.Response ParseResponse(string fileContent)
 209:          {
 210:              string service;
 211:              Match match;
 212:              Ia.Ngn.Cl.Model.Business.Service.ServiceSupplementaryService serviceSupplementaryService;
 213:              Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode returnCode;
 214:              Ia.Ngn.Cl.Model.Business.Ericsson.Axe.Response response;
 215:   
 216:              Debug.WriteLine(" ");
 217:              Debug.WriteLine("============================================");
 218:   
 219:              response = new Ia.Ngn.Cl.Model.Business.Ericsson.Axe.Response();
 220:   
 221:              if (fileContent.StartsWith("SUBSCRIBER DATA") && fileContent.EndsWith("END"))
 222:              {
 223:                  /*
 224:  
 225:      SUBSCRIBER DATA
 226:      SNB        DEV            DETY    SUT SCL         MIS             COS
 227:      25382234   LIMA-634                   CCB-1
 228:  
 229:      END
 230:  
 231:  
 232:      SUBSCRIBER DATA
 233:      SNB        DEV            DETY    SUT SCL         MIS             COS
 234:      25387526                          NC
 235:      END
 236:  
 237:  
 238:      SUBSCRIBER DATA
 239:      SNB        DEV            DETY    SUT SCL         MIS             COS
 240:      25381111                          PB  IPT-2
 241:                                            ANT-2
 242:                                            CBA-2
 243:  
 244:      END
 245:                   */
 246:                  match = Regex.Match(fileContent, @"\r\n(\d{8})\s+");
 247:   
 248:                  if (match.Success)
 249:                  {
 250:                      service = match.Groups[1].Value;
 251:   
 252:                      response.CommandString = @"SUSCP:SNB=" + service + ";";
 253:   
 254:                      response.Service = int.Parse(service);
 255:   
 256:                      if (fileContent.Contains("            NC"))
 257:                      {
 258:                          response.IsProvisioned = false;
 259:   
 260:                          returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.NotConnected;
 261:                      }
 262:                      else
 263:                      {
 264:                          serviceSupplementaryService = Ia.Ngn.Cl.Model.Business.Ericsson.Axe.ServiceSupplementaryServiceStateFromServiceNetManagerOutputString(fileContent);
 265:   
 266:                          response.IsProvisioned = true;
 267:                          response.ServiceSupplementaryService = serviceSupplementaryService;
 268:   
 269:                          returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.OperationIsSuccessful;
 270:                      }
 271:                  }
 272:                  else
 273:                  {
 274:                      returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.OperationFailed;
 275:                  }
 276:              }
 277:              else if (fileContent.Contains("NOT ACCEPTED") && fileContent.Contains("UNREASONABLE VALUE"))
 278:              {
 279:                  /*
 280:  <SUSCP:SNB=25612222;
 281:  NOT ACCEPTED
 282:  UNREASONABLE VALUE
 283:  (0)SNB=25612222
 284:                   */
 285:                  match = Regex.Match(fileContent, @"SNB=(\d{8})");
 286:   
 287:                  if (match.Success)
 288:                  {
 289:                      service = match.Groups[1].Value;
 290:   
 291:                      response.CommandString = @"SUSCP:SNB=" + service + ";";
 292:   
 293:                      response.Service = int.Parse(service);
 294:                      response.IsProvisioned = false;
 295:   
 296:                      returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.NotAcceptedUnreasonableValue;
 297:                  }
 298:                  else
 299:                  {
 300:                      returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.OperationFailed;
 301:                  }
 302:              }
 303:              else
 304:              {
 305:                  returnCode = Ia.Ngn.Cl.Model.Client.Ericsson.Axe.ResultCode.OperationFailed;
 306:              }
 307:   
 308:              response.ReturnCode = returnCode;
 309:   
 310:              Debug.WriteLine("ParseResponse(): response.Service: " + response.Service);
 311:              Debug.WriteLine("============================================");
 312:              Debug.WriteLine(" ");
 313:   
 314:              return response;
 315:          }
 316:   
 317:          ////////////////////////////////////////////////////////////////////////////
 318:          ////////////////////////////////////////////////////////////////////////////
 319:      }
 320:   
 321:      ////////////////////////////////////////////////////////////////////////////
 322:      ////////////////////////////////////////////////////////////////////////////    
 323:  }
 324: