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

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 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:                  /*
 258:                  if (serviceRequestServiceDefaultList.Count > 0)
 259:                  {
 260:                      serviceRequestServiceList = serviceRequestServiceDefaultList;
 261:                      serviceList = service1List;
 262:  
 263:                      /*
 264:                      serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 265:  
 266:                      foreach (var v in serviceRequestService1List) serviceRequestServiceList.Add(v);
 267:  
 268:                      if (serviceRequestService2List.Count > 0)
 269:                      {
 270:                          serviceList = service1List.Union(service2List).ToList();
 271:  
 272:                          foreach (var v in serviceRequestService2List)
 273:                          {
 274:                              if (!serviceRequestServiceList.Any(u => u.Id == v.Id))
 275:                              {
 276:                                  serviceRequestServiceList.Add(v);
 277:                              }
 278:                          }
 279:                      }
 280:                      else
 281:                      {
 282:                          serviceList = service1List;
 283:                      }
 284:                      * /
 285:                  }
 286:                  else
 287:                  {
 288:                  */
 289:   
 290:                  // SRH
 291:                  // 9. Read all SRHs related to collected numbers
 292:                  serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List(numberList);
 293:   
 294:                  // 8. Collect numbers in string format into int list
 295:                  service2List = (from n in numberList select n.ToString()).ToList<string>();
 296:   
 297:                  if (serviceRequestHistoryList.Count > 0)
 298:                  {
 299:                      serviceRequestServiceHistoryList = ServiceRequestServiceFromServiceRequestHistory(service2List, serviceRequestHistoryList);
 300:   
 301:                      // 12. Remove duplicates (Linq orderyby boolean See http://stackoverflow.com/questions/9481054/linq-orderyby-boolean)
 302:                      serviceRequestServiceHistoryList = serviceRequestServiceHistoryList.OrderByDescending(u => u.Serial).OrderByDescending(u => u.Provisioned).OrderByDescending(u => u.LastRequestDateTime).GroupBy(u => u.Id).Select(u => u.First()).ToList();
 303:                  }
 304:                  else
 305:                  {
 306:                      serviceRequestServiceHistoryList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 307:                  }
 308:   
 309:                  //serviceRequestServiceList = serviceRequestServiceHistoryList;
 310:                  //serviceList = service2List;
 311:                  //}
 312:   
 313:                  foreach (var srsh in serviceRequestServiceHistoryList)
 314:                  {
 315:                      if (!serviceRequestServiceDefaultList.Any(u => u.Id == srsh.Id)) serviceRequestServiceList.Add(srsh);
 316:                  }
 317:                  foreach (var s in service2List) serviceList.Add(s);
 318:   
 319:                  serviceList = serviceList.Distinct().ToList();
 320:   
 321:                  // 13. Update service request services
 322:                  Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateWithServiceList(serviceList, serviceRequestServiceList, out r1);
 323:   
 324:                  // 14. Update service requests with SRS foreign keys
 325:                  Ia.Ngn.Cl.Model.Data.ServiceRequest.UpdateWithServiceList(serviceList, serviceRequestList, out r2);
 326:              }
 327:   
 328:              result = r1 + " " + r2;
 329:          }
 330:   
 331:          ////////////////////////////////////////////////////////////////////////////
 332:   
 333:          /// <summary>
 334:          ///
 335:          /// </summary>
 336:          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)
 337:          {
 338:              int serial, serviceType, serviceId;
 339:              string service, serviceSerial, serviceRequestServiceId, changedToServiceRequestServiceId, changedToServiceNumber;
 340:              DateTime lastRequestDateTime;
 341:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService, changedToServiceRequestService;
 342:              Dictionary<string, int> serviceToSerialDictionary;
 343:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 344:   
 345:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService; // irrelevant?
 346:              lastRequestDateTime = DateTime.MinValue;
 347:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>(serviceRequestList.Count);
 348:              serviceToSerialDictionary = new Dictionary<string, int>();
 349:   
 350:   
 351:              // create initial serviceRequestServiceList from serviceList with all Provisioned = false records:
 352:   
 353:   
 354:              // 11. Loop through all sr records by request id ascending
 355:              var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38).ThenBy(p => p.Id); // <service id="38" arabicName="مجموعة الخدمات" />
 356:              foreach (Ia.Ngn.Cl.Model.ServiceRequest serviceRequest in list) // serviceRequestList.OrderBy(p => p.Id))
 357:              {
 358:                  if (Ia.Ngn.Cl.Model.Business.Authority.ServiceRequestIsAllowedProcessing(serviceRequest))
 359:                  {
 360:                      if (serviceRequest.ServiceCategoryId == 3)
 361:                      {
 362:                          // <category id="3" arabicName="هاتف" />
 363:   
 364:                          if (serviceRequest.Status == 2003 || serviceRequest.Status == 2005)
 365:                          {
 366:                              // <status id="2003" arabicName="قيد التنفيذ" />
 367:                              // <status id="2005" arabicName="تم التنفيذ" />
 368:   
 369:                              service = serviceRequest.Number.ToString();
 370:                              serial = serviceRequest.Serial;
 371:                              serviceId = serviceRequest.ServiceId;
 372:                              serviceSerial = service + ":" + serial;
 373:   
 374:                              serviceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(service, serviceType);
 375:   
 376:                              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();
 377:   
 378:                              if (serviceRequestService == null || serviceRequestService.Provisioned == false)
 379:                              {
 380:                                  if (serviceId == 1 || serviceId == 129 || serviceId == 54)
 381:                                  {
 382:                                      // <service id="1" arabicName="خط هاتف" />
 383:                                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 384:                                      // <service id="54" arabicName="اعادة تركيب" />
 385:   
 386:                                      serviceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
 387:   
 388:                                      serviceRequestService.Id = serviceRequestServiceId;
 389:                                      serviceRequestService.Service = service;
 390:                                      serviceRequestService.Serial = serial;
 391:                                      serviceRequestService.AreaCode = Ia.Ngn.Cl.Model.Business.Service.CountryCode;
 392:                                      serviceRequestService.ServiceType = serviceType;
 393:                                      serviceRequestService.Provisioned = true;
 394:   
 395:                                      TelephonyService(serviceRequest, serviceRequestTypeList, ref serviceRequestService);
 396:   
 397:                                      serviceRequestServiceList.Add(serviceRequestService);
 398:                                      serviceRequest.ServiceRequestService = serviceRequestService;
 399:   
 400:                                      lastRequestDateTime = serviceRequest.RequestDateTime;
 401:                                      if (serviceRequestService.LastRequestDateTime < lastRequestDateTime) serviceRequestService.LastRequestDateTime = lastRequestDateTime;
 402:                                  }
 403:                                  else
 404:                                  {
 405:                                      // incomplete service request list for serial
 406:                                  }
 407:                              }
 408:                              else
 409:                              {
 410:                                  if (serviceRequestService.Provisioned && serviceRequestService.Serial == serial)
 411:                                  {
 412:                                      if (serviceRequest.ServiceId == 41)
 413:                                      {
 414:                                          // <service id="41" arabicName="تغيير رقم" />
 415:   
 416:                                          // below: <type id="11" name="dn" arabicName="dn" oracleFieldName="الرقم الجديد"/>
 417:                                          changedToServiceNumber = (from srt in serviceRequestTypeList where srt.ServiceRequest.Id == serviceRequest.Id && srt.TypeId == 11 && srt.Value != null select srt.Value).SingleOrDefault();
 418:   
 419:                                          if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(changedToServiceNumber)) // important because some numbers are null
 420:                                          {
 421:                                              // Set Provision to false for changed number
 422:                                              serviceRequestService.Provisioned = false;
 423:   
 424:                                              // Create or update entry for new number
 425:                                              changedToServiceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(changedToServiceNumber, serviceType);
 426:   
 427:                                              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();
 428:   
 429:                                              if (changedToServiceRequestService == null)
 430:                                              {
 431:                                                  changedToServiceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
 432:                                                  changedToServiceRequestService.Id = changedToServiceRequestServiceId; // keep here and keep below
 433:   
 434:                                                  serviceRequestServiceList.Add(changedToServiceRequestService);
 435:   
 436:                                                  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();
 437:                                              }
 438:   
 439:                                              changedToServiceRequestService.Copy(serviceRequestService); // order is very important, first Copy then modify
 440:                                              changedToServiceRequestService.Id = changedToServiceRequestServiceId; // keep here and keep above
 441:                                              changedToServiceRequestService.Service = changedToServiceNumber;
 442:                                              // below: you must assign a serial that is an increment of any previously existing serial for the changed-to number, or 0 of non
 443:                                              changedToServiceRequestService.Serial = serviceToSerialDictionary.ContainsKey(changedToServiceNumber) ? serviceToSerialDictionary[changedToServiceNumber] + 1 : 0;
 444:                                              changedToServiceRequestService.Provisioned = true;
 445:   
 446:                                              lastRequestDateTime = serviceRequest.RequestDateTime;
 447:                                              if (changedToServiceRequestService.LastRequestDateTime < lastRequestDateTime) changedToServiceRequestService.LastRequestDateTime = lastRequestDateTime;
 448:   
 449:                                              if (changedToServiceRequestService != null) serviceToSerialDictionary[changedToServiceRequestService.Service] = changedToServiceRequestService.Serial;
 450:                                          }
 451:                                          else
 452:                                          {
 453:   
 454:                                          }
 455:                                      }
 456:                                      else
 457:                                      {
 458:                                          TelephonyService(serviceRequest, serviceRequestTypeList, ref serviceRequestService);
 459:                                      }
 460:   
 461:                                      lastRequestDateTime = serviceRequest.RequestDateTime;
 462:                                      if (serviceRequestService.LastRequestDateTime < lastRequestDateTime) serviceRequestService.LastRequestDateTime = lastRequestDateTime;
 463:                                  }
 464:   
 465:                                  serviceRequest.ServiceRequestService = serviceRequestService;
 466:                              }
 467:   
 468:                              if (serviceRequestService != null) serviceToSerialDictionary[serviceRequestService.Service] = serviceRequestService.Serial;
 469:                          }
 470:                          else
 471:                          {
 472:                          }
 473:                      }
 474:                  }
 475:              }
 476:   
 477:              return serviceRequestServiceList;
 478:          }
 479:   
 480:          ////////////////////////////////////////////////////////////////////////////
 481:   
 482:          /// <summary>
 483:          ///
 484:          /// </summary>
 485:          public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceFromServiceRequestHistory(List<string> serviceList, List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList)
 486:          {
 487:              int serial, status, serviceType, serviceId;
 488:              string service, serviceSerial, serviceIdIssue;
 489:              DateTime lastRequestDateTime;
 490:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
 491:              Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService serviceSerialRequestService;
 492:              List<string> serviceSerialsToRemoveList;
 493:              List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceSerialRequestServiceList;
 494:              List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 495:              Dictionary<string, int> serviceToLastSerialDictionary;
 496:              Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestHistoryNumberSerialComplementaryServiceDictionary;
 497:   
 498:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService; // irrelevant?
 499:              serviceIdIssue = string.Empty;
 500:              lastRequestDateTime = DateTime.MinValue;
 501:              serviceSerialsToRemoveList = new List<string>();
 502:              serviceSerialRequestServiceList = new List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
 503:   
 504:              serviceToLastSerialDictionary = new Dictionary<string, int>(serviceRequestHistoryList.Count);
 505:   
 506:              serviceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
 507:   
 508:              // create initial serviceRequestServiceList from serviceList with all Provisioned = false records:
 509:   
 510:   
 511:   
 512:   
 513:              // 11. Loop through all srh records by request id ascending
 514:   
 515:              // build service request service from service request histories.
 516:              var list2 = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
 517:              foreach (var serviceRequestHistory in list2)
 518:              {
 519:                  if (Ia.Ngn.Cl.Model.Business.Authority.ServiceRequestHistoryIsAllowedProcessing(serviceRequestHistory))
 520:                  {
 521:                      if (serviceRequestHistory.ServiceCategoryId == 3)
 522:                      {
 523:                          // <category id="3" arabicName="هاتف" />
 524:                          service = serviceRequestHistory.Number.ToString();
 525:                          serial = serviceRequestHistory.Serial;
 526:                          serviceId = serviceRequestHistory.ServiceId;
 527:                          status = serviceRequestHistory.Status;
 528:   
 529:                          serviceSerial = service + ":" + serial;
 530:   
 531:                          if (serviceToLastSerialDictionary.ContainsKey(service))
 532:                          {
 533:                              if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
 534:                          }
 535:                          else serviceToLastSerialDictionary[service] = serial;
 536:   
 537:                          if (!serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
 538:                          {
 539:                              if (serviceId == 1 || serviceId == 129 || serviceId == 54)
 540:                              {
 541:                                  // <service id="1" arabicName="خط هاتف" />
 542:                                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 543:                                  // <service id="54" arabicName="اعادة تركيب" />
 544:   
 545:                                  serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
 546:   
 547:                                  serviceSerialRequestService.Id = serviceSerial;
 548:                                  serviceSerialRequestService.Service = service;
 549:                                  serviceSerialRequestService.Serial = serial;
 550:                                  serviceSerialRequestService.Provisioned = true;
 551:   
 552:                                  serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
 553:   
 554:                                  lastRequestDateTime = serviceRequestHistory.ServiceDateTime;
 555:                              }
 556:                              else
 557:                              {
 558:                                  // incomplete service request list for serial
 559:                              }
 560:                          }
 561:                          else
 562:                          {
 563:                              if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
 564:                              {
 565:                                  if (serviceId == 41)
 566:                                  {
 567:                                      // <service id="41" arabicName="تغيير رقم" />
 568:                                  }
 569:                                  else
 570:                                  {
 571:                                      Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyService2(ref serviceRequestHistoryNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
 572:                                  }
 573:   
 574:                                  lastRequestDateTime = serviceRequestHistory.ServiceDateTime;
 575:                              }
 576:                          }
 577:                      }
 578:                  }
 579:   
 580:                  // collect all numbers serials that are not the last in their serial series:
 581:                  foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
 582:                  {
 583:                      if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
 584:                      {
 585:                          if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
 586:                      }
 587:                      else
 588:                      {
 589:                          serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
 590:                      }
 591:                  }
 592:              }
 593:   
 594:              // remove previous service-serials
 595:              foreach (string s in serviceSerialsToRemoveList)
 596:              {
 597:                  serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Remove(s);
 598:              }
 599:   
 600:              // construct serviceRequestServiceList from dictionary
 601:              serviceRequestServiceList = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
 602:   
 603:              foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
 604:              {
 605:                  serviceRequestService = new Model.ServiceRequestService()
 606:                  {
 607:                      Id = kvp.Value.Service + ":1:965",
 608:                      Service = kvp.Value.Service,
 609:                      Serial = kvp.Value.Serial,
 610:                      Provisioned = kvp.Value.Provisioned,
 611:                      CallWaiting = kvp.Value.CallWaiting,
 612:                      InternationalCallingUserControlled = kvp.Value.InternationalCallingUserControlled,
 613:                      CallerId = kvp.Value.CallerId,
 614:                      CallForwarding = kvp.Value.CallForwarding,
 615:                      CallBarring = kvp.Value.CallBarring,
 616:                      ConferenceCall = kvp.Value.ConferenceCall,
 617:                      AbbriviatedCalling = kvp.Value.AbbriviatedCalling,
 618:                      InternationalCalling = kvp.Value.InternationalCalling,
 619:                      AlarmCall = kvp.Value.AlarmCall,
 620:                      WakeupCall = kvp.Value.WakeupCall,
 621:                      BarringOfAllOutgoingCalls = kvp.Value.BarringOfAllOutgoingCalls,
 622:                      BarringOfAllIncomingCalls = kvp.Value.BarringOfAllIncomingCalls,
 623:                      LastRequestDateTime = lastRequestDateTime
 624:                  };
 625:   
 626:                  serviceRequestServiceList.Add(serviceRequestService);
 627:              }
 628:   
 629:              return serviceRequestServiceList;
 630:          }
 631:   
 632:          ////////////////////////////////////////////////////////////////////////////
 633:   
 634:          /// <summary>
 635:          ///
 636:          /// </summary>
 637:          private static void TelephonyService(Ia.Ngn.Cl.Model.ServiceRequest serviceRequest, List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList, ref Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService)
 638:          {
 639:              Ia.Ngn.Cl.Model.Access access;
 640:   
 641:              if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 39 || serviceRequest.ServiceId == 54)
 642:              {
 643:                  // <service id="1" arabicName="خط هاتف" />
 644:                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 645:                  // <service id="39" arabicName="نقل خارجى" />
 646:                  // <service id="54" arabicName="اعادة تركيب" />
 647:   
 648:                  if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 129 || serviceRequest.ServiceId == 54)
 649:                  {
 650:                      // <service id="1" arabicName="خط هاتف" />
 651:                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 652:                      // <service id="54" arabicName="اعادة تركيب" />
 653:   
 654:                      // below: keep this here and don't move it out to accommodate 39
 655:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 656:                      {
 657:                          // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 658:                          access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 659:   
 660:                          if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 661:                          else serviceRequestService.Access = null;
 662:                          /*
 663:                           * I will not use statistical estimation for incomplete workorders
 664:                          else
 665:                          {
 666:                              serviceAddress = Ia.Ngn.Cl.Model.Business.ServiceRequest.StatisticalServiceAddress(serviceRequestService.Service, serviceRequest.CustomerAddress, out level);
 667:  
 668:                              if (serviceAddress != null)
 669:                              {
 670:                                  accessList = (from a in db.Accesses where a.AreaId == serviceAddress.AreaId select a).ToList();
 671:  
 672:                                  access = Ia.Ngn.Cl.Model.Data.Access.StatisticalAccess(serviceAddress, ref accessList);
 673:  
 674:                                  if (access != null)
 675:                                  {
 676:                                      serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 677:                                  }
 678:                                  else serviceRequestService.Access = null;
 679:                              }
 680:                              else serviceRequestService.Access = null;
 681:                          }
 682:                          */
 683:                      }
 684:   
 685:                      serviceRequestService.CallerId = false;
 686:   
 687:                      serviceRequestService.AlarmCall = false;
 688:                      serviceRequestService.WakeupCall = false;
 689:   
 690:                      ///serviceRequestService.InternationalCallingUserControlled = true; // as requested by MOC NGN management
 691:                      serviceRequestService.CallWaiting = false;
 692:                      serviceRequestService.CallForwarding = false;
 693:                      serviceRequestService.ConferenceCall = false;
 694:                      serviceRequestService.CallBarring = false;
 695:   
 696:                      if (serviceRequest.ServiceId == 1 || serviceRequest.ServiceId == 54) serviceRequestService.InternationalCalling = false;
 697:                      else if (serviceRequest.ServiceId == 129) serviceRequestService.InternationalCalling = true;
 698:                  }
 699:                  else if (serviceRequest.ServiceId == 39)
 700:                  {
 701:                      // <service id="39" arabicName="نقل خارجى" />
 702:   
 703:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 704:                      {
 705:                          // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
 706:                          access = Ia.Ngn.Cl.Model.Business.ServiceRequestType.ExtractAccess(serviceRequest.Id, serviceRequestTypeList);
 707:   
 708:                          if (access != null) serviceRequestService.Access = (from a in db.Accesses where a.Id == access.Id select a).SingleOrDefault();
 709:                          //else serviceRequestService.Access = null;
 710:                      }
 711:                  }
 712:              }
 713:              else
 714:              {
 715:                  switch (serviceRequest.ServiceId)
 716:                  {
 717:                      // below: <service id="40" arabicName="رفع خط" />
 718:                      case 40:
 719:                          {
 720:                              // will reset all to false
 721:   
 722:                              serviceRequestService.Provisioned = false;
 723:   
 724:                              serviceRequestService.CallerId = false;
 725:                              serviceRequestService.AlarmCall = false;
 726:                              serviceRequestService.WakeupCall = false;
 727:                              serviceRequestService.InternationalCallingUserControlled = false;
 728:                              serviceRequestService.CallWaiting = false;
 729:                              serviceRequestService.CallForwarding = false;
 730:                              serviceRequestService.ConferenceCall = false;
 731:                              serviceRequestService.CallBarring = false;
 732:                              serviceRequestService.InternationalCalling = false;
 733:   
 734:                              break;
 735:                          }
 736:   
 737:                      // below: <service id="131" arabicName="خط ذهبي"/>
 738:                      case 131: { break; }
 739:   
 740:                      // below: <service id="132" arabicName="خط فضي"/>
 741:                      case 132: { break; }
 742:   
 743:                      // below: <service id="133" arabicName="خط برونزي"/>
 744:                      case 133: { break; }
 745:   
 746:                      // below: <service id="12" arabicName="خدمة الانتظار" />
 747:                      case 12: { serviceRequestService.CallWaiting = true; break; }
 748:   
 749:                      // below: <service id="68" arabicName="إيقاف خدمة الانتظار" />
 750:                      case 68: { serviceRequestService.CallWaiting = false; break; }
 751:   
 752:                      // below: <service id="13" arabicName="التحكم بالصفر الدولي" />
 753:                      case 13: { serviceRequestService.InternationalCallingUserControlled = true; break; }
 754:   
 755:                      // below: <service id="67" arabicName="وقف التحكم بالصفر" />
 756:                      case 67: { serviceRequestService.InternationalCallingUserControlled = false; break; }
 757:   
 758:                      // below: <service id="14" arabicName="كاشف رقم" />
 759:                      case 14: { serviceRequestService.CallerId = true; break; }
 760:   
 761:                      // below: <service id="66" arabicName="إيقاف كاشف" />
 762:                      case 66: { serviceRequestService.CallerId = false; break; }
 763:   
 764:                      // below: <service id="5" arabicName="تحويل مكالمات" />
 765:                      case 5: { serviceRequestService.CallForwarding = true; break; }
 766:   
 767:                      // below: <service id="75" arabicName="إيقاف التحويل" />
 768:                      case 75: { serviceRequestService.CallForwarding = false; break; }
 769:   
 770:                      // below: <service id="20" arabicName="النداء الآلي" />
 771:                      case 20: { serviceRequestService.InternationalCalling = true; break; }
 772:   
 773:                      // below: <service id="19" arabicName="قطع النداء الآلي" />
 774:                      case 19: { serviceRequestService.InternationalCalling = false; break; }
 775:   
 776:                      // below: <service id="38" arabicName="مجموعة الخدمات" />
 777:                      case 38:
 778:                          {
 779:                              serviceRequestService.CallerId = true;
 780:   
 781:                              serviceRequestService.AlarmCall = true;
 782:                              serviceRequestService.WakeupCall = true;
 783:   
 784:                              //serviceRequestService.InternationalCallingUserControlled = true;
 785:                              serviceRequestService.CallWaiting = true;
 786:                              serviceRequestService.CallForwarding = true;
 787:                              serviceRequestService.ConferenceCall = true;
 788:                              break;
 789:                          }
 790:   
 791:                      // below: <service id="62" arabicName="إيقاف مجموعة الخدمات" />
 792:                      case 62:
 793:                          {
 794:                              serviceRequestService.CallerId = false;
 795:   
 796:                              serviceRequestService.AlarmCall = false;
 797:                              serviceRequestService.WakeupCall = false;
 798:   
 799:                              //serviceRequestService.InternationalCallingUserControlled = false;
 800:                              serviceRequestService.CallWaiting = false;
 801:                              serviceRequestService.CallForwarding = false;
 802:                              serviceRequestService.ConferenceCall = false;
 803:                              break;
 804:                          }
 805:   
 806:                      // below: <service id="52" arabicName="قطع حرارة" />
 807:                      case 52: { serviceRequestService.CallBarring = true; break; }
 808:   
 809:                      // below: <service id="53" arabicName="اعادة حرارة" />
 810:                      case 53: { serviceRequestService.CallBarring = false; break; }
 811:   
 812:                      // below: <service id="7" arabicName="منع الاتصال" />
 813:                      case 7: { serviceRequestService.BarringOfAllOutgoingCalls = true; break; }
 814:   
 815:                      // below: <service id="73" arabicName="إيقاف منع الاتصال" />
 816:                      case 73: { serviceRequestService.BarringOfAllOutgoingCalls = false; break; }
 817:   
 818:                      // below: <service id="8" arabicName="ايقاف استقبال" />
 819:                      case 8: { serviceRequestService.BarringOfAllIncomingCalls = true; break; }
 820:   
 821:                      // below: <service id="72" arabicName="رد استقبال" />
 822:                      case 72: { serviceRequestService.BarringOfAllIncomingCalls = false; break; }
 823:   
 824:                      // below: <service id="10" arabicName="خدمة الإيقاظ" />
 825:                      case 10:
 826:                          {
 827:                              serviceRequestService.AlarmCall = true;
 828:                              serviceRequestService.WakeupCall = true;
 829:                              break;
 830:                          }
 831:   
 832:                      // below: <service id="70" arabicName="إيقاف خدمة الإيقاظ" />
 833:                      case 70:
 834:                          {
 835:                              serviceRequestService.AlarmCall = false;
 836:                              serviceRequestService.WakeupCall = false;
 837:                              break;
 838:                          }
 839:   
 840:                      // below: <service id="6" arabicName="استشارة" />
 841:                      case 6: { serviceRequestService.ConferenceCall = true; break; }
 842:   
 843:                      // below: <service id="74" arabicName="إيقاف استشارة" />
 844:                      case 74: { serviceRequestService.ConferenceCall = false; break; }
 845:   
 846:                      // below: <service id="11" arabicName="إختصار الرقم" />
 847:                      case 11: { serviceRequestService.AbbriviatedCalling = true; break; }
 848:   
 849:                      // below: <service id="69" arabicName="إيقاف إختصار الرقم" />
 850:                      case 69: { serviceRequestService.AbbriviatedCalling = false; break; }
 851:   
 852:                      // below: <service id="55" arabicName="مفتاح بدالة" />
 853:                      case 55: { break; }
 854:   
 855:                      // below: <if id="60" name_ar="إيقاف مفتاح بدالة"...
 856:                      case 60: { break; }
 857:   
 858:                      // below: <if id="56" name_ar="فرع بدالة"...
 859:                      case 56: { break; }
 860:   
 861:                      // below: <if id="59" name_ar="إيقاف فرع بدالة"...
 862:                      case 59: { break; }
 863:   
 864:                      // below: <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
 865:                      case 64: { break; }
 866:   
 867:                      // below: <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
 868:                      case 63: { break; }
 869:   
 870:                      // below: <service id="608" arabicName="خط رقمي دسل"/>
 871:                      case 608: { break; }
 872:   
 873:                      // below: <service id="609" arabicName="قطع خط رقمي دسل"/>
 874:                      case 609: { break; }
 875:   
 876:                      // below: <service id="15" arabicName="خدمة المحاسبة" />
 877:                      case 15: { break; }
 878:   
 879:                      // below: <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
 880:                      case 65: { break; }
 881:   
 882:                      // below: <service id="271" arabicName="تغيير اسم"/>
 883:                      case 271: { break; }
 884:   
 885:                      // below: <service id="44" arabicName="تغيير نوع اشتراك" />
 886:                      case 44: { break; }
 887:   
 888:                      // below: <service id="42" arabicName="نقل داخلي" />
 889:                      case 42: { break; }
 890:   
 891:                      // below: <service id="46" arabicName="جهاز كاشف" />
 892:                      case 46: { break; }
 893:   
 894:                      // below: <service id="45" arabicName="تعديل اسم" />
 895:                      case 45: { break; }
 896:   
 897:                      // below: <service id="47" arabicName="جهاز تلفون" />
 898:                      case 47: { break; }
 899:   
 900:                      // below: <service id="49" arabicName="رسوم مودم" />
 901:                      case 49: { break; }
 902:   
 903:                      // below: <service id="37" arabicName="برقية" />
 904:                      case 37: { break; }
 905:   
 906:                      // below: <service id="23" arabicName="مكالمات مصلحية -دفع" />
 907:                      case 23: { break; }
 908:   
 909:                      // below: <service id="17" arabicName="نظام التحويل الآلي/بدالة رئيس" />
 910:                      case 17: { break; }
 911:   
 912:                      // below: <service id="18" arabicName="نظام التحويل الآلي/بدالة فرع" />
 913:                      case 18: { break; }
 914:   
 915:                      // below: <service id="3" arabicName="نداء عاجل" />
 916:                      case 3: { break; }
 917:   
 918:                      // below: <service id="22" arabicName="رسوم كابل" />
 919:                      case 22: { break; }
 920:   
 921:                      // below: <service id="61" arabicName="إيقاف إعادة تركيب" />
 922:                      case 61: { break; }
 923:   
 924:                      // below: <service id="43" arabicName="تنازل" />
 925:                      case 43:
 926:                          {
 927:                              serviceRequestService.Serial++;
 928:                              break;
 929:                          }
 930:   
 931:                      default:
 932:                          {
 933:                              log.AppendLine("TelephonyService(): For ServiceRequest.Number=" + serviceRequest.Number + " ServiceId=" + serviceRequest.ServiceId + " was not recognized. ");
 934:                              break;
 935:                          }
 936:                  }
 937:              }
 938:          }
 939:   
 940:          ////////////////////////////////////////////////////////////////////////////
 941:   
 942:          /// <summary>
 943:          /// 
 944:          /// </summary>
 945:          public static void TelephonyService2(ref Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestNumberSerialComplementaryServiceDictionary, string serviceSerial, int status, int serviceId, ref string serviceIdIssue)
 946:          {
 947:              if (serviceId == 1 || serviceId == 129 || serviceId == 39 || serviceId == 54)
 948:              {
 949:                  // <service id="1" arabicName="خط هاتف" />
 950:                  // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 951:                  // <service id="39" arabicName="نقل خارجى" />
 952:                  // <service id="54" arabicName="اعادة تركيب" />
 953:   
 954:                  if (serviceId == 1 || serviceId == 129 || serviceId == 54)
 955:                  {
 956:                      // <service id="1" arabicName="خط هاتف" />
 957:                      // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
 958:                      // <service id="54" arabicName="اعادة تركيب" />
 959:   
 960:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
 961:   
 962:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
 963:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
 964:   
 965:                      ///dic[id].InternationalCallingUserControlled = true; // as requested by NGN management
 966:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
 967:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
 968:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
 969:                      serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false;
 970:   
 971:                      if (serviceId == 1 || serviceId == 54) serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false;
 972:                      else if (serviceId == 129) serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = true;
 973:                  }
 974:                  else if (serviceId == 39)
 975:                  {
 976:                      // <service id="39" arabicName="نقل خارجى" />
 977:                  }
 978:              }
 979:              else
 980:              {
 981:                  switch (serviceId)
 982:                  {
 983:                      // below: <service id="40" arabicName="رفع خط" />
 984:                      case 40:
 985:                          {
 986:                              // - 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)
 987:                              // - Note that status is specific to SRH
 988:   
 989:                              if (status == 7001 || status == 7003) { }
 990:                              else
 991:                              {
 992:                                  // - Will reset all to false
 993:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned = false;
 994:   
 995:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
 996:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
 997:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
 998:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false;
 999:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
1000:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
1001:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
1002:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false;
1003:                                  serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false;
1004:                              }
1005:                              break;
1006:                          }
1007:   
1008:                      // below: <service id="131" arabicName="خط ذهبي"/>
1009:                      case 131: { break; }
1010:   
1011:                      // below: <service id="132" arabicName="خط فضي"/>
1012:                      case 132: { break; }
1013:   
1014:                      // below: <service id="133" arabicName="خط برونزي"/>
1015:                      case 133: { break; }
1016:   
1017:                      // below: <service id="12" arabicName="خدمة الانتظار" />
1018:                      case 12: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = true; break; }
1019:   
1020:                      // below: <service id="68" arabicName="إيقاف خدمة الانتظار" />
1021:                      case 68: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false; break; }
1022:   
1023:                      // below: <service id="13" arabicName="التحكم بالصفر الدولي" />
1024:                      case 13: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = true; break; }
1025:   
1026:                      // below: <service id="67" arabicName="وقف التحكم بالصفر" />
1027:                      case 67: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false; break; }
1028:   
1029:                      // below: <service id="14" arabicName="كاشف رقم" />
1030:                      case 14: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = true; break; }
1031:   
1032:                      // below: <service id="66" arabicName="إيقاف كاشف" />
1033:                      case 66: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false; break; }
1034:   
1035:                      // below: <service id="5" arabicName="تحويل مكالمات" />
1036:                      case 5: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = true; break; }
1037:   
1038:                      // below: <service id="75" arabicName="إيقاف التحويل" />
1039:                      case 75: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false; break; }
1040:   
1041:                      // below: <service id="20" arabicName="النداء الآلي" />
1042:                      case 20: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = true; break; }
1043:   
1044:                      // below: <service id="19" arabicName="قطع النداء الآلي" />
1045:                      case 19: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCalling = false; break; }
1046:   
1047:                      // below: <service id="38" arabicName="مجموعة الخدمات" />
1048:                      case 38:
1049:                          {
1050:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = true;
1051:   
1052:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = true;
1053:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = true;
1054:   
1055:                              // serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = true;
1056:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = true;
1057:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = true;
1058:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = true;
1059:   
1060:                              break;
1061:                          }
1062:   
1063:                      // below: <service id="62" arabicName="إيقاف مجموعة الخدمات" />
1064:                      case 62:
1065:                          {
1066:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallerId = false;
1067:   
1068:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1069:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1070:   
1071:                              //serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].InternationalCallingUserControlled = false;
1072:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallWaiting = false;
1073:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallForwarding = false;
1074:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false;
1075:   
1076:                              break;
1077:                          }
1078:   
1079:                      // below: <service id="52" arabicName="قطع حرارة" />
1080:                      case 52: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = true; break; }
1081:   
1082:                      // below: <service id="53" arabicName="اعادة حرارة" />
1083:                      case 53: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].CallBarring = false; break; }
1084:   
1085:                      // below: <service id="7" arabicName="منع الاتصال" />
1086:                      case 7: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllOutgoingCalls = true; break; }
1087:   
1088:                      // below: <service id="73" arabicName="إيقاف منع الاتصال" />
1089:                      case 73: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllOutgoingCalls = false; break; }
1090:   
1091:                      // below: <service id="8" arabicName="ايقاف استقبال" />
1092:                      case 8: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllIncomingCalls = true; break; }
1093:   
1094:                      // below: <service id="72" arabicName="رد استقبال" />
1095:                      case 72: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].BarringOfAllIncomingCalls = false; break; }
1096:   
1097:                      // below: <service id="10" arabicName="خدمة الإيقاظ" />
1098:                      case 10:
1099:                          {
1100:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = true;
1101:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = true;
1102:                              break;
1103:                          }
1104:   
1105:                      // below: <service id="70" arabicName="إيقاف خدمة الإيقاظ" />
1106:                      case 70:
1107:                          {
1108:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AlarmCall = false;
1109:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].WakeupCall = false;
1110:                              break;
1111:                          }
1112:   
1113:                      // below: <service id="6" arabicName="استشارة" />
1114:                      case 6: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = true; break; }
1115:   
1116:                      // below: <service id="74" arabicName="إيقاف استشارة" />
1117:                      case 74: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].ConferenceCall = false; break; }
1118:   
1119:                      // below: <service id="11" arabicName="اختصار الرقم" />
1120:                      case 11: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AbbriviatedCalling = true; break; }
1121:   
1122:                      // below: <service id="69" arabicName="إيقاف اختصار الرقم" />
1123:                      case 69: { serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].AbbriviatedCalling = false; break; }
1124:   
1125:                      // below: <service id="55" arabicName="مفتاح بدالة" />
1126:                      case 55: { break; }
1127:   
1128:                      // below: <if id="60" name_ar="إيقاف مفتاح بدالة"...
1129:                      case 60: { break; }
1130:   
1131:                      // below: <if id="56" name_ar="فرع بدالة"...
1132:                      case 56: { break; }
1133:   
1134:                      // below: <if id="59" name_ar="إيقاف فرع بدالة"...
1135:                      case 59: { break; }
1136:   
1137:                      // below: <service id="64" arabicName="ايقاف التحويل الآلي/بدالة رئيس" />
1138:                      case 64: { break; }
1139:   
1140:                      // below: <service id="63" arabicName="ايقاف التحويل الآلي/بدالة فرع" />
1141:                      case 63: { break; }
1142:   
1143:                      // below: <service id="608" arabicName="خط رقمي دسل"/>
1144:                      case 608: { break; }
1145:   
1146:                      // below: <service id="609" arabicName="قطع خط رقمي دسل"/>
1147:                      case 609: { break; }
1148:   
1149:                      // below: <service id="15" arabicName="خدمة المحاسبة" />
1150:                      case 15: { break; }
1151:   
1152:                      // below: <service id="65" arabicName="إيقاف المحاسبة الذاتية" />
1153:                      case 65: { break; }
1154:   
1155:                      // below: <service id="271" arabicName="تغيير اسم"/>
1156:                      case 271: { break; }
1157:   
1158:                      // below: <service id="44" arabicName="تغيير نوع اشتراك" />
1159:                      case 44: { break; }
1160:   
1161:                      // below: <service id="42" arabicName="نقل داخلي" />
1162:                      case 42: { break; }
1163:   
1164:                      // below: <service id="46" arabicName="جهاز كاشف" />
1165:                      case 46: { break; }
1166:   
1167:                      // below: <service id="45" arabicName="تعديل اسم" />
1168:                      case 45: { break; }
1169:   
1170:                      // below: <service id="47" arabicName="جهاز تلفون" />
1171:                      case 47: { break; }
1172:   
1173:                      // below: <service id="49" arabicName="رسوم مودم" />
1174:                      case 49: { break; }
1175:   
1176:                      // below: <service id="37" arabicName="برقية" />
1177:                      case 37: { break; }
1178:   
1179:                      // below: <service id="23" arabicName="مكالمات مصلحية -دفع" />
1180:                      case 23: { break; }
1181:   
1182:                      // below: <service id="17" arabicName="نظام التحويل الآلي/بدالة رئيس" />
1183:                      case 17: { break; }
1184:   
1185:                      // below: <service id="18" arabicName="نظام التحويل الآلي/بدالة فرع" />
1186:                      case 18: { break; }
1187:   
1188:                      // below: <service id="3" arabicName="نداء عاجل" />
1189:                      case 3: { break; }
1190:   
1191:                      // below: <service id="22" arabicName="رسوم كابل" />
1192:                      case 22: { break; }
1193:   
1194:                      // below: <service id="61" arabicName="إيقاف إعادة تركيب" />
1195:                      case 61: { break; }
1196:   
1197:                      // below: <service id="43" arabicName="تنازل" />
1198:                      case 43:
1199:                          {
1200:                              serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Serial++;
1201:                              break;
1202:                          }
1203:   
1204:                      default:
1205:                          {
1206:                              serviceIdIssue += "SrsTest(): Service=" + serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Service + " ServiceId=" + serviceId + " was not recognized. " + "\r\n";
1207:                              break;
1208:                          }
1209:                  }
1210:              }
1211:          }
1212:   
1213:          ////////////////////////////////////////////////////////////////////////////
1214:          ////////////////////////////////////////////////////////////////////////////
1215:      }
1216:   
1217:      ////////////////////////////////////////////////////////////////////////////
1218:      ////////////////////////////////////////////////////////////////////////////
1219:  }