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

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

ONT-SERVICEHSI support class for Next Generation Network (NGN) Nokia data model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Web;
   6:  using System.Web.Security;
   7:  using System.Text.RegularExpressions;
   8:  using System.Data.Entity;
   9:  using System.Text;
  10:   
  11:  namespace Ia.Ngn.Cl.Model.Data.Nokia
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// ONT-SERVICEHSI support class for Next Generation Network (NGN) Nokia data model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  21:      ///
  22:      /// 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
  23:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  24:      ///
  25:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  26:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  27:      /// 
  28:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  29:      /// 
  30:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  31:      /// </remarks> 
  32:      public partial class OntServiceHsi
  33:      {
  34:          /// <summary/>
  35:          public OntServiceHsi() { }
  36:   
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public static bool Create(Ia.Ngn.Cl.Model.OntServiceHsi ontServiceHsi, out string result)
  43:          {
  44:              bool b;
  45:   
  46:              b = false;
  47:              result = "";
  48:   
  49:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  50:              {
  51:                  ontServiceHsi.Created = ontServiceHsi.Updated = DateTime.UtcNow.AddHours(3);
  52:   
  53:                  db.OntServiceHsis.Add(ontServiceHsi);
  54:                  db.SaveChanges();
  55:   
  56:                  b = true;
  57:              }
  58:   
  59:              return b;
  60:          }
  61:   
  62:          ////////////////////////////////////////////////////////////////////////////
  63:   
  64:          /// <summary>
  65:          ///
  66:          /// </summary>
  67:          public static Ia.Ngn.Cl.Model.OntServiceHsi Read(string id)
  68:          {
  69:              Ia.Ngn.Cl.Model.OntServiceHsi item;
  70:   
  71:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  72:              {
  73:                  item = (from osh in db.OntServiceHsis where osh.Id == id select osh).SingleOrDefault();
  74:              }
  75:   
  76:              return item;
  77:          }
  78:   
  79:          ////////////////////////////////////////////////////////////////////////////
  80:   
  81:          /// <summary>
  82:          ///
  83:          /// </summary>
  84:          public static List<Ia.Ngn.Cl.Model.OntServiceHsi> ReadList()
  85:          {
  86:              List<Ia.Ngn.Cl.Model.OntServiceHsi> list;
  87:   
  88:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  89:              {
  90:                  list = (from osh in db.OntServiceHsis select osh).ToList();
  91:              }
  92:   
  93:              return list;
  94:          }
  95:   
  96:          ////////////////////////////////////////////////////////////////////////////
  97:   
  98:          /// <summary>
  99:          ///
 100:          /// </summary>
 101:          public static List<Ia.Ngn.Cl.Model.OntServiceHsi> ListIncludeOntAccess()
 102:          {
 103:              List<Ia.Ngn.Cl.Model.OntServiceHsi> list;
 104:   
 105:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 106:              {
 107:                  list = (from osh in db.OntServiceHsis select osh).Include(u => u.Ont.Access).ToList();
 108:              }
 109:   
 110:              return list;
 111:          }
 112:   
 113:          ////////////////////////////////////////////////////////////////////////////
 114:   
 115:          /// <summary>
 116:          ///
 117:          /// </summary>
 118:          public static bool Update(Ia.Ngn.Cl.Model.OntServiceHsi ontServiceHsi, out string result)
 119:          {
 120:              bool b;
 121:   
 122:              b = false;
 123:              result = "";
 124:   
 125:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 126:              {
 127:                  ontServiceHsi = (from osh in db.OntServiceHsis where osh.Id == ontServiceHsi.Id select osh).SingleOrDefault();
 128:   
 129:                  ontServiceHsi.Updated = DateTime.UtcNow.AddHours(3);
 130:   
 131:                  db.OntServiceHsis.Attach(ontServiceHsi);
 132:   
 133:                  var v = db.Entry(ontServiceHsi);
 134:                  v.State = System.Data.Entity.EntityState.Modified;
 135:                  db.SaveChanges();
 136:   
 137:                  b = true;
 138:              }
 139:   
 140:              return b;
 141:          }
 142:   
 143:          ////////////////////////////////////////////////////////////////////////////
 144:   
 145:          /// <summary>
 146:          ///
 147:          /// </summary>
 148:          public static bool Delete(string id, out string result)
 149:          {
 150:              bool b;
 151:   
 152:              b = false;
 153:              result = "";
 154:   
 155:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 156:              {
 157:                  var v = (from osh in db.OntServiceHsis where osh.Id == id select osh).FirstOrDefault();
 158:   
 159:                  db.OntServiceHsis.Remove(v);
 160:                  db.SaveChanges();
 161:   
 162:                  b = true;
 163:              }
 164:   
 165:              return b;
 166:          }
 167:   
 168:          ////////////////////////////////////////////////////////////////////////////
 169:   
 170:          /// <summary>
 171:          ///
 172:          /// </summary>
 173:          public static Dictionary<int, int> DownstreamBandwidthProfileIdAndCountDictionary
 174:          {
 175:              get
 176:              {
 177:                  Dictionary<int, int> dictionary;
 178:   
 179:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 180:                  {
 181:                      dictionary = (from osh in db.OntServiceHsis
 182:                             group osh.Id by osh.DownstreamBandwidthProfileId into g
 183:                             select new { Id = g.Key, Count = g.Count() }).ToDictionary(u => u.Id, u => u.Count);
 184:                  }
 185:   
 186:                  return dictionary;
 187:              }
 188:          }
 189:   
 190:          ////////////////////////////////////////////////////////////////////////////
 191:   
 192:          /// <summary>
 193:          ///
 194:          /// </summary>
 195:          public static List<string> AccessNameForDownstreamBandwidthProfileIdList(int profileId)
 196:          {
 197:              string s;
 198:              Hashtable ht;
 199:              List<string> accessIdList, list;
 200:   
 201:              accessIdList = AccessIdForDownstreamBandwidthProfileIdList(profileId);
 202:   
 203:              list = new List<string>(accessIdList.Count);
 204:   
 205:              ht = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToAccessNameHashtable;
 206:   
 207:              foreach (string accessId in accessIdList)
 208:              {
 209:                  if (ht[accessId] != null)
 210:                  {
 211:                      s = ht[accessId].ToString();
 212:   
 213:                      list.Add(s);
 214:                  }
 215:              }
 216:   
 217:              return list;
 218:          }
 219:   
 220:          ////////////////////////////////////////////////////////////////////////////
 221:   
 222:          /// <summary>
 223:          ///
 224:          /// </summary>
 225:          public static List<string> AccessIdForDownstreamBandwidthProfileIdList(int profileId)
 226:          {
 227:              List<string> list;
 228:   
 229:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 230:              {
 231:                  list = (from osh in db.OntServiceHsis
 232:                          join o in db.Onts on osh.Ont.Id equals o.Id
 233:                          join a in db.Accesses on o.Access.Id equals a.Id
 234:                          where osh.DownstreamBandwidthProfileId == profileId
 235:                          select a.Id).ToList();
 236:              }
 237:   
 238:              return list;
 239:          }
 240:   
 241:          /*
 242:          ////////////////////////////////////////////////////////////////////////////
 243:  
 244:          /// <summary>
 245:          ///
 246:          /// </summary>
 247:          public static List<Ia.Ngn.Cl.Model.OntServiceHsi> ReadListBySerial(string serial)
 248:          {
 249:              List<Ia.Ngn.Cl.Model.OntServiceHsi> list;
 250:  
 251:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 252:              {
 253:                  list = (from q in db.Onts where q.Serial == serial select q).ToList();
 254:              }
 255:  
 256:              return list;
 257:          }
 258:           */
 259:   
 260:          ////////////////////////////////////////////////////////////////////////////
 261:   
 262:          /// <summary>
 263:          ///
 264:          /// </summary>
 265:          public static Dictionary<string, string> IdToOntIdDictionary
 266:          {
 267:              get
 268:              {
 269:                  Dictionary<string, string> dictionary;
 270:   
 271:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 272:                  {
 273:                      dictionary = (from s in db.OntServiceHsis select new { s.Id, OntId = s.Ont.Id }).ToDictionary(u => u.Id, u => u.OntId);
 274:                  }
 275:   
 276:                  return dictionary.ToDictionary(u => u.Key, u => u.Value);
 277:              }
 278:          }
 279:   
 280:          ////////////////////////////////////////////////////////////////////////////
 281:          ////////////////////////////////////////////////////////////////////////////
 282:   
 283:          /// <summary>
 284:          ///
 285:          /// </summary>
 286:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.OntServiceHsi ontServiceHsi)
 287:          {
 288:              StringBuilder sb;
 289:   
 290:              sb = new StringBuilder();
 291:   
 292:              //sb.AppendLine("Vendor: " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia.Name);
 293:              sb.AppendLine("State: " + ontServiceHsi.State);
 294:              sb.AppendLine("Card: " + ontServiceHsi.Card);
 295:              sb.AppendLine("Port: " + ontServiceHsi.Port);
 296:              sb.AppendLine("Service: " + ontServiceHsi.Service);
 297:   
 298:              sb.AppendLine("DownstreamBandwidthProfile: " + Ia.Ngn.Cl.Model.Data.Hsi.ProfileFromProfileId(ontServiceHsi.DownstreamBandwidthProfileId).Name);
 299:              sb.AppendLine("UpstreamBandwidthProfile: " + Ia.Ngn.Cl.Model.Data.Hsi.ProfileFromProfileId(ontServiceHsi.UpstreamBandwidthProfileId).Name);
 300:              sb.AppendLine("PriorityQueueProfileId: " + ontServiceHsi.PriorityQueueProfileId);
 301:   
 302:              //sb.AppendLine("Aes: " + ontServiceHsi.Aes);
 303:              sb.AppendLine("Svlan: " + ontServiceHsi.Svlan);
 304:              sb.AppendLine("Label: " + ontServiceHsi.Label);
 305:              sb.AppendLine("Customer: " + ontServiceHsi.Customer);
 306:   
 307:              return sb.ToString();
 308:          }
 309:   
 310:          ////////////////////////////////////////////////////////////////////////////
 311:          ////////////////////////////////////////////////////////////////////////////
 312:      }
 313:   
 314:      ////////////////////////////////////////////////////////////////////////////
 315:      ////////////////////////////////////////////////////////////////////////////
 316:  }