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

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

POTS legacy support class for Fixed Telecommunications Network (FTN) data model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.IO;
    4: using System.Reflection;
    5: using System.Xml.Linq;
    6:  
    7: namespace Ia.Ftn.Cl.Models.Data
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// POTS legacy support class for Fixed Telecommunications Network (FTN) data model.
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     /// </remarks> 
   18:     public class Pots
   19:     {
   20:         private static XDocument xDocument;
   21:         private static List<Category> categoryList;
   22:  
   23:         private static readonly object objectLock = new object();
   24:  
   25:         ////////////////////////////////////////////////////////////////////////////
   26:  
   27:         /// <summary>
   28:         ///
   29:         /// </summary>
   30:         public Pots() { }
   31:  
   32:         ////////////////////////////////////////////////////////////////////////////
   33:         ////////////////////////////////////////////////////////////////////////////
   34:  
   35:         public class Category
   36:         {
   37:             public Category() { }
   38:  
   39:             public int Id { get; set; }
   40:             public string Name { get; set; }
   41:             public string ArabicName { get; set; }
   42:             /*
   43:             public virtual ICollection<Area> Areas
   44:             {
   45:                 get
   46:                 {
   47:                     return (from q in AreaList where q.Category.Id == this.Id select q).ToList();
   48:                 }
   49:             }
   50:              */
   51:         }
   52:  
   53:         ////////////////////////////////////////////////////////////////////////////
   54:  
   55:         /// <summary>
   56:         ///
   57:         /// </summary>
   58:         public static List<Ia.Ftn.Cl.Models.Data.Pots.Category> CategoryList
   59:         {
   60:             get
   61:             {
   62:                 if (categoryList == null || categoryList.Count == 0)
   63:                 {
   64:                     lock (objectLock)
   65:                     {
   66:                         categoryList = Ia.Ftn.Cl.Models.Data.Pots._CategoryList;
   67:                     }
   68:                 }
   69:  
   70:                 return categoryList;
   71:             }
   72:         }
   73:  
   74:         ////////////////////////////////////////////////////////////////////////////
   75:  
   76:         /// <summary>
   77:         ///
   78:         /// </summary>
   79:         private static List<Ia.Ftn.Cl.Models.Data.Pots.Category> _CategoryList
   80:         {
   81:             get
   82:             {
   83:                 int id;
   84:                 Category category;
   85:  
   86:                 categoryList = new List<Category>();
   87:  
   88:                 foreach (XElement x in XDocument.Element("report").Elements("category"))
   89:                 {
   90:                     category = new Category();
   91:  
   92:                     id = int.Parse(x.Attribute("id").Value);
   93:  
   94:                     category.Id = id;
   95:                     category.Name = x.Attribute("name").Value;
   96:                     category.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
   97:  
   98:                     categoryList.Add(category);
   99:                 }
  100:  
  101:                 return categoryList;
  102:             }
  103:         }
  104:  
  105:         ////////////////////////////////////////////////////////////////////////////
  106:         ////////////////////////////////////////////////////////////////////////////
  107:  
  108:         /// <summary>
  109:         /// 
  110:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
  111:         /// 
  112:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
  113:         /// 2. Add "using System.Reflection".
  114:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  115:         /// 
  116:         /// </summary>
  117:  
  118:         public static XDocument XDocument
  119:         {
  120:             get
  121:             {
  122:                 if (xDocument == null)
  123:                 {
  124:                     lock (objectLock)
  125:                     {
  126:                         Assembly assembly;
  127:                         StreamReader streamReader;
  128:  
  129:                         assembly = Assembly.GetExecutingAssembly();
  130:                         streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Ftn.Cl.Models.Data.pots.xml"));
  131:  
  132:                         try
  133:                         {
  134:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  135:                         }
  136:                         catch (Exception)
  137:                         {
  138:                         }
  139:                         finally
  140:                         {
  141:                         }
  142:                     }
  143:                 }
  144:  
  145:                 return xDocument;
  146:             }
  147:         }
  148:  
  149:         ////////////////////////////////////////////////////////////////////////////
  150:         ////////////////////////////////////////////////////////////////////////////    
  151:     }
  152:  
  153:     ////////////////////////////////////////////////////////////////////////////
  154:     ////////////////////////////////////////////////////////////////////////////   
  155: }