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

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

    1: using System.Net;
    2:  
    3: namespace Ia.Ftn.Wa.Models.Provision.Access
    4: {
    5:     ////////////////////////////////////////////////////////////////////////////
    6:  
    7:     /// <summary publish="true">
    8:     ///
    9:     /// </summary>
   10:     /// 
   11:     /// <remarks> 
   12:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   13:     ///
   14:     /// 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
   15:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   16:     ///
   17:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   18:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   19:     /// 
   20:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   21:     /// 
   22:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   23:     /// </remarks> 
   24:     public static class Service
   25:     {
   26:         ////////////////////////////////////////////////////////////////////////////
   27:  
   28:         /// <summary>
   29:         ///
   30:         /// </summary>
   31:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Provision.Access.ServiceViewModel serviceViewModel)
   32:         {
   33:             // http://ftn/provision/access/service.aspx?service=25233434&accessName=SHD.20.11&port=2
   34:  
   35:             // serviceViewModel.ServiceInput = Request.QueryString["service"] != null ? WebUtility.HtmlDecode(Request.QueryString["service"].ToString()) : string.Empty;
   36:             // serviceViewModel.AccessNameInput = Request.QueryString["accessName"] != null ? WebUtility.HtmlDecode(Request.QueryString["accessName"].ToString()) : string.Empty;
   37:             // serviceViewModel.PortInput = Request.QueryString["port"] != null ? WebUtility.HtmlDecode(Request.QueryString["port"].ToString()) : string.Empty;
   38:  
   39:             serviceViewModel.Label = "1-" + Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts;
   40:  
   41:             serviceViewModel.CreateReadServiceTaskButtonEnabled = serviceViewModel.DeleteReadServiceTaskButtonEnabled = Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser);
   42:         }
   43:  
   44:         ////////////////////////////////////////////////////////////////////////////
   45:  
   46:         /// <summary>
   47:         ///
   48:         /// </summary>
   49:         public static void Post(ref Ia.Ftn.Wa.Models.Provision.Access.ServiceViewModel serviceViewModel, string commandName)
   50:         {
   51:             if (commandName == "enqueueCreateRead") EnqueueCreateRead(ref serviceViewModel);
   52:             else if (commandName == "enqueueDeleteRead") EnqueueDeleteRead(ref serviceViewModel);
   53:             else
   54:             {
   55:             }
   56:         }
   57:  
   58:         ////////////////////////////////////////////////////////////////////////////
   59:         ////////////////////////////////////////////////////////////////////////////
   60:  
   61:         /// <summary>
   62:         ///
   63:         /// </summary>
   64:         private static void EnqueueCreateRead(ref Ia.Ftn.Wa.Models.Provision.Access.ServiceViewModel serviceViewModel)
   65:         {
   66:             EnqueueCreateReadOrDeleteRead(ref serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceOrAmsServiceAccessPort);
   67:         }
   68:  
   69:         ////////////////////////////////////////////////////////////////////////////
   70:  
   71:         /// <summary>
   72:         ///
   73:         /// </summary>
   74:         private static void EnqueueDeleteRead(ref Ia.Ftn.Wa.Models.Provision.Access.ServiceViewModel serviceViewModel)
   75:         {
   76:             EnqueueCreateReadOrDeleteRead(ref serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceOrAmsServiceAccessPort);
   77:         }
   78:  
   79:         ////////////////////////////////////////////////////////////////////////////
   80:  
   81:         /// <summary>
   82:         ///
   83:         /// </summary>
   84:         private static void EnqueueCreateReadOrDeleteRead(ref Ia.Ftn.Wa.Models.Provision.Access.ServiceViewModel serviceViewModel, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process)
   85:         {
   86:             int portNumber;
   87:             string service, accessName, port, accessNameOrEmpty;
   88:             Ia.Cl.Models.Result result;
   89:             Ia.Ftn.Cl.Models.Access access;
   90:  
   91:             result = new Ia.Cl.Models.Result();
   92:  
   93:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(serviceViewModel.CurrentStaffIdentityUser))
   94:             {
   95:                 if (!string.IsNullOrEmpty(serviceViewModel.ServiceInput))
   96:                 {
   97:                     service = WebUtility.HtmlDecode(serviceViewModel.ServiceInput);
   98:                     service = service.Trim();
   99:  
  100:                     if (service.Length > 0)
  101:                     {
  102:                         if (int.TryParse(service, out int number))
  103:                         {
  104:                             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
  105:                             {
  106:                                 port = WebUtility.HtmlDecode(serviceViewModel.PortInput);
  107:  
  108:                                 if (string.IsNullOrEmpty(port)) port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown.ToString();
  109:  
  110:                                 port = port.Trim();
  111:  
  112:                                 if (int.TryParse(port, out portNumber))
  113:                                 {
  114:                                     if (portNumber >= Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown && portNumber <= Ia.Ftn.Cl.Models.Data.Default.MaximumOntTelPorts)
  115:                                     {
  116:                                         if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceOrAmsServiceAccessPort)
  117:                                         {
  118:                                             if (!string.IsNullOrEmpty(serviceViewModel.AccessNameInput))
  119:                                             {
  120:                                                 accessName = WebUtility.HtmlDecode(serviceViewModel.AccessNameInput);
  121:                                                 accessName = accessName.Trim();
  122:  
  123:                                                 if (accessName.Length > 0)
  124:                                                 {
  125:                                                     if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  126:                                                     {
  127:                                                         access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  128:  
  129:                                                         if (access != null)
  130:                                                         {
  131:                                                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessPortTask(process, service, access.Name, portNumber, serviceViewModel.CurrentStaffIdentityUser, out result);
  132:                                                         }
  133:                                                         else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف)");
  134:                                                     }
  135:                                                     else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة)");
  136:                                                 }
  137:                                                 else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  138:                                             }
  139:                                             else result.AddError("No input was entered for access (لم يتم إدخال جهاز)");
  140:                                         }
  141:                                         else if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceOrAmsServiceAccessPort)
  142:                                         {
  143:                                             if (!string.IsNullOrEmpty(serviceViewModel.AccessNameInput))
  144:                                             {
  145:                                                 accessName = WebUtility.HtmlDecode(serviceViewModel.AccessNameInput);
  146:                                                 accessName = accessName.Trim();
  147:  
  148:                                                 if (accessName.Length > 0)
  149:                                                 {
  150:                                                     if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(accessName, out string accessName2))
  151:                                                     {
  152:                                                         access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName2);
  153:  
  154:                                                         if (access != null) accessNameOrEmpty = access.Name;
  155:                                                         else accessNameOrEmpty = string.Empty;
  156:                                                     }
  157:                                                     else accessNameOrEmpty = string.Empty;
  158:                                                 }
  159:                                                 else accessNameOrEmpty = string.Empty;
  160:                                             }
  161:                                             else accessNameOrEmpty = string.Empty;
  162:  
  163:                                             Ia.Ftn.Cl.Models.Business.Maintenance.Task.ServiceAccessPortTask(process, service, accessNameOrEmpty, portNumber, serviceViewModel.CurrentStaffIdentityUser, out result);
  164:                                         }
  165:                                         else throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  166:                                     }
  167:                                     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. (رقم المدخل خارج نطاق المقبول");
  168:                                 }
  169:                                 else result.AddError(@"The port number """ + port + @""" is not empty or a valid number (ليس خاليا ولا رقماَ)");
  170:                             }
  171:                             else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة)");
  172:                         }
  173:                         else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ)");
  174:                     }
  175:                     else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  176:                 }
  177:                 else result.AddError("No input was entered for service (لم يتم إدخال رقم)");
  178:             }
  179:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة)");
  180:  
  181:             serviceViewModel.Result = result;
  182:         }
  183:  
  184:         ////////////////////////////////////////////////////////////////////////////
  185:         ////////////////////////////////////////////////////////////////////////////
  186:     }
  187:  
  188:     ////////////////////////////////////////////////////////////////////////////
  189:     ////////////////////////////////////////////////////////////////////////////
  190: }