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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Pots

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

POTS legacy support class for Next Generation Network (NGN) 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.Ngn.Cl.Model.Data
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// POTS legacy support class for Next Generation Network (NGN) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 partial class Pots
  29:      {
  30:          private static XDocument xDocument;
  31:          private static List<Category> categoryList;
  32:   
  33:          ////////////////////////////////////////////////////////////////////////////
  34:   
  35:          /// <summary>
  36:          ///
  37:          /// </summary>
  38:          public Pots() { }
  39:   
  40:          ////////////////////////////////////////////////////////////////////////////
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          public class Category
  44:          {
  45:              public Category() { }
  46:   
  47:              public int Id { get; set; }
  48:              public string Name { get; set; }
  49:              public string ArabicName { get; set; }
  50:              /*
  51:              public virtual ICollection<Area> Areas
  52:              {
  53:                  get
  54:                  {
  55:                      return (from q in AreaList where q.Category.Id == this.Id select q).ToList();
  56:                  }
  57:              }
  58:               */
  59:          }
  60:   
  61:          ////////////////////////////////////////////////////////////////////////////
  62:   
  63:          /// <summary>
  64:          ///
  65:          /// </summary>
  66:          public static List<Ia.Ngn.Cl.Model.Data.Pots.Category> CategoryList
  67:          {
  68:              get
  69:              {
  70:                  if (categoryList == null || categoryList.Count == 0)
  71:                  {
  72:                      int id;
  73:                      Category category;
  74:   
  75:                      categoryList = new List<Category>();
  76:   
  77:                      foreach (XElement x in XDocument.Element("report").Elements("category"))
  78:                      {
  79:                          category = new Category();
  80:   
  81:                          id = int.Parse(x.Attribute("id").Value);
  82:   
  83:                          category.Id = id;
  84:                          category.Name = x.Attribute("name").Value;
  85:                          category.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
  86:   
  87:                          categoryList.Add(category);
  88:                      }
  89:                  }
  90:   
  91:                  return categoryList;
  92:              }
  93:          }
  94:   
  95:          ////////////////////////////////////////////////////////////////////////////
  96:          ////////////////////////////////////////////////////////////////////////////
  97:   
  98:          /// <summary>
  99:          /// 
 100:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 101:          /// 
 102:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 103:          /// 2. Add "using System.Reflection".
 104:          /// 3. See sample below.
 105:          /// 
 106:          /// </summary>
 107:   
 108:          public static XDocument XDocument
 109:          {
 110:              get
 111:              {
 112:                  Assembly _assembly;
 113:                  StreamReader streamReader;
 114:   
 115:                  if (xDocument == null)
 116:                  {
 117:                      _assembly = Assembly.GetExecutingAssembly();
 118:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.pots.xml"));
 119:   
 120:                      try
 121:                      {
 122:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 123:                      }
 124:                      catch (Exception)
 125:                      {
 126:                      }
 127:                      finally
 128:                      {
 129:                      }
 130:                  }
 131:   
 132:                  return xDocument;
 133:              }
 134:          }
 135:   
 136:          ////////////////////////////////////////////////////////////////////////////
 137:          ////////////////////////////////////////////////////////////////////////////    
 138:      }
 139:   
 140:      ////////////////////////////////////////////////////////////////////////////
 141:      ////////////////////////////////////////////////////////////////////////////   
 142:  }