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