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