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

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

    1: using Microsoft.AspNetCore.Mvc.Rendering;
    2: using System.Data;
    3: using System.Net;
    4:  
    5: namespace Ia.Ftn.Wa.Models.Provision
    6: {
    7:     ////////////////////////////////////////////////////////////////////////////
    8:  
    9:     /// <summary publish="true">
   10:     ///
   11:     /// </summary>
   12:     /// 
   13:     /// <remarks> 
   14:     /// Copyright © 2006-2025 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:     public static class Service
   27:     {
   28:         ////////////////////////////////////////////////////////////////////////////
   29:  
   30:         /// <summary>
   31:         ///
   32:         /// </summary>
   33:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
   34:         {
   35:             // http://ftn/provision/service.aspx?service=25233434&accessName=SHD.20.11
   36:  
   37:             //serviceViewModel.ServiceInput = serviceViewModel.ServiceSupplementaryServiceInput = Request.QueryString["service"] != null ? WebUtility.HtmlDecode(Request.QueryString["service"].ToString()) : string.Empty;
   38:             //serviceViewModel.AccessNameInput = Request.QueryString["accessName"] != null ? WebUtility.HtmlDecode(Request.QueryString["accessName"].ToString()) : string.Empty;
   39:  
   40:             SupplementaryServiceSelectList_ViewModel(ref serviceViewModel);
   41:  
   42:             Page_ViewModel(ref serviceViewModel);
   43:         }
   44:  
   45:         ////////////////////////////////////////////////////////////////////////////
   46:  
   47:         /// <summary>
   48:         ///
   49:         /// </summary>
   50:         public static void Post(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel, string commandName)
   51:         {
   52:             if (commandName == "createReadServiceTask") EnqueueCreateRead(ref serviceViewModel);
   53:             else if (commandName == "deleteReadServiceTask") EnqueueDeleteRead(ref serviceViewModel);
   54:             else if (commandName == "supplementaryServiceSetReadTask") EnqueueSetRead(ref serviceViewModel);
   55:             else if (commandName == "supplementaryServiceResetReadTask") EnqueueResetRead(ref serviceViewModel);
   56:             else
   57:             {
   58:             }
   59:         }
   60:  
   61:         ////////////////////////////////////////////////////////////////////////////
   62:         ////////////////////////////////////////////////////////////////////////////
   63:  
   64:         /// <summary>
   65:         ///
   66:         /// </summary>
   67:         private static void Page_ViewModel(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
   68:         {
   69:             serviceViewModel.Label = "1-" + Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts;
   70:  
   71:             serviceViewModel.CreateDeleteReadServiceTaskButtonEnabled = serviceViewModel.SupplementaryServiceSetResetReadTaskButtonEnabled = (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser)) ? true : false;
   72:  
   73:             serviceViewModel.CreateDeleteReadServiceTaskButtonEnabled = serviceViewModel.OverrideRouterDomainRestrictionCheckBoxEnabled = Ia.Ftn.Cl.Models.Business.Authority.StaffCanOverrideRouterDomainRestrictionInCreatingService(serviceViewModel.CurrentStaffIdentityUser);
   74:         }
   75:  
   76:         ////////////////////////////////////////////////////////////////////////////
   77:  
   78:         /// <summary>
   79:         ///
   80:         /// </summary>
   81:         private static void SupplementaryServiceSelectList_ViewModel(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
   82:         {
   83:             string itemValue, itemText;
   84:             var supplementaryServiceList = Enum.GetValues(typeof(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService));
   85:             var supplementaryServiceArabicDictionary = Ia.Ftn.Cl.Models.Business.Service.SupplementaryServiceArabicDictionary;
   86:  
   87:             var supplementaryServiceSelectList = new List<SelectListItem>();
   88:  
   89:             if (supplementaryServiceList.Length == supplementaryServiceArabicDictionary.Count)
   90:             {
   91:                 for (var i = 0; i < supplementaryServiceList.Length; i++)
   92:                 {
   93:                     itemValue = supplementaryServiceList.GetValue(i).ToString();
   94:                     itemText = supplementaryServiceList.GetValue(i) + " (" + supplementaryServiceArabicDictionary[(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService)supplementaryServiceList.GetValue(i)] + ")";
   95:  
   96:                     supplementaryServiceSelectList.Add(new SelectListItem(itemText, itemValue));
   97:                 }
   98:  
   99:                 serviceViewModel.SupplementaryServiceSelectList = new SelectList(supplementaryServiceSelectList, "Value", "Text");
  100:             }
  101:             else throw new ArgumentOutOfRangeException("supplementaryServiceList and supplementaryServiceArabicList lengths do not match.");
  102:         }
  103:  
  104:         ////////////////////////////////////////////////////////////////////////////
  105:         ////////////////////////////////////////////////////////////////////////////
  106:  
  107:         /// <summary>
  108:         ///
  109:         /// </summary>
  110:         private static void EnqueueCreateRead(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
  111:         {
  112:             EnqueueCreateReadOrDeleteRead(ref serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort, serviceViewModel.ServiceInput, serviceViewModel.AccessNameInput, serviceViewModel.PortInput, serviceViewModel.OverrideRouterDomainRestrictionCheckBoxEnabled);
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:  
  117:         /// <summary>
  118:         ///
  119:         /// </summary>
  120:         private static void EnqueueDeleteRead(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
  121:         {
  122:             EnqueueCreateReadOrDeleteRead(ref serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess, serviceViewModel.ServiceInput, serviceViewModel.AccessNameInput, serviceViewModel.PortInput, serviceViewModel.OverrideRouterDomainRestrictionCheckBoxEnabled);
  123:         }
  124:  
  125:         ////////////////////////////////////////////////////////////////////////////
  126:  
  127:         /// <summary>
  128:         ///
  129:         /// </summary>
  130:         private static void EnqueueCreateReadOrDeleteRead(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service0, string accessName0, string port0, bool overrideRouterDomainRestriction)
  131:         {
  132:             int portNumber;
  133:             string service, accessName, port, accessNameOrEmpty;
  134:             Ia.Cl.Models.Result result;
  135:             Ia.Ftn.Cl.Models.Access access;
  136:  
  137:             result = new Ia.Cl.Models.Result();
  138:  
  139:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser))
  140:             {
  141:                 if (!string.IsNullOrEmpty(service0))
  142:                 {
  143:                     service = WebUtility.HtmlDecode(service0);
  144:                     service = service.Trim();
  145:  
  146:                     if (service.Length > 0)
  147:                     {
  148:                         if (int.TryParse(service, out int number))
  149:                         {
  150:                             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  151:                             {
  152:                                 if (string.IsNullOrEmpty(port0)) port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown.ToString();
  153:                                 else
  154:                                 {
  155:                                     port = WebUtility.HtmlDecode(port0);
  156:                                     port = port.Trim();
  157:                                 }
  158:  
  159:                                 if (int.TryParse(port, out portNumber))
  160:                                 {
  161:                                     if (portNumber >= Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown && portNumber <= Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts)
  162:                                     {
  163:                                         if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort)
  164:                                         {
  165:                                             if (Ia.Ftn.Cl.Models.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
  166:                                             {
  167:                                                 if (!string.IsNullOrEmpty(accessName0))
  168:                                                 {
  169:                                                     accessName = WebUtility.HtmlDecode(accessName0);
  170:                                                     accessName = accessName.Trim();
  171:  
  172:                                                     if (accessName.Length > 0)
  173:                                                     {
  174:                                                         if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  175:                                                         {
  176:                                                             access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  177:  
  178:                                                             if (access != null)
  179:                                                             {
  180:                                                                 Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessPortTask(process, service, access.Name, portNumber, overrideRouterDomainRestriction, serviceViewModel.CurrentStaffIdentityUser, out result);
  181:                                                             }
  182:                                                             else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف)");
  183:                                                         }
  184:                                                         else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة)");
  185:                                                     }
  186:                                                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  187:                                                 }
  188:                                                 else result.AddError("Can't create a Nokia service without an access. AccessName is null or empty. (لم يتم إدخال جهاز لتركيب رقم نوكيا)");
  189:                                             }
  190:                                             else if (Ia.Ftn.Cl.Models.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
  191:                                             {
  192:                                                 if (!string.IsNullOrEmpty(accessName0))
  193:                                                 {
  194:                                                     accessName = WebUtility.HtmlDecode(accessName0);
  195:                                                     accessName = accessName.Trim();
  196:  
  197:                                                     if (accessName.Length > 0)
  198:                                                     {
  199:                                                         if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  200:                                                         {
  201:                                                             access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  202:  
  203:                                                             if (access != null)
  204:                                                             {
  205:                                                                 Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, access.Name, overrideRouterDomainRestriction, serviceViewModel.CurrentStaffIdentityUser, out result);
  206:                                                             }
  207:                                                             else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف)");
  208:                                                         }
  209:                                                         else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة)");
  210:                                                     }
  211:                                                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  212:                                                 }
  213:                                                 else
  214:                                                 {
  215:                                                     Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, string.Empty, overrideRouterDomainRestriction, serviceViewModel.CurrentStaffIdentityUser, out result);
  216:                                                 }
  217:                                             }
  218:                                             else result.AddError("No input was entered for access (لم يتم إدخال جهاز)");
  219:                                         }
  220:                                         else if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  221:                                         {
  222:                                             if (!string.IsNullOrEmpty(accessName0))
  223:                                             {
  224:                                                 accessName = WebUtility.HtmlDecode(accessName0);
  225:                                                 accessName = accessName.Trim();
  226:  
  227:                                                 if (accessName.Length > 0)
  228:                                                 {
  229:                                                     if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  230:                                                     {
  231:                                                         access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  232:  
  233:                                                         if (access != null) accessNameOrEmpty = access.Name;
  234:                                                         else accessNameOrEmpty = string.Empty;
  235:                                                     }
  236:                                                     else accessNameOrEmpty = string.Empty;
  237:                                                 }
  238:                                                 else accessNameOrEmpty = string.Empty;
  239:                                             }
  240:                                             else accessNameOrEmpty = string.Empty;
  241:  
  242:                                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessTask(process, service, accessNameOrEmpty, overrideRouterDomainRestriction, serviceViewModel.CurrentStaffIdentityUser, out result);
  243:                                         }
  244:                                         else throw new ArgumentOutOfRangeException("Message queue process " + process.ToString() + " is undefined");
  245:                                     }
  246:                                     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. (رقم المدخل خارج نطاق المقبول");
  247:                                 }
  248:                                 else result.AddError(@"The port number """ + port + @""" is not empty or a valid number (ليس خاليا ولا رقماَ)");
  249:                             }
  250:                             else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  251:                         }
  252:                         else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ)");
  253:                     }
  254:                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  255:                 }
  256:                 else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  257:             }
  258:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).");
  259:  
  260:             serviceViewModel.ServiceTaskResultLabel = result;
  261:         }
  262:  
  263:         ////////////////////////////////////////////////////////////////////////////
  264:         ////////////////////////////////////////////////////////////////////////////
  265:  
  266:         /// <summary>
  267:         ///
  268:         /// </summary>
  269:         private static void EnqueueSetRead(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
  270:         {
  271:             var result = new Ia.Cl.Models.Result();
  272:  
  273:             var service = serviceViewModel.ServiceSupplementaryServiceInput;
  274:             var selectedItem = serviceViewModel.SupplementaryServiceSelectedValue;
  275:  
  276:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser))
  277:             {
  278:                 if (!string.IsNullOrEmpty(service))
  279:                 {
  280:                     service = WebUtility.HtmlDecode(service);
  281:                     service = service.Trim();
  282:  
  283:                     if (service.Length > 0)
  284:                     {
  285:                         if (int.TryParse(service, out int number))
  286:                         {
  287:                             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  288:                             {
  289:                                 Ia.Ftn.Cl.Models.Business.Maintenance.Task.SupplementaryServiceTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService, service, selectedItem, true, serviceViewModel.CurrentStaffIdentityUser, out result);
  290:                             }
  291:                             else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  292:                         }
  293:                         else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ)");
  294:                     }
  295:                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  296:                 }
  297:                 else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  298:             }
  299:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).");
  300:  
  301:             serviceViewModel.ServiceSupplementaryServiceTaskResultLabel = result;
  302:         }
  303:  
  304:         ////////////////////////////////////////////////////////////////////////////
  305:  
  306:         /// <summary>
  307:         ///
  308:         /// </summary>
  309:         private static void EnqueueResetRead(ref Ia.Ftn.Wa.Models.Provision.ServiceViewModel serviceViewModel)
  310:         {
  311:             var result = new Ia.Cl.Models.Result();
  312:  
  313:             var service = serviceViewModel.ServiceSupplementaryServiceInput;
  314:             var selectedItem = serviceViewModel.SupplementaryServiceSelectedValue;
  315:  
  316:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser))
  317:             {
  318:                 if (!string.IsNullOrEmpty(service))
  319:                 {
  320:                     service = WebUtility.HtmlDecode(service);
  321:                     service = service.Trim();
  322:  
  323:                     if (service.Length > 0)
  324:                     {
  325:                         if (int.TryParse(service, out int number))
  326:                         {
  327:                             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  328:                             {
  329:                                 Ia.Ftn.Cl.Models.Business.Maintenance.Task.SupplementaryServiceTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService, service, selectedItem, false, serviceViewModel.CurrentStaffIdentityUser, out result);
  330:                             }
  331:                             else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
  332:                         }
  333:                         else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ)");
  334:                     }
  335:                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  336:                 }
  337:                 else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
  338:             }
  339:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).");
  340:  
  341:             serviceViewModel.ServiceSupplementaryServiceTaskResultLabel = result;
  342:         }
  343:  
  344:         ////////////////////////////////////////////////////////////////////////////
  345:         ////////////////////////////////////////////////////////////////////////////
  346:     }
  347:  
  348:     ////////////////////////////////////////////////////////////////////////////
  349:     ////////////////////////////////////////////////////////////////////////////
  350: }