Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Hsi

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

High Speed Internet (HSI) support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.Linq;
   5:  using System.IO;
   6:  using System.Configuration;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.SqlClient;
  11:  using System.Web.UI;
  12:  using System.Web.UI.WebControls;
  13:  using System.Collections;
  14:  using System.Collections.Generic;
  15:  using System.Reflection;
  16:   
  17:  namespace Ia.Ngn.Cl.Model.Data
  18:  {
  19:      ////////////////////////////////////////////////////////////////////////////
  20:   
  21:      /// <summary publish="true">
  22:      /// High Speed Internet (HSI) support class for Next Generation Network (NGN) data model.
  23:      /// </summary>
  24:      /// 
  25:      /// <remarks> 
  26:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  27:      ///
  28:      /// 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
  29:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  30:      ///
  31:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  32:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  33:      /// 
  34:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  35:      /// 
  36:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  37:      /// </remarks> 
  38:      public partial class Hsi
  39:      {
  40:          private static XDocument xDocument;
  41:   
  42:          ////////////////////////////////////////////////////////////////////////////
  43:   
  44:          /// <summary>
  45:          ///
  46:          /// </summary>
  47:          public Hsi() { }
  48:   
  49:          ////////////////////////////////////////////////////////////////////////////
  50:   
  51:          /// <summary>
  52:          ///
  53:          /// </summary>
  54:          public class Isp
  55:          {
  56:              public Isp() { }
  57:   
  58:              public int Id { get; set; }
  59:              public bool Active { get; set; }
  60:              public int Lan { get; set; }
  61:              public string Name { get; set; }
  62:              public string ArabicName { get; set; }
  63:              public string Description { get; set; }
  64:          }
  65:   
  66:          ////////////////////////////////////////////////////////////////////////////
  67:   
  68:          /// <summary>
  69:          ///
  70:          /// </summary>
  71:          public class Profile
  72:          {
  73:              public Profile() { }
  74:   
  75:              public int Id { get; set; }
  76:              public string Name { get; set; }
  77:              public string Description { get; set; }
  78:          }
  79:   
  80:          //////////////////////////////////////////////////////////////////////////////
  81:   
  82:          ///// <summary>
  83:          /////
  84:          ///// </summary>
  85:          public static Isp IspFromIspId(int ispId)
  86:          {
  87:              Isp isp;
  88:   
  89:              isp = new Isp();
  90:   
  91:              foreach (Isp i in IspList)
  92:              {
  93:                  if (i.Id == ispId)
  94:                  {
  95:                      isp = i;
  96:                      break;
  97:                  }
  98:              }
  99:   
 100:              return isp;
 101:          }
 102:   
 103:          //////////////////////////////////////////////////////////////////////////////
 104:   
 105:          ///// <summary>
 106:          /////
 107:          ///// </summary>
 108:          public static Profile ProfileFromProfileId(int profileId)
 109:          {
 110:              Profile profile;
 111:   
 112:              profile = new Profile();
 113:   
 114:              foreach (Profile i in ProfileList)
 115:              {
 116:                  if (i.Id == profileId)
 117:                  {
 118:                      profile = i;
 119:                      break;
 120:                  }
 121:              }
 122:   
 123:              return profile;
 124:          }
 125:   
 126:          //////////////////////////////////////////////////////////////////////////////
 127:   
 128:          ///// <summary>
 129:          /////
 130:          ///// </summary>
 131:          public static List<Isp> IspList
 132:          {
 133:              get
 134:              {
 135:                  Isp isp;
 136:                  List<Isp> ispList;
 137:   
 138:                  ispList = new List<Isp>();
 139:   
 140:                  foreach (XElement xe in XDocument.Element("hsi").Element("ispList").Elements("isp"))
 141:                  {
 142:                      isp = new Isp();
 143:   
 144:                      isp.Id = int.Parse(xe.Attribute("id").Value);
 145:                      isp.Active = bool.Parse(xe.Attribute("active").Value);
 146:                      isp.Lan = int.Parse(xe.Attribute("lan").Value);
 147:                      isp.Name = xe.Attribute("name").Value;
 148:                      isp.ArabicName = xe.Attribute("arabicName").Value;
 149:                      isp.Description = xe.Attribute("description").Value;
 150:   
 151:                      ispList.Add(isp);
 152:                  }
 153:   
 154:                  return ispList;
 155:              }
 156:          }
 157:   
 158:          //////////////////////////////////////////////////////////////////////////////
 159:   
 160:          ///// <summary>
 161:          /////
 162:          ///// </summary>
 163:          public static List<Profile> ProfileList
 164:          {
 165:              get
 166:              {
 167:                  Profile profile;
 168:                  List<Profile> profileList;
 169:   
 170:                  profileList = new List<Profile>();
 171:   
 172:                  foreach (XElement xe in XDocument.Element("hsi").Element("profileList").Elements("profile"))
 173:                  {
 174:                      profile = new Profile();
 175:   
 176:                      profile.Id = int.Parse(xe.Attribute("id").Value);
 177:                      profile.Name = xe.Attribute("name").Value;
 178:                      profile.Description = xe.Attribute("description").Value;
 179:   
 180:                      profileList.Add(profile);
 181:                  }
 182:   
 183:                  return profileList;
 184:              }
 185:          }
 186:   
 187:          ////////////////////////////////////////////////////////////////////////////
 188:   
 189:          /// <summary>
 190:          /// 
 191:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 192:          /// 
 193:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 194:          /// 2. Add "using System.Reflection".
 195:          /// 3. See sample below.
 196:          /// 
 197:          /// </summary>
 198:   
 199:          private static XDocument XDocument
 200:          {
 201:              get
 202:              {
 203:                  if (xDocument == null)
 204:                  {
 205:                      Assembly _assembly;
 206:                      StreamReader streamReader;
 207:   
 208:                      _assembly = Assembly.GetExecutingAssembly();
 209:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.hsi.xml"));
 210:   
 211:                      try
 212:                      {
 213:                          if (streamReader.Peek() != -1)
 214:                          {
 215:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 216:                          }
 217:                      }
 218:                      catch (Exception)
 219:                      {
 220:                      }
 221:                      finally
 222:                      {
 223:                      }
 224:                  }
 225:   
 226:                  return xDocument;
 227:              }
 228:          }
 229:   
 230:          ////////////////////////////////////////////////////////////////////////////
 231:          ////////////////////////////////////////////////////////////////////////////    
 232:      }
 233:   
 234:      ////////////////////////////////////////////////////////////////////////////
 235:      ////////////////////////////////////////////////////////////////////////////   
 236:  }