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