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

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

    1: using Microsoft.AspNetCore.Identity;
    2: using Microsoft.AspNetCore.Mvc.Rendering;
    3: using System.Text;
    4: using System.Text.RegularExpressions;
    5:  
    6: namespace Ia.Ftn.Wa.Models.Administration
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     ///
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// 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
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public static class ServiceRequestAdministrativeIssue
   28:     {
   29:         //private Ia.Ftn.Cl.Model.Staff staff;
   30:  
   31:         /*
   32:         private bool serviceState;
   33:         private int number;
   34:         private const string processStateSessionName = "Administration_Service_Suspension_Process_State";
   35:         private const string numberSessionName = "Administration_Service_Suspension_Number";
   36:         private const string serviceStateSessionName = "Administration_Service_Suspension_Service_State";
   37:         private NextProcessState processState;
   38: 
   39:         private enum NextProcessState { Read, Update };
   40:         */
   41:  
   42:         ////////////////////////////////////////////////////////////////////////////
   43:  
   44:         /// <summary>
   45:         ///
   46:         /// </summary>
   47:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Administration.ServiceRequestAdministrativeIssueViewModel serviceRequestAdministrativeIssueViewModel)
   48:         {
   49:             // staff = Ia.Ftn.Cl.Model.Data.Staff.MembershipUser;
   50:  
   51:             /*
   52:             StringBuilder stringBuilder;
   53:             List<string> serviceList, pendingSuspensionList; //, pendingActivationList;
   54: 
   55:             processState = (ViewState[processStateSessionName] != null) ? (NextProcessState)ViewState[processStateSessionName] : NextProcessState.Read;
   56:             number = (ViewState[numberSessionName] != null) ? int.Parse(ViewState[numberSessionName].ToString()) : 0;
   57:             serviceState = (ViewState[serviceStateSessionName] != null) ? bool.Parse(ViewState[serviceStateSessionName].ToString()) : false;
   58: 
   59:             serviceTextBox.Text = (number != 0) ? number.ToString() : "";
   60: 
   61:             if (processState == NextProcessState.Read)
   62:             {
   63:                 serviceTextBox.Enabled = true;
   64:                 readButton.Enabled = readButton.Visible = true;
   65:                 updateButton.Enabled = updateButton.Visible = false;
   66:             }
   67:             else if (processState == NextProcessState.Update)
   68:             {
   69:                 serviceTextBox.Enabled = false;
   70:                 readButton.Enabled = readButton.Visible = false;
   71:                 updateButton.Enabled = updateButton.Visible = true;
   72:             }
   73: 
   74:             serviceList = Ia.Ftn.Cl.Model.Data.Service2.ServiceSuspensionIsTrueStringNumberList;
   75:             pendingSuspensionList = Ia.Ftn.Cl.Model.Business.Provision.ServiceSuspendedInServiceRequestServiceButNotInServiceStringNumberList;
   76:             //pendingActivationList = Ia.Ftn.Cl.Model.Business.Provision.ServiceActiveInServiceRequestServiceButNotInServiceStringNumberList;
   77: 
   78:             stringBuilder = new StringBuilder(50 * serviceList.Count);
   79:             foreach (string s in serviceList) stringBuilder.Append(@"<a href=""../maintenance/find.aspx?input=" + s + @""">" + s + "</a> ");
   80:             serviceSuspensionListLabel.Text = stringBuilder.ToString();
   81: 
   82:             stringBuilder = new StringBuilder(50 * pendingSuspensionList.Count);
   83:             foreach (string s in pendingSuspensionList) stringBuilder.Append(@"<a href=""../maintenance/find.aspx?input=" + s + @""">" + s + "</a> ");
   84:             pendingServiceSuspensionListLabel.Text = stringBuilder.ToString();
   85:             */
   86:  
   87:             /*
   88:             stringBuilder = new StringBuilder(50 * pendingActivationList.Count);
   89:             foreach (string s in pendingActivationList) stringBuilder.Append(@"<a href=""../maintenance/find.aspx?input=" + s + @""">" + s + "</a> ");
   90:             pendingServiceActivationListLabel.Text = stringBuilder.ToString();
   91:             */
   92:  
   93:             ServiceRequestAdministrativeIssueList_DataBind(ref serviceRequestAdministrativeIssueViewModel);
   94:  
   95:             ServiceRequestAdministrativeIssueTypeList_DataBind(ref serviceRequestAdministrativeIssueViewModel);
   96:  
   97:             // below: check permissions
   98:             //readButton.Enabled = readButton.Enabled && Ia.Ftn.Cl.Model.Business.Authority.StaffCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ftn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staff);
   99:             //updateButton.Enabled = updateButton.Enabled && Ia.Ftn.Cl.Model.Business.Authority.StaffCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ftn.Cl.Model.Business.Authority.PersistentStorageFunction.Update, staff);
  100:         }
  101:  
  102:         /*
  103:         ////////////////////////////////////////////////////////////////////////////
  104: 
  105:         /// <summary>
  106:         ///
  107:         /// </summary>
  108:         public void ReadButton_Click(object sender, EventArgs e)
  109:         {
  110:             string numberString;
  111:             DateTime now;
  112:             Guid userId;
  113:             Ia.Ftn.Cl.Model.ServiceRequestService serviceRequestService;
  114: 
  115:             numberString = Server.HtmlDecode(serviceTextBox.Text);
  116:             numberString = numberString.Trim();
  117: 
  118:             userId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
  119:             now = DateTime.UtcNow.AddHours(3);
  120: 
  121:             if (Ia.Ftn.Cl.Model.Business.Authority.StaffCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ftn.Cl.Model.Business.Authority.PersistentStorageFunction.Read, staff))
  122:             {
  123:                 if (numberString.Length > 0 && int.TryParse(numberString, out number))
  124:                 {
  125:                     if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
  126:                     {
  127:                         serviceRequestService = Ia.Ftn.Cl.Model.Data.ServiceRequestService.Read(number);
  128: 
  129:                         if (serviceRequestService != null)
  130:                         {
  131:                             processState = NextProcessState.Update;
  132: 
  133:                             resultLabel.Text = "Service record '" + numberString + "' has a service suspension value of '" + serviceRequestService.ServiceSuspension.ToString().ToLower() + "'. ";
  134:                             resultLabel.CssClass = "success";
  135: 
  136:                             // set the button text
  137:                             updateButton.Text = serviceRequestService.ServiceSuspension ? "Unsuspend (Activate)" : "Suspend";
  138: 
  139:                             ViewState[numberSessionName] = serviceRequestService.Service;
  140:                             ViewState[serviceStateSessionName] = serviceRequestService.ServiceSuspension;
  141:                             ViewState[processStateSessionName] = processState;
  142:                         }
  143:                         else
  144:                         {
  145:                             resultLabel.Text = "Service record for '" + numberString + "' does not exist. ";
  146:                             resultLabel.CssClass = "error";
  147:                         }
  148:                     }
  149:                     else
  150:                     {
  151:                         resultLabel.Text = @"The number '" + number + @"' does not belong to the network (الرقم لا ينتمي للشبكة).";
  152:                         resultLabel.CssClass = "error";
  153:                     }
  154:                 }
  155:                 else
  156:                 {
  157:                     resultLabel.Text = "Number format is incorrect or nothing was entered (الرقم غير مفهوم أو مفقود). ";
  158:                     resultLabel.CssClass = "error";
  159:                 }
  160:             }
  161:             else
  162:             {
  163:                 resultLabel.Text = "You are not authorized to read this value (لست مخولاً بقراءة هذه القيمة). ";
  164:                 resultLabel.CssClass = "error";
  165:             }
  166: 
  167:             Page_DataBind();
  168:         }
  169:         */
  170:  
  171:         /*
  172:         ////////////////////////////////////////////////////////////////////////////
  173: 
  174:         /// <summary>
  175:         ///
  176:         /// </summary>
  177:         public void UpdateButton_Click(object sender, EventArgs e)
  178:         {
  179:             int number;
  180:             string numberString;
  181:             Guid userId;
  182:             Ia.Cl.Models.Result result;
  183:             Ia.Ftn.Cl.Model.ServiceRequestService serviceRequestService;
  184: 
  185:             numberString = Server.HtmlDecode(serviceTextBox.Text);
  186:             numberString = numberString.Trim();
  187: 
  188:             userId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
  189: 
  190:             if (Ia.Ftn.Cl.Model.Business.Authority.StaffCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ftn.Cl.Model.Business.Authority.PersistentStorageFunction.Update, staff))
  191:             {
  192:                 if (numberString.Length > 0 && int.TryParse(numberString, out number))
  193:                 {
  194:                     if (Ia.Ftn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
  195:                     {
  196:                         serviceRequestService = Ia.Ftn.Cl.Model.Data.ServiceRequestService.Read(number);
  197: 
  198:                         Ia.Ftn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(number.ToString(), !serviceRequestService.ServiceSuspension, userId, out result);
  199: 
  200:                         //Ia.Ftn.Cl.Model.Data.Msmq.ServiceQueue.ServiceSuspensionQueue.Enqueue(number.ToString());
  201: 
  202:                         if (result.IsSuccessful)
  203:                         {
  204:                             processState = NextProcessState.Read;
  205: 
  206:                             ViewState[numberSessionName] = null;
  207:                             ViewState[serviceStateSessionName] = null;
  208:                             ViewState[processStateSessionName] = processState;
  209: 
  210:                             resultLabel.Text = "Service record '" + numberString + "' has its service suspension value updated to '" + (!serviceRequestService.ServiceSuspension).ToString().ToLower() + "'";
  211:                             resultLabel.CssClass = "success";
  212:                         }
  213:                         else
  214:                         {
  215:                             resultLabel.Text = result.Error;
  216:                             resultLabel.CssClass = "error";
  217:                         }
  218:                     }
  219:                     else
  220:                     {
  221:                         resultLabel.Text = @"The number '" + number + @"' does not belong to the network (الرقم لا ينتمي للشبكة).";
  222:                         resultLabel.CssClass = "error";
  223:                     }
  224:                 }
  225:                 else
  226:                 {
  227:                     resultLabel.Text = "Number format is incorrect. ";
  228:                     resultLabel.CssClass = "error";
  229:                 }
  230:             }
  231:             else
  232:             {
  233:                 resultLabel.Text = "You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).";
  234:                 resultLabel.CssClass = "error";
  235:             }
  236: 
  237:             Page_DataBind();
  238:         }
  239:         */
  240:  
  241:         ////////////////////////////////////////////////////////////////////////////
  242:  
  243:         /// <summary>
  244:         ///
  245:         /// </summary>
  246:         private static void ServiceRequestAdministrativeIssueList_DataBind(ref Ia.Ftn.Wa.Models.Administration.ServiceRequestAdministrativeIssueViewModel serviceRequestAdministrativeIssueViewModel)
  247:         {
  248:             Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType disconnectionType;
  249:             Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueType serviceRequestAdministrativeIssueType;
  250:  
  251:             serviceRequestAdministrativeIssueViewModel.Result = new Ia.Cl.Models.Result();
  252:             serviceRequestAdministrativeIssueViewModel.Result2 = new Ia.Cl.Models.Result();
  253:  
  254:             disconnectionType = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedAccounting;
  255:  
  256:             serviceRequestAdministrativeIssueType = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueTypeByDisconnectionType(disconnectionType);
  257:  
  258:             var list = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.ServiceList(disconnectionType);
  259:  
  260:             if (list.Count > 0)
  261:             {
  262:                 serviceRequestAdministrativeIssueViewModel.Result.AddSuccess(serviceRequestAdministrativeIssueType.NameArabicName + ": list contains " + list.Count + " services.");
  263:  
  264:                 var stringBuilder = new StringBuilder();
  265:  
  266:                 foreach (string s in list)
  267:                 {
  268:                     stringBuilder.Append(@"<a href=""../maintenance/find.aspx?input=" + s + @""">" + s + "</a> ");
  269:                 }
  270:  
  271:                 serviceRequestAdministrativeIssueViewModel.ListText = stringBuilder.ToString();
  272:             }
  273:             else
  274:             {
  275:                 serviceRequestAdministrativeIssueViewModel.Result.AddWarning(serviceRequestAdministrativeIssueType.NameArabicName + ": list contains no services.");
  276:             }
  277:  
  278:  
  279:             disconnectionType = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.ProgrammedInternationalCalling;
  280:  
  281:             serviceRequestAdministrativeIssueType = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueTypeByDisconnectionType(disconnectionType);
  282:  
  283:             var list2 = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.ServiceList(disconnectionType);
  284:  
  285:             if (list2.Count > 0)
  286:             {
  287:                 serviceRequestAdministrativeIssueViewModel.Result2.AddSuccess(serviceRequestAdministrativeIssueType.NameArabicName + ": list contains " + list2.Count + " services.");
  288:  
  289:                 var stringBuilder = new StringBuilder();
  290:  
  291:                 foreach (string s in list2)
  292:                 {
  293:                     stringBuilder.Append(@"<a href=""../maintenance/find.aspx?input=" + s + @""">" + s + "</a> ");
  294:                 }
  295:  
  296:                 serviceRequestAdministrativeIssueViewModel.List2Text = stringBuilder.ToString();
  297:             }
  298:             else
  299:             {
  300:                 serviceRequestAdministrativeIssueViewModel.Result2.AddWarning(serviceRequestAdministrativeIssueType.NameArabicName + ": list contains no services.");
  301:             }
  302:         }
  303:  
  304:         ////////////////////////////////////////////////////////////////////////////
  305:  
  306:         /// <summary>
  307:         ///
  308:         /// </summary>
  309:         private static void ServiceRequestAdministrativeIssueTypeList_DataBind(ref Ia.Ftn.Wa.Models.Administration.ServiceRequestAdministrativeIssueViewModel serviceRequestAdministrativeIssueViewModel)
  310:         {
  311:             var list = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueTypeList;
  312:  
  313:             var s = "NameArabicName<br/>\r\n";
  314:  
  315:             foreach (var l in list)
  316:             {
  317:                 s += l.NameArabicName + "<br/>\r\n";
  318:             }
  319:  
  320:             serviceRequestAdministrativeIssueViewModel.LiteralText = s;
  321:         }
  322:  
  323:         ////////////////////////////////////////////////////////////////////////////
  324:         ////////////////////////////////////////////////////////////////////////////
  325:     }
  326:  
  327:     ////////////////////////////////////////////////////////////////////////////
  328:     ////////////////////////////////////////////////////////////////////////////
  329: }