)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Transaction (Ia.Ftn.Cl.Models.Data)

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

Transaction support class for Fixed Telecommunications Network (FTN) 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.Ftn.Cl.Models.Data
   10: {
   11:     ////////////////////////////////////////////////////////////////////////////
   12:  
   13:     /// <summary publish="true">
   14:     /// Transaction support class for Fixed Telecommunications Network (FTN) data model.
   15:     /// </summary>
   16:     /// 
   17:     /// <remarks> 
   18:     /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     /// </remarks> 
   20:     public class Transaction
   21:     {
   22:         private static XDocument xDocument;
   23:         private static List<System> systemList;
   24:         private static List<Process> processList;
   25:         private static List<Function> functionList;
   26:  
   27:         private static readonly object objectLock = new object();
   28:  
   29:         ////////////////////////////////////////////////////////////////////////////
   30:  
   31:         /// <summary>
   32:         ///
   33:         /// </summary>
   34:         public struct Direction
   35:         {
   36:             public int Id { get; set; }
   37:             public string Name { get; set; }
   38:             public string ArabicName { get; set; }
   39:         }
   40:  
   41:         ////////////////////////////////////////////////////////////////////////////
   42:  
   43:         /// <summary>
   44:         ///
   45:         /// </summary>
   46:         public class System
   47:         {
   48:             public int Id { get; set; }
   49:             public string Name { get; set; }
   50:             public virtual ICollection<Process> Processes
   51:             {
   52:                 get
   53:                 {
   54:                     return (from p in ProcessList where p.System.Id == this.Id select p).ToList();
   55:                 }
   56:             }
   57:         }
   58:  
   59:         ////////////////////////////////////////////////////////////////////////////
   60:  
   61:         /// <summary>
   62:         ///
   63:         /// </summary>
   64:         public class Process
   65:         {
   66:             public int Id { get; set; }
   67:             public string Name { get; set; }
   68:             public virtual System System { get; set; }
   69:             public virtual ICollection<Function> Functions
   70:             {
   71:                 get
   72:                 {
   73:                     return (from f in FunctionList where f.Process.Id == this.Id select f).ToList();
   74:                 }
   75:             }
   76:  
   77:             public static int ProcessId(int systemId, int id)
   78:             {
   79:                 return systemId * 100 + id;
   80:             }
   81:         }
   82:  
   83:         ////////////////////////////////////////////////////////////////////////////
   84:  
   85:         /// <summary>
   86:         ///
   87:         /// </summary>
   88:         public class Function
   89:         {
   90:             public int Id { get; set; }
   91:             public string Name { get; set; }
   92:             public string Parameter { get; set; }
   93:             public virtual Process Process { get; set; }
   94:  
   95:             public static int FunctionId(int processId, int id)
   96:             {
   97:                 return processId * 100 + id;
   98:             }
   99:         }
  100:  
  101:         ////////////////////////////////////////////////////////////////////////////
  102:  
  103:         /// <summary>
  104:         ///
  105:         /// </summary>
  106:         public Transaction() { }
  107:  
  108:         //////////////////////////////////////////////////////////////////////////////
  109:  
  110:         ///// <summary>
  111:         /////
  112:         ///// </summary>
  113:         public static List<System> SystemList
  114:         {
  115:             get
  116:             {
  117:                 if (systemList == null || systemList.Count == 0)
  118:                 {
  119:                     lock (objectLock)
  120:                     {
  121:                         systemList = Ia.Ftn.Cl.Models.Data.Transaction._SystemList;
  122:                     }
  123:                 }
  124:  
  125:                 return systemList;
  126:             }
  127:         }
  128:  
  129:         //////////////////////////////////////////////////////////////////////////////
  130:  
  131:         ///// <summary>
  132:         /////
  133:         ///// </summary>
  134:         private static List<System> _SystemList
  135:         {
  136:             get
  137:             {
  138:                 System system;
  139:  
  140:                 systemList = new List<System>();
  141:  
  142:                 foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system"))
  143:                 {
  144:                     system = new System();
  145:  
  146:                     system.Id = int.Parse(xe.Attribute("id").Value);
  147:                     system.Name = xe.Attribute("name").Value;
  148:  
  149:                     systemList.Add(system);
  150:                 }
  151:  
  152:                 return systemList;
  153:             }
  154:         }
  155:  
  156:         //////////////////////////////////////////////////////////////////////////////
  157:  
  158:         ///// <summary>
  159:         /////
  160:         ///// </summary>
  161:         public static List<Process> ProcessList
  162:         {
  163:             get
  164:             {
  165:                 if (processList == null || processList.Count == 0)
  166:                 {
  167:                     lock (objectLock)
  168:                     {
  169:                         processList = Ia.Ftn.Cl.Models.Data.Transaction._ProcessList;
  170:                     }
  171:                 }
  172:  
  173:                 return processList;
  174:             }
  175:         }
  176:  
  177:         //////////////////////////////////////////////////////////////////////////////
  178:  
  179:         ///// <summary>
  180:         /////
  181:         ///// </summary>
  182:         private static List<Process> _ProcessList
  183:         {
  184:             get
  185:             {
  186:                 int systemId, id;
  187:                 Process process;
  188:  
  189:                 processList = new List<Process>();
  190:  
  191:                 foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system").Elements("processList").Elements("process"))
  192:                 {
  193:                     process = new Process();
  194:  
  195:                     systemId = int.Parse(xe.Parent.Parent.Attribute("id").Value);
  196:                     id = int.Parse(xe.Attribute("id").Value);
  197:  
  198:                     process.System = (from s in SystemList where s.Id == systemId select s).Single();
  199:                     process.Id = Process.ProcessId(systemId, id);
  200:                     process.Name = xe.Attribute("name").Value;
  201:  
  202:                     processList.Add(process);
  203:                 }
  204:  
  205:                 return processList;
  206:             }
  207:         }
  208:  
  209:         //////////////////////////////////////////////////////////////////////////////
  210:  
  211:         ///// <summary>
  212:         /////
  213:         ///// </summary>
  214:         public static List<Function> FunctionList
  215:         {
  216:             get
  217:             {
  218:                 if (functionList == null || functionList.Count == 0)
  219:                 {
  220:                     lock (objectLock)
  221:                     {
  222:                         functionList = Ia.Ftn.Cl.Models.Data.Transaction._FunctionList;
  223:                     }
  224:                 }
  225:  
  226:                 return functionList;
  227:             }
  228:         }
  229:  
  230:         //////////////////////////////////////////////////////////////////////////////
  231:  
  232:         ///// <summary>
  233:         /////
  234:         ///// </summary>
  235:         private static List<Function> _FunctionList
  236:         {
  237:             get
  238:             {
  239:                 int systemId, processId, id;
  240:                 Function function;
  241:  
  242:                 functionList = new List<Function>();
  243:  
  244:                 foreach (XElement xe in XDocument.Element("transaction").Elements("systemList").Elements("system").Elements("processList").Elements("process").Elements("functionList").Elements("function"))
  245:                 {
  246:                     function = new Function();
  247:  
  248:                     systemId = int.Parse(xe.Parent.Parent.Parent.Parent.Attribute("id").Value);
  249:                     id = int.Parse(xe.Parent.Parent.Attribute("id").Value);
  250:                     processId = Process.ProcessId(systemId, id);
  251:                     id = int.Parse(xe.Attribute("id").Value);
  252:  
  253:                     function.Process = (from p in ProcessList where p.Id == processId select p).Single();
  254:                     function.Id = Function.FunctionId(processId, id);
  255:                     function.Name = xe.Attribute("name").Value;
  256:  
  257:                     functionList.Add(function);
  258:                 }
  259:  
  260:                 return functionList;
  261:             }
  262:         }
  263:  
  264:         ////////////////////////////////////////////////////////////////////////////
  265:  
  266:         /// <summary>
  267:         /// 
  268:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
  269:         /// 
  270:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
  271:         /// 2. Add "using System.Reflection".
  272:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  273:         /// 
  274:         /// </summary>
  275:  
  276:         private static XDocument XDocument
  277:         {
  278:             get
  279:             {
  280:                 if (xDocument == null)
  281:                 {
  282:                     lock (objectLock)
  283:                     {
  284:                         Assembly assembly;
  285:                         StreamReader streamReader;
  286:  
  287:                         assembly = Assembly.GetExecutingAssembly();
  288:                         streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Ftn.Cl.Models.Data.transaction.xml"));
  289:  
  290:                         try
  291:                         {
  292:                             if (streamReader.Peek() != -1)
  293:                             {
  294:                                 xDocument = global::System.Xml.Linq.XDocument.Load(streamReader);
  295:                             }
  296:                         }
  297:                         catch (Exception)
  298:                         {
  299:                         }
  300:                         finally
  301:                         {
  302:                         }
  303:                     }
  304:                 }
  305:  
  306:                 return xDocument;
  307:             }
  308:         }
  309:  
  310:         ////////////////////////////////////////////////////////////////////////////
  311:         ////////////////////////////////////////////////////////////////////////////    
  312:     }
  313:  
  314:     /*
  315:     /// <summary/>
  316:     public enum State
  317:     {
  318:         Initiated = 1, NoConnection = 2, NotSent = 3, Sent = 4, Closed = 5, Unspecified = 6
  319:     }
  320: 
  321:     /// <summary/>
  322:     public enum Priority
  323:     {
  324:         Urgent = 1, Important = 2, Regular = 3, Unspecified = 4
  325:     }
  326: 
  327:     /// <summary/>
  328:     public enum Recipient
  329:     {
  330:         AluMgc = 1, AluAms = 2, AluIms = 3 //Ftp, Hsi, HuIms, Si???, Tnmd, etc
  331:     }
  332:      */
  333:  
  334:     ////////////////////////////////////////////////////////////////////////////
  335:     ////////////////////////////////////////////////////////////////////////////   
  336: }