)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   15:     /// 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
   16:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   17:     ///
   18:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   19:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   20:     /// 
   21:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   22:     /// 
   23:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   24:     /// </remarks> 
   25:     public class Task
   26:     {
   27:         ////////////////////////////////////////////////////////////////////////////
   28:  
   29:         /// <summary>
   30:         ///
   31:         /// </summary>
   32:         public Task() { }
   33:  
   34:         ////////////////////////////////////////////////////////////////////////////
   35:  
   36:         /// <summary>
   37:         ///
   38:         /// </summary>
   39:         public static void AccessTask(string processItemValue, string accessName, Ia.Ftn.Cl.Models.StaffIdentityUser currentStaffIdentityUser, out Ia.Cl.Models.Result result)
   40:         {
   41:             string rawAccessName, input;
   42:  
   43:             result = new Ia.Cl.Models.Result();
   44:  
   45:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteAccessTasks(currentStaffIdentityUser))
   46:             {
   47:                 if (!string.IsNullOrEmpty(accessName))
   48:                 {
   49:                     rawAccessName = accessName;
   50:  
   51:                     var process = (Ia.Ftn.Cl.Models.Business.MessageQueue.Process)int.Parse(processItemValue);
   52:  
   53:                     if (!string.IsNullOrEmpty(accessName))
   54:                     {
   55:                         accessName = accessName.Trim();
   56:                         input = accessName.ToUpper();
   57:  
   58:                         if (input.Length > 0)
   59:                         {
   60:                             if (Ia.Ftn.Cl.Models.Business.Access.AccessNameIsInAValidFormat(input))
   61:                             {
   62:                                 var nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(input);
   63:  
   64:                                 if (nddOnt != null)
   65:                                 {
   66:                                     if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadAccess || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ResetAccess)
   67:                                     {
   68:                                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, input);
   69:                                     }
   70:                                     else
   71:                                     {
   72:  
   73:                                     }
   74:  
   75:                                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
   76:                                 }
   77:                                 else
   78:                                 {
   79:                                     result.AddError("The ONT \"" + rawAccessName + "\" does not belong to the network (الجهاز لا ينتمي للشبكة).");
   80:                                 }
   81:                             }
   82:                             else
   83:                             {
   84:                                 result.AddError("Input format is unknown (قيمة غير مفهومة).");
   85:                             }
   86:                         }
   87:                         else result.AddError("No input was entered (لم يتم إدخال أي شيء).");
   88:                     }
   89:                     else result.AddError("Input is null or empty (لم يتم إدخال أي شيء).");
   90:                 }
   91:                 else
   92:                 {
   93:                     //rawInput = null;
   94:                 }
   95:             }
   96:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////
  100:  
  101:         /// <summary>
  102:         ///
  103:         /// </summary>
  104:         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)
  105:         {
  106:             string userId;
  107:  
  108:             result = new Ia.Cl.Models.Result();
  109:  
  110:             var port = Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
  111:  
  112:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  113:             {
  114:                 userId = (staff != null) ? staff.Id : string.Empty;
  115:  
  116:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  117:                 {
  118:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port, overrideRouterDomainRestriction, userId);
  119:  
  120:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  121:                 }
  122:                 else
  123:                 {
  124:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  125:                 }
  126:             }
  127:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  128:         }
  129:  
  130:         ////////////////////////////////////////////////////////////////////////////
  131:  
  132:         /// <summary>
  133:         ///
  134:         /// </summary>
  135:         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)
  136:         {
  137:             string userId;
  138:  
  139:             result = new Ia.Cl.Models.Result();
  140:  
  141:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  142:             {
  143:                 userId = (staff != null) ? staff.Id : string.Empty;
  144:  
  145:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess)
  146:                 {
  147:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port, overrideRouterDomainRestriction, userId);
  148:  
  149:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  150:                 }
  151:                 else
  152:                 {
  153:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  154:                 }
  155:             }
  156:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  157:         }
  158:  
  159:         ////////////////////////////////////////////////////////////////////////////
  160:  
  161:         /// <summary>
  162:         ///
  163:         /// </summary>
  164:         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)
  165:         {
  166:             result = new Ia.Cl.Models.Result();
  167:  
  168:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  169:             {
  170:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceOrAmsServiceAccessPort || process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceOrAmsServiceAccessPort)
  171:                 {
  172:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, accessName, port);
  173:  
  174:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  175:                 }
  176:                 else
  177:                 {
  178:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  179:                 }
  180:             }
  181:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  182:         }
  183:  
  184:         ////////////////////////////////////////////////////////////////////////////
  185:  
  186:         /// <summary>
  187:         ///
  188:         /// </summary>
  189:         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)
  190:         {
  191:             result = new Ia.Cl.Models.Result();
  192:  
  193:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  194:             {
  195:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceMsanServiceMsanCabinetFrameFnSnPn)
  196:                 {
  197:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, msanDevId, fn, sn, pn, service);
  198:  
  199:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  200:                 }
  201:                 else
  202:                 {
  203:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process + " is undefined");
  204:                 }
  205:             }
  206:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  207:         }
  208:  
  209:         ////////////////////////////////////////////////////////////////////////////
  210:  
  211:         /// <summary>
  212:         ///
  213:         /// </summary>
  214:         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)
  215:         {
  216:             result = new Ia.Cl.Models.Result();
  217:  
  218:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  219:             {
  220:                 if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceMsanService)
  221:                 {
  222:                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service);
  223:  
  224:                     result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  225:                 }
  226:                 else
  227:                 {
  228:                     throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  229:                 }
  230:             }
  231:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  232:         }
  233:  
  234:         ////////////////////////////////////////////////////////////////////////////
  235:  
  236:         /// <summary>
  237:         ///
  238:         /// </summary>
  239:         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)
  240:         {
  241:             string userId;
  242:  
  243:             result = new Ia.Cl.Models.Result();
  244:  
  245:             if (staff == null || Ia.Ftn.Cl.Models.Business.Authority.StaffCanExecuteTasks(staff))
  246:             {
  247:                 userId = (staff != null) ? staff.Id : string.Empty;
  248:  
  249:                 result = new Ia.Cl.Models.Result();
  250:  
  251:                 var supplementaryService = (Ia.Ftn.Cl.Models.Business.Service.SupplementaryService)Enum.Parse(typeof(Ia.Ftn.Cl.Models.Business.Service.SupplementaryService), supplementaryServiceItemValue);
  252:  
  253:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  254:                 {
  255:                     if (process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.UpdateReadServiceSupplementaryService)
  256:                     {
  257:                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, process, service, supplementaryService, supplementaryServiceState, userId);
  258:  
  259:                         result.AddSuccess("Task Enqueued (تم إرسال المهمة).");
  260:                     }
  261:                     else
  262:                     {
  263:                         throw new ArgumentOutOfRangeException("MessageQueue process " + process.ToString() + " is undefined");
  264:                     }
  265:                 }
  266:                 else result.AddError("Input format is unknown (قيمة غير مفهومة).");
  267:             }
  268:             else result.AddError("You are not authorized to execute tasks (لست مخولاً بتنفيذ وظائف).");
  269:         }
  270:  
  271:         ////////////////////////////////////////////////////////////////////////////
  272:         ////////////////////////////////////////////////////////////////////////////   
  273:     }
  274:  
  275:     ////////////////////////////////////////////////////////////////////////////
  276:     ////////////////////////////////////////////////////////////////////////////   
  277: }