)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » AgcfEndpoint (Ia.Ftn.Cl.Models.Data.Nokia)

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 Microsoft.EntityFrameworkCore;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.Linq;
    5:  
    6: namespace Ia.Ftn.Cl.Models.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), Integrated 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 class AgcfEndpoint
   28:     {
   29:         public AgcfEndpoint() { }
   30:  
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         ///
   35:         /// </summary>
   36:         public static bool Create(Ia.Ftn.Cl.Models.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.Ftn.Cl.Db())
   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.Ftn.Cl.Models.Nokia.AgcfEndpoint Read(string id)
   62:         {
   63:             Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint agcfEndpoint;
   64:  
   65:             using (var db = new Ia.Ftn.Cl.Db())
   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.Ftn.Cl.Models.Nokia.AgcfEndpoint ReadbyGwId(int gwId)
   79:         {
   80:             Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint agcfEndpoint;
   81:  
   82:             using (var db = new Ia.Ftn.Cl.Db())
   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.Ftn.Cl.Models.Nokia.AgcfEndpoint ReadWithAgcfGatewayRecord(string id)
   96:         {
   97:             Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint agcfEndpoint;
   98:  
   99:             using (var db = new Ia.Ftn.Cl.Db())
  100:             {
  101:                 agcfEndpoint = (from ep in db.AgcfEndpoints where ep.Id == id select ep).Include(u => u.AgcfGatewayRecord).SingleOrDefault();
  102:             }
  103:  
  104:             return agcfEndpoint;
  105:         }
  106:  
  107:         ////////////////////////////////////////////////////////////////////////////
  108:  
  109:         /// <summary>
  110:         ///
  111:         /// </summary>
  112:         public static List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> ReadList()
  113:         {
  114:             List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> agcfEndpointList;
  115:  
  116:             using (var db = new Ia.Ftn.Cl.Db())
  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.Ftn.Cl.Models.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.Ftn.Cl.Db())
  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 = Microsoft.EntityFrameworkCore.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.Ftn.Cl.Db())
  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.Ftn.Cl.Models.Nokia.AgcfGatewayRecord AgcfGatewayRecordFromId(string agcfEndpointId)
  184:         {
  185:             Ia.Ftn.Cl.Models.Nokia.AgcfGatewayRecord agcfGatewayRecord;
  186:  
  187:             using (var db = new Ia.Ftn.Cl.Db())
  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.Ftn.Cl.Db())
  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.Ftn.Cl.Db())
  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.Ftn.Cl.Models.Nokia.AgcfEndpoint> List()
  238:         {
  239:             List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> agcfEndpointList;
  240:  
  241:             using (var db = new Ia.Ftn.Cl.Db())
  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.Ftn.Cl.Models.Nokia.AgcfEndpoint> List(int gwId)
  255:         {
  256:             List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> agcfEndpointList;
  257:  
  258:             using (var db = new Ia.Ftn.Cl.Db())
  259:             {
  260:                 agcfEndpointList = (from a in db.AgcfEndpoints 
  261:                                     where a.GwId == gwId 
  262:                                     select a).Include(a => a.AgcfGatewayRecord).AsNoTracking().ToList();
  263:             }
  264:  
  265:             return agcfEndpointList;
  266:         }
  267:  
  268:         ////////////////////////////////////////////////////////////////////////////
  269:  
  270:         /// <summary>
  271:         ///
  272:         /// </summary>
  273:         public static List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> List(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  274:         {
  275:             List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> ontList;
  276:             List<Ia.Ftn.Cl.Models.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
  277:             List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> agcfEndpointList;
  278:  
  279:             // below: FTN ONT list
  280:             ontList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntList 
  281:                           where o.Pon.PonGroup.Olt.Id == olt.Id 
  282:                           select o).ToList();
  283:  
  284:             using (var db = new Ia.Ftn.Cl.Db())
  285:             {
  286:                 agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).AsNoTracking().ToList();
  287:  
  288:                 agcfEndpointList = (from a in db.AgcfEndpoints select a).AsNoTracking().ToList();
  289:             }
  290:  
  291:             agcfGatewayRecordList = (from gr in agcfGatewayRecordList 
  292:                                      join no in ontList on gr.IP1 equals no.Ip 
  293:                                      select gr).ToList();
  294:  
  295:             agcfEndpointList = (from e in agcfEndpointList
  296:                                 join gr in agcfGatewayRecordList on e.GwId equals gr.GwId
  297:                                 select e).ToList();
  298:  
  299:             return agcfEndpointList;
  300:         }
  301:  
  302:         ////////////////////////////////////////////////////////////////////////////
  303:  
  304:         /// <summary>
  305:         ///
  306:         /// </summary>
  307:         public static List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> List(List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt> oltList)
  308:         {
  309:             List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> ontList;
  310:             List<Ia.Ftn.Cl.Models.Nokia.AgcfGatewayRecord> agcfGatewayRecordList;
  311:             List<Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint> agcfEndpointList;
  312:  
  313:             // below: FTN ONT list
  314:             ontList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntList 
  315:                           where oltList.Any(u => u.Id == o.Pon.PonGroup.Olt.Id) 
  316:                           select o).ToList();
  317:  
  318:             using (var db = new Ia.Ftn.Cl.Db())
  319:             {
  320:                 agcfGatewayRecordList = (from a in db.AgcfGatewayRecords select a).AsNoTracking().ToList();
  321:  
  322:                 agcfEndpointList = (from a in db.AgcfEndpoints select a).AsNoTracking().ToList();
  323:             }
  324:  
  325:             agcfGatewayRecordList = (from gr in agcfGatewayRecordList
  326:                                      join no in ontList on gr.IP1 equals no.Ip
  327:                                      select gr).ToList();
  328:  
  329:             agcfEndpointList = (from e in agcfEndpointList
  330:                                 join gr in agcfGatewayRecordList on e.GwId equals gr.GwId
  331:                                 select e).ToList();
  332:  
  333:             return agcfEndpointList;
  334:         }
  335:  
  336:         ////////////////////////////////////////////////////////////////////////////
  337:  
  338:         /// <summary>
  339:         ///
  340:         /// </summary>
  341:         public static Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint ReadByPrividUser(string prividUser)
  342:         {
  343:             Ia.Ftn.Cl.Models.Nokia.AgcfEndpoint agcfEndpoint;
  344:  
  345:             using (var db = new Ia.Ftn.Cl.Db())
  346:             {
  347:                 agcfEndpoint = (from a in db.AgcfEndpoints where a.PrividUser == prividUser select a).Include(a => a.AgcfGatewayRecord).SingleOrDefault();
  348:             }
  349:  
  350:             return agcfEndpoint;
  351:         }
  352:  
  353:         ////////////////////////////////////////////////////////////////////////////
  354:         ////////////////////////////////////////////////////////////////////////////
  355:     }
  356:  
  357:     ////////////////////////////////////////////////////////////////////////////
  358:     ////////////////////////////////////////////////////////////////////////////
  359: }