)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation Links

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

MSMQ support class for Optical Fiber Network (OFN) business model.

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