)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Axe (Ia.Ftn.Cl.Model.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.Model.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.Model.Client.Ericsson.Axe axe, out Ia.Cl.Models.Result result)
   41:         {
   42:             bool b;
   43:             Ia.Ftn.Cl.Model.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.Model.Data.Ericsson.Axe.ParseResponse(content);
   52:  
   53:                 if (response.ReturnCode == Ia.Ftn.Cl.Model.Client.Ericsson.Axe.ResultCode.Successful)
   54:                 {
   55:                     if (!string.IsNullOrEmpty(response.CommandString))
   56:                     {
   57:                         if (response.CommandString.StartsWith("SUSCP:"))
   58:                         {
   59:                             Ia.Ftn.Cl.Model.Data.Ericsson.Axe.UpdateSubscriberAndServiceFromAxeResponse(response, out result);
   60:  
   61:                             b = result.IsSuccessful;
   62:                         }
   63:                         else if (response.CommandString.StartsWith("SUSCC:"))
   64:                         {
   65:                             result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
   66:                         }
   67:                         else if (response.CommandString.StartsWith("SULIE:"))
   68:                         {
   69:                             result.AddSuccess(response.DateTime.ToString("yyyy-MM-dd hh:mm:ss"));
   70:                         }
   71:                         else
   72:                         {
   73:                             result.AddError("No designated opcode to process");
   74:  
   75:                             b = false;
   76:                         }
   77:                     }
   78:                     else
   79:                     {
   80:                         result.AddSuccess(response.ReturnCode.ToString());
   81:                     }
   82:                 }
   83:                 else
   84:                 {
   85:                     result.AddError(response.ReturnCode.ToString());
   86:  
   87:                     b = false;
   88:                 }
   89:             }
   90:  
   91:             return b;
   92:         }
   93:  
   94:         ////////////////////////////////////////////////////////////////////////////
   95:  
   96:         /// <summary>
   97:         ///
   98:         /// </summary>
   99:         private static void UpdateSubscriberAndServiceFromAxeResponse(Ia.Ftn.Cl.Model.Business.Ericsson.Axe.Response response, out Ia.Cl.Models.Result result)
  100:         {
  101:             result = new Ia.Cl.Models.Result();
  102:  
  103:             Ia.Ftn.Cl.Model.Data.Ericsson.Subscriber.Update(response, out Ia.Cl.Models.Result subscriberResult);
  104:  
  105:             Ia.Ftn.Cl.Model.Data.Ericsson.Axe.UpdateService(response, out Ia.Cl.Models.Result serviceResult);
  106:  
  107:             result.AddSuccess("Subscriber: " + subscriberResult.Message + "Service: " + serviceResult.Message);
  108:         }
  109:  
  110:         ////////////////////////////////////////////////////////////////////////////
  111:  
  112:         /// <summary>
  113:         ///
  114:         /// </summary>
  115:         private static bool UpdateService(Ia.Ftn.Cl.Model.Business.Ericsson.Axe.Response response, out Ia.Cl.Models.Result result)
  116:         {
  117:             bool wasUpdated;
  118:             int /*querySnb,*/ readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
  119:             int serviceType;
  120:             string serviceId, service;
  121:             Ia.Ftn.Cl.Model.Service2 service2, newService;
  122:  
  123:             wasUpdated = false;
  124:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  125:             result = new Ia.Cl.Models.Result();
  126:  
  127:             service = response.Service.ToString();
  128:  
  129:             serviceType = Ia.Ftn.Cl.Model.Business.Service.ServiceType.PstnService;
  130:             serviceId = Ia.Ftn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
  131:  
  132:             readItemCount = 1; // response.Count;
  133:  
  134:             using (var db = new Ia.Ftn.Cl.Model.Db())
  135:             {
  136:                 if (response.IsProvisioned)
  137:                 {
  138:                     newService = new Ia.Ftn.Cl.Model.Service2();
  139:  
  140:                     newService.Id = serviceId;
  141:                     newService.AreaCode = Ia.Ftn.Cl.Model.Business.Service.CountryCode;
  142:                     newService.Service = service;
  143:                     newService.ServiceType = serviceType;
  144:  
  145:                     newService.CallerId = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallerId);
  146:                     newService.AbbriviatedCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling);
  147:                     newService.CallForwarding = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallForwarding);
  148:                     newService.CallWaiting = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.CallWaiting);
  149:                     newService.ConferenceCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall);
  150:                     newService.InternationalCalling = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling);
  151:                     newService.InternationalCallingUserControlled = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled);
  152:  
  153:                     newService.AlarmCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall);
  154:                     newService.WakeupCall = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.WakeupCall);
  155:  
  156:                     newService.ServiceSuspension = response.ServiceSupplementaryService.SupplementaryServiceList.Contains(Ia.Ftn.Cl.Model.Business.Service.SupplementaryService.ServiceSuspension);
  157:                     //newService.CallBarring = subParty.ServiceSuspension;
  158:  
  159:                     newService.Pin = int.TryParse(response.ServiceSupplementaryService.Pin, out int i) ? i : 0;
  160:  
  161:                     //if (nddOnt != null) newService.Access = (from a in db.Accesses where a.Id == nddOnt.Access.Id select a).SingleOrDefault();
  162:                     //else
  163:                     newService.Access = null;
  164:  
  165:                     service2 = (from s in db.Service2
  166:                                 where s.ServiceType == Ia.Ftn.Cl.Model.Business.Service.ServiceType.PstnService && s.Id == newService.Id
  167:                                 select s).SingleOrDefault();
  168:  
  169:                     existingItemCount = (service2 != null) ? 1 : 0;
  170:  
  171:                     if (service2 == null)
  172:                     {
  173:                         newService.Created = newService.Updated = DateTime.UtcNow.AddHours(3);
  174:                         db.Service2.Add(newService);
  175:  
  176:                         insertedItemCount++;
  177:                     }
  178:                     else
  179:                     {
  180:                         if (service2.Update(newService))
  181:                         {
  182:                             db.Service2.Attach(service2);
  183:                             db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  184:  
  185:                             updatedItemCount++;
  186:                         }
  187:                     }
  188:                 }
  189:                 else
  190:                 {
  191:                     service2 = (from s in db.Service2
  192:                                 where s.ServiceType == Ia.Ftn.Cl.Model.Business.Service.ServiceType.PstnService && s.Id == serviceId
  193:                                 select s).SingleOrDefault();
  194:  
  195:                     if (service2 != null)
  196:                     {
  197:                         db.Service2.Remove(service2);
  198:  
  199:                         deletedItemCount++;
  200:                     }
  201:                 }
  202:  
  203:                 db.SaveChanges();
  204:             }
  205:  
  206:             if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) wasUpdated = true;
  207:             else wasUpdated = false;
  208:  
  209:             result.AddSuccess("(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  210:  
  211:             return wasUpdated;
  212:         }
  213:  
  214:         ////////////////////////////////////////////////////////////////////////////
  215:  
  216:         /// <summary>
  217:         /// Parse response of Ericsson AXE
  218:         /// </summary>
  219:         public static Ia.Ftn.Cl.Model.Business.Ericsson.Axe.Response ParseResponse(string content)
  220:         {
  221:             Ia.Ftn.Cl.Model.Business.Ericsson.Axe.Response response;
  222:  
  223:             response = new Ia.Ftn.Cl.Model.Business.Ericsson.Axe.Response(content);
  224:  
  225:             return response;
  226:         }
  227:  
  228:         ////////////////////////////////////////////////////////////////////////////
  229:         ////////////////////////////////////////////////////////////////////////////
  230:     }
  231:  
  232:     ////////////////////////////////////////////////////////////////////////////
  233:     ////////////////////////////////////////////////////////////////////////////    
  234: }
  235: