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

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 partial class Msmq
  25:      {
  26:          ////////////////////////////////////////////////////////////////////////////
  27:   
  28:          /// <summary>
  29:          ///
  30:          /// </summary>
  31:          public sealed class ServiceQueue
  32:          {
  33:              private const string queueName = "msmq/data/default/queue/service";
  34:   
  35:              /// <summary/>
  36:              public static void Enqueue(string service)
  37:              {
  38:                  // I will check if the items is in the list, if not I will enqueue
  39:                  if(!List.Contains(service)) Ia.Cl.Model.Msmq.SendPrivate(queueName, "enqueue", service);
  40:              }
  41:   
  42:              /// <summary/>
  43:              public static string Dequeue
  44:              {
  45:                  get
  46:                  {
  47:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
  48:   
  49:                      return body;
  50:                  }
  51:              }
  52:   
  53:              /// <summary/>
  54:              public static string Peek
  55:              {
  56:                  get
  57:                  {
  58:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
  59:   
  60:                      return body;
  61:                  }
  62:              }
  63:   
  64:              /// <summary/>
  65:              public static List<string> List
  66:              {
  67:                  get
  68:                  {
  69:                      return Ia.Cl.Model.Msmq.PeekPrivateList(queueName);
  70:                  }
  71:              }
  72:   
  73:              /// <summary/>
  74:              public static long Count
  75:              {
  76:                  get
  77:                  {
  78:                      return Ia.Cl.Model.Msmq.Count(queueName);
  79:                  }
  80:              }
  81:          }
  82:   
  83:          ////////////////////////////////////////////////////////////////////////////
  84:   
  85:          /// <summary>
  86:          ///
  87:          /// </summary>
  88:          public sealed class AccessNameQueue
  89:          {
  90:              private const string queueName = "msmq/data/default/queue/access-name";
  91:   
  92:              /// <summary/>
  93:              public static void Enqueue(string accessName)
  94:              {
  95:                  // I will check if the items is in the list, if not I will enqueue
  96:                  if (!List.Contains(accessName)) Ia.Cl.Model.Msmq.SendPrivate(queueName, "enqueue", accessName);
  97:              }
  98:   
  99:              /// <summary/>
 100:              public static string Dequeue
 101:              {
 102:                  get
 103:                  {
 104:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 105:   
 106:                      return body;
 107:                  }
 108:              }
 109:   
 110:              /// <summary/>
 111:              public static string Peek
 112:              {
 113:                  get
 114:                  {
 115:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
 116:   
 117:                      return body;
 118:                  }
 119:              }
 120:   
 121:              /// <summary/>
 122:              public static List<string> List
 123:              {
 124:                  get
 125:                  {
 126:                      return Ia.Cl.Model.Msmq.PeekPrivateList(queueName);
 127:                  }
 128:              }
 129:   
 130:              /// <summary/>
 131:              public static long Count
 132:              {
 133:                  get
 134:                  {
 135:                      return Ia.Cl.Model.Msmq.Count(queueName);
 136:                  }
 137:              }
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:   
 142:          /// <summary>
 143:          ///
 144:          /// </summary>
 145:          public sealed class GatewayIdQueue
 146:          {
 147:              private const string queueName = "msmq/data/default/queue/gatewayId";
 148:   
 149:              /// <summary/>
 150:              public static void Enqueue(int gatewayId)
 151:              {
 152:                  // I will check if the items is in the list, if not I will enqueue
 153:                  if (!List.Contains(gatewayId.ToString())) Ia.Cl.Model.Msmq.SendPrivate(queueName, "enqueue", gatewayId.ToString());
 154:              }
 155:   
 156:              /// <summary/>
 157:              public static int Dequeue
 158:              {
 159:                  get
 160:                  {
 161:                      int i;
 162:   
 163:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 164:   
 165:                      i = int.TryParse(body, out i) ? i : 0;
 166:   
 167:                      return i;
 168:                  }
 169:              }
 170:   
 171:              /// <summary/>
 172:              public static int Peek
 173:              {
 174:                  get
 175:                  {
 176:                      int i;
 177:   
 178:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
 179:   
 180:                      i = int.TryParse(body, out i) ? i : 0;
 181:   
 182:                      return i;
 183:                  }
 184:              }
 185:   
 186:              /// <summary/>
 187:              public static List<string> List
 188:              {
 189:                  get
 190:                  {
 191:                      return Ia.Cl.Model.Msmq.PeekPrivateList(queueName);
 192:                  }
 193:              }
 194:   
 195:              /// <summary/>
 196:              public static long Count
 197:              {
 198:                  get
 199:                  {
 200:                      return Ia.Cl.Model.Msmq.Count(queueName);
 201:                  }
 202:              }
 203:          }
 204:   
 205:          ////////////////////////////////////////////////////////////////////////////
 206:   
 207:          /// <summary>
 208:          ///
 209:          /// </summary>
 210:          public sealed class NewAccessFlag
 211:          {
 212:              private const string queueName = "msmq/data/default/flag/new-access";
 213:   
 214:              /// <summary/>
 215:              public static void Set()
 216:              {
 217:                  Ia.Cl.Model.Msmq.SendPrivate(queueName, "set", true.ToString());
 218:              }
 219:   
 220:              /// <summary/>
 221:              public static void Reset()
 222:              {
 223:                  Ia.Cl.Model.Msmq.SendPrivate(queueName, "reset", false.ToString());
 224:              }
 225:   
 226:              /// <summary/>
 227:              public static bool Read
 228:              {
 229:                  get
 230:                  {
 231:                      bool b;
 232:   
 233:                      Ia.Cl.Model.Msmq.RecievePrivate(queueName, out string label, out string body);
 234:   
 235:                      b = bool.TryParse(body.ToString(), out b) ? b : false;
 236:   
 237:                      return b;
 238:                  }
 239:              }
 240:   
 241:              /// <summary/>
 242:              public static bool Peek
 243:              {
 244:                  get
 245:                  {
 246:                      bool b;
 247:   
 248:                      Ia.Cl.Model.Msmq.PeekPrivate(queueName, out string label, out string body);
 249:   
 250:                      b = bool.TryParse(body.ToString(), out b) ? b : false;
 251:   
 252:                      return b;
 253:                  }
 254:              }
 255:          }
 256:   
 257:          ////////////////////////////////////////////////////////////////////////////
 258:          ////////////////////////////////////////////////////////////////////////////
 259:      }
 260:  }