)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » ServiceRequestServiceAccess (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 ServiceRequestServiceAccess
   27:     {
   28:         ////////////////////////////////////////////////////////////////////////////
   29:  
   30:         /// <summary>
   31:         ///
   32:         /// </summary>
   33:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestServiceAccessViewModel serviceRequestServiceAccessViewModel)
   34:         {
   35:             // http://ftn/provision/service-request-service-access.aspx?service=25233434&accessName=SHD.20.11
   36:  
   37:             // serviceRequestServiceAccessViewModel.ServiceInput = Request.QueryString["service"] != null ? WebUtility.HtmlDecode(Request.QueryString["service"].ToString()) : string.Empty;
   38:             // serviceRequestServiceAccessViewModel.AccessNameInput = Request.QueryString["accessName"] != null ? WebUtility.HtmlDecode(Request.QueryString["accessName"].ToString()) : string.Empty;
   39:  
   40:             serviceRequestServiceAccessViewModel.ReferenceButtonEnabled = (Ia.Ftn.Cl.Models.Business.Authority.StaffCanReadUpdateServiceRequestServiceAccess(serviceRequestServiceAccessViewModel.CurrentStaffIdentityUser)) ? true : false;
   41:         }
   42:  
   43:         ////////////////////////////////////////////////////////////////////////////
   44:  
   45:         /// <summary>
   46:         ///
   47:         /// </summary>
   48:         public static void Post(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestServiceAccessViewModel serviceRequestServiceAccessViewModel, string commandName)
   49:         {
   50:             if (commandName == "reference") Reference(ref serviceRequestServiceAccessViewModel);
   51:         }
   52:  
   53:         ////////////////////////////////////////////////////////////////////////////
   54:  
   55:         /// <summary>
   56:         ///
   57:         /// </summary>
   58:         private static void Reference(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestServiceAccessViewModel serviceRequestServiceAccessViewModel)
   59:         {
   60:             string service, input, accessName;
   61:             int number;
   62:             Ia.Ftn.Cl.Models.Access access;
   63:  
   64:             var result = new Ia.Cl.Models.Result();
   65:  
   66:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanReadUpdateServiceRequestServiceAccess(serviceRequestServiceAccessViewModel.CurrentStaffIdentityUser))
   67:             {
   68:                 if (!string.IsNullOrEmpty(serviceRequestServiceAccessViewModel.ServiceInput))
   69:                 {
   70:                     service = WebUtility.HtmlDecode(serviceRequestServiceAccessViewModel.ServiceInput);
   71:  
   72:                     if (!string.IsNullOrEmpty(service))
   73:                     {
   74:                         service = service.Trim();
   75:  
   76:                         if (service.Length > 0)
   77:                         {
   78:                             if (int.TryParse(service, out number))
   79:                             {
   80:                                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(number))
   81:                                 {
   82:                                     if (!string.IsNullOrEmpty(serviceRequestServiceAccessViewModel.AccessNameInput) && !string.IsNullOrEmpty(WebUtility.HtmlDecode(serviceRequestServiceAccessViewModel.AccessNameInput)))
   83:                                     {
   84:                                         input = WebUtility.HtmlDecode(serviceRequestServiceAccessViewModel.AccessNameInput);
   85:  
   86:                                         input = input.Trim();
   87:  
   88:                                         if (input.Length > 0)
   89:                                         {
   90:                                             if (Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(input, out accessName))
   91:                                             {
   92:                                                 access = Ia.Ftn.Cl.Models.Data.Access.ReadByAccessName(accessName);
   93:  
   94:                                                 if (access != null)
   95:                                                 {
   96:                                                     Ia.Ftn.Cl.Models.Data.ServiceRequestService.UpdateServiceRequestServiceAccess(service, access.Id, serviceRequestServiceAccessViewModel.CurrentStaffIdentityUser.Id, out result);
   97:  
   98:                                                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadAccess, access.Name);
   99:                                                 }
  100:                                                 else result.AddError(@"""" + accessName + @""" does not exist (الجهاز غير معرف)");
  101:                                             }
  102:                                             else result.AddError(@"""" + accessName + @""" does not belong to the network (الجهاز لا ينتمي للشبكة)");
  103:                                         }
  104:                                         else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  105:                                     }
  106:                                     else
  107:                                     {
  108:                                         Ia.Ftn.Cl.Models.Data.ServiceRequestService.UpdateServiceRequestServiceAccess(service, string.Empty, serviceRequestServiceAccessViewModel.CurrentStaffIdentityUser.Id, out result);
  109:  
  110:                                         if (result.IsSuccessful)
  111:                                         {
  112:                                             result.AddSuccess("Reference removed for " + service + " (تمت إزالة ربط الرقم)");
  113:                                         }
  114:                                         else
  115:                                         {
  116:                                             result.AddError(result.Error);
  117:                                         }
  118:                                     }
  119:                                 }
  120:                                 else result.AddError(@"The number """ + number + @""" does not belong to the network (الرقم لا ينتمي للشبكة)");
  121:                             }
  122:                             else result.AddError(@"The service number """ + service + @""" is not a valid number (ليس رقماَ)");
  123:                         }
  124:                         else result.AddError("Input format is unknown (قيمة غير مفهومة)");
  125:                     }
  126:                     else result.AddError("No input was entered for service (لم يتم إدخال رقم)");
  127:                 }
  128:                 else result.AddError("No input was entered for service (لم يتم إدخال رقم)");
  129:             }
  130:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة)");
  131:  
  132:             serviceRequestServiceAccessViewModel.Result = result;
  133:         }
  134:  
  135:         ////////////////////////////////////////////////////////////////////////////
  136:         ////////////////////////////////////////////////////////////////////////////
  137:     }
  138:  
  139:     ////////////////////////////////////////////////////////////////////////////
  140:     ////////////////////////////////////////////////////////////////////////////
  141: }