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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Transaction

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

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

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data;
   4:  using System.IO;
   5:  using System.Linq;
   6:  using System.Reflection;
   7:  using System.Xml.Linq;
   8:   
   9:  namespace Ia.Ngn.Cl.Model.Data
  10:  {
  11:      ////////////////////////////////////////////////////////////////////////////
  12:   
  13:      /// <summary publish="true">
  14:      /// Transaction support class for Next Generation Network (NGN) data model.
  15:      /// </summary>
  16:      /// 
  17:      /// <remarks> 
  18:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  19:      ///
  20:      /// 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
  21:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  22:      ///
  23:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  24:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  25:      /// 
  26:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  27:      /// 
  28:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  29:      /// </remarks> 
  30:      public partial class Transaction
  31:      {
  32:          private static XDocument xDocument;
  33:          private static List<System> systemList;
  34:          private static List<Process> processList;
  35:          private static List<Function> functionList;
  36:   
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public struct Direction
  43:          {
  44:              public int Id { get; set; }
  45:              public string Name { get; set; }
  46:              public string ArabicName { get; set; }
  47:          }
  48:   
  49:          ////////////////////////////////////////////////////////////////////////////
  50:   
  51:          /// <summary>
  52:          ///
  53:          /// </summary>
  54:          public class System
  55:          {
  56:              public int Id { get; set; }
  57:              public string Name { get; set; }
  58:              public virtual ICollection<Process> Processes
  59:              {
  60:                  get
  61:                  {
  62:                      return (from p in ProcessList where p.System.Id == this.Id select p).ToList();
  63:                  }
  64:              }
  65:          }
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          public class Process
  73:          {
  74:              public int Id { get; set; }
  75:              public string Name { get; set; }
  76:              public virtual System System { get; set; }
  77:              public virtual ICollection<Function> Functions
  78:              {
  79:                  get
  80:                  {
  81:                      return (from f in FunctionList where f.Process.Id == this.Id select f).ToList();
  82:                  }
  83:              }
  84:   
  85:              public static int ProcessId(int systemId, int id)
  86:              {
  87:                  return systemId * 100 + id;
  88:              }
  89:          }
  90:   
  91:          ////////////////////////////////////////////////////////////////////////////
  92:   
  93:          /// <summary>
  94:          ///
  95:          /// </summary>
  96:          public class Function
  97:          {
  98:              public int Id { get; set; }
  99:              public string Name { get; set; }
 100:              public string Parameter { get; set; }
 101:              public virtual Process Process { get; set; }
 102:   
 103:              public static int FunctionId(int processId, int id)
 104:              {
 105:                  return processId * 100 + id;
 106:              }
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          ///
 113:          /// </summary>
 114:          public Transaction() { }
 115:   
 116:          //////////////////////////////////////////////////////////////////////////////
 117:   
 118:          ///// <summary>
 119:          /////
 120:          ///// </summary>
 121:          public static List<System> SystemList
 122:          {
 123:              get
 124:              {
 125:                  if (systemList == null || systemList.Count == 0)
 126:                  {
 127:                      System system;
 128:   
 129:                      systemList = new List<System>();
 130:   
 131:                      foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system"))
 132:                      {
 133:                          system = new System();
 134:   
 135:                          system.Id = int.Parse(xe.Attribute("id").Value);
 136:                          system.Name = xe.Attribute("name").Value;
 137:   
 138:                          systemList.Add(system);
 139:                      }
 140:                  }
 141:   
 142:                  return systemList;
 143:              }
 144:          }
 145:   
 146:          //////////////////////////////////////////////////////////////////////////////
 147:   
 148:          ///// <summary>
 149:          /////
 150:          ///// </summary>
 151:          public static List<Process> ProcessList
 152:          {
 153:              get
 154:              {
 155:                  if (processList == null || processList.Count == 0)
 156:                  {
 157:                      int systemId, id;
 158:                      Process process;
 159:   
 160:                      processList = new List<Process>();
 161:   
 162:                      foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system").Elements("processList").Elements("process"))
 163:                      {
 164:                          process = new Process();
 165:   
 166:                          systemId = int.Parse(xe.Parent.Parent.Attribute("id").Value);
 167:                          id = int.Parse(xe.Attribute("id").Value);
 168:   
 169:                          process.System = (from s in SystemList where s.Id == systemId select s).Single();
 170:                          process.Id = Process.ProcessId(systemId, id);
 171:                          process.Name = xe.Attribute("name").Value;
 172:   
 173:                          processList.Add(process);
 174:                      }
 175:                  }
 176:   
 177:                  return processList;
 178:              }
 179:          }
 180:   
 181:          //////////////////////////////////////////////////////////////////////////////
 182:   
 183:          ///// <summary>
 184:          /////
 185:          ///// </summary>
 186:          public static List<Function> FunctionList
 187:          {
 188:              get
 189:              {
 190:                  if (functionList == null || functionList.Count == 0)
 191:                  {
 192:                      int systemId, processId, id;
 193:                      Function function;
 194:   
 195:                      functionList = new List<Function>();
 196:   
 197:                      foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system").Elements("processList").Elements("process").Elements("functionList").Elements("function"))
 198:                      {
 199:                          function = new Function();
 200:   
 201:                          systemId = int.Parse(xe.Parent.Parent.Parent.Parent.Attribute("id").Value);
 202:                          id = int.Parse(xe.Parent.Parent.Attribute("id").Value);
 203:                          processId = Process.ProcessId(systemId, id);
 204:                          id = int.Parse(xe.Attribute("id").Value);
 205:   
 206:                          function.Process = (from p in ProcessList where p.Id == processId select p).Single();
 207:                          function.Id = Function.FunctionId(processId, id);
 208:                          function.Name = xe.Attribute("name").Value;
 209:   
 210:                          functionList.Add(function);
 211:                      }
 212:                  }
 213:   
 214:                  return functionList;
 215:              }
 216:          }
 217:   
 218:          ////////////////////////////////////////////////////////////////////////////
 219:   
 220:          /// <summary>
 221:          /// 
 222:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 223:          /// 
 224:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 225:          /// 2. Add "using System.Reflection".
 226:          /// 3. See sample below.
 227:          /// 
 228:          /// </summary>
 229:   
 230:          private static XDocument XDocument
 231:          {
 232:              get
 233:              {
 234:                  if (xDocument == null)
 235:                  {
 236:                      Assembly _assembly;
 237:                      StreamReader streamReader;
 238:   
 239:                      _assembly = Assembly.GetExecutingAssembly();
 240:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.transaction.xml"));
 241:   
 242:                      try
 243:                      {
 244:                          if (streamReader.Peek() != -1)
 245:                          {
 246:                              xDocument = global::System.Xml.Linq.XDocument.Load(streamReader);
 247:                          }
 248:                      }
 249:                      catch (Exception)
 250:                      {
 251:                      }
 252:                      finally
 253:                      {
 254:                      }
 255:                  }
 256:   
 257:                  return xDocument;
 258:              }
 259:          }
 260:   
 261:          ////////////////////////////////////////////////////////////////////////////
 262:          ////////////////////////////////////////////////////////////////////////////    
 263:      }
 264:   
 265:      /*
 266:      /// <summary/>
 267:      public enum State
 268:      {
 269:          Initiated = 1, NoConnection = 2, NotSent = 3, Sent = 4, Closed = 5, Unspecified = 6
 270:      }
 271:  
 272:      /// <summary/>
 273:      public enum Priority
 274:      {
 275:          Urgent = 1, Important = 2, Regular = 3, Unspecified = 4
 276:      }
 277:  
 278:      /// <summary/>
 279:      public enum Recipient
 280:      {
 281:          AluMgc = 1, AluAms = 2, AluIms = 3 //Ftp, Hsi, HuIms, Si???, Tnmd, etc
 282:      }
 283:       */
 284:   
 285:      ////////////////////////////////////////////////////////////////////////////
 286:      ////////////////////////////////////////////////////////////////////////////   
 287:  }