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

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.Generic;
   3:  using System.Data;
   4:  using System.Linq;
   5:  using System.Text;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Business
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Service Request Service support class of Next Generation Network'a (NGN's) business model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// 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
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public partial class ServiceRequestService
  29:      {
  30:          private static readonly StringBuilder log = new StringBuilder();
  31:   
  32:          ////////////////////////////////////////////////////////////////////////////
  33:   
  34:          /// <summary>
  35:          ///
  36:          /// </summary>
  37:          public enum ServiceRequestServiceType { Create = 1, Read, Update, Delete };
  38:   
  39:          ////////////////////////////////////////////////////////////////////////////
  40:   
  41:          /// <summary>
  42:          ///
  43:          /// </summary>
  44:          public ServiceRequestService() { }
  45:   
  46:          ////////////////////////////////////////////////////////////////////////////
  47:   
  48:          /// <summary>
  49:          ///
  50:          /// </summary>
  51:          public static string ServiceIdToService(string service)
  52:          {
  53:              return Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(service);
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public static string ServiceRequestServiceId(string service, int serviceType)
  62:          {
  63:              // below:
  64:              string id;
  65:   
  66:              id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
  67:   
  68:              return id;
  69:          }
  70:   
  71:          ////////////////////////////////////////////////////////////////////////////
  72:   
  73:          /// <summary>
  74:          ///
  75:          /// </summary>
  76:          public static void UpdateServiceSuspension(string service, bool serviceSuspensionState, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact, out Ia.Cl.Model.Result result)
  77:          {
  78:              result = new Ia.Cl.Model.Result();
  79:   
  80:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Update, staffContact))
  81:              {
  82:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(service))
  83:                  {
  84:                      Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(service, serviceSuspensionState, staffContact.UserId, out result);
  85:   
  86:                      Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.ServiceSuspensionQueue.Enqueue(service);
  87:   
  88:                      if (result.IsSuccessful)
  89:                      {
  90:                          result.AddSuccess("Service record '" + service + "' has its service suspension value updated to '" + serviceSuspensionState.ToString().ToLower() + "'");
  91:                      }
  92:                      else
  93:                      {
  94:                      }
  95:                  }
  96:                  else
  97:                  {
  98:                      result.AddError(@"The number '" + service + @"' does not belong to the network (الرقم لا ينتمي للشبكة). ");
  99:                  }
 100:              }
 101:              else
 102:              {
 103:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
 104:              }
 105:          }
 106:   
 107:          ////////////////////////////////////////////////////////////////////////////
 108:   
 109:          /// <summary>
 110:          ///
 111:          /// </summary>
 112:          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)
 113:          {
 114:              DateTime now;
 115:              Ia.Ngn.Cl.Model.Service2 service2;
 116:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
 117:   
 118:              result = new Ia.Cl.Model.Result();
 119:   
 120:              isSuspended = false;
 121:              serviceLastUpdated = DateTime.MinValue;
 122:   
 123:              now = DateTime.UtcNow.AddHours(3);
 124:   
 125:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staffContact))
 126:              {
 127:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(service))
 128:                  {
 129:                      serviceRequestService = Ia.Ngn.Cl.Model.Data.ServiceRequestService.Read(service);
 130:                      service2 = Ia.Ngn.Cl.Model.Data.Service2.Read(service);
 131:   
 132:                      if (serviceRequestService != null && service2 != null)
 133:                      {
 134:                          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 + "). ");
 135:   
 136:                          isSuspended = service2.ServiceSuspension;
 137:                          serviceLastUpdated = service2.Updated;
 138:                      }
 139:                      else
 140:                      {
 141:                          result.AddError("Service and/or service request service record for '" + service + "' does not exist. ");
 142:                      }
 143:                  }
 144:                  else
 145:                  {
 146:                      result.AddError(@"The number '" + service + @"' does not belong to the network (الرقم لا ينتمي للشبكة). ");
 147:                  }
 148:              }
 149:              else
 150:              {
 151:                  result.AddError("You are not authorized to read this value (لست مخولاً بقراءة هذه القيمة). ");
 152:              }
 153:          }
 154:   
 155:          ////////////////////////////////////////////////////////////////////////////
 156:   
 157:          /// <summary>
 158:          /// Update service-request-service table with data from service requests
 159:          /// </summary>
 160:          public static string UpdateForServiceRequestIdRange(Tuple<int, int> startEndRange)
 161:          {
 162:              string result;
 163:              List<int> numberList;
 164:              List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
 165:   
 166:              // 1. Read all SRs for this range
 167:              serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.ListWithinIdRange(startEndRange.Item1, startEndRange.Item2);
 168:   
 169:              // 2. Collect numbers in int format into int list
 170:              numberList = serviceRequestList.NumberList();
 171:   
 172:              UpdateForServiceList(numberList, out result);
 173:   
 174:              return result;
 175:          }
 176:   
 177:          ////////////////////////////////////////////////////////////////////////////
 178:   
 179:          /// <summary>
 180:          ///
 181:          /// </summary>
 182:          public static string UpdateForService(string service)
 183:          {
 184:              string result;
 185:              List<int> numberList;
 186:   
 187:              numberList = new List<int>();
 188:   
 189:              if (int.TryParse(service, out int i))
 190:              {
 191:                  numberList.Add(i);
 192:   
 193:                  UpdateForServiceList(numberList, out result);
 194:              }
 195:              else
 196:              {
 197:                  result = "Error: service: " + service + " is not in integer format. ";
 198:              }
 199:   
 200:              return result;
 201:          }
 202:   
 203:          ////////////////////////////////////////////////////////////////////////////
 204:   
 205:          /// <summary>
 206:          /// Update service-request-service table with service list
 207:          /// </summary>
 208:          public static void UpdateForServiceList(List<int> numberList, out string result)
 209:          {
 210:              string r0, r1, r2;
 211:              List<int> number1List;
 212:              List<string> serviceList, service1List, service2List;
 213:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 214:              List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
 215:              List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList;
 216:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList, serviceRequestServiceDefaultList, serviceRequestServiceHistoryList;
 217:   
 218:              r0 = r1 = r2 = string.Empty;
 219:   
 220:              serviceList = new List<string>();
 221:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 222:   
 223:              using (var db = new Ia.Ngn.Cl.Model.Ngn()) // important to enable usage of Include from different functions
 224:              {
 225:                  // SR
 226:                  // 3. Collect numbers in int format into int list
 227:                  number1List = Ia.Ngn.Cl.Model.Data.ServiceRequest.NumberAndChangedAndChangedToList(numberList);
 228:   
 229:                  if (number1List.Count > 0)
 230:                  {
 231:                      // 6 Read all SRs related to collected numbers
 232:                      serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List(number1List);
 233:   
 234:                      // 7. Read all SRTs related to collected numbers
 235:                      serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.List(number1List);
 236:   
 237:                      // 8. Collect numbers in string format into int list
 238:                      service1List = (from n in number1List select n.ToString()).ToList<string>();
 239:   
 240:                      serviceRequestServiceDefaultList = ServiceRequestServiceFromServiceRequest(service1List, serviceRequestList, serviceRequestTypeList);
 241:   
 242:                      // 12. Remove duplicates (Linq orderyby boolean See http://stackoverflow.com/questions/9481054/linq-orderyby-boolean)
 243:                      serviceRequestServiceDefaultList = serviceRequestServiceDefaultList.OrderByDescending(u => u.Serial).OrderByDescending(u => u.Provisioned).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).ToList();
 244:                  }
 245:                  else
 246:                  {
 247:                      serviceRequestList = new List<Ia.Ngn.Cl.Model.ServiceRequest>();
 248:                      serviceRequestTypeList = new List<Ia.Ngn.Cl.Model.ServiceRequestType>();
 249:                      service1List = new List<string>();
 250:   
 251:                      serviceRequestServiceDefaultList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 252:                  }
 253:   
 254:                  //foreach (var srsd in serviceRequestServiceDefaultList) serviceRequestServiceList.Add(srsd);
 255:                  foreach (var s in service1List) serviceList.Add(s);
 256:   
 257:                  // SRH
 258:                  // 9. Read all SRHs related to collected numbers
 259:                  serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List(numberList);
 260:   
 261:                  // 8. Collect numbers in string format into int list
 262:                  service2List = (from n in numberList select n.ToString()).ToList<string>();
 263:   
 264:                  if (serviceRequestHistoryList.Count > 0)
 265:                  {
 266:                      serviceRequestServiceHistoryList = ServiceRequestServiceFromServiceRequestHistory(service2List, serviceRequestHistoryList);
 267:   
 268:                      // 12. Remove duplicates (Linq orderyby boolean See http://stackoverflow.com/questions/9481054/linq-orderyby-boolean)
 269:                      serviceRequestServiceHistoryList = serviceRequestServiceHistoryList.OrderByDescending(u => u.Serial).OrderByDescending(u => u.Provisioned).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).ToList();
 270:                  }
 271:                  else
 272:                  {
 273:                      serviceRequestServiceHistoryList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 274:                  }
 275:   
 276:   
 277:                  // Consolidate SRS from SR and SRH
 278:                  if (serviceRequestServiceDefaultList.Count > 0)
 279:                  {
 280:                      foreach (var srsd in serviceRequestServiceDefaultList)
 281:                      {
 282:                          if (!serviceRequestServiceHistoryList.Any(u => u.Id == srsd.Id)) serviceRequestServiceList.Add(srsd);
 283:                          else
 284:                          {
 285:                              var serviceRequestService = srsd;
 286:   
 287:                              var srsh = (from _srsh in serviceRequestServiceHistoryList where _srsh.Id == srsd.Id select _srsh).Single();
 288:   
 289:                              serviceRequestService.Provisioned = srsd.Provisioned || srsh.Provisioned;
 290:                              serviceRequestService.InternationalCalling = srsd.InternationalCalling || srsh.InternationalCalling;
 291:                              serviceRequestService.InternationalCallingUserControlled = srsd.InternationalCallingUserControlled || srsh.InternationalCallingUserControlled;
 292:                              serviceRequestService.CallForwarding = srsd.CallForwarding || srsh.CallForwarding;
 293:                              serviceRequestService.CallWaiting = srsd.CallWaiting || srsh.CallWaiting;
 294:                              serviceRequestService.ConferenceCall = srsd.ConferenceCall || srsh.ConferenceCall;
 295:                              serviceRequestService.AlarmCall = srsd.AlarmCall || srsh.AlarmCall;
 296:                              serviceRequestService.WakeupCall = srsd.WakeupCall || srsh.WakeupCall;
 297:                              serviceRequestService.AbbriviatedCalling = srsd.AbbriviatedCalling || srsh.AbbriviatedCalling;
 298:                              //serviceRequestService.ServiceSuspension = srsd.ServiceSuspension || srsh.ServiceSuspension;
 299:   
 300:                              serviceRequestServiceList.Add(serviceRequestService);
 301:                          }
 302:                      }
 303:                  }
 304:                  else
 305:                  {
 306:                      foreach (var srsh in serviceRequestServiceHistoryList)
 307:                      {
 308:                          var serviceRequestService = srsh;
 309:   
 310:                          serviceRequestService.Provisioned = srsh.Provisioned;
 311:                          serviceRequestService.InternationalCalling = srsh.InternationalCalling;
 312:                          serviceRequestService.InternationalCallingUserControlled = srsh.InternationalCallingUserControlled;
 313:                          serviceRequestService.CallForwarding = srsh.CallForwarding;
 314:                          serviceRequestService.CallWaiting = srsh.CallWaiting;
 315:                          serviceRequestService.ConferenceCall = srsh.ConferenceCall;
 316:                          serviceRequestService.AlarmCall = srsh.AlarmCall;
 317:                          serviceRequestService.WakeupCall = srsh.WakeupCall;
 318:                          serviceRequestService.AbbriviatedCalling = srsh.AbbriviatedCalling;
 319:                          //serviceRequestService.ServiceSuspension = srsh.ServiceSuspension;
 320:   
 321:                          serviceRequestServiceList.Add(serviceRequestService);
 322:                      }
 323:                  }
 324:   
 325:   
 326:                  foreach (var s in service2List) serviceList.Add(s);
 327:   
 328:                  serviceList = serviceList.Distinct().ToList();
 329:   
 330:                  // 13. Update service request services
 331:                  Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateWithServiceList(serviceList, serviceRequestServiceList, out r1);
 332:   
 333:                  // 14. Update service requests with SRS foreign keys
 334:                  Ia.Ngn.Cl.Model.Data.ServiceRequest.UpdateWithServiceList(serviceList, serviceRequestList, out r2);
 335:              }
 336:   
 337:              result = r1 + " " + r2;
 338:          }
 339:   
 340:          ////////////////////////////////////////////////////////////////////////////
 341:   
 342:          /// <summary>
 343:          ///
 344:          /// </summary>
 345:          public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceFromServiceRequest(List<string> serviceList, List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList, List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList)
 346:          {
 347:              int serial, serviceType, serviceId;
 348:              string service, serviceSerial, serviceRequestServiceId, changedToServiceRequestServiceId, changedToServiceNumber;
 349:              DateTime lastRequestDateTime;
 350:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService, changedToServiceRequestService;
 351:              Dictionary<string, int> serviceToSerialDictionary;
 352:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 353:   
 354:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService; // irrelevant?
 355:              lastRequestDateTime = DateTime.MinValue;
 356:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>(serviceRequestList.Count);
 357:              serviceToSerialDictionary = new Dictionary<string, int>();
 358:   
 359:   
 360:              // create initial serviceRequestServiceList from serviceList with all Provisioned = false records:
 361:   
 362:   
 363:              // 11. Loop through all sr records by request id ascending
 364:              var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38).ThenBy(p => p.Id); // <service id="38" arabicName="مجموعة الخدمات" />
 365:              foreach (Ia.Ngn.Cl.Model.ServiceRequest serviceRequest in list) // serviceRequestList.OrderBy(p => p.Id))
 366:              {
 367:                  if (Ia.Ngn.Cl.Model.Business.Authority.ServiceRequestIsAllowedProcessing(serviceRequest))
 368:                  {
 369:                      if (serviceRequest.ServiceCategoryId == 3)
 370:                      {
 371:                          // <category id="3" arabicName="هاتف" />
 372:   
 373:                          if (serviceRequest.Status == 2003 || serviceRequest.Status == 2005)
 374:                          {
 375:                              // <status id="2003" arabicName="قيد التنفيذ" />
 376:                              // <status id="2005" arabicName="تم التنفيذ" />
 377:   
 378:                              service = serviceRequest.Number.ToString();
 379:                              serial = serviceRequest.Serial;
 380:                              serviceId = serviceRequest.ServiceId;
 381:                              serviceSerial = service + ":" + serial;
 382:   
 383:                              serviceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(service, serviceType);
 384:   
 385:                              serviceRequestService = (from srs in serviceRequestServiceList where srs.Id == serviceRequestServiceId select srs).OrderByDescending(u => u.Serial).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).FirstOrDefault(); //.SingleOrDefault();
 386:   
 387:                              if (serviceRequestService == null || serviceRequestService.Provisioned == false)
 388:                              {
 389:                                  if (serviceId == 1 || serviceId == 129 || serviceId == 54)
 390:                                  {
 391:                                      // <service id="1" arabicName="خط هاتف" />
 392:                                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 393:                                      // <service id="54" arabicName="اعادة تركيب" />
 394:   
 395:                                      serviceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
 396:   
 397:                                      serviceRequestService.Id = serviceRequestServiceId;
 398:                                      serviceRequestService.Service = service;
 399:                                      serviceRequestService.Serial = serial;
 400:                                      serviceRequestService.AreaCode = Ia.Ngn.Cl.Model.Business.Service.CountryCode;
 401:                                      serviceRequestService.ServiceType = serviceType;
 402:                                      serviceRequestService.Provisioned = true;
 403:   
 404:                                      TelephonyService(serviceRequest, serviceRequestTypeList, ref serviceRequestService);
 405:   
 406:                                      serviceRequestServiceList.Add(serviceRequestService);
 407:                                      serviceRequest.ServiceRequestService = serviceRequestService;
 408:   
 409:                                      lastRequestDateTime = serviceRequest.RequestDateTime;
 410:                                      if (serviceRequestService.LastRequestDateTime < lastRequestDateTime) serviceRequestService.LastRequestDateTime = lastRequestDateTime;
 411:                                  }
 412:                                  else
 413:                                  {
 414:                                      // incomplete service request list for serial
 415:                                  }
 416:                              }
 417:                              else
 418:                              {
 419:                                  if (serviceRequestService.Provisioned && serviceRequestService.Serial == serial)
 420:                                  {
 421:                                      if (serviceRequest.ServiceId == 41)
 422:                                      {
 423:                                          // <service id="41" arabicName="تغيير رقم" />
 424:   
 425:                                          // below: <type id="11" name="dn" arabicName="dn" oracleFieldName="الرقم الجديد"/>
 426:                                          changedToServiceNumber = (from srt in serviceRequestTypeList
 427:                                                                    where srt.ServiceRequest.Id == serviceRequest.Id && srt.TypeId == 11 && srt.Value != null 
 428:                                                                    select srt.Value).SingleOrDefault();
 429:   
 430:                                          if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(changedToServiceNumber)) // important because some numbers are null
 431:                                          {
 432:                                              // Set Provision to false for changed number
 433:                                              serviceRequestService.Provisioned = false;
 434:   
 435:                                              // Create or update entry for new number
 436:                                              changedToServiceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(changedToServiceNumber, serviceType);
 437:   
 438:                                              changedToServiceRequestService = (from srs in serviceRequestServiceList where srs.Id == changedToServiceRequestServiceId select srs).OrderByDescending(u => u.Serial).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).FirstOrDefault(); //.SingleOrDefault();
 439:   
 440:                                              if (changedToServiceRequestService == null)
 441:                                              {
 442:                                                  changedToServiceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
 443:                                                  changedToServiceRequestService.Id = changedToServiceRequestServiceId; // keep here and keep below
 444:   
 445:                                                  serviceRequestServiceList.Add(changedToServiceRequestService);
 446:   
 447:                                                  changedToServiceRequestService = (from srs in serviceRequestServiceList where srs.Id == changedToServiceRequestServiceId select srs).OrderByDescending(u => u.Serial).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).FirstOrDefault(); //.SingleOrDefault();
 448:                                              }
 449:   
 450:                                              changedToServiceRequestService.Copy(serviceRequestService); // order is very important, first Copy then modify
 451:                                              changedToServiceRequestService.Id = changedToServiceRequestServiceId; // keep here and keep above
 452:                                              changedToServiceRequestService.Service = changedToServiceNumber;
 453:                                              // below: you must assign a serial that is an increment of any previously existing serial for the changed-to number, or 0 of non
 454:                                              changedToServiceRequestService.Serial = serviceToSerialDictionary.ContainsKey(changedToServiceNumber) ? serviceToSerialDictionary[changedToServiceNumber] + 1 : 0;
 455:                                              changedToServiceRequestService.Provisioned = true;
 456:   
 457:                                              lastRequestDateTime = serviceRequest.RequestDateTime;
 458:                                              if (changedToServiceRequestService.LastRequestDateTime < lastRequestDateTime) changedToServiceRequestService.LastRequestDateTime = lastRequestDateTime;
 459:   
 460:                                              if (changedToServiceRequestService != null) serviceToSerialDictionary[changedToServiceRequestService.Service] = changedToServiceRequestService.Serial;
 461:                                          }
 462:                                          else
 463:                                          {
 464:   
 465:                                          }
 466:                                      }
 467:                                      else
 468:                                      {
 469:                                          TelephonyService(serviceRequest, serviceRequestTypeList, ref serviceRequestService);
 470:                                      }
 471:   
 472:                                      lastRequestDateTime = serviceRequest.RequestDateTime;
 473:                                      if (serviceRequestService.LastRequestDateTime < lastRequestDateTime) serviceRequestService.LastRequestDateTime = lastRequestDateTime;
 474:                                  }
 475:   
 476:                                  serviceRequest.ServiceRequestService = serviceRequestService;
 477:                              }
 478:   
 479:                              if (serviceRequestService != null) serviceToSerialDictionary[serviceRequestService.Service] = serviceRequestService.Serial;
 480:                          }
 481:                          else
 482:                          {
 483:                          }
 484:                      }
 485:                  }
 486:              }
 487:   
 488:              return serviceRequestServiceList;
 489:          }
 490:   
 491:          ////////////////////////////////////////////////////////////////////////////
 492:   
 493:          /// <summary>
 494:          ///
 495:          /// </summary>
 496:          public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceFromServiceRequestHistory(List<string> serviceList, List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList)
 497:          {
 498:              int serial, status, serviceType, serviceId;
 499:              string service, serviceSerial, serviceIdIssue;
 500:              DateTime lastRequestDateTime;
 501:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
 502:              Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService serviceSerialRequestService;
 503:              List<string> serviceSerialsToRemoveList;
 504:              List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceSerialRequestServiceList;
 505:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 506:              Dictionary<string, int> serviceToLastSerialDictionary, serviceSerialToStatusDictionary;
 507:              Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestHistoryNumberSerialComplementaryServiceDictionary;
 508:   
 509:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService; // irrelevant?
 510:              serviceIdIssue = string.Empty;
 511:              lastRequestDateTime = DateTime.MinValue;
 512:              serviceSerialsToRemoveList = new List<string>();
 513:              serviceSerialRequestServiceList = new List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
 514:   
 515:              serviceToLastSerialDictionary = new Dictionary<string, int>(serviceRequestHistoryList.Count);
 516:              serviceSerialToStatusDictionary = new Dictionary<string, int>(serviceRequestHistoryList.Count);
 517:   
 518:              serviceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
 519:   
 520:              // create initial serviceRequestServiceList from serviceList with all Provisioned = false records:
 521:   
 522:   
 523:   
 524:   
 525:              // 11. Loop through all srh records by request id ascending
 526:   
 527:              // build service request service from service request histories.
 528:              var list2 = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
 529:              foreach (var serviceRequestHistory in list2)
 530:              {
 531:                  if (Ia.Ngn.Cl.Model.Business.Authority.ServiceRequestHistoryIsAllowedProcessing(serviceRequestHistory))
 532:                  {
 533:                      if (serviceRequestHistory.ServiceCategoryId == 3)
 534:                      {
 535:                          // <category id="3" arabicName="هاتف" />
 536:   
 537:                          service = serviceRequestHistory.Number.ToString();
 538:                          serial = serviceRequestHistory.Serial;
 539:                          serviceId = serviceRequestHistory.ServiceId;
 540:                          status = serviceRequestHistory.Status;
 541:   
 542:                          serviceSerial = service + ":" + serial;
 543:   
 544:                          serviceSerialToStatusDictionary[serviceSerial] = status;
 545:   
 546:                          if (serviceToLastSerialDictionary.ContainsKey(service))
 547:                          {
 548:                              if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
 549:                          }
 550:                          else serviceToLastSerialDictionary[service] = serial;
 551:   
 552:                          if (!serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
 553:                          {
 554:                              if (serviceId == 1 || serviceId == 129 || serviceId == 54)
 555:                              {
 556:                                  // <service id="1" arabicName="خط هاتف" />
 557:                                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 558:                                  // <service id="54" arabicName="اعادة تركيب" />
 559:   
 560:                                  serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
 561:   
 562:                                  serviceSerialRequestService.Id = serviceSerial;
 563:                                  serviceSerialRequestService.Service = service;
 564:                                  serviceSerialRequestService.Serial = serial;
 565:                                  serviceSerialRequestService.Provisioned = true;
 566:   
 567:                                  serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
 568:   
 569:                                  lastRequestDateTime = serviceRequestHistory.ServiceDateTime;
 570:                              }
 571:                              else
 572:                              {
 573:                                  // incomplete service request list for serial
 574:                              }
 575:                          }
 576:                          else
 577:                          {
 578:                              if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
 579:                              {
 580:                                  if (serviceId == 41)
 581:                                  {
 582:                                      // <service id="41" arabicName="تغيير رقم" />
 583:                                  }
 584:                                  else
 585:                                  {
 586:                                      Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyServiceHistory(ref serviceRequestHistoryNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
 587:                                  }
 588:   
 589:                                  lastRequestDateTime = serviceRequestHistory.ServiceDateTime;
 590:                              }
 591:                          }
 592:                      }
 593:                      else
 594:                      {
 595:   
 596:                      }
 597:                  }
 598:   
 599:                  // collect all numbers serials that are not the last in their serial series:
 600:                  foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
 601:                  {
 602:                      if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
 603:                      {
 604:                          if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
 605:                      }
 606:                      else
 607:                      {
 608:                          serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
 609:                      }
 610:                  }
 611:              }
 612:   
 613:              // remove previous service-serials
 614:              foreach (string s in serviceSerialsToRemoveList)
 615:              {
 616:                  serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Remove(s);
 617:              }
 618:   
 619:              // construct serviceRequestServiceList from dictionary
 620:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 621:   
 622:              foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
 623:              {
 624:                  serviceSerial = kvp.Value.Service + ":" + kvp.Value.Serial;
 625:   
 626:                  serviceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService()
 627:                  {
 628:                      Id = kvp.Value.Service + ":1:965",
 629:                      Service = kvp.Value.Service,
 630:                      Serial = kvp.Value.Serial,
 631:                      //Provisioned = kvp.Value.Provisioned,
 632:                      Provisioned = ServiceRequestServiceHistoryProvisionedValueFromStatus(serviceSerialToStatusDictionary[serviceSerial]),
 633:                      CallWaiting = kvp.Value.CallWaiting,
 634:                      InternationalCallingUserControlled = kvp.Value.InternationalCallingUserControlled,
 635:                      CallerId = kvp.Value.CallerId,
 636:                      CallForwarding = kvp.Value.CallForwarding,
 637:                      CallBarring = kvp.Value.CallBarring,
 638:                      ConferenceCall = kvp.Value.ConferenceCall,
 639:                      AbbriviatedCalling = kvp.Value.AbbriviatedCalling,
 640:                      InternationalCalling = kvp.Value.InternationalCalling,
 641:                      AlarmCall = kvp.Value.AlarmCall,
 642:                      WakeupCall = kvp.Value.WakeupCall,
 643:                      BarringOfAllOutgoingCalls = kvp.Value.BarringOfAllOutgoingCalls,
 644:                      BarringOfAllIncomingCalls = kvp.Value.BarringOfAllIncomingCalls,
 645:                      LastRequestDateTime = lastRequestDateTime
 646:                  };
 647:   
 648:                  serviceRequestServiceList.Add(serviceRequestService);
 649:              }
 650:   
 651:              return serviceRequestServiceList;
 652:          }
 653:   
 654:          ////////////////////////////////////////////////////////////////////////////
 655:   
 656:          /// <summary>
 657:          ///
 658:          /// </summary>
 659:          private static bool ServiceRequestServiceHistoryProvisionedValueFromStatus(int status)
 660:          {
 661:              bool provisioned;
 662:   
 663:              if (status == 7001 || status == 7002 || status == 7003 || status == 7004 || status == 7008)
 664:              {
 665:                  /*
 666:          [7001] = "يعمل",
 667:          [7002] = "قطع مؤقت",
 668:          [7003] = "قطع مبرمج",
 669:          [7004] = "قيد التنفيذ",
 670:          [7008] = "قطع معاكسة",
 671:                   */
 672:   
 673:                  provisioned = true;
 674:              }
 675:              else if (status == 7005 || status == 7006 || status == 7009 || status == 7010)
 676:              {
 677:                  /*
 678:          [7005] = "تعذر التنفيذ",
 679:          [7006] = "رفع نهائي",
 680:          [7009] = "ملغى",
 681:          [7010] = "لا يعمل",
 682:                   */
 683:   
 684:                  provisioned = false;
 685:              }
 686:              else
 687:              {
 688:                  provisioned = false;
 689:              }
 690:   
 691:              return provisioned;
 692:          }
 693:   
 694:          ////////////////////////////////////////////////////////////////////////////
 695:   
 696:          /// <summary>
 697:          ///
 698:          /// </summary>
 699:          private static void TelephonyService(Ia.Ngn.Cl.Model.ServiceRequest serviceRequest, List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList, ref Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService)
 700:          {
 701:              Ia.Ngn.Cl.Model.Access access;
 702:   
 703:              if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 39 || serviceRequest.ServiceId == 54)
 704:              {
 705:                  // <service id="1" arabicName="خط هاتف" />
 706:                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 707:                  // <service id="39" arabicName="نقل خارجى" />
 708:                  // <service id="54" arabicName="اعادة تركيب" />
 709:   
 710:                  if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 54)
 711:                  {
 712:                      // <service id="1" arabicName="خط هاتف" />
 713:                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 714:                      // <service id="54" arabicName="اعادة تركيب" />
 715:   
 716:                      // below: keep this here and don't move it out to accommodate 39
 717:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 718:                      {
 719:                          // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 720:                          access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 721:   
 722:                          if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 723:                          else serviceRequestService.Access = null;
 724:                          /*
 725:                           * I will not use statistical estimation for incomplete workorders
 726:                          else
 727:                          {
 728:                              serviceAddress = Ia.Ngn.Cl.Model.Business.ServiceRequest.StatisticalServiceAddress(serviceRequestService.Service, serviceRequest.CustomerAddress, out level);
 729:  
 730:                              if (serviceAddress != null)
 731:                              {
 732:                                  accessList = (from a in db.Accesses where a.AreaId == serviceAddress.AreaId select a).ToList();
 733:  
 734:                                  access = Ia.Ngn.Cl.Model.Data.Access.StatisticalAccess(serviceAddress, ref accessList);
 735:  
 736:                                  if (access != null)
 737:                                  {
 738:                                      serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 739:                                  }
 740:                                  else serviceRequestService.Access = null;
 741:                              }
 742:                              else serviceRequestService.Access = null;
 743:                          }
 744:                          */
 745:                      }
 746:   
 747:                      serviceRequestService.CallerId = false;
 748:   
 749:                      serviceRequestService.AlarmCall = false;
 750:                      serviceRequestService.WakeupCall = false;
 751:   
 752:                      ///serviceRequestService.InternationalCallingUserControlled = true; // as requested by MOC NGN management
 753:                      serviceRequestService.CallWaiting = false;
 754:                      serviceRequestService.CallForwarding = false;
 755:                      serviceRequestService.ConferenceCall = false;
 756:                      serviceRequestService.CallBarring = false;
 757:   
 758:                      if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 54) serviceRequestService.InternationalCalling = false;
 759:                      else if (serviceRequest.ServiceId == 129) serviceRequestService.InternationalCalling = true;
 760:                  }
 761:                  else if (serviceRequest.ServiceId == 39)
 762:                  {
 763:                      // <service id="39" arabicName="نقل خارجى" />
 764:   
 765:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 766:                      {
 767:                          // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 768:                          access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 769:   
 770:                          if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 771:                          //else serviceRequestService.Access = null;
 772:                      }
 773:                  }
 774:              }
 775:              else
 776:              {
 777:                  switch (serviceRequest.ServiceId)
 778:                  {
 779:                      // below: <service id="40" arabicName="رفع خط" />
 780:                      case 40:
 781:                          {
 782:                              // will reset all to false
 783:   
 784:                              serviceRequestService.Provisioned = false;
 785:   
 786:                              serviceRequestService.CallerId = false;
 787:                              serviceRequestService.AlarmCall = false;
 788:                              serviceRequestService.WakeupCall = false;
 789:                              serviceRequestService.InternationalCallingUserControlled = false;
 790:                              serviceRequestService.CallWaiting = false;
 791:                              serviceRequestService.CallForwarding = false;
 792:                              serviceRequestService.ConferenceCall = false;
 793:                              serviceRequestService.CallBarring = false;
 794:                              serviceRequestService.InternationalCalling = false;
 795:   
 796:                              break;
 797:                          }
 798:   
 799:                      // below: <service id="131" arabicName="خط ذهبي"/>
 800:                      case 131: { break; }
 801:   
 802:                      // below: <service id="132" arabicName="خط فضي"/>
 803:                      case 132: { break; }
 804:   
 805:                      // below: <service id="133" arabicName="خط برونزي"/>
 806:                      case 133: { break; }
 807:   
 808:                      // below: <service id="12" arabicName="خدمة الانتظار" />
 809:                      case 12: { serviceRequestService.CallWaiting = true; break; }
 810:   
 811:                      // below: <service id="68" arabicName="إيقاف خدمة الانتظار" />
 812:                      case 68: { serviceRequestService.CallWaiting = false; break; }
 813:   
 814:                      // below: <service id="13" arabicName="التحكم بالصفر الدولي" />
 815:                      case 13: { serviceRequestService.InternationalCallingUserControlled = true; break; }
 816:   
 817:                      // below: <service id="67" arabicName="وقف التحكم بالصفر" />
 818:                      case 67: { serviceRequestService.InternationalCallingUserControlled = false; break; }
 819:   
 820:                      // below: <service id="14" arabicName="كاشف رقم" />
 821:                      case 14: { serviceRequestService.CallerId = true; break; }
 822:   
 823:                      // below: <service id="66" arabicName="إيقاف كاشف" />
 824:                      case 66: { serviceRequestService.CallerId = false; break; }
 825:   
 826:                      // below: <service id="5" arabicName="تحويل مكالمات" />
 827:                      case 5: { serviceRequestService.CallForwarding = true; break; }
 828:   
 829:                      // below: <service id="75" arabicName="إيقاف التحويل" />
 830:                      case 75: { serviceRequestService.CallForwarding = false; break; }
 831:   
 832:                      // below: <service id="20" arabicName="النداء الآلي" />
 833:                      case 20: { serviceRequestService.InternationalCalling = true; break; }
 834:   
 835:                      // below: <service id="19" arabicName="قطع النداء الآلي" />
 836:                      case 19: { serviceRequestService.InternationalCalling = false; break; }
 837:   
 838:                      // below: <service id="38" arabicName="مجموعة الخدمات" />
 839:                      case 38:
 840:                          {
 841:                              serviceRequestService.CallerId = true;
 842:   
 843:                              serviceRequestService.AlarmCall = true;
 844:                              serviceRequestService.WakeupCall = true;
 845:   
 846:                              //serviceRequestService.InternationalCallingUserControlled = true;
 847:                              serviceRequestService.CallWaiting = true;
 848:                              serviceRequestService.CallForwarding = true;
 849:                              serviceRequestService.ConferenceCall = true;
 850:                              break;
 851:                          }
 852:   
 853:                      // below: <service id="62" arabicName="إيقاف مجموعة الخدمات" />
 854:                      case 62:
 855:                          {
 856:                              serviceRequestService.CallerId = false;
 857:   
 858:                              serviceRequestService.AlarmCall = false;
 859:                              serviceRequestService.WakeupCall = false;
 860:   
 861:                              //serviceRequestService.InternationalCallingUserControlled = false;
 862:                              serviceRequestService.CallWaiting = false;
 863:                              serviceRequestService.CallForwarding = false;
 864:                              serviceRequestService.ConferenceCall = false;
 865:                              break;
 866:                          }
 867:   
 868:                      // below: <service id="52" arabicName="قطع حرارة" />
 869:                      case 52: { serviceRequestService.CallBarring = true; break; }
 870:   
 871:                      // below: <service id="53" arabicName="اعادة حرارة" />
 872:                      case 53: { serviceRequestService.CallBarring = false; break; }
 873:   
 874:                      // below: <service id="7" arabicName="منع الاتصال" />
 875:                      case 7: { serviceRequestService.BarringOfAllOutgoingCalls = true; break; }
 876:   
 877:                      // below: <service id="73" arabicName="إيقاف منع الاتصال" />
 878:                      case 73: { serviceRequestService.BarringOfAllOutgoingCalls = false; break; }
 879:   
 880:                      // below: <service id="8" arabicName="ايقاف استقبال" />
 881:                      case 8: { serviceRequestService.BarringOfAllIncomingCalls = true; break; }
 882:   
 883:                      // below: <service id="72" arabicName="رد استقبال" />
 884:                      case 72: { serviceRequestService.BarringOfAllIncomingCalls = false; break; }
 885:   
 886:                      // below: <service id="10" arabicName="خدمة الإيقاظ" />
 887:                      case 10:
 888:                          {
 889:                              serviceRequestService.AlarmCall = true;
 890:                              serviceRequestService.WakeupCall = true;
 891:                              break;
 892:                          }
 893:   
 894:                      // below: <service id="70" arabicName="إيقاف خدمة الإيقاظ" />
 895:                      case 70:
 896:                          {
 897:                              serviceRequestService.AlarmCall = false;
 898:                              serviceRequestService.WakeupCall = false;
 899:                              break;
 900:                          }
 901:   
 902:                      // below: <service id="6" arabicName="استشارة" />
 903:                      case 6: { serviceRequestService.ConferenceCall = true; break; }
 904:   
 905:                      // below: <service id="74" arabicName="إيقاف استشارة" />
 906:                      case 74: { serviceRequestService.ConferenceCall = false; break; }
 907:   
 908:                      // below: <service id="11" arabicName="إختصار الرقم" />
 909:                      case 11: { serviceRequestService.AbbriviatedCalling = true; break; }
 910:   
 911:                      // below: <service id="69" arabicName="إيقاف إختصار الرقم" />
 912:                      case 69: { serviceRequestService.AbbriviatedCalling = false; break; }
 913:   
 914:                      // below: <service id="55" arabicName="مفتاح بدالة" />
 915:                      case 55: { break; }
 916:   
 917:                      // below: <if id="60" name_ar="إيقاف مفتاح بدالة"...
 918:                      case 60: { break; }
 919:   
 920:                      // below: <if id="56" name_ar="فرع بدالة"...
 921:                      case 56: { break; }
 922:   
 923:                      // below: <if id="59" name_ar="إيقاف فرع بدالة"...
 924:                      case 59: { break; }
 925:   
 926:                      // below: <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
 927:                      case 64: { break; }
 928:   
 929:                      // below: <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
 930:                      case 63: { break; }
 931:   
 932:                      // below: <service id="608" arabicName="خط رقمي دسل"/>
 933:                      case 608: { break; }
 934:   
 935:                      // below: <service id="609" arabicName="قطع خط رقمي دسل"/>
 936:                      case 609: { break; }
 937:   
 938:                      // below: <service id="15" arabicName="خدمة المحاسبة" />
 939:                      case 15: { break; }
 940:   
 941:                      // below: <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
 942:                      case 65: { break; }
 943:   
 944:                      // below: <service id="271" arabicName="تغيير اسم"/>
 945:                      case 271: { break; }
 946:   
 947:                      // below: <service id="44" arabicName="تغيير نوع اشتراك" />
 948:                      case 44: { break; }
 949:   
 950:                      // below: <service id="42" arabicName="نقل داخلي" />
 951:                      case 42: { break; }
 952:   
 953:                      // below: <service id="46" arabicName="جهاز كاشف" />
 954:                      case 46: { break; }
 955:   
 956:                      // below: <service id="45" arabicName="تعديل اسم" />
 957:                      case 45: { break; }
 958:   
 959:                      // below: <service id="47" arabicName="جهاز تلفون" />
 960:                      case 47: { break; }
 961:   
 962:                      // below: <service id="49" arabicName="رسوم مودم" />
 963:                      case 49: { break; }
 964:   
 965:                      // below: <service id="37" arabicName="برقية" />
 966:                      case 37: { break; }
 967:   
 968:                      // below: <service id="23" arabicName="مكالمات مصلحية -دفع" />
 969:                      case 23: { break; }
 970:   
 971:                      // below: <service id="17" arabicName="نظام التحويل الآلي/بدالة رئيس" />
 972:                      case 17: { break; }
 973:   
 974:                      // below: <service id="18" arabicName="نظام التحويل الآلي/بدالة فرع" />
 975:                      case 18: { break; }
 976:   
 977:                      // below: <service id="3" arabicName="نداء عاجل" />
 978:                      case 3: { break; }
 979:   
 980:                      // below: <service id="22" arabicName="رسوم كابل" />
 981:                      case 22: { break; }
 982:   
 983:                      // below: <service id="61" arabicName="إيقاف إعادة تركيب" />
 984:                      case 61: { break; }
 985:   
 986:                      // below: <service id="43" arabicName="تنازل" />
 987:                      case 43:
 988:                          {
 989:                              serviceRequestService.Serial++;
 990:                              break;
 991:                          }
 992:   
 993:                      default:
 994:                          {
 995:                              log.AppendLine("TelephonyService(): For ServiceRequest.Number=" + serviceRequest.Number + " ServiceId=" + serviceRequest.ServiceId + " was not recognized. ");
 996:                              break;
 997:                          }
 998:                  }
 999:              }
1000:          }
1001:   
1002:          ////////////////////////////////////////////////////////////////////////////
1003:   
1004:          /// <summary>
1005:          /// 
1006:          /// </summary>
1007:          public static void TelephonyServiceHistory(ref Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestNumberSerialComplementaryServiceDictionary, string serviceSerial, int status, int serviceId, ref string serviceIdIssue)
1008:          {
1009:              if (serviceId == 1 || serviceId == 129 || serviceId == 39 || serviceId == 54)
1010:              {
1011:                  // <service id="1" arabicName="خط هاتف" />
1012:                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
1013:                  // <service id="39" arabicName="نقل خارجى" />
1014:                  // <service id="54" arabicName="اعادة تركيب" />
1015:   
1016:                  if (serviceId == 1 || serviceId == 129 || serviceId == 54)
1017:                  {
1018:                      // <service id="1" arabicName="خط هاتف" />
1019:                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
1020:                      // <service id="54" arabicName="اعادة تركيب" />
1021:   
1022:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
1023:   
1024:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1025:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1026:   
1027:                      ///dic[id].InternationalCallingUserControlled = true; // as requested by NGN management
1028:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
1029:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
1030:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
1031:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false;
1032:   
1033:                      if (serviceId == 1 || serviceId == 54) serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false;
1034:                      else if (serviceId == 129) serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = true;
1035:                  }
1036:                  else if (serviceId == 39)
1037:                  {
1038:                      // <service id="39" arabicName="نقل خارجى" />
1039:                  }
1040:              }
1041:              else
1042:              {
1043:                  switch (serviceId)
1044:                  {
1045:                      // below: <service id="40" arabicName="رفع خط" />
1046:                      case 40:
1047:                          {
1048:                              // - For SRH issues, I will ignore the service رفع خط (<service id="40" arabicName="رفع خط" />) if the number is يعمل (systemCode[7001] = "يعمل") (e.g. 25426947) or number is قطع مبرمج (systemCode[7003] = "قطع مبرمج") (e.g. 25417139)
1049:                              // - Note that status is specific to SRH
1050:   
1051:                              if (status == 7001 || status == 7003) { }
1052:                              else
1053:                              {
1054:                                  // - Will reset all to false
1055:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned = false;
1056:   
1057:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
1058:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1059:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1060:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false;
1061:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
1062:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
1063:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
1064:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false;
1065:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false;
1066:                              }
1067:                              break;
1068:                          }
1069:   
1070:                      // below: <service id="131" arabicName="خط ذهبي"/>
1071:                      case 131: { break; }
1072:   
1073:                      // below: <service id="132" arabicName="خط فضي"/>
1074:                      case 132: { break; }
1075:   
1076:                      // below: <service id="133" arabicName="خط برونزي"/>
1077:                      case 133: { break; }
1078:   
1079:                      // below: <service id="12" arabicName="خدمة الانتظار" />
1080:                      case 12: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = true; break; }
1081:   
1082:                      // below: <service id="68" arabicName="إيقاف خدمة الانتظار" />
1083:                      case 68: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false; break; }
1084:   
1085:                      // below: <service id="13" arabicName="التحكم بالصفر الدولي" />
1086:                      case 13: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = true; break; }
1087:   
1088:                      // below: <service id="67" arabicName="وقف التحكم بالصفر" />
1089:                      case 67: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false; break; }
1090:   
1091:                      // below: <service id="14" arabicName="كاشف رقم" />
1092:                      case 14: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = true; break; }
1093:   
1094:                      // below: <service id="66" arabicName="إيقاف كاشف" />
1095:                      case 66: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false; break; }
1096:   
1097:                      // below: <service id="5" arabicName="تحويل مكالمات" />
1098:                      case 5: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = true; break; }
1099:   
1100:                      // below: <service id="75" arabicName="إيقاف التحويل" />
1101:                      case 75: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false; break; }
1102:   
1103:                      // below: <service id="20" arabicName="النداء الآلي" />
1104:                      case 20: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = true; break; }
1105:   
1106:                      // below: <service id="19" arabicName="قطع النداء الآلي" />
1107:                      case 19: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false; break; }
1108:   
1109:                      // below: <service id="38" arabicName="مجموعة الخدمات" />
1110:                      case 38:
1111:                          {
1112:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = true;
1113:   
1114:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = true;
1115:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = true;
1116:   
1117:                              // serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = true;
1118:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = true;
1119:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = true;
1120:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = true;
1121:   
1122:                              break;
1123:                          }
1124:   
1125:                      // below: <service id="62" arabicName="إيقاف مجموعة الخدمات" />
1126:                      case 62:
1127:                          {
1128:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
1129:   
1130:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1131:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1132:   
1133:                              //serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false;
1134:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
1135:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
1136:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
1137:   
1138:                              break;
1139:                          }
1140:   
1141:                      // below: <service id="52" arabicName="قطع حرارة" />
1142:                      case 52: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = true; break; }
1143:   
1144:                      // below: <service id="53" arabicName="اعادة حرارة" />
1145:                      case 53: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false; break; }
1146:   
1147:                      // below: <service id="7" arabicName="منع الاتصال" />
1148:                      case 7: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllOutgoingCalls = true; break; }
1149:   
1150:                      // below: <service id="73" arabicName="إيقاف منع الاتصال" />
1151:                      case 73: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllOutgoingCalls = false; break; }
1152:   
1153:                      // below: <service id="8" arabicName="ايقاف استقبال" />
1154:                      case 8: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllIncomingCalls = true; break; }
1155:   
1156:                      // below: <service id="72" arabicName="رد استقبال" />
1157:                      case 72: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllIncomingCalls = false; break; }
1158:   
1159:                      // below: <service id="10" arabicName="خدمة الإيقاظ" />
1160:                      case 10:
1161:                          {
1162:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = true;
1163:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = true;
1164:                              break;
1165:                          }
1166:   
1167:                      // below: <service id="70" arabicName="إيقاف خدمة الإيقاظ" />
1168:                      case 70:
1169:                          {
1170:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1171:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1172:                              break;
1173:                          }
1174:   
1175:                      // below: <service id="6" arabicName="استشارة" />
1176:                      case 6: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = true; break; }
1177:   
1178:                      // below: <service id="74" arabicName="إيقاف استشارة" />
1179:                      case 74: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false; break; }
1180:   
1181:                      // below: <service id="11" arabicName="اختصار الرقم" />
1182:                      case 11: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AbbriviatedCalling = true; break; }
1183:   
1184:                      // below: <service id="69" arabicName="إيقاف اختصار الرقم" />
1185:                      case 69: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AbbriviatedCalling = false; break; }
1186:   
1187:                      // below: <service id="55" arabicName="مفتاح بدالة" />
1188:                      case 55: { break; }
1189:   
1190:                      // below: <if id="60" name_ar="إيقاف مفتاح بدالة"...
1191:                      case 60: { break; }
1192:   
1193:                      // below: <if id="56" name_ar="فرع بدالة"...
1194:                      case 56: { break; }
1195:   
1196:                      // below: <if id="59" name_ar="إيقاف فرع بدالة"...
1197:                      case 59: { break; }
1198:   
1199:                      // below: <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
1200:                      case 64: { break; }
1201:   
1202:                      // below: <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
1203:                      case 63: { break; }
1204:   
1205:                      // below: <service id="608" arabicName="خط رقمي دسل"/>
1206:                      case 608: { break; }
1207:   
1208:                      // below: <service id="609" arabicName="قطع خط رقمي دسل"/>
1209:                      case 609: { break; }
1210:   
1211:                      // below: <service id="15" arabicName="خدمة المحاسبة" />
1212:                      case 15: { break; }
1213:   
1214:                      // below: <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
1215:                      case 65: { break; }
1216:   
1217:                      // below: <service id="271" arabicName="تغيير اسم"/>
1218:                      case 271: { break; }
1219:   
1220:                      // below: <service id="44" arabicName="تغيير نوع اشتراك" />
1221:                      case 44: { break; }
1222:   
1223:                      // below: <service id="42" arabicName="نقل داخلي" />
1224:                      case 42: { break; }
1225:   
1226:                      // below: <service id="46" arabicName="جهاز كاشف" />
1227:                      case 46: { break; }
1228:   
1229:                      // below: <service id="45" arabicName="تعديل اسم" />
1230:                      case 45: { break; }
1231:   
1232:                      // below: <service id="47" arabicName="جهاز تلفون" />
1233:                      case 47: { break; }
1234:   
1235:                      // below: <service id="49" arabicName="رسوم مودم" />
1236:                      case 49: { break; }
1237:   
1238:                      // below: <service id="37" arabicName="برقية" />
1239:                      case 37: { break; }
1240:   
1241:                      // below: <service id="23" arabicName="مكالمات مصلحية -دفع" />
1242:                      case 23: { break; }
1243:   
1244:                      // below: <service id="17" arabicName="نظام التحويل الآلي/بدالة رئيس" />
1245:                      case 17: { break; }
1246:   
1247:                      // below: <service id="18" arabicName="نظام التحويل الآلي/بدالة فرع" />
1248:                      case 18: { break; }
1249:   
1250:                      // below: <service id="3" arabicName="نداء عاجل" />
1251:                      case 3: { break; }
1252:   
1253:                      // below: <service id="22" arabicName="رسوم كابل" />
1254:                      case 22: { break; }
1255:   
1256:                      // below: <service id="61" arabicName="إيقاف إعادة تركيب" />
1257:                      case 61: { break; }
1258:   
1259:                      // below: <service id="43" arabicName="تنازل" />
1260:                      case 43:
1261:                          {
1262:                              //serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Serial++; I removed this from History
1263:                              break;
1264:                          }
1265:   
1266:                      default:
1267:                          {
1268:                              serviceIdIssue += "SrsTest(): Service=" + serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Service + " ServiceId=" + serviceId + " was not recognized. " + "\r\n";
1269:                              break;
1270:                          }
1271:                  }
1272:              }
1273:          }
1274:   
1275:          ////////////////////////////////////////////////////////////////////////////
1276:          ////////////////////////////////////////////////////////////////////////////
1277:      }
1278:   
1279:      ////////////////////////////////////////////////////////////////////////////
1280:      ////////////////////////////////////////////////////////////////////////////
1281:  }