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