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

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

Service Request API Controller class of Fixed Telecommunications Network (FTN) model.

    1: using Microsoft.AspNetCore.Identity;
    2: using Microsoft.AspNetCore.Mvc;
    3: using System.Runtime.Serialization;
    4:  
    5: namespace Ia.Ftn.Api.Wa.Controllers
    6: {
    7:     ////////////////////////////////////////////////////////////////////////////
    8:  
    9:     /// <summary publish="true">
   10:     /// Service Request API Controller class of Fixed Telecommunications Network (FTN) model.
   11:     /// </summary>
   12:     /// 
   13:     /// <remarks> 
   14:     /// Copyright © 2021-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   15:     /// </remarks> 
   16:     [ApiController]
   17:     // [Authorize]
   18:     public class ServiceRequestController : ControllerBase
   19:     {
   20:         private readonly UserManager<Ia.Ftn.Cl.Models.StaffIdentityUser> userManager;
   21:  
   22:         //private static readonly object objectLock = new object();
   23:  
   24:         ////////////////////////////////////////////////////////////////////////////
   25:  
   26:         /// <summary>
   27:         /// Service Request: List service request numbers within the Fixed Telecommunications Network
   28:         /// </summary>
   29:         public ServiceRequestController() { }
   30:  
   31:         /////////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         ///
   35:         /// </summary>
   36:         public ServiceRequestController(UserManager<Ia.Ftn.Cl.Models.StaffIdentityUser> _userManager)
   37:         {
   38:             userManager = _userManager;
   39:         }
   40:  
   41:         /*
   42:         ////////////////////////////////////////////////////////////////////////////
   43:         ////////////////////////////////////////////////////////////////////////////
   44: 
   45:         /// <summary>
   46:         ///
   47:         /// </summary>
   48:         [HttpGet]
   49:         [Route("api/v1/service-requests/system-codes")]
   50:         public Dictionary<int, string> SystemCode()
   51:         {
   52:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.SystemCode;
   53:         }
   54: 
   55:         ////////////////////////////////////////////////////////////////////////////
   56: 
   57:         /// <summary>
   58:         ///
   59:         /// </summary>
   60:         [HttpGet]
   61:         [Route("api/v1/service-requests/service-categories")]
   62:         public SortedList ServiceCategory()
   63:         {
   64:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.ServiceCategorySortedList;
   65:         }
   66: 
   67:         ////////////////////////////////////////////////////////////////////////////
   68: 
   69:         /// <summary>
   70:         ///
   71:         /// </summary>
   72:         [HttpGet]
   73:         [Route("api/v1/service-requests/services")]
   74:         public SortedList Service()
   75:         {
   76:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.ServiceSortedList;
   77:         }
   78: 
   79:         ////////////////////////////////////////////////////////////////////////////
   80: 
   81:         /// <summary>
   82:         ///
   83:         /// </summary>
   84:         [HttpGet]
   85:         [Route("api/v1/service-requests/customer-categories")]
   86:         public SortedList CustomerCategory()
   87:         {
   88:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.CustomerCategorySortedList;
   89:         }
   90: 
   91:         ////////////////////////////////////////////////////////////////////////////
   92: 
   93:         /// <summary>
   94:         ///
   95:         /// </summary>
   96:         [HttpGet]
   97:         [Route("api/v1/service-requests/status")]
   98:         public SortedList Status()
   99:         {
  100:             return Ia.Ftn.Cl.Models.Data.ServiceRequest.StatusSortedList;
  101:         }
  102:         */
  103:  
  104:         ////////////////////////////////////////////////////////////////////////////
  105:  
  106:         /// <summary>
  107:         ///
  108:         /// </summary>
  109:         [DataContract(IsReference = true, Namespace = "kw.com.ia.ofn.api.serviceRequest", Name = "PostCreateServiceRequestResponse")]
  110:         public class PostCreateServiceRequestResponse
  111:         {
  112:             /// <summary/>
  113:             [DataMember]
  114:             public string Id { get; set; }
  115:  
  116:             /// <summary/>
  117:             [DataMember]
  118:             public string Service { get; set; }
  119:  
  120:             /// <summary/>
  121:             [DataMember]
  122:             public string AccessName { get; set; }
  123:  
  124:             /// <summary/>
  125:             [DataMember]
  126:             public bool IsWithinAllowedToBeProvisionedDomainList { get; set; }
  127:  
  128:             /// <summary/>
  129:             [DataMember]
  130:             public bool HasValidAction { get; set; }
  131:  
  132:             /// <summary/>
  133:             [DataMember]
  134:             public bool CallerId { get; set; }
  135:  
  136:             /// <summary/>
  137:             [DataMember]
  138:             public bool InternationalCalling { get; set; }
  139:  
  140:             /// <summary/>
  141:             [DataMember]
  142:             public bool InternationalCallingUserControlled { get; set; }
  143:  
  144:             /// <summary/>
  145:             [DataMember]
  146:             public bool CallForwarding { get; set; }
  147:  
  148:             /// <summary/>
  149:             [DataMember]
  150:             public bool CallWaiting { get; set; }
  151:  
  152:             /// <summary/>
  153:             [DataMember]
  154:             public bool ConferenceCall { get; set; }
  155:  
  156:             /// <summary/>
  157:             [DataMember]
  158:             public bool WakeupCall { get; set; }
  159:  
  160:             /// <summary/>
  161:             [DataMember]
  162:             public bool AbbriviatedCalling { get; set; }
  163:  
  164:             /// <summary/>
  165:             [DataMember]
  166:             public DateTime RequestDateTime { get; set; }
  167:  
  168:             /// <summary/>
  169:             [DataMember]
  170:             public bool IsSuccessful { get; set; }
  171:         }
  172:  
  173:         ////////////////////////////////////////////////////////////////////////////
  174:  
  175:         /// <summary>
  176:         /// Post (create) a service request with action and complementary service
  177:         /// </summary>
  178:         [HttpPost]
  179:         [Route("api/v1/service-requests")]
  180:         public PostCreateServiceRequestResponse PostCreateServiceRequest(string service, string action, string accessName, string callerId, string internationalCalling, string internationalCallingUserControlled, string callForwardingCounterpart, string callWaiting, string conferenceCall, string wakeupCall, string abbriviatedCalling)
  181:         {
  182:             bool isWithinAllowedToBeProvisionedDomainList, hasValidAction, hasCallerId, hasInternationalCalling, hasInternationalCallingUserControlled, hasCallForwarding, hasCallWaiting, hasConferenceCall, hasWakeupCall, hasAbbriviatedCalling, isSuccessful;
  183:             DateTime requestDateTime;
  184:  
  185:             requestDateTime = DateTime.UtcNow.AddHours(3);
  186:  
  187:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  188:             {
  189:                 isWithinAllowedToBeProvisionedDomainList = true;
  190:  
  191:                 hasCallerId = (!string.IsNullOrEmpty(callerId) && callerId.ToUpper() == "Y");
  192:                 hasInternationalCalling = (!string.IsNullOrEmpty(internationalCalling) && internationalCalling.ToUpper() == "Y");
  193:                 hasInternationalCallingUserControlled = (!string.IsNullOrEmpty(internationalCallingUserControlled) && internationalCallingUserControlled.ToUpper() == "Y");
  194:                 hasCallForwarding = (!string.IsNullOrEmpty(callForwardingCounterpart) && callForwardingCounterpart.ToUpper() == "Y");
  195:                 hasCallWaiting = (!string.IsNullOrEmpty(callWaiting) && callWaiting.ToUpper() == "Y");
  196:                 hasConferenceCall = (!string.IsNullOrEmpty(conferenceCall) && conferenceCall.ToUpper() == "Y");
  197:                 hasWakeupCall = (!string.IsNullOrEmpty(wakeupCall) && wakeupCall.ToUpper() == "Y");
  198:                 hasAbbriviatedCalling = (!string.IsNullOrEmpty(abbriviatedCalling) && abbriviatedCalling.ToUpper() == "Y");
  199:  
  200:                 /*
  201:                 var dataTable = new DataTable();
  202:                 service = SRV_NO.ToString();
  203: 
  204:                 dataTable = new DataTable();
  205:                 dataTable.TableName = @"SRV_NO = " + service + "+ order by SRV_REQ_ID asc";
  206:                 dataTable.Columns.Add("SRV_REQ_ID", typeof(int));
  207:                 dataTable.Columns.Add("SRV_NO", typeof(int));
  208:                 dataTable.Columns.Add("ADDRESS", typeof(string));
  209:                 dataTable.Columns.Add("CUST_CAT_ID", typeof(int));
  210:                 dataTable.Columns.Add("ACCOUNT_NO", typeof(int));
  211:                 dataTable.Columns.Add("NAME", typeof(string));
  212:                 dataTable.Columns.Add("REQ_DATE", typeof(DateTime));
  213:                 dataTable.Columns.Add("SRV_SER_NO", typeof(int));
  214:                 dataTable.Columns.Add("SRV_CAT_ID", typeof(int));
  215:                 dataTable.Columns.Add("SRV_ID", typeof(int));
  216:                 dataTable.Columns.Add("BALANCE", typeof(double));
  217:                 dataTable.Columns.Add("STATUS", typeof(int));
  218: 
  219:                 dataTable.Rows.Add(SRV_REQ_ID, SRV_NO, ADDRESS, CUST_CAT_ID, ACCOUNT_NO, NAME, REQ_DATE, SRV_SER_NO, SRV_CAT_ID, SRV_ID, BALANCE, STATUS);
  220: 
  221:                 Ia.Ftn.Cl.Models.Data.ServiceRequest.UpdateForServiceRequestWithOutputDataTableAndService(dataTable, service, out isUpdated, out result);
  222: 
  223:                 Ia.Ftn.Cl.Models.Data.Default.Log(" _PostServiceRequest(): " + SRV_REQ_ID);
  224:                 */
  225:  
  226:                 var port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown.ToString();
  227:  
  228:                 switch (action)
  229:                 {
  230:                     case "1":
  231:                         {
  232:                             InsertServiceExemption(service);
  233:  
  234:                             EnqueueCreateReadOrDeleteRead(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort, service, accessName, port, false);
  235:  
  236:                             hasValidAction = true;
  237:                             isSuccessful = true;
  238:  
  239:                             break;
  240:                         }
  241:  
  242:                     case "2":
  243:                         {
  244:                             InsertServiceExemption(service);
  245:  
  246:                             /* public enum SupplementaryService
  247:                              * {
  248:                              *   CallerId = 1, InternationalCalling, InternationalCallingUserControlled, CallForwarding, CallWaiting, ConferenceCall, WakeupCall, AbbriviatedCalling, ServiceSuspension
  249:                              * };
  250:                              */
  251:  
  252:                             if (hasCallerId) EnqueueSetReadButton(service, "1");
  253:                             if (hasInternationalCalling) EnqueueSetReadButton(service, "2");
  254:                             if (hasInternationalCallingUserControlled) EnqueueSetReadButton(service, "3");
  255:                             if (hasCallForwarding) EnqueueSetReadButton(service, "4");
  256:                             if (hasCallWaiting) EnqueueSetReadButton(service, "5");
  257:                             if (hasConferenceCall) EnqueueSetReadButton(service, "6");
  258:                             if (hasWakeupCall) EnqueueSetReadButton(service, "7");
  259:                             if (hasAbbriviatedCalling) EnqueueSetReadButton(service, "8");
  260:  
  261:                             hasValidAction = true;
  262:                             isSuccessful = true;
  263:  
  264:                             break;
  265:                         }
  266:  
  267:                     case "3":
  268:                         {
  269:                             InsertServiceExemption(service);
  270:  
  271:                             EnqueueCreateReadOrDeleteRead(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess, service, accessName, port, false);
  272:  
  273:                             hasValidAction = true;
  274:                             isSuccessful = true;
  275:  
  276:                             break;
  277:                         }
  278:  
  279:                     default:
  280:                         {
  281:                             hasValidAction = false;
  282:                             isSuccessful = false;
  283:  
  284:                             break;
  285:                         }
  286:                 }
  287:             }
  288:             else
  289:             {
  290:                 isWithinAllowedToBeProvisionedDomainList = false;
  291:                 hasValidAction = false;
  292:                 hasCallerId = false;
  293:                 hasInternationalCalling = false;
  294:                 hasInternationalCallingUserControlled = false;
  295:                 hasCallForwarding = false;
  296:                 hasCallWaiting = false;
  297:                 hasConferenceCall = false;
  298:                 hasWakeupCall = false;
  299:                 hasAbbriviatedCalling = false;
  300:                 isSuccessful = false;
  301:             }
  302:  
  303:             var postCreateServiceRequestResponse = new PostCreateServiceRequestResponse
  304:             {
  305:                 Service = service,
  306:                 AccessName = accessName,
  307:                 IsWithinAllowedToBeProvisionedDomainList = isWithinAllowedToBeProvisionedDomainList,
  308:                 HasValidAction = hasValidAction,
  309:                 CallerId = hasCallerId,
  310:                 InternationalCalling = hasInternationalCalling,
  311:                 InternationalCallingUserControlled = hasInternationalCallingUserControlled,
  312:                 CallForwarding = hasCallForwarding,
  313:                 CallWaiting = hasCallWaiting,
  314:                 ConferenceCall = hasConferenceCall,
  315:                 WakeupCall = hasWakeupCall,
  316:                 AbbriviatedCalling = hasAbbriviatedCalling,
  317:                 RequestDateTime = requestDateTime,
  318:                 IsSuccessful = isSuccessful
  319:             };
  320:  
  321:             return postCreateServiceRequestResponse;
  322:         }
  323:  
  324:         ////////////////////////////////////////////////////////////////////////////
  325:         ////////////////////////////////////////////////////////////////////////////
  326:  
  327:         /// <summary>
  328:         ///
  329:         /// </summary>
  330:         [DataContract(IsReference = true, Namespace = "kw.com.ia.ofn.api.serviceRequest", Name = "GetReadServiceRequestResponse")]
  331:         public class GetReadServiceRequestResponse
  332:         {
  333:             /// <summary/>
  334:             [DataMember]
  335:             public string Id { get; set; }
  336:  
  337:             /// <summary/>
  338:             [DataMember]
  339:             public string Service { get; set; }
  340:  
  341:             /// <summary/>
  342:             [DataMember]
  343:             public string AccessName { get; set; }
  344:  
  345:             /// <summary/>
  346:             [DataMember]
  347:             public bool IsWithinAllowedToBeProvisionedDomainList { get; set; }
  348:  
  349:             /// <summary/>
  350:             [DataMember]
  351:             public bool CallerId { get; set; }
  352:  
  353:             /// <summary/>
  354:             [DataMember]
  355:             public bool InternationalCalling { get; set; }
  356:  
  357:             /// <summary/>
  358:             [DataMember]
  359:             public bool InternationalCallingUserControlled { get; set; }
  360:  
  361:             /// <summary/>
  362:             [DataMember]
  363:             public bool CallForwarding { get; set; }
  364:  
  365:             /// <summary/>
  366:             [DataMember]
  367:             public bool CallWaiting { get; set; }
  368:  
  369:             /// <summary/>
  370:             [DataMember]
  371:             public bool ConferenceCall { get; set; }
  372:  
  373:             /// <summary/>
  374:             [DataMember]
  375:             public bool WakeupCall { get; set; }
  376:  
  377:             /// <summary/>
  378:             [DataMember]
  379:             public bool AbbriviatedCalling { get; set; }
  380:  
  381:             /// <summary/>
  382:             [DataMember]
  383:             public bool ServiceIsSuspended { get; set; }
  384:  
  385:             /// <summary/>
  386:             [DataMember]
  387:             public DateTime RequestDateTime { get; set; }
  388:  
  389:             /// <summary/>
  390:             [DataMember]
  391:             public bool IsSuccessful { get; set; }
  392:         }
  393:  
  394:         ////////////////////////////////////////////////////////////////////////////
  395:  
  396:         /// <summary>
  397:         /// Get (read) a service request list by service
  398:         /// </summary>
  399:         [HttpGet]
  400:         [Route("api/v1/service-requests")]
  401:         public List<GetReadServiceRequestResponse> GetReadServiceRequestByService(string service)
  402:         {
  403:             bool isWithinAllowedToBeProvisionedDomainList/*, hasCallerId, hasInternationalCalling, hasInternationalCallingUserControlled, hasCallForwarding, hasCallWaiting, hasConferenceCall, hasWakeupCall, hasAbbriviatedCalling, ServiceIsSuspended*/, isSuccessful;
  404:             //string accessName;
  405:  
  406:             var responseList = new List<GetReadServiceRequestResponse>();
  407:  
  408:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  409:             {
  410:                 isWithinAllowedToBeProvisionedDomainList = true;
  411:                 isSuccessful = true;
  412:  
  413:                 var list = Ia.Ftn.Cl.Models.Data.ServiceRequest.List(service);
  414:  
  415:                 foreach (var item in list)
  416:                 {
  417:                     responseList.Add(new GetReadServiceRequestResponse
  418:                     {
  419:                         Service = service,
  420:                         AccessName = string.Empty,
  421:                         IsWithinAllowedToBeProvisionedDomainList = isWithinAllowedToBeProvisionedDomainList,
  422:                         CallerId = false,
  423:                         InternationalCalling = false,
  424:                         InternationalCallingUserControlled = false,
  425:                         CallForwarding = false,
  426:                         CallWaiting = false,
  427:                         ConferenceCall = false,
  428:                         WakeupCall = false,
  429:                         AbbriviatedCalling = false,
  430:                         ServiceIsSuspended = false,
  431:                         RequestDateTime = item.RequestDateTime,
  432:                         IsSuccessful = isSuccessful
  433:                     });
  434:                 }
  435:             }
  436:             else
  437:             {
  438:                 isWithinAllowedToBeProvisionedDomainList = false;
  439:                 isSuccessful = false;
  440:  
  441:                 responseList.Add(new GetReadServiceRequestResponse
  442:                 {
  443:                     Service = service,
  444:                     AccessName = string.Empty,
  445:                     IsWithinAllowedToBeProvisionedDomainList = isWithinAllowedToBeProvisionedDomainList,
  446:                     CallerId = false,
  447:                     InternationalCalling = false,
  448:                     InternationalCallingUserControlled = false,
  449:                     CallForwarding = false,
  450:                     CallWaiting = false,
  451:                     ConferenceCall = false,
  452:                     WakeupCall = false,
  453:                     AbbriviatedCalling = false,
  454:                     ServiceIsSuspended = false,
  455:                     RequestDateTime = DateTime.MinValue,
  456:                     IsSuccessful = isSuccessful
  457:                 });
  458:             }
  459:  
  460:             Ia.Ftn.Cl.Models.Data.Default.Log("GetReadServiceRequesttByService(): " + service);
  461:  
  462:             return responseList;
  463:         }
  464:  
  465:         ////////////////////////////////////////////////////////////////////////////
  466:         ////////////////////////////////////////////////////////////////////////////
  467:  
  468:         /// <summary>
  469:         ///
  470:         /// </summary>
  471:         [DataContract(IsReference = true, Namespace = "kw.com.ia.ofn.api.serviceRequest", Name = "DeleteDeleteServiceRequestResponse")]
  472:         public class DeleteDeleteServiceRequestResponse
  473:         {
  474:             /// <summary/>
  475:             [DataMember]
  476:             public string Id { get; set; }
  477:  
  478:             /// <summary/>
  479:             [DataMember]
  480:             public string Service { get; set; }
  481:  
  482:             /// <summary/>
  483:             [DataMember]
  484:             public string AccessName { get; set; }
  485:  
  486:             /// <summary/>
  487:             [DataMember]
  488:             public bool IsWithinAllowedToBeProvisionedDomainList { get; set; }
  489:  
  490:             /// <summary/>
  491:             [DataMember]
  492:             public DateTime RequestDateTime { get; set; }
  493:  
  494:             /// <summary/>
  495:             [DataMember]
  496:             public bool IsSuccessful { get; set; }
  497:         }
  498:  
  499:         ////////////////////////////////////////////////////////////////////////////
  500:  
  501:         /// <summary>
  502:         /// Delete (delete) a service request by id
  503:         /// </summary>
  504:         [HttpDelete]
  505:         [Route("api/v1/service-requests")]
  506:         public DeleteDeleteServiceRequestResponse DeleteDeleteServiceRequestById(string id)
  507:         {
  508:             bool isWithinAllowedToBeProvisionedDomainList, isSuccessful;
  509:             //string accessName;
  510:             DateTime requestDateTime;
  511:  
  512:             requestDateTime = DateTime.UtcNow.AddHours(3);
  513:  
  514:             /*
  515:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  516:             {
  517:                 isWithinAllowedToBeProvisionedDomainList = true;
  518: 
  519:                 // var list = Ia.Ftn.Cl.Models.Data.ServiceRequest.List(service);
  520: 
  521: 
  522: 
  523: 
  524:                 isSuccessful = false;
  525:             }
  526:             else
  527:             {
  528:                 isWithinAllowedToBeProvisionedDomainList = false;
  529:                 isSuccessful = false;
  530:             }
  531:             */
  532:  
  533:             isWithinAllowedToBeProvisionedDomainList = false;
  534:             isSuccessful = false;
  535:  
  536:             Ia.Ftn.Cl.Models.Data.Default.Log("DeleteDeleteServiceRequesttByService(): " + id);
  537:  
  538:             var deleteServiceRequestResponse = new DeleteDeleteServiceRequestResponse
  539:             {
  540:                 Id = id,
  541:                 IsWithinAllowedToBeProvisionedDomainList = isWithinAllowedToBeProvisionedDomainList,
  542:                 RequestDateTime = requestDateTime,
  543:                 IsSuccessful = isSuccessful
  544:             };
  545:  
  546:             return deleteServiceRequestResponse;
  547:         }
  548:  
  549:         /*
  550:         ////////////////////////////////////////////////////////////////////////////
  551: 
  552:         /// <summary>
  553:         /// List service request by id
  554:         /// </summary>
  555:         [HttpGet]
  556:         [Route("api/v1/service-requests/{id}")]
  557:         public List<Ia.Ftn.Cl.Models.ServiceRequest> ListById(int id)
  558:         {
  559:             var list = Ia.Ftn.Cl.Models.Data.ServiceRequest.ListById(id);
  560: 
  561:             Ia.Ftn.Cl.Models.Data.Default.Log(" ListById(): " + id);
  562: 
  563:             return list;
  564:         }
  565:         */
  566:  
  567:         ////////////////////////////////////////////////////////////////////////////
  568:  
  569:         /// <summary>
  570:         ///
  571:         /// </summary>
  572:         protected static string EnqueueCreateReadOrDeleteRead(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service0, string accessName0, string port0, bool overrideRouterDomainRestriction)
  573:         {
  574:             string service, accessName, port, accessNameOrEmpty, serviceTaskResult;
  575:             Ia.Cl.Models.Result result;
  576:             Ia.Ftn.Cl.Models.Access access;
  577:  
  578:             result = new Ia.Cl.Models.Result();
  579:  
  580:             if (!string.IsNullOrEmpty(service0))
  581:             {
  582:                 service = service0.Trim();
  583:  
  584:                 if (service.Length > 0)
  585:                 {
  586:                     if (int.TryParse(service, out int number))
  587:                     {
  588:                         if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  589:                         {
  590:                             port = port0.Trim();
  591:  
  592:                             if (string.IsNullOrEmpty(port)) port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown.ToString();
  593:  
  594:                             if (int.TryParse(port, out int portNumber))
  595:                             {
  596:                                 if (portNumber >= Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown && portNumber <= Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts)
  597:                                 {
  598:                                     if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort)
  599:                                     {
  600:                                         if (Ia.Ftn.Cl.Models.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
  601:                                         {
  602:                                             if (!string.IsNullOrEmpty(accessName0))
  603:                                             {
  604:                                                 accessName = accessName0.Trim();
  605:  
  606:                                                 if (accessName.Length > 0)
  607:                                                 {
  608:                                                     if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  609:                                                     {
  610:                                                         access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  611:  
  612:                                                         if (access != null)
  613:                                                         {
  614:                                                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessPortTask(process, service, access.Name, portNumber, overrideRouterDomainRestriction, null, out result);
  615:                                                         }
  616:                                                         else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف). ");
  617:                                                     }
  618:                                                     else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة). ");
  619:                                                 }
  620:                                                 else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  621:                                             }
  622:                                             else result.AddError("Can't create a Nokia service without an access. AccessName is null or empty. (لم يتم إدخال جهاز لتركيب رقم نوكيا). ");
  623:                                         }
  624:                                         else if (Ia.Ftn.Cl.Models.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
  625:                                         {
  626:                                             if (!string.IsNullOrEmpty(accessName0))
  627:                                             {
  628:                                                 accessName = accessName0.Trim();
  629:  
  630:                                                 if (accessName.Length > 0)
  631:                                                 {
  632:                                                     if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  633:                                                     {
  634:                                                         access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  635:  
  636:                                                         if (access != null)
  637:                                                         {
  638:                                                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, access.Name, overrideRouterDomainRestriction, null, out result);
  639:                                                         }
  640:                                                         else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف). ");
  641:                                                     }
  642:                                                     else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة). ");
  643:                                                 }
  644:                                                 else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  645:                                             }
  646:                                             else
  647:                                             {
  648:                                                 Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, string.Empty, overrideRouterDomainRestriction, null, out result);
  649:                                             }
  650:                                         }
  651:                                         else result.AddError("No input was entered for access (لم يتم إدخال جهاز). ");
  652:                                     }
  653:                                     else if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  654:                                     {
  655:                                         if (!string.IsNullOrEmpty(accessName0))
  656:                                         {
  657:                                             accessName = accessName0.Trim();
  658:  
  659:                                             if (accessName.Length > 0)
  660:                                             {
  661:                                                 if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  662:                                                 {
  663:                                                     access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  664:  
  665:                                                     if (access != null) accessNameOrEmpty = access.Name;
  666:                                                     else accessNameOrEmpty = string.Empty;
  667:                                                 }
  668:                                                 else accessNameOrEmpty = string.Empty;
  669:                                             }
  670:                                             else accessNameOrEmpty = string.Empty;
  671:                                         }
  672:                                         else accessNameOrEmpty = string.Empty;
  673:  
  674:                                         Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, accessNameOrEmpty, overrideRouterDomainRestriction, null, out result);
  675:                                     }
  676:                                     else throw new ArgumentOutOfRangeException("RabbitMQ process " + process.ToString() + " is undefined");
  677:                                 }
  678:                                 else result.AddError(@"The port number """ + port + @""" is out of range. Should be between " + Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown + " and " + Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts + " inclusive. (رقم المدخل خارج نطاق المقبول");
  679:                             }
  680:                             else result.AddError(@"The port number """ + port + @""" is not empty or a valid number (ليس خاليا ولا رقماَ). ");
  681:                         }
  682:                         else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  683:                     }
  684:                     else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ). ");
  685:                 }
  686:                 else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  687:             }
  688:             else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  689:  
  690:             if (result.IsSuccessful)
  691:             {
  692:                 if (result.HasWarning)
  693:                 {
  694:                     serviceTaskResult = result.Message + result.Warning;
  695:                 }
  696:                 else
  697:                 {
  698:                     serviceTaskResult = result.Message;
  699:                 }
  700:             }
  701:             else
  702:             {
  703:                 serviceTaskResult = result.Error;
  704:             }
  705:  
  706:             return serviceTaskResult;
  707:         }
  708:  
  709:         ////////////////////////////////////////////////////////////////////////////
  710:         ////////////////////////////////////////////////////////////////////////////
  711:  
  712:         /// <summary>
  713:         ///
  714:         /// </summary>
  715:         protected static string EnqueueSetReadButton(string service, string supplementaryService)
  716:         {
  717:             string serviceSupplementaryServiceTaskResult;
  718:  
  719:             var result = new Ia.Cl.Models.Result();
  720:  
  721:             var selectedItem = supplementaryService;
  722:  
  723:             if (!string.IsNullOrEmpty(service))
  724:             {
  725:                 service = service.Trim();
  726:  
  727:                 if (service.Length > 0)
  728:                 {
  729:                     if (int.TryParse(service, out int number))
  730:                     {
  731:                         if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  732:                         {
  733:                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.SupplementaryServiceTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService, service, selectedItem, true, null, out result);
  734:                         }
  735:                         else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  736:                     }
  737:                     else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ). ");
  738:                 }
  739:                 else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  740:             }
  741:             else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  742:  
  743:             if (result.IsSuccessful)
  744:             {
  745:                 if (result.HasWarning)
  746:                 {
  747:                     serviceSupplementaryServiceTaskResult = result.Message + result.Warning;
  748:                 }
  749:                 else
  750:                 {
  751:                     serviceSupplementaryServiceTaskResult = result.Message;
  752:                 }
  753:             }
  754:             else
  755:             {
  756:                 serviceSupplementaryServiceTaskResult = result.Error;
  757:             }
  758:  
  759:             return serviceSupplementaryServiceTaskResult;
  760:         }
  761:  
  762:         ////////////////////////////////////////////////////////////////////////////
  763:  
  764:         /// <summary>
  765:         ///
  766:         /// </summary>
  767:         protected static string EnqueueResetReadButton(UserManager<Ia.Ftn.Cl.Models.StaffIdentityUser> userManager, string service, string supplementaryService)
  768:         {
  769:             string serviceSupplementaryServiceTaskResult;
  770:  
  771:             var result = new Ia.Cl.Models.Result();
  772:  
  773:             var selectedItem = supplementaryService;
  774:  
  775:             if (!string.IsNullOrEmpty(service))
  776:             {
  777:                 service = service.Trim();
  778:  
  779:                 if (service.Length > 0)
  780:                 {
  781:                     if (int.TryParse(service, out int number))
  782:                     {
  783:                         if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  784:                         {
  785:                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.SupplementaryServiceTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService, service, selectedItem, false, null, out result);
  786:                         }
  787:                         else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  788:                     }
  789:                     else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ). ");
  790:                 }
  791:                 else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  792:             }
  793:             else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  794:  
  795:             if (result.IsSuccessful)
  796:             {
  797:                 if (result.HasWarning)
  798:                 {
  799:                     serviceSupplementaryServiceTaskResult = result.Message + result.Warning;
  800:                 }
  801:                 else
  802:                 {
  803:                     serviceSupplementaryServiceTaskResult = result.Message;
  804:                 }
  805:             }
  806:             else
  807:             {
  808:                 serviceSupplementaryServiceTaskResult = result.Error;
  809:             }
  810:  
  811:             return serviceSupplementaryServiceTaskResult;
  812:         }
  813:  
  814:         ////////////////////////////////////////////////////////////////////////////
  815:         ////////////////////////////////////////////////////////////////////////////
  816:  
  817:         /// <summary>
  818:         ///
  819:         /// </summary>
  820:         protected static string InsertServiceExemption(string service)
  821:         {
  822:             string id, note, serviceExemptionId, result;
  823:             DateTime now;
  824:             Ia.Ftn.Cl.Models.ServiceExemption serviceExemption;
  825:  
  826:             note = "New billing system service request order test";
  827:  
  828:             now = DateTime.UtcNow.AddHours(3);
  829:  
  830:             id = Ia.Ftn.Cl.Models.ServiceExemption.ServiceServiceExemptionId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
  831:  
  832:             var serviceExemption0 = Ia.Ftn.Cl.Models.Data.ServiceExemption.Read(id);
  833:  
  834:             if (serviceExemption0 == null)
  835:             {
  836:                 serviceExemption = new Ia.Ftn.Cl.Models.ServiceExemption()
  837:                 {
  838:                     Id = id,
  839:                     Service = service,
  840:                     Note = note,
  841:                     StaffIdentityUser = null,
  842:                     Created = now,
  843:                     Updated = now
  844:                 };
  845:  
  846:                 serviceExemptionId = Ia.Ftn.Cl.Models.Data.ServiceExemption.Create(serviceExemption, out result);
  847:  
  848:                 if (!string.IsNullOrEmpty(serviceExemptionId))
  849:                 {
  850:                     result = "Success: Service \"" + service + "\" added to exemption list (تمت إضافة الرقم للقائمة).";
  851:                 }
  852:                 else
  853:                 {
  854:                 }
  855:             }
  856:             else
  857:             {
  858:                 result = "The service \"" + service + "\" already exists in the list (الرقم ينتمي للقائمة).";
  859:             }
  860:  
  861:             return result;
  862:         }
  863:  
  864:         ////////////////////////////////////////////////////////////////////////////
  865:         ////////////////////////////////////////////////////////////////////////////
  866:     }
  867: }