)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Axe (Ia.Ftn.Cl.Models.Data.Ericsson)

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

Ericsson AXE support class of Fixed Telecommunications Network (FTN) data model.

    1: using System;
    2: using System.Data;
    3: using System.Linq;
    4:  
    5: namespace Ia.Ftn.Cl.Models.Data.Ericsson
    6: {
    7:     ////////////////////////////////////////////////////////////////////////////
    8:  
    9:     /// <summary publish="true">
   10:     /// Ericsson AXE support class of Fixed Telecommunications Network (FTN) data model.
   11:     /// </summary>
   12:     /// 
   13:     /// <remarks> 
   14:     /// Copyright © 2017-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   15:     ///
   16:     /// 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
   17:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   18:     ///
   19:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   20:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   21:     /// 
   22:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   23:     /// 
   24:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   25:     /// </remarks> 
   26:     public class Axe
   27:     {
   28:         ////////////////////////////////////////////////////////////////////////////
   29:  
   30:         /// <summary>
   31:         ///
   32:         /// </summary>
   33:         public Axe() { }
   34:  
   35:         ////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public static bool UpdateDatabaseWithAxeCommandOutput(string content, ref Ia.Ftn.Cl.Models.Client.Ericsson.Axe axe, out Ia.Cl.Models.Result result)
   41:         {
   42:             bool b;
   43:             Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response response;
   44:  
   45:             b = false;
   46:             result = new Ia.Cl.Models.Result();
   47:  
   48:             if (content.StartsWith("WO   ")) b = true; // WO      MSF KW64/CN-G2/ACG210   NVT-929   TIME 200103 2115  PAGE    1
   49:             else
   50:             {
   51:                 response = Ia.Ftn.Cl.Models.Data.Ericsson.Axe.ParseResponse(content);
   52:  
   53:                 if (response != null)
   54:                 {
   55:                     if (response.ReturnCode == Ia.Ftn.Cl.Models.Client.Ericsson.Axe.ResultCode.Successful)
   56:                     {
   57:                         if (!string.IsNullOrEmpty(response.CommandString))
   58:                         {
   59:                             if (response.CommandString.StartsWith("SUSCP:"))
   60:                             {
   61:                                 Ia.Ftn.Cl.Models.Data.Ericsson.Axe.UpdateSubscriberAndServiceFromAxeResponse(response, out result);
   62:  
   63:                                 b = result.IsSuccessful;
   64:                             }
   65:                             else if (response.CommandString.StartsWith("SUSCC:"))
   66:                             {
   67:                                 result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
   68:                             }
   69:                             else if (response.CommandString.StartsWith("SULIE:"))
   70:                             {
   71:                                 result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
   72:                             }
   73:                             else
   74:                             {
   75:                                 result.AddError("No designated opcode to process");
   76:  
   77:                                 b = false;
   78:                             }
   79:                         }
   80:                         else
   81:                         {
   82:                             result.AddSuccess(response.ReturnCode.ToString());
   83:                         }
   84:                     }
   85:                     else
   86:                     {
   87:                         result.AddError(response.ReturnCode.ToString());
   88:  
   89:                         b = false;
   90:                     }
   91:                 }
   92:                 else
   93:                 {
   94:                     result.AddError("Response is null");
   95:  
   96:                     b = false;
   97:                 }
   98:             }
   99:  
  100:             return b;
  101:         }
  102:  
  103:         ////////////////////////////////////////////////////////////////////////////
  104:  
  105:         /// <summary>
  106:         ///
  107:         /// </summary>
  108:         private static void UpdateSubscriberAndServiceFromAxeResponse(Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response response, out Ia.Cl.Models.Result result)
  109:         {
  110:             result = new Ia.Cl.Models.Result();
  111:  
  112:             Ia.Ftn.Cl.Models.Data.Ericsson.Subscriber.Update(response, out Ia.Cl.Models.Result subscriberResult);
  113:  
  114:             Ia.Ftn.Cl.Models.Data.Ericsson.Axe.UpdateService(response, out Ia.Cl.Models.Result serviceResult);
  115:  
  116:             result.AddSuccess("Subscriber: " + subscriberResult.Message + "Service: " + serviceResult.Message);
  117:         }
  118:  
  119:         ////////////////////////////////////////////////////////////////////////////
  120:  
  121:         /// <summary>
  122:         ///
  123:         /// </summary>
  124:         private static bool UpdateService(Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response response, out Ia.Cl.Models.Result result)
  125:         {
  126:             bool wasUpdated;
  127:             int /*querySnb,*/ readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
  128:             int serviceType;
  129:             string serviceId, service;
  130:             Ia.Ftn.Cl.Models.Service2 service2, newService;
  131:  
  132:             wasUpdated = false;
  133:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  134:             result = new Ia.Cl.Models.Result();
  135:  
  136:             service = response.Service.ToString();
  137:  
  138:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.PstnService;
  139:             serviceId = Ia.Ftn.Cl.Models.Business.Service2.ServiceId(service, serviceType);
  140:  
  141:             readItemCount = 1; // response.Count;
  142:  
  143:             using (var db = new Ia.Ftn.Cl.Db())
  144:             {
  145:                 if (response.IsProvisioned)
  146:                 {
  147:                     newService = new Ia.Ftn.Cl.Models.Service2();
  148:  
  149:                     newService.Id = serviceId;
  150:                     newService.AreaCode = Ia.Ftn.Cl.Models.Business.Service.CountryCode;
  151:                     newService.Service = service;
  152:                     newService.ServiceType = serviceType;
  153:  
  154:                     newService.CallerId = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.CallerId);
  155:                     newService.AbbriviatedCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.AbbriviatedCalling);
  156:                     newService.CallForwarding = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.CallForwarding);
  157:                     newService.CallWaiting = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.CallWaiting);
  158:                     newService.ConferenceCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.ConferenceCall);
  159:                     newService.InternationalCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.InternationalCalling);
  160:                     newService.InternationalCallingUserControlled = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.InternationalCallingUserControlled);
  161:  
  162:                     newService.AlarmCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.WakeupCall);
  163:                     newService.WakeupCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.WakeupCall);
  164:  
  165:                     newService.ServiceSuspension = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService.ServiceSuspension);
  166:                     //newService.CallBarring = subParty.ServiceSuspension;
  167:  
  168:                     newService.Pin = int.TryParse(response.ServiceSupplementaryService.Pin, out int i) ? i : 0;
  169:  
  170:                     //if (nddOnt != null) newService.Access = (from a in db.Accesses where a.Id == nddOnt.Access.Id select a).SingleOrDefault();
  171:                     //else
  172:                     newService.Access = null;
  173:  
  174:                     service2 = (from s in db.Service2
  175:                                 where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.PstnService && s.Id == newService.Id
  176:                                 select s).SingleOrDefault();
  177:  
  178:                     existingItemCount = (service2 != null) ? 1 : 0;
  179:  
  180:                     if (service2 == null)
  181:                     {
  182:                         newService.Created = newService.Updated = DateTime.UtcNow.AddHours(3);
  183:                         db.Service2.Add(newService);
  184:  
  185:                         insertedItemCount++;
  186:                     }
  187:                     else
  188:                     {
  189:                         if (service2.Update(newService))
  190:                         {
  191:                             db.Service2.Attach(service2);
  192:                             db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  193:  
  194:                             updatedItemCount++;
  195:                         }
  196:                     }
  197:                 }
  198:                 else
  199:                 {
  200:                     service2 = (from s in db.Service2
  201:                                 where s.ServiceType == Ia.Ftn.Cl.Models.Business.Service.ServiceType.PstnService && s.Id == serviceId
  202:                                 select s).SingleOrDefault();
  203:  
  204:                     if (service2 != null)
  205:                     {
  206:                         db.Service2.Remove(service2);
  207:  
  208:                         deletedItemCount++;
  209:                     }
  210:                 }
  211:  
  212:                 db.SaveChanges();
  213:             }
  214:  
  215:             if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) wasUpdated = true;
  216:             else wasUpdated = false;
  217:  
  218:             result.AddSuccess("(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  219:  
  220:             return wasUpdated;
  221:         }
  222:  
  223:         ////////////////////////////////////////////////////////////////////////////
  224:  
  225:         /// <summary>
  226:         /// Parse response of Ericsson AXE
  227:         /// </summary>
  228:         public static Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response ParseResponse(string content)
  229:         {
  230:             Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response response;
  231:  
  232:             response = new Ia.Ftn.Cl.Models.Business.Ericsson.Axe.Response(content);
  233:  
  234:             return response;
  235:         }
  236:  
  237:         ////////////////////////////////////////////////////////////////////////////
  238:         ////////////////////////////////////////////////////////////////////////////
  239:     }
  240:  
  241:     ////////////////////////////////////////////////////////////////////////////
  242:     ////////////////////////////////////////////////////////////////////////////    
  243: }
  244: