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

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.Web;
   3:  using System.Xml;
   4:  using System.Xml.Xsl;
   5:  using System.Xml.Serialization;
   6:  using System.Xml.Linq;
   7:  using System.Xml.XPath;
   8:  using System.IO;
   9:  using System.Configuration;
  10:  using System.Text;
  11:  using System.Text.RegularExpressions;
  12:  using System.Data;
  13:  using System.Data.SqlClient;
  14:  using System.Data.Entity;
  15:  using System.Web.UI;
  16:  using System.Web.UI.WebControls;
  17:  using System.Collections;
  18:  using System.Collections.Generic;
  19:  using System.Reflection;
  20:  using System.Linq;
  21:   
  22:  namespace Ia.Ngn.Cl.Model.Data
  23:  {
  24:      ////////////////////////////////////////////////////////////////////////////
  25:   
  26:      /// <summary publish="true">
  27:      /// POTS legacy support class for Next Generation Network (NGN) data model.
  28:      /// </summary>
  29:      /// 
  30:      /// <remarks> 
  31:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  32:      ///
  33:      /// 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
  34:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  35:      ///
  36:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  37:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  38:      /// 
  39:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  40:      /// 
  41:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  42:      /// </remarks> 
  43:      public partial class Pots
  44:      {
  45:          private static XDocument xDocument;
  46:          private static List<Category> categoryList;
  47:   
  48:          ////////////////////////////////////////////////////////////////////////////
  49:   
  50:          /// <summary>
  51:          ///
  52:          /// </summary>
  53:          public Pots() { }
  54:   
  55:          ////////////////////////////////////////////////////////////////////////////
  56:          ////////////////////////////////////////////////////////////////////////////
  57:   
  58:          public class Category
  59:          {
  60:              public Category() { }
  61:   
  62:              public int Id { get; set; }
  63:              public string Name { get; set; }
  64:              public string ArabicName { get; set; }
  65:              /*
  66:              public virtual ICollection<Area> Areas
  67:              {
  68:                  get
  69:                  {
  70:                      return (from q in AreaList where q.Category.Id == this.Id select q).ToList();
  71:                  }
  72:              }
  73:               */ 
  74:          }
  75:   
  76:          ////////////////////////////////////////////////////////////////////////////
  77:   
  78:          /// <summary>
  79:          ///
  80:          /// </summary>
  81:          public static List<Ia.Ngn.Cl.Model.Data.Pots.Category> CategoryList
  82:          {
  83:              get
  84:              {
  85:                  if (categoryList == null || categoryList.Count == 0)
  86:                  {
  87:                      int id;
  88:                      Category category;
  89:   
  90:                      categoryList = new List<Category>();
  91:   
  92:                      foreach (XElement x in XDocument.Element("report").Elements("category"))
  93:                      {
  94:                          category = new Category();
  95:   
  96:                          id = int.Parse(x.Attribute("id").Value);
  97:   
  98:                          category.Id = id;
  99:                          category.Name = x.Attribute("name").Value;
 100:                          category.ArabicName = (x.Attribute("arabicName") != null) ? x.Attribute("arabicName").Value : string.Empty;
 101:   
 102:                          categoryList.Add(category);
 103:                      }
 104:                  }
 105:   
 106:                  return categoryList;
 107:              }
 108:          }
 109:          
 110:          ////////////////////////////////////////////////////////////////////////////
 111:          ////////////////////////////////////////////////////////////////////////////
 112:   
 113:          /// <summary>
 114:          /// 
 115:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 116:          /// 
 117:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 118:          /// 2. Add "using System.Reflection".
 119:          /// 3. See sample below.
 120:          /// 
 121:          /// </summary>
 122:   
 123:          public static XDocument XDocument
 124:          {
 125:              get
 126:              {
 127:                  Assembly _assembly;
 128:                  StreamReader streamReader;
 129:   
 130:                  if (xDocument == null)
 131:                  {
 132:                      _assembly = Assembly.GetExecutingAssembly();
 133:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.pots.xml"));
 134:   
 135:                      try
 136:                      {
 137:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 138:                      }
 139:                      catch (Exception)
 140:                      {
 141:                      }
 142:                      finally
 143:                      {
 144:                      }
 145:                  }
 146:   
 147:                  return xDocument;
 148:              }
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:          ////////////////////////////////////////////////////////////////////////////    
 153:      }
 154:   
 155:      ////////////////////////////////////////////////////////////////////////////
 156:      ////////////////////////////////////////////////////////////////////////////   
 157:  }