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

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

Service Request API Controller class of Optical Fiber Network (OFN) model.

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