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

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

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