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