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

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

Execute backend task support class for the Fixed Telecommunications Network business model

    1: using Microsoft.AspNetCore.Identity;
    2: using System;
    3:  
    4: namespace Ia.Ftn.Cl.Models.Business.Maintenance
    5: {
    6:     ////////////////////////////////////////////////////////////////////////////
    7:  
    8:     /// <summary publish="true">
    9:     /// Execute backend task support class for the Fixed Telecommunications Network business model
   10:     /// </summary>
   11:     /// 
   12:     /// <remarks> 
   13:     /// Copyright © 2019-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   14:     /// </remarks> 
   15:     public class Task
   16:     {
   17:         ////////////////////////////////////////////////////////////////////////////
   18:  
   19:         /// <summary>
   20:         ///
   21:         /// </summary>
   22:         public Task() { }
   23:  
   24:         ////////////////////////////////////////////////////////////////////////////
   25:  
   26:         /// <summary>
   27:         ///
   28:         /// </summary>
   29:         public static void AccessTask(string processItemValue, string accessName, Ia.Ftn.Cl.Models.StaffIdentityUser currentStaffIdentityUser, out Ia.Cl.Models.Result result)
   30:         {
   31:             string rawAccessName, input;
   32:  
   33:             result = new Ia.Cl.Models.Result();
   34:  
   35:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteAccessTasks(currentStaffIdentityUser))
   36:             {
   37:                 if (!string.IsNullOrEmpty(accessName))
   38:                 {
   39:                     rawAccessName = accessName;
   40:  
   41:                     var process = (Ia.Ftn.Cl.Models.Business.MessageQueue.Process)int.Parse(processItemValue);
   42:  
   43:                     if (!string.IsNullOrEmpty(accessName))
   44:                     {
   45:                         accessName = accessName.Trim();
   46:                         input = accessName.ToUpper();
   47:  
   48:                         if (input.Length > 0)
   49:                         {
   50:                             if (Ia.Ftn.Cl.Models.Business.Access.AccessNameIsInAValidFormat(input))
   51:                             {
   52:                                 var nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(input);
   53:  
   54:                                 if (nddOnt != null)
   55:                                 {
   56:                                     if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadAccess || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ResetAccess)
   57:                                     {
   58:                                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, input);
   59:                                     }
   60:                                     else
   61:                                     {
   62:  
   63:                                     }
   64:  
   65:                                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
   66:                                 }
   67:                                 else
   68:                                 {
   69:                                     result.AddError("The ONT \"" + rawAccessName + "\" does not belong to the network (الجهاز لا ينتمي للشبكة).");
   70:                                 }
   71:                             }
   72:                             else
   73:                             {
   74:                                 result.AddError("Input format is unknown (قيمة غير مفهومة).");
   75:                             }
   76:                         }
   77:                         else result.AddError("No input was entered (لم يتم إدخال أي شيء).");
   78:                     }
   79:                     else result.AddError("Input is null or empty (لم يتم إدخال أي شيء).");
   80:                 }
   81:                 else
   82:                 {
   83:                     //rawInput = null;
   84:                 }
   85:             }
   86:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
   87:         }
   88:  
   89:         ////////////////////////////////////////////////////////////////////////////
   90:  
   91:         /// <summary>
   92:         ///
   93:         /// </summary>
   94:         public static void ServiceAccessTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, bool overrideRouterDomainRestriction, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
   95:         {
   96:             string userId;
   97:  
   98:             result = new Ia.Cl.Models.Result();
   99:  
  100:             var port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
  101:  
  102:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  103:             {
  104:                 userId = (staff != null) ? staff.Id : string.Empty;
  105:  
  106:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  107:                 {
  108:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port, overrideRouterDomainRestriction, userId);
  109:  
  110:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  111:                 }
  112:                 else
  113:                 {
  114:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  115:                 }
  116:             }
  117:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  118:         }
  119:  
  120:         ////////////////////////////////////////////////////////////////////////////
  121:  
  122:         /// <summary>
  123:         ///
  124:         /// </summary>
  125:         public static void ServiceAccessPortTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, int port, bool overrideRouterDomainRestriction, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
  126:         {
  127:             string userId;
  128:  
  129:             result = new Ia.Cl.Models.Result();
  130:  
  131:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  132:             {
  133:                 userId = (staff != null) ? staff.Id : string.Empty;
  134:  
  135:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  136:                 {
  137:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port, overrideRouterDomainRestriction, userId);
  138:  
  139:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  140:                 }
  141:                 else
  142:                 {
  143:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  144:                 }
  145:             }
  146:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  147:         }
  148:  
  149:         ////////////////////////////////////////////////////////////////////////////
  150:  
  151:         /// <summary>
  152:         ///
  153:         /// </summary>
  154:         public static void ServiceAccessPortTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, int port, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
  155:         {
  156:             result = new Ia.Cl.Models.Result();
  157:  
  158:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  159:             {
  160:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceOrAmsServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceOrAmsServiceAccessPort)
  161:                 {
  162:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port);
  163:  
  164:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  165:                 }
  166:                 else
  167:                 {
  168:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  169:                 }
  170:             }
  171:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  172:         }
  173:  
  174:         ////////////////////////////////////////////////////////////////////////////
  175:  
  176:         /// <summary>
  177:         ///
  178:         /// </summary>
  179:         public static void ServiceMsanTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string msanDevId, int cabinet, int frame, int fn, int sn, int pn, string service, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
  180:         {
  181:             result = new Ia.Cl.Models.Result();
  182:  
  183:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  184:             {
  185:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceMsanServiceMsanCabinetFrameFnSnPn)
  186:                 {
  187:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, msanDevId, fn, sn, pn, service);
  188:  
  189:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  190:                 }
  191:                 else
  192:                 {
  193:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  194:                 }
  195:             }
  196:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  197:         }
  198:  
  199:         ////////////////////////////////////////////////////////////////////////////
  200:  
  201:         /// <summary>
  202:         ///
  203:         /// </summary>
  204:         public static void ServiceMsanTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
  205:         {
  206:             result = new Ia.Cl.Models.Result();
  207:  
  208:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  209:             {
  210:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceMsanService)
  211:                 {
  212:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service);
  213:  
  214:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  215:                 }
  216:                 else
  217:                 {
  218:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  219:                 }
  220:             }
  221:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  222:         }
  223:  
  224:         ////////////////////////////////////////////////////////////////////////////
  225:  
  226:         /// <summary>
  227:         ///
  228:         /// </summary>
  229:         public static void SupplementaryServiceTask(Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string supplementaryServiceItemValue, bool supplementaryServiceState, Ia.Ftn.Cl.Models.StaffIdentityUser staff, out Ia.Cl.Models.Result result)
  230:         {
  231:             string userId;
  232:  
  233:             result = new Ia.Cl.Models.Result();
  234:  
  235:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  236:             {
  237:                 userId = (staff != null) ? staff.Id : string.Empty;
  238:  
  239:                 result = new Ia.Cl.Models.Result();
  240:  
  241:                 var supplementaryService = (Ia.Ftn.Cl.Models.Business.Service.SupplementaryService)Enum.Parse(typeof(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService), supplementaryServiceItemValue);
  242:  
  243:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  244:                 {
  245:                     if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService)
  246:                     {
  247:                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, supplementaryService, supplementaryServiceState, userId);
  248:  
  249:                         result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  250:                     }
  251:                     else
  252:                     {
  253:                         throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  254:                     }
  255:                 }
  256:                 else result.AddError("Input format is unknown (قيمة غير مفهومة).");
  257:             }
  258:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  259:         }
  260:  
  261:         ////////////////////////////////////////////////////////////////////////////
  262:         ////////////////////////////////////////////////////////////////////////////   
  263:     }
  264:  
  265:     ////////////////////////////////////////////////////////////////////////////
  266:     ////////////////////////////////////////////////////////////////////////////   
  267: }