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

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

Nokia's Siemens EWSD support class of Fixed Telecommunications Network (FTN) data model.

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