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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » AgcfEndpoint

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

AGCF Endpoint support class for Nokia data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data.Entity;
   4:  using System.Linq;
   5:   
   6:  namespace Ia.Ngn.Cl.Model.Data.Nokia
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// AGCF Endpoint support class for Nokia data model.
  12:      /// </summary>
  13:      /// 
  14:      /// <remarks> 
  15:      /// Copyright � 2014-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  16:      ///
  17:      /// 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
  18:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  19:      ///
  20:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  21:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  22:      /// 
  23:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  24:      /// 
  25:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  26:      /// </remarks> 
  27:      public partial class AgcfEndpoint
  28:      {
  29:          public AgcfEndpoint() { }
  30:   
  31:          ////////////////////////////////////////////////////////////////////////////
  32:   
  33:          /// <summary>
  34:          ///
  35:          /// </summary>
  36:          public static bool Create(Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint, out string result)
  37:          {
  38:              bool b;
  39:   
  40:              b = false;
  41:              result = string.Empty;
  42:   
  43:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  44:              {
  45:                  agcfEndpoint.Created = agcfEndpoint.Updated = DateTime.UtcNow.AddHours(3);
  46:   
  47:                  db.AgcfEndpoints.Add(agcfEndpoint);
  48:                  db.SaveChanges();
  49:   
  50:                  b = true;
  51:              }
  52:   
  53:              return b;
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint Read(string id)
  62:          {
  63:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
  64:   
  65:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  66:              {
  67:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == id select ep).SingleOrDefault();
  68:              }
  69:   
  70:              return agcfEndpoint;
  71:          }
  72:   
  73:          ////////////////////////////////////////////////////////////////////////////
  74:   
  75:          /// <summary>
  76:          ///
  77:          /// </summary>
  78:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadbyGwId(int gwId)
  79:          {
  80:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
  81:   
  82:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  83:              {
  84:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.GwId == gwId select ep).SingleOrDefault();
  85:              }
  86:   
  87:              return agcfEndpoint;
  88:          }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////
  91:   
  92:          /// <summary>
  93:          ///
  94:          /// </summary>
  95:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadWithAgcfGatewayRecord(string id)
  96:          {
  97:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
  98:   
  99:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 100:              {
 101:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == id select ep).Include(x => x.AgcfGatewayRecord).SingleOrDefault();
 102:              }
 103:   
 104:              return agcfEndpoint;
 105:          }
 106:   
 107:          ////////////////////////////////////////////////////////////////////////////
 108:   
 109:          /// <summary>
 110:          ///
 111:          /// </summary>
 112:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> ReadList()
 113:          {
 114:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 115:   
 116:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 117:              {
 118:                  agcfEndpointList = (from ep in db.AgcfEndpoints select ep).ToList();
 119:              }
 120:   
 121:              return agcfEndpointList;
 122:          }
 123:   
 124:          ////////////////////////////////////////////////////////////////////////////
 125:   
 126:          /// <summary>
 127:          ///
 128:          /// </summary>
 129:          public static bool Update(Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint, out string result)
 130:          {
 131:              bool b;
 132:   
 133:              b = false;
 134:              result = string.Empty;
 135:   
 136:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 137:              {
 138:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == agcfEndpoint.Id select ep).SingleOrDefault();
 139:   
 140:                  agcfEndpoint.Updated = DateTime.UtcNow.AddHours(3);
 141:   
 142:                  db.AgcfEndpoints.Attach(agcfEndpoint);
 143:   
 144:                  db.Entry(agcfEndpoint).State = System.Data.Entity.EntityState.Modified;
 145:                  db.SaveChanges();
 146:   
 147:                  b = true;
 148:              }
 149:   
 150:              return b;
 151:          }
 152:   
 153:          ////////////////////////////////////////////////////////////////////////////
 154:   
 155:          /// <summary>
 156:          ///
 157:          /// </summary>
 158:          public static bool Delete(string id, out string result)
 159:          {
 160:              bool b;
 161:   
 162:              b = false;
 163:              result = string.Empty;
 164:   
 165:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 166:              {
 167:                  var v = (from ep in db.AgcfEndpoints where ep.Id == id select ep).FirstOrDefault();
 168:   
 169:                  db.AgcfEndpoints.Remove(v);
 170:                  db.SaveChanges();
 171:   
 172:                  b = true;
 173:              }
 174:   
 175:              return b;
 176:          }
 177:   
 178:          ////////////////////////////////////////////////////////////////////////////
 179:   
 180:          /// <summary>
 181:          ///
 182:          /// </summary>
 183:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordFromId(string agcfEndpointId)
 184:          {
 185:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 186:   
 187:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 188:              {
 189:                  agcfGatewayRecord = (from e in db.AgcfEndpoints join g in db.AgcfGatewayRecords on e.GwId equals g.GwId where e.Id == agcfEndpointId select g).SingleOrDefault();
 190:              }
 191:   
 192:              return agcfGatewayRecord;
 193:          }
 194:   
 195:          ////////////////////////////////////////////////////////////////////////////
 196:   
 197:          /// <summary>
 198:          ///
 199:          /// </summary>
 200:          public static List<string> ReadPrividUserList
 201:          {
 202:              get
 203:              {
 204:                  List<string> prividUserlist;
 205:   
 206:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 207:                  {
 208:                      prividUserlist = (from ep in db.AgcfEndpoints orderby ep.GwId ascending select ep.PrividUser).ToList();
 209:                  }
 210:   
 211:                  return prividUserlist;
 212:              }
 213:          }
 214:   
 215:          ////////////////////////////////////////////////////////////////////////////
 216:   
 217:          /// <summary>
 218:          ///
 219:          /// </summary>
 220:          public static List<int> UsedFlatTermIdListForGatewayId(int gwId)
 221:          {
 222:              List<int> list;
 223:   
 224:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 225:              {
 226:                  list = (from e in db.AgcfEndpoints where e.GwId == gwId orderby e.FlatTermID ascending select e.FlatTermID).ToList<int>();
 227:              }
 228:   
 229:              return list;
 230:          }
 231:   
 232:          ////////////////////////////////////////////////////////////////////////////
 233:   
 234:          /// <summary>
 235:          ///
 236:          /// </summary>
 237:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List()
 238:          {
 239:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 240:   
 241:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 242:              {
 243:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).Include(a => a.AgcfGatewayRecord).ToList();
 244:              }
 245:   
 246:              return agcfEndpointList;
 247:          }
 248:   
 249:          ////////////////////////////////////////////////////////////////////////////
 250:   
 251:          /// <summary>
 252:          ///
 253:          /// </summary>
 254:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(int gwId)
 255:          {
 256:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 257:   
 258:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 259:              {
 260:                  agcfEndpointList = (from a in db.AgcfEndpoints where a.GwId == gwId select a).Include(a => a.AgcfGatewayRecord).ToList();
 261:              }
 262:   
 263:              return agcfEndpointList;
 264:          }
 265:   
 266:          ////////////////////////////////////////////////////////////////////////////
 267:   
 268:          /// <summary>
 269:          ///
 270:          /// </summary>
 271:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 272:          {
 273:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ngnOntList;
 274:              List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
 275:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 276:   
 277:              // below: NGN ONT list
 278:              ngnOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 279:   
 280:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 281:              {
 282:                  agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).ToList();
 283:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).ToList();
 284:              }
 285:   
 286:              agcfGatewayRecordList = (from gr in agcfGatewayRecordList join no in ngnOntList on gr.IP1 equals no.Ip select gr).ToList();
 287:   
 288:              agcfEndpointList = (from e in agcfEndpointList join gr in agcfGatewayRecordList on e.GwId equals gr.GwId select e).ToList();
 289:   
 290:              return agcfEndpointList;
 291:          }
 292:   
 293:          ////////////////////////////////////////////////////////////////////////////
 294:   
 295:          /// <summary>
 296:          ///
 297:          /// </summary>
 298:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList)
 299:          {
 300:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ngnOntList;
 301:              List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
 302:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 303:   
 304:              // below: NGN ONT list
 305:              ngnOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where oltList.Any(u => u.Id == o.Pon.PonGroup.Olt.Id) select o).ToList();
 306:   
 307:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 308:              {
 309:                  agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).ToList();
 310:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).ToList();
 311:              }
 312:   
 313:              agcfGatewayRecordList = (from gr in agcfGatewayRecordList join no in ngnOntList on gr.IP1 equals no.Ip select gr).ToList();
 314:   
 315:              agcfEndpointList = (from e in agcfEndpointList join gr in agcfGatewayRecordList on e.GwId equals gr.GwId select e).ToList();
 316:   
 317:              return agcfEndpointList;
 318:          }
 319:   
 320:          ////////////////////////////////////////////////////////////////////////////
 321:   
 322:          /// <summary>
 323:          ///
 324:          /// </summary>
 325:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadByPrividUser(string prividUser)
 326:          {
 327:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
 328:   
 329:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 330:              {
 331:                  agcfEndpoint = (from a in db.AgcfEndpoints where a.PrividUser == prividUser select a).Include(a => a.AgcfGatewayRecord).SingleOrDefault();
 332:              }
 333:   
 334:              return agcfEndpoint;
 335:          }
 336:   
 337:          ////////////////////////////////////////////////////////////////////////////
 338:          ////////////////////////////////////////////////////////////////////////////
 339:      }
 340:   
 341:      ////////////////////////////////////////////////////////////////////////////
 342:      ////////////////////////////////////////////////////////////////////////////
 343:  }