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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » ServiceRequestService

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

Service Request Service support class of Next Generation Network'a (NGN's) business model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Web;
   6:  using System.ComponentModel.DataAnnotations;
   7:  using System.ComponentModel.DataAnnotations.Schema;
   8:  using System.Data;
   9:  using System.Text;
  10:   
  11:  namespace Ia.Ngn.Cl.Model.Business
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// Service Request Service support class of Next Generation Network'a (NGN's) business model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  21:      ///
  22:      /// 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
  23:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  24:      ///
  25:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  26:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  27:      /// 
  28:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  29:      /// 
  30:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  31:      /// </remarks> 
  32:      public partial class ServiceRequestService
  33:      {
  34:          private static StringBuilder log = new StringBuilder();
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public enum ServiceRequestServiceType { Create = 1, Read, Update, Delete };
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////
  44:   
  45:          /// <summary>
  46:          ///
  47:          /// </summary>
  48:          public ServiceRequestService() { }
  49:   
  50:          ////////////////////////////////////////////////////////////////////////////
  51:   
  52:          /// <summary>
  53:          ///
  54:          /// </summary>
  55:          public static string ServiceIdToService(string service)
  56:          {
  57:              return Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(service);
  58:          }
  59:   
  60:          ////////////////////////////////////////////////////////////////////////////
  61:   
  62:          /// <summary>
  63:          ///
  64:          /// </summary>
  65:          public static string ServiceRequestServiceId(string service, int serviceType)
  66:          {
  67:              // below:
  68:              string id;
  69:   
  70:              id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
  71:   
  72:              return id;
  73:          }
  74:   
  75:          ////////////////////////////////////////////////////////////////////////////
  76:   
  77:          /// <summary>
  78:          ///
  79:          /// </summary>
  80:          public static void UpdateServiceSuspension(string service, bool serviceSuspensionState, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact, out Ia.Cl.Model.Result result)
  81:          {
  82:              string numberString;
  83:   
  84:              result = new Ia.Cl.Model.Result();
  85:   
  86:              numberString = service; // HttpServerUtility.HtmlEncode(service);
  87:              numberString = numberString.Trim();
  88:   
  89:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanReadUpdateServiceSuspension(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Update, staffContact))
  90:              {
  91:                  if (numberString.Length > 0 && int.TryParse(numberString, out int number))
  92:                  {
  93:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
  94:                      {
  95:                          Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(number.ToString(), serviceSuspensionState, staffContact.UserId, out result);
  96:   
  97:                          if (result.IsSuccessful)
  98:                          {
  99:                              result.AddSuccess("Service record '" + numberString + "' has its service suspension value updated to '" + serviceSuspensionState.ToString().ToLower() + "'");
 100:                          }
 101:                          else
 102:                          {
 103:                          }
 104:                      }
 105:                      else
 106:                      {
 107:                          result.AddError(@"The number '" + number + @"' does not belong to the network (الرقم لا ينتمي للشبكة). ");
 108:                      }
 109:                  }
 110:                  else
 111:                  {
 112:                      result.AddError("Number format is incorrect or nothing was entered (الرقم غير مفهوم أو مفقود). ");
 113:                  }
 114:              }
 115:              else
 116:              {
 117:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
 118:              }
 119:          }
 120:   
 121:          ////////////////////////////////////////////////////////////////////////////
 122:   
 123:          /// <summary>
 124:          ///
 125:          /// </summary>
 126:          public static void ReadServiceSuspension(string service, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact, string key, out bool isSuspended, out DateTime serviceLastUpdated, out Ia.Cl.Model.Result result)
 127:          {
 128:              string numberString;
 129:              DateTime now;
 130:              Ia.Ngn.Cl.Model.Service2 service2;
 131:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
 132:   
 133:              result = new Ia.Cl.Model.Result();
 134:   
 135:              isSuspended = false;
 136:              serviceLastUpdated = DateTime.MinValue;
 137:   
 138:              numberString = service; // Server.HtmlDecode(serviceTextBox.Text);
 139:              numberString = numberString.Trim();
 140:   
 141:              now = DateTime.UtcNow.AddHours(3);
 142:   
 143:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanReadUpdateServiceSuspension(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staffContact))
 144:              {
 145:                  if (numberString.Length > 0 && int.TryParse(numberString, out int number))
 146:                  {
 147:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
 148:                      {
 149:                          serviceRequestService = Ia.Ngn.Cl.Model.Data.ServiceRequestService.Read(number);
 150:                          service2 = Ia.Ngn.Cl.Model.Data.Service2.Read(number);
 151:   
 152:                          if (serviceRequestService != null && service2 != null)
 153:                          {
 154:                              result.AddSuccess("Pending service suspension value is '" + serviceRequestService.ServiceSuspension.ToString().ToLower() + "' (updated: " + serviceRequestService.Updated + "). System service suspension value is '" + service2.ServiceSuspension.ToString().ToLower() + "' (updated: " + service2.Updated + "). ");
 155:   
 156:                              isSuspended = service2.ServiceSuspension;
 157:                              serviceLastUpdated = service2.Updated;
 158:                          }
 159:                          else
 160:                          {
 161:                              result.AddError("Service and/or service request service record for '" + numberString + "' does not exist. ");
 162:                          }
 163:                      }
 164:                      else
 165:                      {
 166:                          result.AddError(@"The number '" + number + @"' does not belong to the network (الرقم لا ينتمي للشبكة). ");
 167:                      }
 168:                  }
 169:                  else
 170:                  {
 171:                      result.AddError("Number format is incorrect or nothing was entered (الرقم غير مفهوم أو مفقود). ");
 172:                  }
 173:              }
 174:              else
 175:              {
 176:                  result.AddError("You are not authorized to read this value (لست مخولاً بقراءة هذه القيمة). ");
 177:              }
 178:          }
 179:   
 180:          ////////////////////////////////////////////////////////////////////////////
 181:   
 182:          /// <summary>
 183:          /// Update service-request-service table with data from service requests
 184:          /// </summary>
 185:          public static void UpdateForServiceRequestIdRange(Tuple<int, int> startEndRange, out string result)
 186:          {
 187:              bool recordExisted;
 188:              int serviceType;
 189:              string service, serviceRequestServiceId, r0, r1, r2;
 190:              DateTime lastRequestDateTime;
 191:              Hashtable serviceNumberChangeHashtable;
 192:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
 193:              //Ia.Ngn.Cl.Model.ServiceInitialState serviceInitialState;
 194:              List<int> numberList, changedNumberList, changedFromNumberList;
 195:              List<string> serviceList;
 196:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 197:              List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
 198:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 199:              List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList;
 200:              //List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList;
 201:   
 202:              recordExisted = false;
 203:              r0 = r1 = r2 = "";
 204:              serviceNumberChangeHashtable = new Hashtable(10);
 205:              // above: serviceNumberChangeHashtable will contain serviceRequestServiceId as keys and the new number as value
 206:   
 207:              lastRequestDateTime = DateTime.MinValue;
 208:   
 209:              // 1. Read all SRs for this range
 210:              serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.ReadListWithinIdRange(startEndRange.Item1, startEndRange.Item2);
 211:   
 212:              // 2. Collect numbers in int format into int list
 213:              numberList = serviceRequestList.DistinctNumberList();
 214:              //numberList = new List<int>();
 215:              //numberList.Add(24848450);
 216:   
 217:              // 3. Return a list of service requests that have numbers (including changed-to numbers) within the passed list
 218:              serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List(numberList);
 219:              numberList.AddRange(Ia.Ngn.Cl.Model.Data.ServiceRequest.NumberListFromServiceRequestList(serviceRequestList));
 220:   
 221:              // 4. Return a list of service request types for service requests that have numbers (including changed-to numbers) within the passed number list
 222:              serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.RelatedToServiceRequestNumberList(numberList);
 223:              //numberList.AddRange(changedNumberList);
 224:   
 225:              /*
 226:              // 5 Read all possible changed, and changed-from, numbers from all SRT and add them to service list
 227:              changedNumberList = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ChangedNumberList(serviceRequestTypeList);
 228:              changedFromNumberList = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ChangedFromNumberList(serviceRequestTypeList);
 229:  
 230:              if (changedNumberList.Count > 0 || changedFromNumberList.Count > 0)
 231:              {
 232:                  numberList.AddRange(changedNumberList);
 233:                  numberList.AddRange(changedFromNumberList);
 234:                  numberList = numberList.Distinct().ToList();
 235:  
 236:                  // 6 Read all SRs related to collected numbers
 237:                  serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List(numberList);
 238:  
 239:                  // 7. Read all SRTs related to collected numbers
 240:                  serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.RelatedToServiceRequestNumberList(numberList);
 241:              }
 242:              */
 243:   
 244:              // 8. Collect numbers in string format into int list (add changed number list)
 245:              serviceList = (from n in numberList select n.ToString()).ToList<string>();
 246:   
 247:              // 9. Read initial states of a service for all numbers in the list
 248:              //serviceInitialStateList = Ia.Ngn.Cl.Model.Data.ServiceInitialState.ReadList(numberList);
 249:   
 250:              // 10. Initialize SRS empty list
 251:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>(serviceRequestList.Count);
 252:   
 253:              serviceType = 1; // (?) <type id="1" name="Dn"
 254:   
 255:              // 11. Loop through all sr records by request id ascending
 256:              foreach (Ia.Ngn.Cl.Model.ServiceRequest serviceRequest in serviceRequestList.OrderBy(p => p.Id))
 257:              {
 258:                  if (Ia.Ngn.Cl.Model.Business.Authority.ServiceRequestIsAllowedProcessing(serviceRequest))
 259:                  {
 260:                      // below: we will only process service requests that have status = 2003 or status = 2005
 261:                      if (serviceRequest.Status == 2003 || serviceRequest.Status == 2005)
 262:                      {
 263:                          // below: we will only process service requests that have allowed service Ids
 264:                          if (Ia.Ngn.Cl.Model.Data.ServiceRequest.ServiceIdAllowedForProcessingList.Contains(serviceRequest.ServiceId))
 265:                          {
 266:                              // <status id="2003" arabicName="قيد التنفيذ" />
 267:                              // <status id="2005" arabicName="تم التنفيذ" />
 268:   
 269:                              // below: first check if there is already a SRS record within this loop
 270:   
 271:                              service = serviceRequest.Number.ToString();
 272:   
 273:                              serviceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(service, serviceType);
 274:   
 275:                              serviceRequestService = (from srs in serviceRequestServiceList where srs.Id == serviceRequestServiceId select srs).OrderByDescending(u => u.Updated).GroupBy(u => u.Id).Select(u => u.First()).FirstOrDefault(); //.SingleOrDefault();
 276:   
 277:                              if (serviceRequestService == null || serviceRequestService.Provisioned == false)
 278:                              {
 279:                                  if (serviceRequestService == null) serviceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
 280:   
 281:                                  serviceRequestService.Id = serviceRequestServiceId;
 282:                                  serviceRequestService.Service = service;
 283:                                  serviceRequestService.AreaCode = Ia.Ngn.Cl.Model.Business.Service.CountryCode;
 284:                                  serviceRequestService.ServiceType = serviceType;
 285:                                  serviceRequestService.Provisioned = true;
 286:   
 287:                                  recordExisted = false;
 288:                              }
 289:                              else recordExisted = true;
 290:   
 291:                              if (serviceRequest.ServiceCategoryId == 3)
 292:                              {
 293:                                  // <category id="1" arabicName="الخدمات الهاتفية" />
 294:   
 295:                                  TelephonyService(serviceRequest, serviceRequestTypeList, ref serviceRequestService, ref lastRequestDateTime);
 296:                              }
 297:                              else if (serviceRequest.ServiceCategoryId == 49)
 298:                              {
 299:                                  // <category id="49" arabicName="إنترنت ألياف ضوئية - مشترك" />
 300:                              }
 301:                              else
 302:                              {
 303:                                  //r0 += "service category id=" + sr.ServiceCategoryId + " was not recognized. \r\n";
 304:                              }
 305:   
 306:                              if (!recordExisted)
 307:                              {
 308:                                  if (serviceRequestService != null)
 309:                                  {
 310:                                      serviceRequestServiceList.Add(serviceRequestService);
 311:   
 312:                                      serviceRequest.ServiceRequestService = serviceRequestService;
 313:                                  }
 314:                              }
 315:                              else if (recordExisted)
 316:                              {
 317:                                  if (serviceRequestService == null) serviceRequestService.Provisioned = false;
 318:                                  else serviceRequest.ServiceRequestService = serviceRequestService;
 319:                              }
 320:                          }
 321:                          else
 322:                          {
 323:                              //r0 += "serviceId=" + sr.ServiceId + " unprocessed. \r\n";
 324:                          }
 325:                      }
 326:                      else
 327:                      {
 328:                          //r0 += "status=" + sr.Status + " unprocessed. \r\n";
 329:                      }
 330:                  }
 331:              }
 332:   
 333:              // 12. Remove duplicates (Linq orderyby boolean See http://stackoverflow.com/questions/9481054/linq-orderyby-boolean)
 334:              serviceRequestServiceList = serviceRequestServiceList.OrderByDescending(u => u.Updated).OrderByDescending(u => u.Provisioned).GroupBy(u => u.Id).Select(u => u.First()).ToList();
 335:   
 336:              // 13. Update service request services
 337:              Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateWithServiceList(serviceList, serviceRequestServiceList, out r1);
 338:   
 339:              // 14. Update service requests with SRS foreign keys
 340:              Ia.Ngn.Cl.Model.Data.ServiceRequest.UpdateWithServiceList(serviceList, serviceRequestList, out r2);
 341:   
 342:              // 15. Update service initial state
 343:              //Ia.Ngn.Cl.Model.Data.ServiceInitialState.DeleteIfServiceRequestServiceExistsList(serviceRequestServiceList, out r3);
 344:   
 345:              result = r1 + " " + r2; // + " " + r3;
 346:          }
 347:   
 348:          ////////////////////////////////////////////////////////////////////////////
 349:   
 350:          /// <summary>
 351:          ///
 352:          /// </summary>
 353:          public static void UpdateForService(string service, out string result)
 354:          {
 355:              result = string.Empty;
 356:          }
 357:   
 358:          ////////////////////////////////////////////////////////////////////////////
 359:   
 360:          /// <summary>
 361:          ///
 362:          /// </summary>
 363:          private static void TelephonyService(Ia.Ngn.Cl.Model.ServiceRequest serviceRequest, List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList, ref Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService, ref DateTime lastRequestDateTime)
 364:          {
 365:              int serviceType;
 366:              string changedServiceNumber;//, level;
 367:              //Ia.Ngn.Cl.Model.Business.ServiceAddress serviceAddress;
 368:              Ia.Ngn.Cl.Model.Access access;
 369:              //List<Ia.Ngn.Cl.Model.Access> accessList;
 370:   
 371:              /*
 372:               * <service id="15" arabicName="خدمة المحاسبة" />
 373:               * <service id="42" arabicName="نقل داخلي" />
 374:               * <service id="44" arabicName="تغيير نوع إشتراك" />
 375:               * <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
 376:               * <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
 377:               * <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
 378:               * <service id="271" arabicName="تغيير اسم"/>
 379:               */
 380:   
 381:              serviceType = 1; // <type id="1" name="Dn"
 382:   
 383:              // below: we will process only telephone service numbers that fall within network specs.
 384:              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(serviceRequest.Number))
 385:              {
 386:                  lastRequestDateTime = serviceRequest.RequestDateTime;
 387:   
 388:                  if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 39 || serviceRequest.ServiceId == 41 || serviceRequest.ServiceId == 54)
 389:                  {
 390:                      // <service id="1" arabicName="خط هاتف" />
 391:                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 392:                      // <service id="39" arabicName="نقل خارجى" />
 393:                      // <service id="41" arabicName="تغيير رقم" />
 394:                      // <service id="54" arabicName="اعادة تركيب" />
 395:   
 396:                      if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 39 || serviceRequest.ServiceId == 54)
 397:                      {
 398:                          // <service id="1" arabicName="خط هاتف" />
 399:                          // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 400:                          // <service id="39" arabicName="نقل خارجى" />
 401:                          // <service id="54" arabicName="اعادة تركيب" />
 402:   
 403:                          if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 54)
 404:                          {
 405:                              // <service id="1" arabicName="خط هاتف" />
 406:                              // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 407:                              // <service id="54" arabicName="اعادة تركيب" />
 408:   
 409:                              // below: keep this here and don't move it out to accommodate 39
 410:                              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 411:                              {
 412:                                  // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 413:                                  access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 414:   
 415:                                  if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 416:                                  else serviceRequestService.Access = null;
 417:                                  /*
 418:                                   * I will not use statistical estimation for incomplete workorders
 419:                                  else
 420:                                  {
 421:                                      serviceAddress = Ia.Ngn.Cl.Model.Business.ServiceRequest.StatisticalServiceAddress(serviceRequestService.Service, serviceRequest.CustomerAddress, out level);
 422:  
 423:                                      if (serviceAddress != null)
 424:                                      {
 425:                                          accessList = (from a in db.Accesses where a.AreaId == serviceAddress.AreaId select a).ToList();
 426:  
 427:                                          access = Ia.Ngn.Cl.Model.Data.Access.StatisticalAccess(serviceAddress, ref accessList);
 428:  
 429:                                          if (access != null)
 430:                                          {
 431:                                              serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 432:                                          }
 433:                                          else serviceRequestService.Access = null;
 434:                                      }
 435:                                      else serviceRequestService.Access = null;
 436:                                  }
 437:                                  */
 438:                              }
 439:   
 440:                              serviceRequestService.CallerId = false;
 441:   
 442:                              serviceRequestService.AlarmCall = false;
 443:                              serviceRequestService.WakeupCall = false;
 444:   
 445:                              ///serviceRequestService.InternationalCallingUserControlled = true; // as requested by MOC NGN management
 446:                              serviceRequestService.CallWaiting = false;
 447:                              serviceRequestService.CallForwarding = false;
 448:                              serviceRequestService.ConferenceCall = false;
 449:                              serviceRequestService.CallBarring = false;
 450:   
 451:                              if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 54) serviceRequestService.InternationalCalling = false;
 452:                              else if (serviceRequest.ServiceId == 129) serviceRequestService.InternationalCalling = true;
 453:                          }
 454:                          else if (serviceRequest.ServiceId == 39)
 455:                          {
 456:                              // <service id="39" arabicName="نقل خارجى" />
 457:   
 458:                              // old: in this case the SRT values of the original 1 or 129 will be updated, therefore we will not do anything here, and the original 1 or 129 will have the result of this 39 service
 459:                              // update: it seems that the 39 order has the new destination address now
 460:   
 461:                              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 462:                              {
 463:                                  // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 464:                                  access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 465:   
 466:                                  if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 467:                                  //else serviceRequestService.Access = null;
 468:                              }
 469:                          }
 470:                      }
 471:                      else if (serviceRequest.ServiceId == 41)
 472:                      {
 473:                          // <service id="41" arabicName="تغيير رقم" />
 474:   
 475:                          // below: <type id="11" name="dn" arabicName="dn" oracleFieldName="الرقم الجديد"/>
 476:                          changedServiceNumber = (from srt in serviceRequestTypeList where srt.ServiceRequest.Id == serviceRequest.Id && srt.TypeId == 11 select srt.Value).SingleOrDefault();
 477:   
 478:                          if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(changedServiceNumber))
 479:                          {
 480:                              serviceRequestService.Id = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(changedServiceNumber, serviceType);
 481:                              serviceRequestService.Service = changedServiceNumber;
 482:                          }
 483:                          else
 484:                          {
 485:   
 486:                          }
 487:                      }
 488:                  }
 489:                  else if (serviceRequest.ServiceId == 43)
 490:                  {
 491:                      // <service id="43" arabicName="تنازل" />
 492:   
 493:                      // Id    Number    Serial    Status    RequestDateTime    CustomerId    CustomerName    CustomerCategoryId    CustomerAddress    ServiceId    ServiceCategoryId    Balance    Created    Updated    UserId    ServiceRequestService_Id
 494:                      // 1821798    24573325    1    2005    2015-08-20 00:00:00.000    1500989    محمد مهاوش سويد السعيدي    1    الجهراء الجهراء,قطعة 5 شارع 1 جادة قسائم العثمان قسيمة الا زرق 29, منزل 529    43    3    0    2015-08-20 20:41:04.403    2015-08-20 20:41:04.403    00000000-0000-0000-0000-000000000000    NULL
 495:                      // 1821312    25234142    0    2005    2015-08-19 00:00:00.000    1476656    رنا فيصل عبدالرزاق الخالد    1    حولى الشهداء,قطعة 1 شارع 3, منزل 501    43    3    0    2015-08-19 11:13:32.827    2015-08-19 11:13:32.827    00000000-0000-0000-0000-000000000000    NULL
 496:   
 497:                      // No SRT records. Nothing to do.
 498:                  }
 499:                  else
 500:                  {
 501:                      switch (serviceRequest.ServiceId)
 502:                      {
 503:                          // below: <service id="40" arabicName="رفع خط" />
 504:                          case 40:
 505:                              {
 506:                                  serviceRequestService.Provisioned = false;
 507:                                  // serviceRequestService = null;
 508:                                  break;
 509:                              }
 510:   
 511:                          // below: <service id="131" arabicName="خط ذهبي"/>
 512:                          case 131: { break; }
 513:   
 514:                          // below: <service id="132" arabicName="خط فضي"/>
 515:                          case 132: { break; }
 516:   
 517:                          // below: <service id="133" arabicName="خط برونزي"/>
 518:                          case 133: { break; }
 519:   
 520:                          // below: <service id="12" arabicName="خدمة الإنتظار" />
 521:                          case 12: { serviceRequestService.CallWaiting = true; break; }
 522:   
 523:                          // below: <service id="68" arabicName="إيقاف خدمة الإنتظار" />
 524:                          case 68: { serviceRequestService.CallWaiting = false; break; }
 525:   
 526:                          // below: <service id="13" arabicName="التحكم بالصفر الدولي" />
 527:                          case 13: { serviceRequestService.InternationalCallingUserControlled = true; break; }
 528:   
 529:                          // below: <service id="67" arabicName="وقف التحكم بالصفر" />
 530:                          case 67: { serviceRequestService.InternationalCallingUserControlled = false; break; }
 531:   
 532:                          // below: <service id="14" arabicName="كاشف رقم" />
 533:                          case 14: { serviceRequestService.CallerId = true; break; }
 534:   
 535:                          // below: <service id="66" arabicName="إيقاف كاشف" />
 536:                          case 66: { serviceRequestService.CallerId = false; break; }
 537:   
 538:                          // below: <service id="5" arabicName="تحويل مكالمات" />
 539:                          case 5: { serviceRequestService.CallForwarding = true; break; }
 540:   
 541:                          // below: <service id="75" arabicName="إيقاف التحويل" />
 542:                          case 75: { serviceRequestService.CallForwarding = false; break; }
 543:   
 544:                          // below: <service id="20" arabicName="النداء الآلي" />
 545:                          case 20: { serviceRequestService.InternationalCalling = true; break; }
 546:   
 547:                          // below: <service id="19" arabicName="قطع النداء الآلي" />
 548:                          case 19: { serviceRequestService.InternationalCalling = false; break; }
 549:   
 550:                          // below: <service id="38" arabicName="مجموعة الخدمات" />
 551:                          case 38:
 552:                              {
 553:                                  serviceRequestService.CallerId = true;
 554:   
 555:                                  serviceRequestService.AlarmCall = true;
 556:                                  serviceRequestService.WakeupCall = true;
 557:   
 558:                                  //serviceRequestService.InternationalCallingUserControlled = true;
 559:                                  serviceRequestService.CallWaiting = true;
 560:                                  serviceRequestService.CallForwarding = true;
 561:                                  serviceRequestService.ConferenceCall = true;
 562:                                  break;
 563:                              }
 564:   
 565:                          // below: <service id="62" arabicName="إيقاف مجموعة الخدمات" />
 566:                          case 62:
 567:                              {
 568:                                  serviceRequestService.CallerId = false;
 569:   
 570:                                  serviceRequestService.AlarmCall = false;
 571:                                  serviceRequestService.WakeupCall = false;
 572:   
 573:                                  //serviceRequestService.InternationalCallingUserControlled = false;
 574:                                  serviceRequestService.CallWaiting = false;
 575:                                  serviceRequestService.CallForwarding = false;
 576:                                  serviceRequestService.ConferenceCall = false;
 577:                                  break;
 578:                              }
 579:   
 580:                          // below: <service id="52" arabicName="قطع حرارة" />
 581:                          case 52: { serviceRequestService.CallBarring = true; break; }
 582:   
 583:                          // below: <service id="53" arabicName="اعادة حرارة" />
 584:                          case 53: { serviceRequestService.CallBarring = false; break; }
 585:   
 586:                          // below: <service id="7" arabicName="منع الإتصال" />
 587:                          case 7: { serviceRequestService.BarringOfAllOutgoingCalls = true; break; }
 588:   
 589:                          // below: <service id="73" arabicName="إيقاف منع الإتصال" />
 590:                          case 73: { serviceRequestService.BarringOfAllOutgoingCalls = false; break; }
 591:   
 592:                          // below: <service id="8" arabicName="ايقاف استقبال" />
 593:                          case 8: { serviceRequestService.BarringOfAllIncomingCalls = true; break; }
 594:   
 595:                          // below: <service id="72" arabicName="رد استقبال" />
 596:                          case 72: { serviceRequestService.BarringOfAllIncomingCalls = false; break; }
 597:   
 598:                          // below: <service id="10" arabicName="خدمة الإيقاظ" />
 599:                          case 10:
 600:                              {
 601:                                  serviceRequestService.AlarmCall = true;
 602:                                  serviceRequestService.WakeupCall = true;
 603:                                  break;
 604:                              }
 605:   
 606:                          // below: <service id="70" arabicName="إيقاف خدمة الإيقاظ" />
 607:                          case 70:
 608:                              {
 609:                                  serviceRequestService.AlarmCall = false;
 610:                                  serviceRequestService.WakeupCall = false;
 611:                                  break;
 612:                              }
 613:   
 614:                          // below: <service id="6" arabicName="استشارة" />
 615:                          case 6: { serviceRequestService.ConferenceCall = true; break; }
 616:   
 617:                          // below: <service id="74" arabicName="إيقاف استشارة" />
 618:                          case 74: { serviceRequestService.ConferenceCall = false; break; }
 619:   
 620:                          // below: <service id="11" arabicName="إختصار الرقم" />
 621:                          case 11: { serviceRequestService.AbbriviatedCalling = true; break; }
 622:   
 623:                          // below: <service id="69" arabicName="إيقاف إختصار الرقم" />
 624:                          case 69: { serviceRequestService.AbbriviatedCalling = false; break; }
 625:   
 626:                          // below: <service id="55" arabicName="مفتاح بدالة" />
 627:                          case 55: { break; }
 628:   
 629:                          // below: <if id="60" name_ar="إيقاف مفتاح بدالة"...
 630:                          case 60: { break; }
 631:   
 632:                          // below: <if id="56" name_ar="فرع بدالة"...
 633:                          case 56:
 634:                              {
 635:                                  //        u = r["pbx_dn"].ToString();
 636:                                  //        u = Regex.Replace(u, @"\/\d", ""); // remove that last /0
 637:                                  //        pbx_dn = int.Parse(Ia.Ngn.Cs.This.Digit_7_to_8(u));
 638:                                  //        dr["pbx_dn_key"] = pbx_dn;
 639:                                  break;
 640:                              }
 641:   
 642:                          // below: <if id="59" name_ar="إيقاف فرع بدالة"...
 643:                          case 59: { break; }
 644:   
 645:                          // below: <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
 646:                          case 64: { break; }
 647:   
 648:                          // below: <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
 649:                          case 63: { break; }
 650:   
 651:                          // below: <service id="608" arabicName="خط رقمي دسل"/>
 652:                          case 608: { break; }
 653:   
 654:                          // below: <service id="609" arabicName="قطع خط رقمي دسل"/>
 655:                          case 609: { break; }
 656:   
 657:                          // below: <service id="15" arabicName="خدمة المحاسبة" />
 658:                          case 15: { break; }
 659:   
 660:                          // below: <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
 661:                          case 65: { break; }
 662:   
 663:                          // below: <service id="271" arabicName="تغيير اسم"/>
 664:                          case 271: { break; }
 665:   
 666:                          // below: <service id="44" arabicName="تغيير نوع إشتراك" />
 667:                          case 44: { break; }
 668:   
 669:                          // below: <service id="42" arabicName="نقل داخلي" />
 670:                          case 42: { break; }
 671:   
 672:                          // below: <service id="46" arabicName="جهاز كاشف" />
 673:                          case 46: { break; }
 674:   
 675:                          // below: <service id="45" arabicName="تعديل اسم" />
 676:                          case 45: { break; }
 677:   
 678:                          // below: <service id="47" arabicName="جهاز تلفون" />
 679:                          case 47: { break; }
 680:   
 681:                          // below: <service id="49" arabicName="رسوم مودم" />
 682:                          case 49: { break; }
 683:   
 684:                          // below: <service id="37" arabicName="برقية" />
 685:                          case 37: { break; }
 686:   
 687:                          // below: <service id="23" arabicName="مكالمات مصلحية -دفع" />
 688:                          case 23: { break; }
 689:   
 690:                          default:
 691:                              {
 692:                                  log.AppendLine("TelephonyService(): For ServiceRequest.Number=" + serviceRequest.Number + " ServiceId=" + serviceRequest.ServiceId + " was not recognized. ");
 693:                                  break;
 694:                              }
 695:                      }
 696:                  }
 697:              }
 698:              else
 699:              {
 700:                  // below: sent provisioned to false
 701:                  serviceRequestService.Provisioned = false;
 702:                  lastRequestDateTime = DateTime.MinValue;
 703:                  //serviceRequestService = null;
 704:              }
 705:   
 706:              if (serviceRequestService.LastRequestDateTime < lastRequestDateTime) serviceRequestService.LastRequestDateTime = lastRequestDateTime;
 707:          }
 708:   
 709:          ////////////////////////////////////////////////////////////////////////////
 710:          ////////////////////////////////////////////////////////////////////////////
 711:      }
 712:   
 713:      ////////////////////////////////////////////////////////////////////////////
 714:      ////////////////////////////////////////////////////////////////////////////
 715:  }