شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Msmq

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

MSMQ support class for Next Generation Network (NGN) data model.

   1:  using System.Collections.Generic;
   2:   
   3:  namespace Ia.Ngn.Cl.Model.Data
   4:  {
   5:      ////////////////////////////////////////////////////////////////////////////
   6:   
   7:      /// <summary publish="true">
   8:      /// MSMQ support class for Next Generation Network (NGN) data model.
   9:      /// </summary>
  10:      /// 
  11:      /// <remarks> 
  12:      /// Copyright © 2018-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  13:      ///
  14:      /// 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
  15:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  16:      ///
  17:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  18:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  19:      /// 
  20:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  21:      /// 
  22:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  23:      /// </remarks> 
  24:      public abstract partial class Msmq
  25:      {
  26:          ////////////////////////////////////////////////////////////////////////////
  27:   
  28:          /// <summary>
  29:          ///
  30:          /// </summary>
  31:          public class Queue
  32:          {
  33:              // I can't use properties from child classes in virtual function in parents
  34:              // there is a reason why I can't construct a virsual abstract method
  35:          }
  36:   
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public abstract class ServiceQueue : Queue
  43:          {
  44:              protected static readonly string serviceApplicationQueueName = "msmq/data/default/queue/service/service-application";
  45:              protected static readonly string netManagerApplicationQueueName = "msmq/data/default/queue/service/net-manager-application";
  46:              protected static readonly string serviceRequestApplicationQueueName = "msmq/data/default/queue/service/service-request-application";
  47:              protected static readonly string spsApplicationQueueName = "msmq/data/default/queue/service/sps-application";
  48:              protected static readonly string axeApplicationQueueName = "msmq/data/default/queue/service/axe-application";
  49:   
  50:              ////////////////////////////////////////////////////////////////////////////
  51:   
  52:              /// <summary>
  53:              ///
  54:              /// </summary>
  55:              public static void Enqueue(string service)
  56:              {
  57:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
  58:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
  59:   
  60:                  if (!Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.ServiceRequestApplication.List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(serviceRequestApplicationQueueName, "enqueue", service);
  61:   
  62:                  switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
  63:   
  64:                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia || switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
  65:                  {
  66:                      if (!Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.ServiceApplication.List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(serviceApplicationQueueName, "enqueue", service);
  67:                  }
  68:   
  69:                  // if service belongs to PSTN:
  70:                  if (Ia.Ngn.Cl.Model.Data.Service.ServiceIsWithinPstnDomainList(service))
  71:                  {
  72:                      // test to see if service is in Siemens EWSD or Ericsson AXE
  73:                      pstn = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnFromService(service);
  74:   
  75:                      if (pstn.PstnExchangeType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd)
  76:                      {
  77:                          if (!Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.NetManagerApplication.List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(netManagerApplicationQueueName, "enqueue", service);
  78:                      }
  79:                      else if (pstn.PstnExchangeType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe)
  80:                      {
  81:                          if (!Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.AxeApplication.List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(axeApplicationQueueName, "enqueue", service);
  82:                      }
  83:                      else
  84:                      {
  85:   
  86:                      }
  87:   
  88:                      if (!Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.SpsApplication.List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(spsApplicationQueueName, "enqueue", service);
  89:                  }
  90:              }
  91:   
  92:              ////////////////////////////////////////////////////////////////////////////
  93:   
  94:              /// <summary>
  95:              ///
  96:              /// </summary>
  97:              public abstract class ServiceApplication
  98:              {
  99:                  private static readonly string queueName = serviceApplicationQueueName;
 100:   
 101:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 102:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 103:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 104:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 105:              }
 106:   
 107:              ////////////////////////////////////////////////////////////////////////////
 108:   
 109:              /// <summary>
 110:              ///
 111:              /// </summary>
 112:              public abstract class NetManagerApplication
 113:              {
 114:                  private static readonly string queueName = netManagerApplicationQueueName;
 115:   
 116:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 117:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 118:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 119:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 120:              }
 121:   
 122:              ////////////////////////////////////////////////////////////////////////////
 123:   
 124:              /// <summary>
 125:              ///
 126:              /// </summary>
 127:              public abstract class ServiceRequestApplication
 128:              {
 129:                  private static readonly string queueName = serviceRequestApplicationQueueName;
 130:   
 131:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 132:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 133:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 134:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 135:              }
 136:   
 137:              ////////////////////////////////////////////////////////////////////////////
 138:   
 139:              /// <summary>
 140:              ///
 141:              /// </summary>
 142:              public abstract class SpsApplication
 143:              {
 144:                  private static readonly string queueName = spsApplicationQueueName;
 145:   
 146:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 147:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 148:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 149:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 150:              }
 151:   
 152:              ////////////////////////////////////////////////////////////////////////////
 153:   
 154:              /// <summary>
 155:              ///
 156:              /// </summary>
 157:              public abstract class AxeApplication
 158:              {
 159:                  private static readonly string queueName = axeApplicationQueueName;
 160:   
 161:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 162:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 163:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 164:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 165:              }
 166:   
 167:              ////////////////////////////////////////////////////////////////////////////
 168:              ////////////////////////////////////////////////////////////////////////////
 169:          }
 170:   
 171:          ////////////////////////////////////////////////////////////////////////////
 172:          ////////////////////////////////////////////////////////////////////////////
 173:   
 174:          /// <summary>
 175:          ///
 176:          /// </summary>
 177:          public abstract class AccessNameQueue : Queue
 178:          {
 179:              protected static readonly string amsApplicationQueueName = "msmq/data/default/queue/access-name/ams-application";
 180:              protected static readonly string msanApplicationQueueName = "msmq/data/default/queue/access-name/msan-application";
 181:   
 182:              ////////////////////////////////////////////////////////////////////////////
 183:   
 184:              /// <summary>
 185:              ///
 186:              /// </summary>
 187:              public static void Enqueue(string accessName)
 188:              {
 189:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor;
 190:   
 191:                  accessVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AccessVendorByAccessName(accessName);
 192:   
 193:                  if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 194:                  {
 195:                      // I will check if the items is in the list, if not I will enqueue
 196:                      if (!Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.AmsApplication.List.Contains(accessName))
 197:                      {
 198:                          Ia.Cl.Model.Msmq.SendPrivate(amsApplicationQueueName, "enqueue", accessName);
 199:                      }
 200:                  }
 201:                  else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 202:                  {
 203:                      if (!Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.MsanApplication.List.Contains(accessName))
 204:                      {
 205:                          Ia.Cl.Model.Msmq.SendPrivate(msanApplicationQueueName, "enqueue", accessName);
 206:                      }
 207:                  }
 208:              }
 209:   
 210:              ////////////////////////////////////////////////////////////////////////////
 211:   
 212:              /// <summary>
 213:              ///
 214:              /// </summary>
 215:              public abstract class AmsApplication
 216:              {
 217:                  private static readonly string queueName = amsApplicationQueueName;
 218:   
 219:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 220:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 221:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 222:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 223:              }
 224:   
 225:              ////////////////////////////////////////////////////////////////////////////
 226:   
 227:              /// <summary>
 228:              ///
 229:              /// </summary>
 230:              public abstract class MsanApplication
 231:              {
 232:                  private static readonly string queueName = msanApplicationQueueName;
 233:   
 234:                  public static string Dequeue { get { Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body); return body; } }
 235:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 236:                  public static List<string> List { get { return Ia.Cl.Model.Msmq.PeekPrivateList(queueName); } }
 237:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 238:              }
 239:   
 240:              ////////////////////////////////////////////////////////////////////////////
 241:              ////////////////////////////////////////////////////////////////////////////
 242:          }
 243:   
 244:          ////////////////////////////////////////////////////////////////////////////
 245:          ////////////////////////////////////////////////////////////////////////////
 246:   
 247:          /// <summary>
 248:          ///
 249:          /// </summary>
 250:          public abstract class GatewayIdQueue : Queue
 251:          {
 252:              protected static readonly string serviceApplicationQueueName = "msmq/data/default/queue/gatewayId/service-application";
 253:   
 254:              ////////////////////////////////////////////////////////////////////////////
 255:   
 256:              /// <summary>
 257:              ///
 258:              /// </summary>
 259:              public static void Enqueue(int gatewayId)
 260:              {
 261:                  // I will check if the items is in the list, if not I will enqueue
 262:                  if (!Ia.Ngn.Cl.Model.Data.Msmq.GatewayIdQueue.ServiceApplication.List.Contains(gatewayId)) Ia.Cl.Model.Msmq.SendPrivate(serviceApplicationQueueName, "enqueue", gatewayId.ToString());
 263:              }
 264:   
 265:              ////////////////////////////////////////////////////////////////////////////
 266:   
 267:              /// <summary>
 268:              ///
 269:              /// </summary>
 270:              public abstract class ServiceApplication
 271:              {
 272:                  private static readonly string queueName = serviceApplicationQueueName;
 273:   
 274:                  ////////////////////////////////////////////////////////////////////////////
 275:   
 276:                  /// <summary>
 277:                  ///
 278:                  /// </summary>
 279:                  public static int Dequeue
 280:                  {
 281:                      get
 282:                      {
 283:   
 284:                          Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 285:   
 286:                          int.TryParse(body, out int gatewayId);
 287:   
 288:                          return gatewayId;
 289:                      }
 290:                  }
 291:   
 292:                  public static string Peek { get { Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body); return body; } }
 293:                  public static List<int> List
 294:                  {
 295:                      get
 296:                      {
 297:                          List<int> gatewayIdList;
 298:   
 299:                          gatewayIdList = new List<int>();
 300:   
 301:                          foreach (string s in Ia.Cl.Model.Msmq.PeekPrivateList(queueName))
 302:                          {
 303:                              if (int.TryParse(s, out int gatewayId)) gatewayIdList.Add(gatewayId);
 304:                          }
 305:   
 306:                          return gatewayIdList;
 307:                      }
 308:                  }
 309:                  public static long Count { get { return Ia.Cl.Model.Msmq.Count(queueName); } }
 310:              }
 311:   
 312:              ////////////////////////////////////////////////////////////////////////////
 313:              ////////////////////////////////////////////////////////////////////////////
 314:          }
 315:   
 316:          ////////////////////////////////////////////////////////////////////////////
 317:          ////////////////////////////////////////////////////////////////////////////
 318:   
 319:          /// <summary>
 320:          ///
 321:          /// </summary>
 322:          public abstract class System : Queue
 323:          {
 324:              protected static readonly string queueName = "msmq/data/default/queue/system";
 325:   
 326:              ////////////////////////////////////////////////////////////////////////////
 327:   
 328:              /// <summary>
 329:              ///
 330:              /// </summary>
 331:              public static void Enqueue(string sender, string message)
 332:              {
 333:                  Ia.Cl.Model.Msmq.SendPrivate(queueName, sender, message);
 334:              }
 335:   
 336:              ////////////////////////////////////////////////////////////////////////////
 337:   
 338:              /// <summary>
 339:              ///
 340:              /// </summary>
 341:              public static string Dequeue
 342:              {
 343:                  get
 344:                  {
 345:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 346:   
 347:                      return body;
 348:                  }
 349:              }
 350:   
 351:              ////////////////////////////////////////////////////////////////////////////
 352:   
 353:              /// <summary>
 354:              ///
 355:              /// </summary>
 356:              public static string Peek
 357:              {
 358:                  get
 359:                  {
 360:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
 361:   
 362:                      return body;
 363:                  }
 364:              }
 365:   
 366:              ////////////////////////////////////////////////////////////////////////////
 367:   
 368:              /// <summary>
 369:              ///
 370:              /// </summary>
 371:              public static List<string> List
 372:              {
 373:                  get
 374:                  {
 375:                      List<string> list;
 376:   
 377:                      list = new List<string>();
 378:   
 379:                      foreach (string s in Ia.Cl.Model.Msmq.PeekPrivateList(queueName)) list.Add(s);
 380:   
 381:                      return list;
 382:                  }
 383:              }
 384:   
 385:              ////////////////////////////////////////////////////////////////////////////
 386:   
 387:              /// <summary>
 388:              ///
 389:              /// </summary>
 390:              public static long Count
 391:              {
 392:                  get
 393:                  {
 394:                      return Ia.Cl.Model.Msmq.Count(queueName);
 395:                  }
 396:              }
 397:   
 398:              ////////////////////////////////////////////////////////////////////////////
 399:              ////////////////////////////////////////////////////////////////////////////
 400:          }
 401:   
 402:          ////////////////////////////////////////////////////////////////////////////
 403:          ////////////////////////////////////////////////////////////////////////////
 404:   
 405:   
 406:   
 407:   
 408:          ////////////////////////////////////////////////////////////////////////////
 409:          ////////////////////////////////////////////////////////////////////////////
 410:   
 411:          /// <summary>
 412:          ///
 413:          /// </summary>
 414:          public sealed class NewAccessFlag
 415:          {
 416:              private const string queueName = "msmq/data/default/flag/new-access";
 417:   
 418:              /// <summary/>
 419:              public static void Set()
 420:              {
 421:                  Ia.Cl.Model.Msmq.SendPrivate(queueName, "set", true.ToString());
 422:              }
 423:   
 424:              /// <summary/>
 425:              public static void Reset()
 426:              {
 427:                  Ia.Cl.Model.Msmq.SendPrivate(queueName, "reset", false.ToString());
 428:              }
 429:   
 430:              /// <summary/>
 431:              public static bool Read
 432:              {
 433:                  get
 434:                  {
 435:                      bool b;
 436:   
 437:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 438:   
 439:                      b = bool.TryParse(body.ToString(), out b) ? b : false;
 440:   
 441:                      return b;
 442:                  }
 443:              }
 444:   
 445:              /// <summary/>
 446:              public static bool Peek
 447:              {
 448:                  get
 449:                  {
 450:                      bool b;
 451:   
 452:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
 453:   
 454:                      b = bool.TryParse(body.ToString(), out b) ? b : false;
 455:   
 456:                      return b;
 457:                  }
 458:              }
 459:          }
 460:   
 461:          ////////////////////////////////////////////////////////////////////////////
 462:          ////////////////////////////////////////////////////////////////////////////
 463:      }
 464:  }