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

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

MessageQueue support class for Fixed Telecommunications Network (FTN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.ComponentModel.DataAnnotations.Schema;
    4: using System.Text.Json;
    5:  
    6: namespace Ia.Ftn.Cl.Models.Business
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// MessageQueue support class for Fixed Telecommunications Network (FTN) business model.
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2018-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 abstract class MessageQueue
   28:     {
   29:         ////////////////////////////////////////////////////////////////////////////
   30:  
   31:         /// <summary>
   32:         ///
   33:         /// </summary>
   34:         public class Application : Enumeration
   35:         {
   36:             private static Dictionary<string, string> assemblyToNameDictionary = new Dictionary<string, string>();
   37:  
   38:             // see and update Ia.Ftn.Cl.Model.Business.Default.ApplicationAssemblyNameToApplicationName
   39:  
   40:             public static Application ServiceApplication = new Application("service-application", "ia.ftn.service.wfa");
   41:             public static Application NetManagerApplication = new Application("net-manager-application", "ia.ftn.netmanager.ca");
   42:             public static Application ServiceRequestApplication = new Application("service-request-application", "ia.ftn.servicerequest.wfa");
   43:             public static Application SpsApplication = new Application("sps-application", "ia.ftn.sps.ca");
   44:             public static Application SoftXApplication = new Application("softx-application", "ia.ftn.softx.ca");
   45:             public static Application AxeApplication = new Application("axe-application", "ia.ftn.axe.ca");
   46:             public static Application AmsApplication = new Application("ams-application", "ia.ftn.ams.wfa");
   47:             public static Application NceApplication = new Application("nce-application", "ia.ftn.nce.wfa");
   48:             public static Application ProvisionApplication = new Application("provision-application", "ia.ftn.provision.wfa");
   49:             public static Application FtnApplication = new Application("ftn-application", "ia.ftn.wa");
   50:             public static Application TelegramApplication = new Application("telegram-application", "ia.ftn.telegram.ca");
   51:             public static Application SecretaryApplication = new Application("secretary-application", "ia.ftn.secretary.ca");
   52:             public static Application EmailApplication = new Application("email-application", "ia.ftn.email.wfa");
   53:             public static Application SchedulerApplication = new Application("scheduler-application", "ia.ftn.scheduler.ca");
   54:             public static Application SdcApplication = new Application("sdc-application", "ia.ftn.sdc.wfa");
   55:             public static Application MdaaApplication = new Application("mdaa-application", "ia.ftn.mdaa.ca");
   56:             public static Application CitrixGuiStarterApplication = new Application("citrix-gui-starter-application", "ia.ftn.citrixguistarter.ca");
   57:             public static Application NetMApplication = new Application("netm-application", "ia.ftn.netm.ca");
   58:  
   59:             /// <summary/>
   60:             public Application(string name, string assembly) : base(name, assembly)
   61:             {
   62:                 if (assemblyToNameDictionary.ContainsKey(assembly))
   63:                 {
   64:                     if (assemblyToNameDictionary[assembly] != name)
   65:                     {
   66:                         throw new ArgumentOutOfRangeException("assembly:name " + assembly + ":" + name + " is already used.");
   67:                     }
   68:                 }
   69:                 else assemblyToNameDictionary[assembly] = name;
   70:  
   71:                 this.Id = 0;
   72:                 this.Name = name;
   73:                 this.Assembly = assembly;
   74:             }
   75:         }
   76:  
   77:         ////////////////////////////////////////////////////////////////////////////
   78:  
   79:         /// <summary>
   80:         ///
   81:         /// </summary>
   82:         public enum Process
   83:         {
   84:             ReadService, UpdateReadServiceSupplementaryService, ReadAccess, ResetAccess, ReadGateway,
   85:             CreateReadServiceAccessPort, DeleteReadServiceAccess,
   86:             AccessCreated,
   87:             ServiceInServiceRequestAdministrativeIssuesUpdated,
   88:             ServiceRequestAndOrServiceRequestTypeUpdated,
   89:             Heartbeat,
   90:             CreateReadNceOrAmsServiceAccessPort, DeleteReadNceOrAmsServiceAccessPort,
   91:             CreateReadNceMsanServiceMsanCabinetFrameFnSnPn, DeleteReadNceMsanService,
   92:             Synchronize, SynchronizeCompleted,
   93:             Updated,
   94:             Message,
   95:             ActiveApplicationRunningPermissionState
   96:         };
   97:  
   98:         ////////////////////////////////////////////////////////////////////////////
   99:  
  100:         /// <summary>
  101:         ///
  102:         /// </summary>
  103:         public class Message
  104:         {
  105:             /// <summary/>
  106:             public Ia.Ftn.Cl.Models.Business.MessageQueue.Application Sender { get; set; }
  107:  
  108:             /// <summary/>
  109:             public Ia.Ftn.Cl.Models.Business.MessageQueue.Application Recipient { get; set; }
  110:  
  111:             /// <summary/>
  112:             public Ia.Ftn.Cl.Models.Business.MessageQueue.Process Process { get; set; }
  113:  
  114:             /// <summary/>
  115:             public string Service { get; set; }
  116:  
  117:             /// <summary/>
  118:             public string AccessName { get; set; }
  119:  
  120:             /// <summary/>
  121:             public int Port { get; set; }
  122:  
  123:             /// <summary/>
  124:             public bool OverrideRouterDomainRestriction { get; set; }
  125:  
  126:             /// <summary/>
  127:             public bool State { get; set; }
  128:  
  129:             /// <summary/>
  130:             public string Payload { get; set; }
  131:  
  132:             /// <summary/>
  133:             public int GatewayId { get; set; }
  134:  
  135:             /// <summary/>
  136:             public Ia.Ftn.Cl.Models.Business.Service.SupplementaryService ServiceSupplementaryService { get; set; }
  137:  
  138:             /// <summary/>
  139:             public bool ServiceSupplementaryServiceState { get; set; }
  140:  
  141:             /// <summary/>
  142:             public string MsanDevId { get; set; }
  143:  
  144:             /// <summary/>
  145:             public int Fn { get; set; }
  146:  
  147:             /// <summary/>
  148:             public int Sn { get; set; }
  149:  
  150:             /// <summary/>
  151:             public int Pn { get; set; }
  152:  
  153:             /// <summary/>
  154:             public string Name { get; set; }
  155:  
  156:             /// <summary/>
  157:             public List<string> List { get; set; }
  158:  
  159:             /// <summary/>
  160:             public DateTime DateTime { get; set; }
  161:  
  162:             /// <summary/>
  163:             public string StaffIdentityUserId { get; set; }
  164:  
  165:             /// <summary/>
  166:             public string Serialization { get; set; }
  167:  
  168:             ////////////////////////////////////////////////////////////////////////////
  169:  
  170:             /// <summary>
  171:             ///
  172:             /// </summary>
  173:             public Message()
  174:             {
  175:             }
  176:  
  177:             ////////////////////////////////////////////////////////////////////////////
  178:  
  179:             /// <summary>
  180:             ///
  181:             /// </summary>
  182:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process)
  183:             {
  184:                 this.Sender = sender;
  185:                 this.Process = process;
  186:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  187:                 this.StaffIdentityUserId = string.Empty;
  188:  
  189:                 this.Serialization = Serialize();
  190:             }
  191:  
  192:             ////////////////////////////////////////////////////////////////////////////
  193:  
  194:             /// <summary>
  195:             ///
  196:             /// </summary>
  197:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, bool state)
  198:             {
  199:                 this.Sender = sender;
  200:                 this.Process = process;
  201:                 this.State = state;
  202:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  203:                 this.StaffIdentityUserId = string.Empty;
  204:  
  205:                 this.Serialization = Serialize();
  206:             }
  207:  
  208:             ////////////////////////////////////////////////////////////////////////////
  209:  
  210:             /// <summary>
  211:             ///
  212:             /// </summary>
  213:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string serviceOrAccessNameOrPayload)
  214:             {
  215:                 this.Sender = sender;
  216:                 this.Process = process;
  217:  
  218:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(serviceOrAccessNameOrPayload))
  219:                 {
  220:                     this.Service = serviceOrAccessNameOrPayload;
  221:                 }
  222:                 else if (Ia.Ftn.Cl.Models.Business.Access.AccessNameIsInAValidFormat(serviceOrAccessNameOrPayload))
  223:                 {
  224:                     this.AccessName = serviceOrAccessNameOrPayload;
  225:                 }
  226:                 else
  227:                 {
  228:                     this.Payload = serviceOrAccessNameOrPayload;
  229:                 }
  230:  
  231:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  232:                 this.StaffIdentityUserId = string.Empty;
  233:  
  234:                 this.Serialization = Serialize();
  235:             }
  236:  
  237:             ////////////////////////////////////////////////////////////////////////////
  238:  
  239:             /// <summary>
  240:             ///
  241:             /// </summary>
  242:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string serviceOrAccessNameOrPayload, string userId)
  243:             {
  244:                 this.Sender = sender;
  245:                 this.Process = process;
  246:  
  247:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(serviceOrAccessNameOrPayload))
  248:                 {
  249:                     this.Service = serviceOrAccessNameOrPayload;
  250:                 }
  251:                 else if (Ia.Ftn.Cl.Models.Business.Access.AccessNameIsInAValidFormat(serviceOrAccessNameOrPayload))
  252:                 {
  253:                     this.AccessName = serviceOrAccessNameOrPayload;
  254:                 }
  255:                 else
  256:                 {
  257:                     this.Payload = serviceOrAccessNameOrPayload;
  258:                 }
  259:  
  260:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  261:                 this.StaffIdentityUserId = userId;
  262:  
  263:                 this.Serialization = Serialize();
  264:             }
  265:  
  266:             ////////////////////////////////////////////////////////////////////////////
  267:  
  268:             /// <summary>
  269:             ///
  270:             /// </summary>
  271:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string name, List<string> list)
  272:             {
  273:                 this.Sender = sender;
  274:                 this.Process = process;
  275:                 this.Name = name;
  276:                 this.List = list;
  277:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  278:                 this.StaffIdentityUserId = string.Empty;
  279:  
  280:                 this.Serialization = Serialize();
  281:             }
  282:  
  283:             ////////////////////////////////////////////////////////////////////////////
  284:  
  285:             /// <summary>
  286:             ///
  287:             /// </summary>
  288:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, int gatewayId)
  289:             {
  290:                 this.Sender = sender;
  291:                 this.Process = process;
  292:                 this.GatewayId = gatewayId;
  293:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  294:                 this.StaffIdentityUserId = string.Empty;
  295:  
  296:                 this.Serialization = Serialize();
  297:             }
  298:  
  299:             ////////////////////////////////////////////////////////////////////////////
  300:  
  301:             /// <summary>
  302:             ///
  303:             /// </summary>
  304:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, int gatewayId, string userId)
  305:             {
  306:                 this.Sender = sender;
  307:                 this.Process = process;
  308:                 this.GatewayId = gatewayId;
  309:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  310:                 this.StaffIdentityUserId = userId;
  311:  
  312:                 this.Serialization = Serialize();
  313:             }
  314:  
  315:             ////////////////////////////////////////////////////////////////////////////
  316:  
  317:             /// <summary>
  318:             ///
  319:             /// </summary>
  320:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, string userId)
  321:             {
  322:                 this.Sender = sender;
  323:                 this.Process = process;
  324:                 this.Service = service;
  325:                 this.AccessName = accessName;
  326:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  327:                 this.StaffIdentityUserId = userId;
  328:  
  329:                 this.Serialization = Serialize();
  330:             }
  331:  
  332:             ////////////////////////////////////////////////////////////////////////////
  333:  
  334:             /// <summary>
  335:             ///
  336:             /// </summary>
  337:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, int port)
  338:             {
  339:                 this.Sender = sender;
  340:                 this.Process = process;
  341:                 this.Service = service;
  342:                 this.AccessName = accessName;
  343:                 this.Port = port;
  344:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  345:                 this.StaffIdentityUserId = string.Empty;
  346:  
  347:                 this.Serialization = Serialize();
  348:             }
  349:  
  350:             ////////////////////////////////////////////////////////////////////////////
  351:  
  352:             /// <summary>
  353:             ///
  354:             /// </summary>
  355:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, bool overrideRouterDomainRestriction, string userId)
  356:             {
  357:                 this.Sender = sender;
  358:                 this.Process = process;
  359:                 this.Service = service;
  360:                 this.AccessName = accessName;
  361:                 this.OverrideRouterDomainRestriction = overrideRouterDomainRestriction;
  362:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  363:                 this.StaffIdentityUserId = userId;
  364:  
  365:                 this.Serialization = Serialize();
  366:             }
  367:  
  368:             ////////////////////////////////////////////////////////////////////////////
  369:  
  370:             /// <summary>
  371:             ///
  372:             /// </summary>
  373:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, string accessName, int port, bool overrideRouterDomainRestriction, string userId)
  374:             {
  375:                 this.Sender = sender;
  376:                 this.Process = process;
  377:                 this.Service = service;
  378:                 this.AccessName = accessName;
  379:                 this.Port = port;
  380:                 this.OverrideRouterDomainRestriction = overrideRouterDomainRestriction;
  381:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  382:                 this.StaffIdentityUserId = userId;
  383:  
  384:                 this.Serialization = Serialize();
  385:             }
  386:  
  387:             ////////////////////////////////////////////////////////////////////////////
  388:  
  389:             /// <summary>
  390:             ///
  391:             /// </summary>
  392:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, Ia.Ftn.Cl.Models.Business.Service.SupplementaryService serviceSupplementaryService, bool serviceSupplementaryServiceState)
  393:             {
  394:                 this.Sender = sender;
  395:                 this.Process = process;
  396:                 this.Service = service;
  397:                 this.ServiceSupplementaryService = serviceSupplementaryService;
  398:                 this.ServiceSupplementaryServiceState = serviceSupplementaryServiceState;
  399:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  400:                 this.StaffIdentityUserId = string.Empty;
  401:  
  402:                 this.Serialization = Serialize();
  403:             }
  404:  
  405:             ////////////////////////////////////////////////////////////////////////////
  406:  
  407:             /// <summary>
  408:             ///
  409:             /// </summary>
  410:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string service, Ia.Ftn.Cl.Models.Business.Service.SupplementaryService serviceSupplementaryService, bool serviceSupplementaryServiceState, string userId)
  411:             {
  412:                 this.Sender = sender;
  413:                 this.Process = process;
  414:                 this.Service = service;
  415:                 this.ServiceSupplementaryService = serviceSupplementaryService;
  416:                 this.ServiceSupplementaryServiceState = serviceSupplementaryServiceState;
  417:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  418:                 this.StaffIdentityUserId = userId;
  419:  
  420:                 this.Serialization = Serialize();
  421:             }
  422:  
  423:             ////////////////////////////////////////////////////////////////////////////
  424:  
  425:             /// <summary>
  426:             ///
  427:             /// </summary>
  428:             public Message(Ia.Ftn.Cl.Models.Business.MessageQueue.Application sender, Ia.Ftn.Cl.Models.Business.MessageQueue.Process process, string msanDevId, int fn, int sn, int pn, string service)
  429:             {
  430:                 this.Sender = sender;
  431:                 this.Process = process;
  432:                 this.MsanDevId = msanDevId;
  433:                 this.Fn = fn;
  434:                 this.Sn = sn;
  435:                 this.Pn = pn;
  436:                 this.Service = service;
  437:                 this.DateTime = DateTime.UtcNow.AddHours(3);
  438:                 this.StaffIdentityUserId = string.Empty;
  439:  
  440:                 this.Serialization = Serialize();
  441:             }
  442:  
  443:             ////////////////////////////////////////////////////////////////////////////
  444:             ////////////////////////////////////////////////////////////////////////////
  445:  
  446:             /// <summary>
  447:             ///
  448:             /// </summary>
  449:             public T DeserializePayload<T>()
  450:             {
  451:                 var t = Deserialize<T>(this.Payload);
  452:  
  453:                 return t;
  454:             }
  455:  
  456:             ////////////////////////////////////////////////////////////////////////////
  457:  
  458:             /// <summary>
  459:             ///
  460:             /// </summary>
  461:             public static Message Deserialize(string json)
  462:             {
  463:                 Message message;
  464:  
  465:                 if (!string.IsNullOrEmpty(json))
  466:                 {
  467:                     message = JsonSerializer.Deserialize<Message>(json);
  468:  
  469:                     message.Serialization = json;
  470:                 }
  471:                 else message = default(Message);
  472:  
  473:                 return message;
  474:             }
  475:  
  476:             ////////////////////////////////////////////////////////////////////////////
  477:  
  478:             /// <summary>
  479:             ///
  480:             /// </summary>
  481:             private string Serialize()
  482:             {
  483:                 var jsonSerializerOptions = new JsonSerializerOptions
  484:                 {
  485:                     WriteIndented = true
  486:                 };
  487:  
  488:                 return JsonSerializer.Serialize(this, jsonSerializerOptions);
  489:             }
  490:  
  491:             ////////////////////////////////////////////////////////////////////////////
  492:  
  493:             /// <summary>
  494:             ///
  495:             /// </summary>
  496:             public static string Serialize<T>(T t)
  497:             {
  498:                 var jsonSerializerOptions = new JsonSerializerOptions
  499:                 {
  500:                     WriteIndented = true
  501:                 };
  502:  
  503:                 var json = JsonSerializer.Serialize<T>(t, jsonSerializerOptions);
  504:  
  505:                 return json;
  506:             }
  507:  
  508:             ////////////////////////////////////////////////////////////////////////////
  509:  
  510:             /// <summary>
  511:             ///
  512:             /// </summary>
  513:             public static T Deserialize<T>(string json)
  514:             {
  515:                 T t;
  516:  
  517:                 if (!string.IsNullOrEmpty(json))
  518:                 {
  519:                     t = JsonSerializer.Deserialize<T>(json);
  520:                 }
  521:                 else t = default;
  522:  
  523:                 return t;
  524:             }
  525:  
  526:             ////////////////////////////////////////////////////////////////////////////
  527:         }
  528:  
  529:         ////////////////////////////////////////////////////////////////////////////
  530:         ////////////////////////////////////////////////////////////////////////////
  531:     }
  532: }