)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Pots (Ia.Ftn.Cl.Model.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.Model.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:     ///
   18:     /// 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
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     public class Pots
   29:     {
   30:         private static XDocument xDocument;
   31:         private static List<Category> categoryList;
   32:  
   33:         private static readonly object objectLock = new object();
   34:  
   35:         ////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public Pots() { }
   41:  
   42:         ////////////////////////////////////////////////////////////////////////////
   43:         ////////////////////////////////////////////////////////////////////////////
   44:  
   45:         public class Category
   46:         {
   47:             public Category() { }
   48:  
   49:             public int Id { get; set; }
   50:             public string Name { get; set; }
   51:             public string ArabicName { get; set; }
   52:             /*
   53:             public virtual ICollection<Area> Areas
   54:             {
   55:                 get
   56:                 {
   57:                     return (from q in AreaList where q.Category.Id == this.Id select q).ToList();
   58:                 }
   59:             }
   60:              */
   61:         }
   62:  
   63:         ////////////////////////////////////////////////////////////////////////////
   64:  
   65:         /// <summary>
   66:         ///
   67:         /// </summary>
   68:         public static List<Ia.Ftn.Cl.Model.Data.Pots.Category> CategoryList
   69:         {
   70:             get
   71:             {
   72:                 if (categoryList == null || categoryList.Count == 0)
   73:                 {
   74:                     lock (objectLock)
   75:                     {
   76:                         categoryList = Ia.Ftn.Cl.Model.Data.Pots._CategoryList;
   77:                     }
   78:                 }
   79:  
   80:                 return categoryList;
   81:             }
   82:         }
   83:  
   84:         ////////////////////////////////////////////////////////////////////////////
   85:  
   86:         /// <summary>
   87:         ///
   88:         /// </summary>
   89:         private static List<Ia.Ftn.Cl.Model.Data.Pots.Category> _CategoryList
   90:         {
   91:             get
   92:             {
   93:                 int id;
   94:                 Category category;
   95:  
   96:                 categoryList = new List<Category>();
   97:  
   98:                 foreach (XElement x in XDocument.Element("report").Elements("category"))
   99:                 {
  100:                     category = new Category();
  101:  
  102:                     id = int.Parse(x.Attribute("id").Value);
  103:  
  104:                     category.Id = id;
  105:                     category.Name = x.Attribute("name").Value;
  106:                     category.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
  107:  
  108:                     categoryList.Add(category);
  109:                 }
  110:  
  111:                 return categoryList;
  112:             }
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:         ////////////////////////////////////////////////////////////////////////////
  117:  
  118:         /// <summary>
  119:         /// 
  120:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
  121:         /// 
  122:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
  123:         /// 2. Add "using System.Reflection".
  124:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  125:         /// 
  126:         /// </summary>
  127:  
  128:         public static XDocument XDocument
  129:         {
  130:             get
  131:             {
  132:                 if (xDocument == null)
  133:                 {
  134:                     lock (objectLock)
  135:                     {
  136:                         Assembly _assembly;
  137:                         StreamReader streamReader;
  138:  
  139:                         _assembly = Assembly.GetExecutingAssembly();
  140:                         streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ftn.Cl.model.data.pots.xml"));
  141:  
  142:                         try
  143:                         {
  144:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  145:                         }
  146:                         catch (Exception)
  147:                         {
  148:                         }
  149:                         finally
  150:                         {
  151:                         }
  152:                     }
  153:                 }
  154:  
  155:                 return xDocument;
  156:             }
  157:         }
  158:  
  159:         ////////////////////////////////////////////////////////////////////////////
  160:         ////////////////////////////////////////////////////////////////////////////    
  161:     }
  162:  
  163:     ////////////////////////////////////////////////////////////////////////////
  164:     ////////////////////////////////////////////////////////////////////////////   
  165: }