Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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.Linq;
   4:  using System.Web;
   5:  using System.Web.Security;
   6:  using System.ComponentModel.DataAnnotations;
   7:  using System.ComponentModel.DataAnnotations.Schema;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data.Entity;
  10:   
  11:  namespace Ia.Ngn.Cl.Model.Data.Nokia
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// AGCF Endpoint support class for Nokia data model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright � 2014-2017 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 AgcfEndpoint
  33:      {
  34:          public AgcfEndpoint() { }
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public static bool Create(Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint, out string result)
  42:          {
  43:              bool b;
  44:   
  45:              b = false;
  46:              result = "";
  47:   
  48:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  49:              {
  50:                  agcfEndpoint.Created = agcfEndpoint.Updated = DateTime.UtcNow.AddHours(3);
  51:   
  52:                  db.AgcfEndpoints.Add(agcfEndpoint);
  53:                  db.SaveChanges();
  54:   
  55:                  b = true;
  56:              }
  57:   
  58:              return b;
  59:          }
  60:   
  61:          ////////////////////////////////////////////////////////////////////////////
  62:   
  63:          /// <summary>
  64:          ///
  65:          /// </summary>
  66:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint Read(string id)
  67:          {
  68:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
  69:   
  70:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  71:              {
  72:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == id select ep).SingleOrDefault();
  73:              }
  74:   
  75:              return agcfEndpoint;
  76:          }
  77:   
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadbyGwId(int gwId)
  84:          {
  85:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
  86:   
  87:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  88:              {
  89:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.GwId == gwId select ep).SingleOrDefault();
  90:              }
  91:   
  92:              return agcfEndpoint;
  93:          }
  94:   
  95:          ////////////////////////////////////////////////////////////////////////////
  96:   
  97:          /// <summary>
  98:          ///
  99:          /// </summary>
 100:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadWithAgcfGatewayRecord(string id)
 101:          {
 102:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
 103:   
 104:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 105:              {
 106:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == id select ep).Include(x => x.AgcfGatewayRecord).SingleOrDefault();
 107:              }
 108:   
 109:              return agcfEndpoint;
 110:          }
 111:   
 112:          ////////////////////////////////////////////////////////////////////////////
 113:   
 114:          /// <summary>
 115:          ///
 116:          /// </summary>
 117:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> ReadList()
 118:          {
 119:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 120:   
 121:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 122:              {
 123:                  agcfEndpointList = (from ep in db.AgcfEndpoints select ep).ToList();
 124:              }
 125:   
 126:              return agcfEndpointList;
 127:          }
 128:   
 129:          ////////////////////////////////////////////////////////////////////////////
 130:   
 131:          /// <summary>
 132:          ///
 133:          /// </summary>
 134:          public static bool Update(Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint, out string result)
 135:          {
 136:              bool b;
 137:   
 138:              b = false;
 139:              result = "";
 140:   
 141:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 142:              {
 143:                  agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == agcfEndpoint.Id select ep).SingleOrDefault();
 144:   
 145:                  agcfEndpoint.Updated = DateTime.UtcNow.AddHours(3);
 146:   
 147:                  db.AgcfEndpoints.Attach(agcfEndpoint);
 148:   
 149:                  db.Entry(agcfEndpoint).State = System.Data.Entity.EntityState.Modified;
 150:                  db.SaveChanges();
 151:   
 152:                  b = true;
 153:              }
 154:   
 155:              return b;
 156:          }
 157:   
 158:          ////////////////////////////////////////////////////////////////////////////
 159:   
 160:          /// <summary>
 161:          ///
 162:          /// </summary>
 163:          public static bool Delete(string id, out string result)
 164:          {
 165:              bool b;
 166:   
 167:              b = false;
 168:              result = "";
 169:   
 170:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 171:              {
 172:                  var v = (from ep in db.AgcfEndpoints where ep.Id == id select ep).FirstOrDefault();
 173:   
 174:                  db.AgcfEndpoints.Remove(v);
 175:                  db.SaveChanges();
 176:   
 177:                  b = true;
 178:              }
 179:   
 180:              return b;
 181:          }
 182:   
 183:          ////////////////////////////////////////////////////////////////////////////
 184:   
 185:          /// <summary>
 186:          ///
 187:          /// </summary>
 188:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordFromId(string agcfEndpointId)
 189:          {
 190:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 191:   
 192:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 193:              {
 194:                  agcfGatewayRecord = (from e in db.AgcfEndpoints join g in db.AgcfGatewayRecords on e.GwId equals g.GwId where e.Id == agcfEndpointId select g).SingleOrDefault();
 195:              }
 196:   
 197:              return agcfGatewayRecord;
 198:          }
 199:   
 200:          ////////////////////////////////////////////////////////////////////////////
 201:   
 202:          /// <summary>
 203:          ///
 204:          /// </summary>
 205:          public static List<string> ReadPrividUserList
 206:          {
 207:              get
 208:              {
 209:                  List<string> prividUserlist;
 210:   
 211:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 212:                  {
 213:                      prividUserlist = (from ep in db.AgcfEndpoints orderby ep.GwId ascending select ep.PrividUser).ToList();
 214:                  }
 215:   
 216:                  return prividUserlist;
 217:              }
 218:          }
 219:   
 220:          ////////////////////////////////////////////////////////////////////////////
 221:   
 222:          /// <summary>
 223:          ///
 224:          /// </summary>
 225:          public static List<int> UsedFlatTermIdListForGatewayId(int gwId)
 226:          {
 227:              List<int> list;
 228:   
 229:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 230:              {
 231:                  list = (from e in db.AgcfEndpoints where e.GwId == gwId orderby e.FlatTermID ascending select e.FlatTermID).ToList<int>();
 232:              }
 233:   
 234:              return list;
 235:          }
 236:   
 237:          ////////////////////////////////////////////////////////////////////////////
 238:   
 239:          /// <summary>
 240:          ///
 241:          /// </summary>
 242:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List()
 243:          {
 244:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 245:   
 246:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 247:              {
 248:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).Include(a => a.AgcfGatewayRecord).ToList();
 249:              }
 250:   
 251:              return agcfEndpointList;
 252:          }
 253:   
 254:          ////////////////////////////////////////////////////////////////////////////
 255:   
 256:          /// <summary>
 257:          ///
 258:          /// </summary>
 259:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(int gwId)
 260:          {
 261:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 262:   
 263:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 264:              {
 265:                  agcfEndpointList = (from a in db.AgcfEndpoints where a.GwId == gwId select a).Include(a => a.AgcfGatewayRecord).ToList();
 266:              }
 267:   
 268:              return agcfEndpointList;
 269:          }
 270:   
 271:          ////////////////////////////////////////////////////////////////////////////
 272:   
 273:          /// <summary>
 274:          ///
 275:          /// </summary>
 276:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 277:          {
 278:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ngnOntList;
 279:              List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
 280:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 281:   
 282:              // below: NGN ONT list
 283:              ngnOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 284:   
 285:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 286:              {
 287:                  agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).ToList();
 288:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).ToList();
 289:              }
 290:   
 291:              agcfGatewayRecordList = (from gr in agcfGatewayRecordList join no in ngnOntList on gr.IP1 equals no.Ip select gr).ToList();
 292:   
 293:              agcfEndpointList = (from e in agcfEndpointList join gr in agcfGatewayRecordList on e.GwId equals gr.GwId select e).ToList();
 294:   
 295:              return agcfEndpointList;
 296:          }
 297:   
 298:          ////////////////////////////////////////////////////////////////////////////
 299:   
 300:          /// <summary>
 301:          ///
 302:          /// </summary>
 303:          public static List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> List(List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList)
 304:          {
 305:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ngnOntList;
 306:              List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
 307:              List<Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint> agcfEndpointList;
 308:   
 309:              // below: NGN ONT list
 310:              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();
 311:   
 312:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 313:              {
 314:                  agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).ToList();
 315:                  agcfEndpointList = (from a in db.AgcfEndpoints select a).ToList();
 316:              }
 317:   
 318:              agcfGatewayRecordList = (from gr in agcfGatewayRecordList join no in ngnOntList on gr.IP1 equals no.Ip select gr).ToList();
 319:   
 320:              agcfEndpointList = (from e in agcfEndpointList join gr in agcfGatewayRecordList on e.GwId equals gr.GwId select e).ToList();
 321:   
 322:              return agcfEndpointList;
 323:          }
 324:   
 325:          ////////////////////////////////////////////////////////////////////////////
 326:   
 327:          /// <summary>
 328:          ///
 329:          /// </summary>
 330:          public static Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint ReadByPrividUser(string prividUser)
 331:          {
 332:              Ia.Ngn.Cl.Model.Nokia.AgcfEndpoint agcfEndpoint;
 333:   
 334:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 335:              {
 336:                  agcfEndpoint = (from a in db.AgcfEndpoints where a.PrividUser == prividUser select a).Include(a => a.AgcfGatewayRecord).SingleOrDefault();
 337:              }
 338:   
 339:              return agcfEndpoint;
 340:          }
 341:   
 342:          ////////////////////////////////////////////////////////////////////////////
 343:          ////////////////////////////////////////////////////////////////////////////
 344:      }
 345:   
 346:      ////////////////////////////////////////////////////////////////////////////
 347:      ////////////////////////////////////////////////////////////////////////////
 348:  }