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

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

Huawei's Ont support class of Fixed Telecommunications Network (FTN) data model.

    1: using Microsoft.EntityFrameworkCore;
    2: using System;
    3: using System.Collections;
    4: using System.Collections.Generic;
    5: using System.Data;
    6: using System.Linq;
    7: using System.Text;
    8:  
    9: namespace Ia.Ftn.Cl.Model.Data.Huawei
   10: {
   11:     ////////////////////////////////////////////////////////////////////////////
   12:  
   13:     /// <summary publish="true">
   14:     /// Huawei's Ont support class of Fixed Telecommunications Network (FTN) data model.
   15:     /// </summary>
   16:     /// 
   17:     /// <remarks> 
   18:     /// Copyright © 2016-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     ///
   20:     /// 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
   21:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   22:     ///
   23:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   24:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   25:     /// 
   26:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   27:     /// 
   28:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   29:     /// </remarks> 
   30:     public class Ont
   31:     {
   32:         /// <summary/>
   33:         public Ont() { }
   34:  
   35:         ////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public static List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> List()
   41:         {
   42:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> list;
   43:  
   44:             using (var db = new Ia.Ftn.Cl.Model.Db())
   45:             {
   46:                 list = (from o in db.EmsOnts select o).ToList();
   47:             }
   48:  
   49:             return list;
   50:         }
   51:  
   52:         ////////////////////////////////////////////////////////////////////////////
   53:  
   54:         /// <summary>
   55:         ///
   56:         /// </summary>
   57:         public static List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ListWithNullAccess()
   58:         {
   59:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> list;
   60:  
   61:             using (var db = new Ia.Ftn.Cl.Model.Db())
   62:             {
   63:                 list = (from o in db.EmsOnts where o.Access == null select o).ToList();
   64:             }
   65:  
   66:             return list;
   67:         }
   68:  
   69:         ////////////////////////////////////////////////////////////////////////////
   70:  
   71:         /// <summary>
   72:         ///
   73:         /// </summary>
   74:         public static List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ListIncludeAccess()
   75:         {
   76:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> list;
   77:  
   78:             using (var db = new Ia.Ftn.Cl.Model.Db())
   79:             {
   80:                 list = (from o in db.EmsOnts select o).Include(u => u.Access).AsNoTracking().ToList();
   81:             }
   82:  
   83:             return list;
   84:         }
   85:  
   86:         ////////////////////////////////////////////////////////////////////////////
   87:  
   88:         /// <summary>
   89:         ///
   90:         /// </summary>
   91:         public static List<string> IdList()
   92:         {
   93:             List<string> list;
   94:  
   95:             using (var db = new Ia.Ftn.Cl.Model.Db())
   96:             {
   97:                 list = (from o in db.EmsOnts select o.Id).ToList();
   98:             }
   99:  
  100:             return list;
  101:         }
  102:  
  103:         ////////////////////////////////////////////////////////////////////////////
  104:  
  105:         /// <summary>
  106:         ///
  107:         /// </summary>
  108:         public static List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ListByDidFnSnPn(int did, int fn, int sn, int pn)
  109:         {
  110:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> list;
  111:  
  112:             using (var db = new Ia.Ftn.Cl.Model.Db())
  113:             {
  114:                 list = (from o in db.EmsOnts
  115:                         where o.DID == did && o.FN == fn && o.SN == sn && o.PN == pn
  116:                         select o).ToList();
  117:             }
  118:  
  119:             return list;
  120:         }
  121:  
  122:         ////////////////////////////////////////////////////////////////////////////
  123:  
  124:         /// <summary>
  125:         ///
  126:         /// </summary>
  127:         public static List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ListByDid(int did)
  128:         {
  129:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> list;
  130:  
  131:             using (var db = new Ia.Ftn.Cl.Model.Db())
  132:             {
  133:                 list = (from o in db.EmsOnts where o.DID == did select o).Include(u => u.Access).ToList();
  134:             }
  135:  
  136:             return list;
  137:         }
  138:  
  139:         ////////////////////////////////////////////////////////////////////////////
  140:  
  141:         /// <summary>
  142:         ///
  143:         /// </summary>
  144:         public static Ia.Ftn.Cl.Model.Huawei.EmsOnt ReadByDidFnSnPnOntId(int did, int fn, int sn, int pn, int ontId)
  145:         {
  146:             Ia.Ftn.Cl.Model.Huawei.EmsOnt item;
  147:  
  148:             using (var db = new Ia.Ftn.Cl.Model.Db())
  149:             {
  150:                 item = (from o in db.EmsOnts
  151:                         where o.DID == did && o.FN == fn && o.SN == sn && o.PN == pn && o.ONTID == ontId
  152:                         select o).SingleOrDefault();
  153:             }
  154:  
  155:             return item;
  156:         }
  157:  
  158:         ////////////////////////////////////////////////////////////////////////////
  159:  
  160:         /// <summary>
  161:         ///
  162:         /// </summary>
  163:         public static Ia.Ftn.Cl.Model.Huawei.EmsOnt Read(string id)
  164:         {
  165:             Ia.Ftn.Cl.Model.Huawei.EmsOnt item;
  166:  
  167:             using (var db = new Ia.Ftn.Cl.Model.Db())
  168:             {
  169:                 item = (from o in db.EmsOnts
  170:                         where o.Id == id
  171:                         select o).AsNoTracking().SingleOrDefault(); // use Id to connect MduDev.NddOntId instead.Include(u => u.Access).SingleOrDefault();
  172:             }
  173:  
  174:             return item;
  175:         }
  176:  
  177:         ////////////////////////////////////////////////////////////////////////////
  178:  
  179:         /// <summary>
  180:         ///
  181:         /// </summary>
  182:         public static Ia.Ftn.Cl.Model.Huawei.EmsOnt ReadIncludeAccess(string id)
  183:         {
  184:             Ia.Ftn.Cl.Model.Huawei.EmsOnt item;
  185:  
  186:             using (var db = new Ia.Ftn.Cl.Model.Db())
  187:             {
  188:                 item = (from o in db.EmsOnts
  189:                         where o.Id == id
  190:                         select o).Include(u => u.Access)/*
  191:                         .Include(u => u.EmsPort)
  192:                         .Include(u => u.EmsPort.EmsBoard)
  193:                         .Include(u => u.EmsPort.EmsBoard.EmsDev)*/.AsNoTracking().SingleOrDefault();
  194:             }
  195:  
  196:             return item;
  197:         }
  198:  
  199:         ////////////////////////////////////////////////////////////////////////////
  200:  
  201:         /// <summary>
  202:         ///
  203:         /// </summary>
  204:         public static Ia.Ftn.Cl.Model.Huawei.EmsOnt ReadIncludeAccessAndEmsOntSipInfosAndEmsVoipPstnUsers(string id)
  205:         {
  206:             Ia.Ftn.Cl.Model.Huawei.EmsOnt item;
  207:  
  208:             using (var db = new Ia.Ftn.Cl.Model.Db())
  209:             {
  210:                 item = (from o in db.EmsOnts
  211:                         where o.Id == id
  212:                         select o).Include(u => u.Access).Include(u => u.EmsOntSipInfos).Include(u => u.EmsVoipPstnUsers).AsNoTracking().SingleOrDefault();
  213:             }
  214:  
  215:             return item;
  216:         }
  217:  
  218:         /*
  219:         ////////////////////////////////////////////////////////////////////////////
  220: 
  221:         /// <summary>
  222:         ///
  223:         /// </summary>
  224:         public static List<Ia.Ftn.Cl.Model.Huawei.Ont> List(string portId)
  225:         {
  226:             List<Ia.Ftn.Cl.Model.Huawei.Ont> list;
  227: 
  228:             using (var db = new Ia.Ftn.Cl.Model.Ftn())
  229:             {
  230:                 list = (from o in db.EmsOnts where o.Port.Id == portId select o).ToList();
  231:             }
  232: 
  233:             return list;
  234:         }
  235:         */
  236:  
  237:         /*
  238:         ////////////////////////////////////////////////////////////////////////////
  239: 
  240:         /// <summary>
  241:         ///
  242:         /// </summary>
  243:         public static List<Ia.Ftn.Cl.Model.Huawei.Ont> ListByBoardId(string boardId)
  244:         {
  245:             List<Ia.Ftn.Cl.Model.Huawei.Ont> list;
  246: 
  247:             using (var db = new Ia.Ftn.Cl.Model.Ftn())
  248:             {
  249:                 list = (from o in db.EmsOnts where o.Port.Board.Id == boardId select o).ToList();
  250:             }
  251: 
  252:             return list;
  253:         }
  254:         */
  255:  
  256:         /*
  257:         ////////////////////////////////////////////////////////////////////////////
  258: 
  259:         /// <summary>
  260:         ///
  261:         /// </summary>
  262:         public static List<Ia.Ftn.Cl.Model.Huawei.Ont> ListByDevId(int devId)
  263:         {
  264:             List<Ia.Ftn.Cl.Model.Huawei.Ont> list;
  265: 
  266:             using (var db = new Ia.Ftn.Cl.Model.Ftn())
  267:             {
  268:                 list = (from o in db.EmsOnts where o.Port.Board.Dev.Id == devId select o).ToList();
  269:             }
  270: 
  271:             return list;
  272:         }
  273:         */
  274:  
  275:         ////////////////////////////////////////////////////////////////////////////
  276:  
  277:         /// <summary>
  278:         ///
  279:         /// </summary>
  280:         public static Dictionary<string, string> IdToAccessIdDictionary
  281:         {
  282:             get
  283:             {
  284:                 Dictionary<string, string> dictionary, nullDictionary;
  285:  
  286:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  287:                 {
  288:                     dictionary = (from s in db.EmsOnts
  289:                                   where s.Access != null
  290:                                   select new
  291:                                   {
  292:                                       s.Id,
  293:                                       s.Access
  294:                                   }).ToDictionary(u => u.Id, u => u.Access.Id);
  295:  
  296:                     nullDictionary = (from s in db.Onts where s.Access == null select s.Id).ToDictionary(u => u, null);
  297:                 }
  298:  
  299:                 return dictionary.Union(nullDictionary).ToDictionary(u => u.Key, u => u.Value);
  300:             }
  301:         }
  302:  
  303:         ////////////////////////////////////////////////////////////////////////////
  304:  
  305:         /// <summary>
  306:         ///
  307:         /// </summary>
  308:         public static Dictionary<string, Ia.Ftn.Cl.Model.Huawei.EmsOnt> IdToOntDictionary
  309:         {
  310:             get
  311:             {
  312:                 Dictionary<string, Ia.Ftn.Cl.Model.Huawei.EmsOnt> dictionary;
  313:  
  314:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  315:                 {
  316:                     dictionary = (from s in db.EmsOnts
  317:                                   where s.Access != null
  318:                                   select new { OntId = s.Id, Ont = s }).ToDictionary(u => u.OntId, u => u.Ont);
  319:                 }
  320:  
  321:                 return dictionary;
  322:             }
  323:         }
  324:  
  325:         ////////////////////////////////////////////////////////////////////////////
  326:  
  327:         /// <summary>
  328:         ///
  329:         /// </summary>
  330:         public static Dictionary<string, Ia.Ftn.Cl.Model.Huawei.EmsOnt> AccessIdToOntDictionary
  331:         {
  332:             get
  333:             {
  334:                 Dictionary<string, Ia.Ftn.Cl.Model.Huawei.EmsOnt> dictionary;
  335:  
  336:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  337:                 {
  338:                     dictionary = (from s in db.EmsOnts
  339:                                   where s.Access != null
  340:                                   select new { OntAccessId = s.Access.Id, Ont = s }).ToDictionary(u => u.OntAccessId, u => u.Ont);
  341:                 }
  342:  
  343:                 return dictionary;
  344:             }
  345:         }
  346:  
  347:         ////////////////////////////////////////////////////////////////////////////
  348:  
  349:         /// <summary>
  350:         ///
  351:         /// </summary>
  352:         public static Hashtable IdWithNullAccessHashtable
  353:         {
  354:             get
  355:             {
  356:                 List<string> list;
  357:                 Hashtable ht;
  358:  
  359:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  360:                 {
  361:                     list = (from eo in db.EmsOnts where eo.Access == null select eo.Id).ToList();
  362:  
  363:                     if (list.Count > 0)
  364:                     {
  365:                         ht = new Hashtable(list.Count);
  366:  
  367:                         foreach (string s in list) ht[s] = null;
  368:                     }
  369:                     else ht = null;
  370:                 }
  371:  
  372:                 return ht;
  373:             }
  374:         }
  375:  
  376:         ////////////////////////////////////////////////////////////////////////////
  377:  
  378:         /// <summary>
  379:         ///
  380:         /// </summary>
  381:         public static Dictionary<string, string> IdToAliasForNonNullAccessDictionary
  382:         {
  383:             get
  384:             {
  385:                 Dictionary<string, string> dictionary;
  386:  
  387:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  388:                 {
  389:                     dictionary = (from eo in db.EmsOnts
  390:                                   where eo.Access != null
  391:                                   select new
  392:                                   {
  393:                                       eo.Id,
  394:                                       eo.ALIAS
  395:                                   }).ToDictionary(u => u.Id, u => u.ALIAS);
  396:                 }
  397:  
  398:                 return dictionary;
  399:             }
  400:         }
  401:  
  402:         ////////////////////////////////////////////////////////////////////////////
  403:  
  404:         /// <summary>
  405:         ///
  406:         /// </summary>
  407:         public static Dictionary<string, int> DistributionOfEquipmentIdInEmsOntWhereAccessIsNotNullDictionary
  408:         {
  409:             get
  410:             {
  411:                 Dictionary<string, int> dictionary;
  412:  
  413:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  414:                 {
  415:                     var v = (from s in db.EmsOnts
  416:                              where s.Access != null
  417:                              group s by s.EQUIPMENTID into g
  418:                              select new { EquipmentId = g.Key, Count = g.Count() });
  419:  
  420:                     dictionary = v.ToDictionary(u => u.EquipmentId, u => u.Count);
  421:                 }
  422:  
  423:                 return dictionary;
  424:             }
  425:         }
  426:  
  427:         ////////////////////////////////////////////////////////////////////////////
  428:  
  429:         /// <summary>
  430:         ///
  431:         /// </summary>
  432:         public static bool Update(Ia.Ftn.Cl.Model.Business.Huawei.Ems.Response response, out Ia.Cl.Models.Result result)
  433:         {
  434:             bool isUpdated;
  435:             int did, dictionaryDid, fn, sn, pn, ontId, queryFn, querySn, queryPn, queryOntId, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
  436:             string id, queryCommand, queryDev, accessId;
  437:             DataColumnCollection columns;
  438:             DataRow dataRow;
  439:             Dictionary<string, int> devToDidDictionary;
  440:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
  441:             Ia.Ftn.Cl.Model.Huawei.EmsOnt ont, newOnt;
  442:             Ia.Ftn.Cl.Model.Huawei.EmsPort port;
  443:             //List<string> itemIdList;
  444:             //List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ontList;
  445:  
  446:             isUpdated = false;
  447:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  448:             result = new Ia.Cl.Models.Result();
  449:  
  450:             queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
  451:  
  452:             // "LST-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::;";
  453:             queryDev = Ia.Cl.Models.Default.Match(queryCommand, @"DEV=(.+?),");
  454:             queryFn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"FN=(\d+)"));
  455:             querySn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"SN=(\d+)"));
  456:             queryPn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"PN=(\d+)"));
  457:             queryOntId = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"ONTID=(\d+)"));
  458:  
  459:             if (response.CompletionCode == "COMPLD")
  460:             {
  461:                 devToDidDictionary = Ia.Ftn.Cl.Model.Data.Huawei.Dev.DevToDidDictionary;
  462:  
  463:                 if (devToDidDictionary.ContainsKey(queryDev))
  464:                 {
  465:                     dictionaryDid = devToDidDictionary[queryDev];
  466:  
  467:                     port = Ia.Ftn.Cl.Model.Data.Huawei.Port.ReadByDidFnSnPn(dictionaryDid, queryFn, querySn, queryPn);
  468:  
  469:                     if (port != null)
  470:                     {
  471:                         //itemIdList = new List<string>(readItemCount + 1);
  472:  
  473:                         pon = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.PonByOltEmsNameAndSnAndPnAndOptionallyOntId(queryDev, querySn, queryPn, queryOntId);
  474:  
  475:                         if (pon != null)
  476:                         {
  477:                             id = Ia.Ftn.Cl.Model.Business.Huawei.Ont.OntId(pon.Id, queryOntId);
  478:  
  479:                             using (var db = new Ia.Ftn.Cl.Model.Db())
  480:                             {
  481:                                 //ontList = (from eo in db.EmsOnts where eo.EmsPort.Id == port.Id select eo).ToList();
  482:  
  483:                                 ont = (from eo in db.EmsOnts where eo.Id == id select eo).SingleOrDefault();
  484:  
  485:                                 if (ont != null) existingItemCount = 1;
  486:  
  487:                                 if (response.QueryDataTable != null)
  488:                                 {
  489:                                     columns = response.QueryDataTable.Columns;
  490:                                     readItemCount = response.QueryDataTable.Rows.Count;
  491:  
  492:                                     if (readItemCount == 1)
  493:                                     {
  494:                                         dataRow = response.QueryDataTable.Rows[0];
  495:  
  496:                                         did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
  497:                                         fn = int.Parse(dataRow[columns.IndexOf("FN")].ToString());
  498:                                         sn = int.Parse(dataRow[columns.IndexOf("SN")].ToString());
  499:                                         pn = int.Parse(dataRow[columns.IndexOf("PN")].ToString());
  500:                                         ontId = int.Parse(dataRow[columns.IndexOf("ONTID")].ToString());
  501:  
  502:                                         if (fn == queryFn && sn == querySn && pn == queryPn && ontId == queryOntId)
  503:                                         {
  504:                                             newOnt = new Ia.Ftn.Cl.Model.Huawei.EmsOnt()
  505:                                             {
  506:                                                 Id = id,
  507:                                                 DID = did,
  508:                                                 ResultCode = (long)response.ResultCode,
  509:                                                 StateId = (int)Ia.Ftn.Cl.Model.Business.Huawei.Ems.BellcoreState.Unknown, // (int)response.ResultCode,
  510:                                                 FN = fn,
  511:                                                 SN = sn,
  512:                                                 PN = pn,
  513:                                                 ONTID = ontId,
  514:                                                 NAME = columns.Contains("NAME") ? dataRow[columns.IndexOf("NAME")].ToString() : string.Empty,
  515:                                                 ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
  516:                                                 CAPABPROF = columns.Contains("CAPABPROF") ? dataRow[columns.IndexOf("CAPABPROF")].ToString() : string.Empty,
  517:                                                 VENDORID = columns.Contains("VENDORID") ? dataRow[columns.IndexOf("VENDORID")].ToString() : string.Empty,
  518:                                                 EQUIPMENTID = columns.Contains("EQUIPMENTID") ? dataRow[columns.IndexOf("EQUIPMENTID")].ToString() : string.Empty,
  519:                                                 MAINSOFTVERSION = columns.Contains("MAINSOFTVERSION") ? dataRow[columns.IndexOf("MAINSOFTVERSION")].ToString() : string.Empty,
  520:                                                 AUTH = columns.Contains("AUTH") ? dataRow[columns.IndexOf("AUTH")].ToString() : string.Empty,
  521:                                                 AUTHTIMEOUT = columns.Contains("AUTHTIMEOUT") ? Ia.Ftn.Cl.Model.Business.Huawei.Ont.SpecialIntegerParameterHandling("AUTHTIMEOUT", dataRow[columns.IndexOf("AUTHTIMEOUT")].ToString()) : 0,
  522:                                                 LINEPROF = columns.Contains("LINEPROF") ? dataRow[columns.IndexOf("LINEPROF")].ToString() : string.Empty,
  523:                                                 SRVPROF = columns.Contains("SRVPROF") ? dataRow[columns.IndexOf("SRVPROF")].ToString() : string.Empty,
  524:                                                 SERIALNUM = columns.Contains("SERIALNUM") ? dataRow[columns.IndexOf("SERIALNUM")].ToString() : string.Empty,
  525:                                                 LOID = columns.Contains("LOID") ? dataRow[columns.IndexOf("LOID")].ToString() : string.Empty,
  526:                                                 CHECKCODE = columns.Contains("CHECKCODE") ? dataRow[columns.IndexOf("CHECKCODE")].ToString() : string.Empty,
  527:                                                 PWD = columns.Contains("PWD") ? dataRow[columns.IndexOf("PWD")].ToString() : string.Empty,
  528:                                                 ALMPROF = columns.Contains("ALMPROF") ? dataRow[columns.IndexOf("ALMPROF")].ToString() : string.Empty,
  529:                                                 DEV = columns.Contains("DEV") ? dataRow[columns.IndexOf("DEV")].ToString() : string.Empty,
  530:                                                 VLAN = columns.Contains("VLAN") ? int.Parse(dataRow[columns.IndexOf("VLAN")].ToString()) : 0,
  531:                                                 PRI = columns.Contains("PRI") ? int.Parse(dataRow[columns.IndexOf("PRI")].ToString()) : 0,
  532:                                                 IP = columns.Contains("IP") ? dataRow[columns.IndexOf("IP")].ToString() : string.Empty,
  533:                                                 MASK = columns.Contains("MASK") ? dataRow[columns.IndexOf("MASK")].ToString() : string.Empty,
  534:                                                 GATE = columns.Contains("GATE") ? dataRow[columns.IndexOf("GATE")].ToString() : string.Empty,
  535:                                                 ROUTEIP = columns.Contains("ROUTEIP") ? dataRow[columns.IndexOf("ROUTEIP")].ToString() : string.Empty,
  536:                                                 ROUTEMASK = columns.Contains("ROUTEMASK") ? dataRow[columns.IndexOf("ROUTEMASK")].ToString() : string.Empty,
  537:                                                 NEXTHOP = columns.Contains("NEXTHOP") ? dataRow[columns.IndexOf("NEXTHOP")].ToString() : string.Empty,
  538:                                                 SNMPPROF = columns.Contains("SNMPPROF") ? dataRow[columns.IndexOf("SNMPPROF")].ToString() : string.Empty,
  539:                                                 OPTALMPROF = columns.Contains("OPTALMPROF") ? dataRow[columns.IndexOf("OPTALMPROF")].ToString() : string.Empty,
  540:                                                 VAPROF = columns.Contains("VAPROF") ? dataRow[columns.IndexOf("VAPROF")].ToString() : string.Empty,
  541:                                                 MACLEARN = columns.Contains("MACLEARN") ? dataRow[columns.IndexOf("MACLEARN")].ToString() : string.Empty,
  542:                                                 SRVLEVELPROF = columns.Contains("SRVLEVELPROF") ? dataRow[columns.IndexOf("SRVLEVELPROF")].ToString() : string.Empty,
  543:                                                 LSTUPTIME = columns.Contains("LSTUPTIME") ? int.Parse(dataRow[columns.IndexOf("LSTUPTIME")].ToString()) : 0,
  544:                                                 LSTDOWNTIME = columns.Contains("LSTDOWNTIME") ? int.Parse(dataRow[columns.IndexOf("LSTDOWNTIME")].ToString()) : 0,
  545:                                                 DEVCURRENTTIME = columns.Contains("DEVCURRENTTIME") ? int.Parse(dataRow[columns.IndexOf("DEVCURRENTTIME")].ToString()) : 0,
  546:                                                 VASPROFILESET = columns.Contains("VASPROFILESET") ? dataRow[columns.IndexOf("VASPROFILESET")].ToString() : string.Empty,
  547:                                                 HARDWAREVERSION = columns.Contains("HARDWAREVERSION") ? dataRow[columns.IndexOf("HARDWAREVERSION")].ToString() : string.Empty,
  548:                                                 OPERSTATE = columns.Contains("OPERSTATE") ? dataRow[columns.IndexOf("OPERSTATE")].ToString() : string.Empty,
  549:                                                 DEVNAME = columns.Contains("DEVNAME") ? dataRow[columns.IndexOf("DEVNAME")].ToString() : string.Empty,
  550:                                                 BINDWIDTHTYPE = columns.Contains("BINDWIDTHTYPE") ? int.Parse(dataRow[columns.IndexOf("BINDWIDTHTYPE")].ToString()) : 0,
  551:                                                 EmsPort = (from ep in db.EmsPorts where ep.Id == port.Id select ep).SingleOrDefault()
  552:                                             };
  553:  
  554:                                             accessId = Ia.Ftn.Cl.Model.Business.Access.AccessId(id);
  555:                                             if (accessId != null) newOnt.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
  556:  
  557:                                             if (ont == null)
  558:                                             {
  559:                                                 newOnt.Created = newOnt.Updated = DateTime.UtcNow.AddHours(3);
  560:  
  561:                                                 db.EmsOnts.Add(newOnt);
  562:  
  563:                                                 insertedItemCount++;
  564:                                             }
  565:                                             else // update
  566:                                             {
  567:                                                 // below: copy values from newOnt to ont
  568:  
  569:                                                 if (ont.Update(newOnt))
  570:                                                 {
  571:                                                     db.EmsOnts.Attach(ont);
  572:                                                     db.Entry(ont).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  573:  
  574:                                                     updatedItemCount++;
  575:                                                 }
  576:                                             }
  577:                                         }
  578:                                         else
  579:                                         {
  580:                                             result.AddError("LST-ONT (" + response.Ctag + "): did, fn, sn, pn, and/or ontId is/are not equal to queryDid, queryFn, querySn, queryPn, and/or ontId. did: " + did + ", queryDid: " + queryDev + ", fn: " + fn + ", queryFn: " + queryFn + ", sn: " + sn + ", querySn: " + querySn + ", pn: " + pn + ", queryPn: " + queryPn + ", ontId: " + ontId + ", queryOntId: " + queryOntId);
  581:                                         }
  582:                                     }
  583:                                     else //if (readItemCount > 1)
  584:                                     {
  585:                                         result.AddError("LST-ONT (" + response.Ctag + "): dataTable.Rows.Count has more than 1 row");
  586:                                     }
  587:                                 }
  588:                                 else
  589:                                 {
  590:                                     // if DataTable is null or "Resource does not exist"
  591:                                     // delete element if exists
  592:  
  593:                                     if (ont != null)
  594:                                     {
  595:                                         db.EmsOnts.Remove(ont);
  596:  
  597:                                         deletedItemCount++;
  598:                                     }
  599:  
  600:                                     result.AddWarning("LST-ONT (" + response.Ctag + "): " + response.CompletionCode + ", " + response.ResultCode.ToString());
  601:                                 }
  602:  
  603:                                 db.SaveChanges();
  604:                             }
  605:  
  606:                             if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
  607:                             else isUpdated = false;
  608:  
  609:                             result.AddSuccess("LST-ONT (" + response.Ctag + "): " + response.CompletionCode + ", " + response.ResultCode.ToString() + " (" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  610:                         }
  611:                         else
  612:                         {
  613:                             result.AddWarning("LST-ONT (" + response.Ctag + "): NDD PON is null");
  614:                         }
  615:                     }
  616:                     else
  617:                     {
  618:                         result.AddWarning("LST-ONT (" + response.Ctag + "): port is null");
  619:                     }
  620:                 }
  621:                 else
  622:                 {
  623:                     result.AddError("LST-ONT (" + response.Ctag + "): devToDidDictionary does not contain key: " + queryDev);
  624:                 }
  625:             }
  626:             else
  627:             {
  628:                 result.AddWarning("LST-ONT (" + response.Ctag + "): (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  629:             }
  630:  
  631:             return isUpdated;
  632:         }
  633:  
  634:         ////////////////////////////////////////////////////////////////////////////
  635:  
  636:         /// <summary>
  637:         ///
  638:         /// </summary>
  639:         public static bool UpdateListWithDid(Ia.Ftn.Cl.Model.Business.Huawei.Ems.Response response, out Ia.Cl.Models.Result result)
  640:         {
  641:             bool isUpdated;
  642:             int queryDid, did, fn, sn, pn, ontId, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
  643:             string id, queryCommand, accessId;
  644:             DataColumnCollection columns;
  645:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
  646:             Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
  647:             Ia.Ftn.Cl.Model.Huawei.EmsOnt ont, newOnt;
  648:             Ia.Ftn.Cl.Model.Huawei.EmsPort port;
  649:             List<string> itemIdList;
  650:             List<Ia.Ftn.Cl.Model.Huawei.EmsOnt> ontList;
  651:  
  652:             isUpdated = false;
  653:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  654:             result = new Ia.Cl.Models.Result();
  655:  
  656:             if (response.CompletionCode == "COMPLD")
  657:             {
  658:                 if (response.QueryDataTable != null)
  659:                 {
  660:                     queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
  661:  
  662:                     columns = response.QueryDataTable.Columns;
  663:                     readItemCount = response.QueryDataTable.Rows.Count;
  664:  
  665:                     // "LST-ONT::DID=" + olt.Did + ":{ctag}::;";
  666:                     queryDid = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"DID=(\d+):"));
  667:  
  668:                     olt = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OltByDid(queryDid);
  669:  
  670:                     if (olt != null)
  671:                     {
  672:                         ontList = Ia.Ftn.Cl.Model.Data.Huawei.Ont.ListByDid(queryDid);
  673:                         existingItemCount = ontList.Count;
  674:  
  675:                         itemIdList = new List<string>(response.QueryDataTable.Rows.Count + 1);
  676:  
  677:                         using (var db = new Ia.Ftn.Cl.Model.Db())
  678:                         {
  679:                             foreach (DataRow dataRow in response.QueryDataTable.Rows)
  680:                             {
  681:                                 did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
  682:                                 fn = int.Parse(dataRow[columns.IndexOf("FN")].ToString());
  683:                                 sn = int.Parse(dataRow[columns.IndexOf("SN")].ToString());
  684:                                 pn = int.Parse(dataRow[columns.IndexOf("PN")].ToString());
  685:                                 ontId = int.Parse(dataRow[columns.IndexOf("ONTID")].ToString());
  686:  
  687:                                 port = Ia.Ftn.Cl.Model.Data.Huawei.Port.ReadByDidFnSnPn(queryDid, fn, sn, pn);
  688:  
  689:                                 if (port != null)
  690:                                 {
  691:                                     ontList = (from eo in db.EmsOnts where eo.EmsPort.Id == port.Id select eo).ToList();
  692:                                     // or ontList = Ia.Ftn.Cl.Model.Data.Huawei.Ont.List(port.Id);
  693:  
  694:                                     if (did == queryDid)
  695:                                     {
  696:                                         pon = Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.PonByOltEmsNameAndSnAndPnAndOptionallyOntId(olt.EmsName, sn, pn, ontId);
  697:  
  698:                                         if (pon != null)
  699:                                         {
  700:                                             id = Ia.Ftn.Cl.Model.Business.Huawei.Ont.OntId(pon.Id, ontId);
  701:  
  702:                                             newOnt = new Ia.Ftn.Cl.Model.Huawei.EmsOnt()
  703:                                             {
  704:                                                 Id = id,
  705:                                                 DID = did,
  706:                                                 FN = fn,
  707:                                                 SN = sn,
  708:                                                 PN = pn,
  709:                                                 ONTID = ontId,
  710:                                                 NAME = columns.Contains("NAME") ? dataRow[columns.IndexOf("NAME")].ToString() : string.Empty,
  711:                                                 ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
  712:                                                 CAPABPROF = columns.Contains("CAPABPROF") ? dataRow[columns.IndexOf("CAPABPROF")].ToString() : string.Empty,
  713:                                                 VENDORID = columns.Contains("VENDORID") ? dataRow[columns.IndexOf("VENDORID")].ToString() : string.Empty,
  714:                                                 EQUIPMENTID = columns.Contains("EQUIPMENTID") ? dataRow[columns.IndexOf("EQUIPMENTID")].ToString() : string.Empty,
  715:                                                 MAINSOFTVERSION = columns.Contains("MAINSOFTVERSION") ? dataRow[columns.IndexOf("MAINSOFTVERSION")].ToString() : string.Empty,
  716:                                                 AUTH = columns.Contains("AUTH") ? dataRow[columns.IndexOf("AUTH")].ToString() : string.Empty,
  717:                                                 AUTHTIMEOUT = columns.Contains("AUTHTIMEOUT") ? Ia.Ftn.Cl.Model.Business.Huawei.Ont.SpecialIntegerParameterHandling("AUTHTIMEOUT", dataRow[columns.IndexOf("AUTHTIMEOUT")].ToString()) : 0,
  718:                                                 LINEPROF = columns.Contains("LINEPROF") ? dataRow[columns.IndexOf("LINEPROF")].ToString() : string.Empty,
  719:                                                 SRVPROF = columns.Contains("SRVPROF") ? dataRow[columns.IndexOf("SRVPROF")].ToString() : string.Empty,
  720:                                                 SERIALNUM = columns.Contains("SERIALNUM") ? dataRow[columns.IndexOf("SERIALNUM")].ToString() : string.Empty,
  721:                                                 LOID = columns.Contains("LOID") ? dataRow[columns.IndexOf("LOID")].ToString() : string.Empty,
  722:                                                 CHECKCODE = columns.Contains("CHECKCODE") ? dataRow[columns.IndexOf("CHECKCODE")].ToString() : string.Empty,
  723:                                                 PWD = columns.Contains("PWD") ? dataRow[columns.IndexOf("PWD")].ToString() : string.Empty,
  724:                                                 ALMPROF = columns.Contains("ALMPROF") ? dataRow[columns.IndexOf("ALMPROF")].ToString() : string.Empty,
  725:                                                 DEV = columns.Contains("DEV") ? dataRow[columns.IndexOf("DEV")].ToString() : string.Empty,
  726:                                                 VLAN = columns.Contains("VLAN") ? int.Parse(dataRow[columns.IndexOf("VLAN")].ToString()) : 0,
  727:                                                 PRI = columns.Contains("PRI") ? int.Parse(dataRow[columns.IndexOf("PRI")].ToString()) : 0,
  728:                                                 IP = columns.Contains("IP") ? dataRow[columns.IndexOf("IP")].ToString() : string.Empty,
  729:                                                 MASK = columns.Contains("MASK") ? dataRow[columns.IndexOf("MASK")].ToString() : string.Empty,
  730:                                                 GATE = columns.Contains("GATE") ? dataRow[columns.IndexOf("GATE")].ToString() : string.Empty,
  731:                                                 ROUTEIP = columns.Contains("ROUTEIP") ? dataRow[columns.IndexOf("ROUTEIP")].ToString() : string.Empty,
  732:                                                 ROUTEMASK = columns.Contains("ROUTEMASK") ? dataRow[columns.IndexOf("ROUTEMASK")].ToString() : string.Empty,
  733:                                                 NEXTHOP = columns.Contains("NEXTHOP") ? dataRow[columns.IndexOf("NEXTHOP")].ToString() : string.Empty,
  734:                                                 SNMPPROF = columns.Contains("SNMPPROF") ? dataRow[columns.IndexOf("SNMPPROF")].ToString() : string.Empty,
  735:                                                 OPTALMPROF = columns.Contains("OPTALMPROF") ? dataRow[columns.IndexOf("OPTALMPROF")].ToString() : string.Empty,
  736:                                                 VAPROF = columns.Contains("VAPROF") ? dataRow[columns.IndexOf("VAPROF")].ToString() : string.Empty,
  737:                                                 MACLEARN = columns.Contains("MACLEARN") ? dataRow[columns.IndexOf("MACLEARN")].ToString() : string.Empty,
  738:                                                 SRVLEVELPROF = columns.Contains("SRVLEVELPROF") ? dataRow[columns.IndexOf("SRVLEVELPROF")].ToString() : string.Empty,
  739:                                                 LSTUPTIME = columns.Contains("LSTUPTIME") ? int.Parse(dataRow[columns.IndexOf("LSTUPTIME")].ToString()) : 0,
  740:                                                 LSTDOWNTIME = columns.Contains("LSTDOWNTIME") ? int.Parse(dataRow[columns.IndexOf("LSTDOWNTIME")].ToString()) : 0,
  741:                                                 DEVCURRENTTIME = columns.Contains("DEVCURRENTTIME") ? int.Parse(dataRow[columns.IndexOf("DEVCURRENTTIME")].ToString()) : 0,
  742:                                                 VASPROFILESET = columns.Contains("VASPROFILESET") ? dataRow[columns.IndexOf("VASPROFILESET")].ToString() : string.Empty,
  743:                                                 HARDWAREVERSION = columns.Contains("HARDWAREVERSION") ? dataRow[columns.IndexOf("HARDWAREVERSION")].ToString() : string.Empty,
  744:                                                 OPERSTATE = columns.Contains("OPERSTATE") ? dataRow[columns.IndexOf("OPERSTATE")].ToString() : string.Empty,
  745:                                                 DEVNAME = columns.Contains("DEVNAME") ? dataRow[columns.IndexOf("DEVNAME")].ToString() : string.Empty,
  746:                                                 BINDWIDTHTYPE = columns.Contains("BINDWIDTHTYPE") ? int.Parse(dataRow[columns.IndexOf("BINDWIDTHTYPE")].ToString()) : 0,
  747:                                                 EmsPort = (from ep in db.EmsPorts where ep.Id == port.Id select ep).SingleOrDefault()
  748:                                             };
  749:  
  750:                                             accessId = Ia.Ftn.Cl.Model.Business.Access.AccessId(id);
  751:                                             if (accessId != null) newOnt.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
  752:  
  753:                                             ont = (from eo in /*ontList*/ db.EmsOnts where eo.Id == id select eo).SingleOrDefault();
  754:  
  755:                                             if (ont == null)
  756:                                             {
  757:                                                 newOnt.Created = newOnt.Updated = DateTime.UtcNow.AddHours(3);
  758:  
  759:                                                 db.EmsOnts.Add(newOnt);
  760:  
  761:                                                 insertedItemCount++;
  762:                                             }
  763:                                             else
  764:                                             {
  765:                                                 // below: copy values from newOnt to ont
  766:  
  767:                                                 if (ont.Update(newOnt))
  768:                                                 {
  769:                                                     db.EmsOnts.Attach(ont);
  770:                                                     db.Entry(ont).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  771:  
  772:                                                     updatedItemCount++;
  773:                                                 }
  774:                                             }
  775:  
  776:                                             itemIdList.Add(id); // keep at the end
  777:                                         }
  778:                                         else
  779:                                         {
  780:                                             result.AddError("LST-ONT (" + response.Ctag + "): PON is null.");
  781:                                         }
  782:                                     }
  783:                                     else
  784:                                     {
  785:                                         result.AddError("LST-ONT (" + response.Ctag + "): did not equal to queryDid. did: " + did);
  786:                                     }
  787:                                 }
  788:                                 else
  789:                                 {
  790:                                     result.AddWarning("LST-ONT (" + response.Ctag + "): port is null");
  791:                                 }
  792:                             }
  793:  
  794:                             // below: this function will remove values that were not present in the reading
  795:                             if (ontList.Count > 0)
  796:                             {
  797:                                 foreach (Ia.Ftn.Cl.Model.Huawei.EmsOnt on in ontList)
  798:                                 {
  799:                                     if (!itemIdList.Contains(on.Id))
  800:                                     {
  801:                                         ont = (from o in db.EmsOnts where o.Id == @on.Id select o).SingleOrDefault();
  802:  
  803:                                         db.EmsOnts.Remove(ont);
  804:  
  805:                                         deletedItemCount++;
  806:                                     }
  807:                                 }
  808:                             }
  809:  
  810:                             db.SaveChanges();
  811:                         }
  812:  
  813:                         if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
  814:                         else isUpdated = false;
  815:  
  816:                         result.AddSuccess("LST-ONT (" + response.Ctag + "): (" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  817:                     }
  818:                     else
  819:                     {
  820:                         result.AddWarning("LST-ONT (" + response.Ctag + "): NDD OLT is null");
  821:                     }
  822:                 }
  823:                 else
  824:                 {
  825:                     result.AddWarning("LST-ONT (" + response.Ctag + "): QueryDataTable is null, (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  826:                 }
  827:             }
  828:             else
  829:             {
  830:                 result.AddWarning("LST-ONT (" + response.Ctag + "): (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  831:             }
  832:  
  833:             return isUpdated;
  834:         }
  835:  
  836:         ////////////////////////////////////////////////////////////////////////////
  837:  
  838:         /// <summary>
  839:         ///
  840:         /// </summary>
  841:         public static bool UpdateResultCode(Ia.Ftn.Cl.Model.Huawei.EmsOnt emsOnt, Ia.Ftn.Cl.Model.Client.Huawei.Ems.ResultCode resultCode)
  842:         {
  843:             // similar to Ia.Ftn.Cl.Model.Data.Huawei.Dev.UpdateResultCode();
  844:             bool isUpdated;
  845:  
  846:             using (var db = new Ia.Ftn.Cl.Model.Db())
  847:             {
  848:                 if (emsOnt != null)
  849:                 {
  850:                     var updatedOnt = (from o in db.EmsOnts where o.Id == emsOnt.Id select o).SingleOrDefault();
  851:  
  852:                     if (updatedOnt != null)
  853:                     {
  854:                         if (updatedOnt.ResultCode != (long)resultCode)
  855:                         {
  856:                             updatedOnt.ResultCode = (long)resultCode;
  857:                             updatedOnt.Updated = DateTime.UtcNow.AddHours(3);
  858:  
  859:                             db.EmsOnts.Attach(updatedOnt);
  860:                             db.Entry(updatedOnt).Property(u => u.ResultCode).IsModified = true;
  861:                             db.Entry(updatedOnt).Property(u => u.Updated).IsModified = true;
  862:  
  863:                             db.SaveChanges();
  864:  
  865:                             isUpdated = true;
  866:                             //result.AddSuccess("EmsOnt.ResultCode updated. ");
  867:                         }
  868:                         else
  869:                         {
  870:                             isUpdated = false;
  871:                             // result.AddWarning("Warning: EmsOnt.ResultCode value was not updated because its the same. ");
  872:                         }
  873:                     }
  874:                     else
  875:                     {
  876:                         isUpdated = false;
  877:                         // result.AddError("Error: updatedOnt is null. ");
  878:                     }
  879:                 }
  880:                 else
  881:                 {
  882:                     isUpdated = false;
  883:                 }
  884:             }
  885:  
  886:             return isUpdated;
  887:         }
  888:  
  889:         ////////////////////////////////////////////////////////////////////////////
  890:  
  891:         /// <summary>
  892:         ///
  893:         /// </summary>
  894:         public static bool NullifyAccessIdByAccessId(string accessId, out string result)
  895:         {
  896:             bool b;
  897:             int numberOfRecordsWhereAccessIsNullified;
  898:             Ia.Ftn.Cl.Model.Huawei.EmsOnt ont;
  899:  
  900:             b = false;
  901:             numberOfRecordsWhereAccessIsNullified = 0;
  902:  
  903:             using (var db = new Ia.Ftn.Cl.Model.Db())
  904:             {
  905:                 // --update EmsOnts set Access_Id = null where Access_Id = '1040101010040004'
  906:                 //var query = (from eo in db.EmsOnts where eo.Access.Id == accessId select eo).ToList();
  907:  
  908:                 //foreach (var v in query)
  909:                 //{
  910:                 ont = (from o in db.EmsOnts where o.Access.Id == accessId select o).Include(u => u.Access).FirstOrDefault(); //.SingleOrDefault();
  911:  
  912:                 if (ont != null)
  913:                 {
  914:                     ont.Access = null;
  915:                     ont.Updated = DateTime.UtcNow.AddHours(3);
  916:  
  917:                     db.EmsOnts.Attach(ont);
  918:                     db.Entry(ont).Property(u => u.Updated).IsModified = true;
  919:  
  920:                     db.SaveChanges();
  921:  
  922:                     numberOfRecordsWhereAccessIsNullified++;
  923:                 }
  924:                 //}
  925:  
  926:                 b = true;
  927:             }
  928:  
  929:             result = "Number of records where access is nullified: " + numberOfRecordsWhereAccessIsNullified;
  930:  
  931:             return b;
  932:         }
  933:  
  934:         ////////////////////////////////////////////////////////////////////////////
  935:  
  936:         /// <summary>
  937:         ///
  938:         /// </summary>
  939:         public static bool Delete(string id, out string result)
  940:         {
  941:             bool b;
  942:  
  943:             b = false;
  944:             result = string.Empty;
  945:  
  946:             using (var db = new Ia.Ftn.Cl.Model.Db())
  947:             {
  948:                 var v = (from em in db.EmsOnts where em.Id == id select em).FirstOrDefault();
  949:  
  950:                 if (v != null)
  951:                 {
  952:                     db.EmsOnts.Remove(v);
  953:                     db.SaveChanges();
  954:  
  955:                     b = true;
  956:                 }
  957:                 else b = false;
  958:             }
  959:  
  960:             return b;
  961:         }
  962:  
  963:         ////////////////////////////////////////////////////////////////////////////
  964:  
  965:         /// <summary>
  966:         ///
  967:         /// </summary>
  968:         public static bool DeleteByAccessId(string accessId, out string result)
  969:         {
  970:             bool b;
  971:  
  972:             b = false;
  973:             result = string.Empty;
  974:  
  975:             using (var db = new Ia.Ftn.Cl.Model.Db())
  976:             {
  977:                 var v = (from eo in db.EmsOnts where eo.Access.Id == accessId select eo).Include(u => u.Access).FirstOrDefault();
  978:  
  979:                 if (v != null)
  980:                 {
  981:                     db.EmsOnts.Remove(v);
  982:                     db.SaveChanges();
  983:  
  984:                     b = true;
  985:                 }
  986:                 else b = false;
  987:             }
  988:  
  989:             return b;
  990:         }
  991:  
  992:         ////////////////////////////////////////////////////////////////////////////
  993:         ////////////////////////////////////////////////////////////////////////////
  994:  
  995:         /// <summary>
  996:         ///
  997:         /// </summary>
  998:         public static string ToSimpleTextString(Ia.Ftn.Cl.Model.Huawei.EmsOnt ont)
  999:         {
 1000:             StringBuilder sb;
 1001:  
 1002:             sb = new StringBuilder();
 1003:  
 1004:             /*
 1005:             //sb.AppendLine("Vendor: " + Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia.Name);
 1006:             sb.AppendLine("State: " + ont.State);
 1007:             sb.AppendLine("FamilyType: " + Ia.Ftn.Cl.Model.Data.Nokia.Ont.FamilyTypeFromId(ont.FamilyTypeId));
 1008:             sb.AppendLine("Serial: " + ont.Serial);
 1009:             sb.AppendLine("EquipmentId: " + ont.EquipmentId);
 1010:             sb.AppendLine("ActiveSoftware: " + ont.ActiveSoftware);
 1011:             //sb.AppendLine("PassiveSoftware: " + ont.PassiveSoftware);
 1012:             sb.AppendLine("PlannedSoftware: " + ont.PlannedSoftware);
 1013:             //sb.AppendLine("BatteryBackupAvailable: " + ont.BatteryBackupAvailable);
 1014:             sb.AppendLine("Description1: " + ont.Description1);
 1015:             sb.AppendLine("Description2: " + ont.Description2);
 1016:             */
 1017:  
 1018:             return sb.ToString();
 1019:         }
 1020:  
 1021:         ////////////////////////////////////////////////////////////////////////////
 1022:         ////////////////////////////////////////////////////////////////////////////
 1023:     }
 1024:  
 1025:     ////////////////////////////////////////////////////////////////////////////
 1026:     ////////////////////////////////////////////////////////////////////////////
 1027: }