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

Integrated Applications Programming Company

Skip Navigation Links

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

Service Request Hsi support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Data;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Service Request Hsi 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), 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 partial class ServiceRequestHsi
  29:      {
  30:          private const int LengthOfRequestOntIdRange = 100;
  31:          private static Hashtable ontListAccessIdToAccessNameHashtable = new Hashtable();
  32:          private static Queue<Ia.Ngn.Cl.Model.ServiceRequestHsi> serviceRequestHsiNotInCustomerDepartmentDatabaseQueue = new Queue<Ia.Ngn.Cl.Model.ServiceRequestHsi>();
  33:          private static Queue<Tuple<string, string>> serviceRequestAccessIdOptimizedStartEndRangeTupleQueue = new Queue<Tuple<string, string>>();
  34:   
  35:          ////////////////////////////////////////////////////////////////////////////
  36:   
  37:          /// <summary>
  38:          ///
  39:          /// </summary>
  40:          public ServiceRequestHsi() { }
  41:   
  42:          ////////////////////////////////////////////////////////////////////////////
  43:   
  44:          /// <summary>
  45:          ///
  46:          /// </summary>
  47:          public static bool Create(Ia.Ngn.Cl.Model.ServiceRequestHsi serviceRequestHsi, out string result)
  48:          {
  49:              bool b;
  50:   
  51:              b = false;
  52:              result = "";
  53:   
  54:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  55:              {
  56:                  serviceRequestHsi.Created = serviceRequestHsi.Updated = DateTime.UtcNow.AddHours(3);
  57:   
  58:                  db.ServiceRequestHsis.Add(serviceRequestHsi);
  59:                  db.SaveChanges();
  60:   
  61:                  b = true;
  62:              }
  63:   
  64:              return b;
  65:          }
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          public static Ia.Ngn.Cl.Model.ServiceRequestHsi Read(string id)
  73:          {
  74:              Ia.Ngn.Cl.Model.ServiceRequestHsi serviceRequestHsi;
  75:   
  76:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  77:              {
  78:                  serviceRequestHsi = (from srh in db.ServiceRequestHsis where srh.Id == id select srh).SingleOrDefault();
  79:              }
  80:   
  81:              return serviceRequestHsi;
  82:          }
  83:   
  84:          ////////////////////////////////////////////////////////////////////////////
  85:   
  86:          /// <summary>
  87:          /// 
  88:          /// </summary>
  89:          public static List<Ia.Ngn.Cl.Model.ServiceRequestHsi> ListFromOntIdList(List<string> ontIdList)
  90:          {
  91:              List<Ia.Ngn.Cl.Model.ServiceRequestHsi> list;
  92:   
  93:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  94:              {
  95:                  list = (from srh in db.ServiceRequestHsis join oid in ontIdList on srh.Ont.Id equals oid select srh).ToList();
  96:              }
  97:   
  98:              return list.Distinct().ToList();
  99:          }
 100:   
 101:          ////////////////////////////////////////////////////////////////////////////
 102:   
 103:          /// <summary>
 104:          ///
 105:          /// </summary>
 106:          public static List<Ia.Ngn.Cl.Model.ServiceRequestHsi> List
 107:          {
 108:              get
 109:              {
 110:                  List<Ia.Ngn.Cl.Model.ServiceRequestHsi> list;
 111:   
 112:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 113:                  {
 114:                      list = (from srh in db.ServiceRequestHsis select srh).ToList();
 115:                  }
 116:   
 117:                  return list;
 118:              }
 119:          }
 120:   
 121:          ////////////////////////////////////////////////////////////////////////////
 122:   
 123:          /// <summary>
 124:          ///
 125:          /// </summary>
 126:          public static bool Update(Ia.Ngn.Cl.Model.ServiceRequestHsi serviceRequestHsi, out string result)
 127:          {
 128:              bool b;
 129:   
 130:              b = false;
 131:              result = "";
 132:   
 133:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 134:              {
 135:                  serviceRequestHsi = (from srh in db.ServiceRequestHsis where srh.Id == serviceRequestHsi.Id select srh).SingleOrDefault();
 136:   
 137:                  serviceRequestHsi.Updated = DateTime.UtcNow.AddHours(3);
 138:   
 139:                  db.ServiceRequestHsis.Attach(serviceRequestHsi);
 140:   
 141:                  var v = db.Entry(serviceRequestHsi);
 142:                  v.State = System.Data.Entity.EntityState.Modified;
 143:                  db.SaveChanges();
 144:   
 145:                  b = true;
 146:              }
 147:   
 148:              return b;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          public static bool Delete(string id, out string result)
 157:          {
 158:              bool b;
 159:   
 160:              b = false;
 161:              result = "";
 162:   
 163:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 164:              {
 165:                  var v = (from srh in db.ServiceRequestHsis where srh.Id == id select srh).FirstOrDefault();
 166:   
 167:                  db.ServiceRequestHsis.Remove(v);
 168:                  db.SaveChanges();
 169:   
 170:                  b = true;
 171:              }
 172:   
 173:              return b;
 174:          }
 175:   
 176:          ////////////////////////////////////////////////////////////////////////////
 177:   
 178:          /// <summary>
 179:          ///
 180:          /// </summary>
 181:          public static Dictionary<string, string> IdToOntIdDictionary
 182:          {
 183:              get
 184:              {
 185:                  Dictionary<string, string> dictionary;
 186:   
 187:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 188:                  {
 189:                      dictionary = (from s in db.ServiceRequestHsis select new { s.Id, OntId = s.Ont.Id }).ToDictionary(u => u.Id, u => u.OntId);
 190:                  }
 191:   
 192:                  return dictionary.ToDictionary(u => u.Key, u => u.Value);
 193:              }
 194:          }
 195:   
 196:          ////////////////////////////////////////////////////////////////////////////    
 197:          ////////////////////////////////////////////////////////////////////////////    
 198:      }
 199:   
 200:      ////////////////////////////////////////////////////////////////////////////
 201:      ////////////////////////////////////////////////////////////////////////////
 202:  }