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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Dev

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

Huawei's Dev support class of Next Generation Network'a (NGN's) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Data;
   5:  using System.Text;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data.Huawei
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Huawei's Dev support class of Next Generation Network'a (NGN's) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2016-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public partial class Dev
  29:      {
  30:          private static Dictionary<string, int> devTypeToDevTypeIdDictionary;
  31:          private static Dictionary<int, string> devTypeIdToDevTypeDictionary;
  32:   
  33:          private static Dictionary<string, int> devToDidDictionary;
  34:          private static Dictionary<int, string> didToDevDictionary;
  35:   
  36:          public static Dictionary<string, int> DevTypeToDevTypeIdDictionary
  37:          {
  38:              get
  39:              {
  40:                  if (devTypeToDevTypeIdDictionary == null || devTypeToDevTypeIdDictionary.Count == 0)
  41:                  {
  42:                      devTypeToDevTypeIdDictionary = new Dictionary<string, int>();
  43:   
  44:                      devTypeToDevTypeIdDictionary["UA5000(PVMV1)"] = 219;
  45:                      devTypeToDevTypeIdDictionary["MA5662"] = 37;
  46:                      devTypeToDevTypeIdDictionary["MA5600V3"] = 44;
  47:                      devTypeToDevTypeIdDictionary["MA5105(BSL)"] = 71;
  48:                      devTypeToDevTypeIdDictionary["MA5100V2"] = 72;
  49:                      devTypeToDevTypeIdDictionary["MA5300V1"] = 74;
  50:                      devTypeToDevTypeIdDictionary["MD5500V1"] = 75;
  51:                      devTypeToDevTypeIdDictionary["UA5000"] = 82;
  52:                      devTypeToDevTypeIdDictionary["MA5100V1"] = 86;
  53:                      devTypeToDevTypeIdDictionary["UA5000(IPMB)"] = 253;
  54:                      devTypeToDevTypeIdDictionary["MA5605"] = 30;
  55:                      devTypeToDevTypeIdDictionary["MA5680T"] = 34;
  56:                      devTypeToDevTypeIdDictionary["MA5606T"] = 57;
  57:                      devTypeToDevTypeIdDictionary["UA5000(PVU)"] = 232;
  58:                      devTypeToDevTypeIdDictionary["MA5600T"] = 249;
  59:                      devTypeToDevTypeIdDictionary["MA5615"] = 60;
  60:                      devTypeToDevTypeIdDictionary["MA5626E"] = 61;
  61:                      devTypeToDevTypeIdDictionary["MA5620E"] = 62;
  62:                      devTypeToDevTypeIdDictionary["MA5651"] = 64;
  63:                      devTypeToDevTypeIdDictionary["MA5620G"] = 65;
  64:                      devTypeToDevTypeIdDictionary["MA5626G"] = 66;
  65:                      devTypeToDevTypeIdDictionary["MA5651G"] = 67;
  66:                      devTypeToDevTypeIdDictionary["MA5610"] = 70;
  67:                      devTypeToDevTypeIdDictionary["MA5652G"] = 92;
  68:                      devTypeToDevTypeIdDictionary["MA5603U"] = 94;
  69:                      devTypeToDevTypeIdDictionary["MA5603T"] = 95;
  70:                      devTypeToDevTypeIdDictionary["MA5620"] = 96;
  71:                      devTypeToDevTypeIdDictionary["MA5626"] = 97;
  72:                      devTypeToDevTypeIdDictionary["MA5616"] = 100;
  73:                      devTypeToDevTypeIdDictionary["MA5635"] = 103;
  74:                      devTypeToDevTypeIdDictionary["MA5612"] = 104;
  75:                      devTypeToDevTypeIdDictionary["MA5621"] = 2319;
  76:                      devTypeToDevTypeIdDictionary["MA5628"] = 2312;
  77:                      devTypeToDevTypeIdDictionary["MA5652"] = 2313;
  78:                      devTypeToDevTypeIdDictionary["MA5631"] = 2317;
  79:                      devTypeToDevTypeIdDictionary["MA5612A"] = 2320;
  80:                      devTypeToDevTypeIdDictionary["MA5669"] = 2321;
  81:                      devTypeToDevTypeIdDictionary["MA5621A"] = 2322;
  82:                      devTypeToDevTypeIdDictionary["MA5622A"] = 2323;
  83:                      devTypeToDevTypeIdDictionary["MA5623"] = 2324;
  84:                      devTypeToDevTypeIdDictionary["MA5623A"] = 2326;
  85:                      devTypeToDevTypeIdDictionary["MA5632"] = 2318;
  86:                      devTypeToDevTypeIdDictionary["MA5608T"] = 2331;
  87:                      devTypeToDevTypeIdDictionary["MA5698"] = 2333;
  88:                      devTypeToDevTypeIdDictionary["MA5694"] = 2335;
  89:                      devTypeToDevTypeIdDictionary["MA5821"] = 2336;
  90:                      devTypeToDevTypeIdDictionary["MA5822"] = 2337;
  91:                      devTypeToDevTypeIdDictionary["MA5898"] = 2338;
  92:                      devTypeToDevTypeIdDictionary["MA5818"] = 2339;
  93:                      devTypeToDevTypeIdDictionary["MA5611S"] = 2340;
  94:                      devTypeToDevTypeIdDictionary["MA5694S"] = 2343;
  95:                      devTypeToDevTypeIdDictionary["RPS"] = 2344;
  96:                  }
  97:   
  98:                  return devTypeToDevTypeIdDictionary;
  99:              }
 100:          }
 101:   
 102:          /// <summary/>
 103:          public Dev() { }
 104:   
 105:          ////////////////////////////////////////////////////////////////////////////
 106:   
 107:          /// <summary>
 108:          ///
 109:          /// </summary>
 110:          public static Dictionary<int, string> DevTypeIdToDevTypeDictionary
 111:          {
 112:              get
 113:              {
 114:                  if (devTypeIdToDevTypeDictionary == null || devTypeIdToDevTypeDictionary.Count == 0)
 115:                  {
 116:                      devTypeIdToDevTypeDictionary = new Dictionary<int, string>();
 117:   
 118:                      foreach (KeyValuePair<string, int> kvp in DevTypeToDevTypeIdDictionary) devTypeIdToDevTypeDictionary[kvp.Value] = kvp.Key;
 119:                  }
 120:   
 121:                  return devTypeIdToDevTypeDictionary;
 122:              }
 123:          }
 124:   
 125:          ////////////////////////////////////////////////////////////////////////////
 126:   
 127:          /// <summary>
 128:          ///
 129:          /// </summary>
 130:          public static Dictionary<string, int> DevToDidDictionary
 131:          {
 132:              get
 133:              {
 134:                  if (devToDidDictionary == null || devToDidDictionary.Count == 0)
 135:                  {
 136:                      devToDidDictionary = new Dictionary<string, int>();
 137:   
 138:                      List<Ia.Ngn.Cl.Model.Huawei.EmsDev> list;
 139:   
 140:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 141:                      {
 142:                          // this will list the Disconnecting devs first so that if there is an override it will allow the Connecting to be in dictionary
 143:                          list = (from ed in db.EmsDevs select ed).OrderBy(u => u.DSTAT == "Connecting").ToList();
 144:                      }
 145:   
 146:                      foreach (var d in list) devToDidDictionary[d.DEV] = d.DID;
 147:                  }
 148:   
 149:                  return devToDidDictionary;
 150:              }
 151:          }
 152:   
 153:          ////////////////////////////////////////////////////////////////////////////
 154:   
 155:          /// <summary>
 156:          ///
 157:          /// </summary>
 158:          public static Dictionary<int, string> DidToDevDictionary
 159:          {
 160:              get
 161:              {
 162:                  if (didToDevDictionary == null || didToDevDictionary.Count == 0)
 163:                  {
 164:                      didToDevDictionary = new Dictionary<int, string>();
 165:   
 166:                      foreach (KeyValuePair<string, int> kvp in DevToDidDictionary) didToDevDictionary[kvp.Value] = kvp.Key;
 167:                  }
 168:   
 169:                  return didToDevDictionary;
 170:              }
 171:          }
 172:   
 173:          ////////////////////////////////////////////////////////////////////////////
 174:   
 175:          /// <summary>
 176:          ///
 177:          /// </summary>
 178:          public static bool Update(Ia.Ngn.Cl.Model.Business.Huawei.Ems.Response response, out Ia.Cl.Model.Result result)
 179:          {
 180:              bool isUpdated;
 181:              int id, queryDtTypeId, did, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 182:              string queryCommand, queryDev, devDev, dtType;
 183:              DataColumnCollection columns;
 184:              DataRow columnDataRow;
 185:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 186:              Ia.Ngn.Cl.Model.Huawei.EmsDev dev, newDev;
 187:              List<int> itemIdList;
 188:              List<Ia.Ngn.Cl.Model.Huawei.EmsDev> devList;
 189:   
 190:              isUpdated = false;
 191:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 192:              result = new Ia.Cl.Model.Result();
 193:   
 194:              if (response.QueryDataTable != null)
 195:              {
 196:                  queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
 197:   
 198:                  columns = response.QueryDataTable.Columns;
 199:                  readItemCount = response.QueryDataTable.Rows.Count;
 200:   
 201:                  itemIdList = new List<int>(response.QueryDataTable.Rows.Count + 1);
 202:   
 203:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 204:                  {
 205:                      if (queryCommand.Contains("LST-DEV::DT") || queryCommand.Contains("LST-DEV::DEV"))
 206:                      {
 207:                          if (queryCommand.Contains("LST-DEV::DT"))
 208:                          {
 209:                              // LST-DEV::DT=100:{ctag}::;
 210:                              queryDtTypeId = int.Parse(Ia.Cl.Model.Default.Match(queryCommand, @"DT=(\d+)"));
 211:   
 212:                              //if (Ia.Ngn.Cl.Model.Data.Huawei.Dev.DevTypeIdToDevTypeDictionary.ContainsKey(queryDtTypeId))
 213:                              //{
 214:                              dtType = Ia.Ngn.Cl.Model.Data.Huawei.Dev.DevTypeIdToDevTypeDictionary[queryDtTypeId];
 215:   
 216:                              devList = (from ed in db.EmsDevs where ed.DT == dtType select ed).ToList();
 217:                              //}
 218:                              //else
 219:                              //{
 220:                              //    result.AddWarning("Ia.Ngn.Cl.Model.Data.Huawei.Dev.DevTypeIdToDevTypeDictionary does not contain key queryDtTypeId: " + queryDtTypeId);
 221:                              //}
 222:                          }
 223:                          else //if (queryCommand.Contains("LST-DEV::DEV"))
 224:                          {
 225:                              // LST-DEV::DEV=MDU-SAB-1443-001:{ctag}::;
 226:   
 227:                              queryDev = Ia.Cl.Model.Default.Match(queryCommand, @"DEV=(.+?):");
 228:   
 229:                              devList = (from ed in db.EmsDevs where ed.DEV == queryDev select ed).ToList();
 230:                          }
 231:   
 232:                          existingItemCount = devList.Count;
 233:   
 234:                          if (response.QueryDataTable.Rows.Count >= 1)
 235:                          {
 236:                              columnDataRow = response.QueryDataTable.Rows[0];
 237:   
 238:                              foreach (DataRow dataRow in response.QueryDataTable.Rows)
 239:                              {
 240:                                  did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
 241:   
 242:                                  id = Ia.Ngn.Cl.Model.Business.Huawei.Dev.DevId(did);
 243:   
 244:                                  dev = (from d in devList where d.Id == id select d).SingleOrDefault();
 245:   
 246:                                  devDev = columns.Contains("DEV") ? dataRow[columns.IndexOf("DEV")].ToString() : string.Empty;
 247:   
 248:                                  newDev = new Ia.Ngn.Cl.Model.Huawei.EmsDev()
 249:                                  {
 250:                                      Id = id,
 251:                                      DID = did,
 252:                                      DEV = devDev,
 253:                                      DEVIP = columns.Contains("DEVIP") ? dataRow[columns.IndexOf("DEVIP")].ToString() : string.Empty,
 254:                                      DT = columns.Contains("DT") ? dataRow[columns.IndexOf("DT")].ToString() : string.Empty,
 255:                                      DVER = columns.Contains("DVER") ? dataRow[columns.IndexOf("DVER")].ToString() : string.Empty,
 256:                                      DSTAT = columns.Contains("DSTAT") ? dataRow[columns.IndexOf("DSTAT")].ToString() : string.Empty,
 257:                                      DLOC = columns.Contains("DLOC") ? dataRow[columns.IndexOf("DLOC")].ToString() : string.Empty,
 258:                                      AdminStat = columns.Contains("AdminStat") ? dataRow[columns.IndexOf("AdminStat")].ToString() : string.Empty,
 259:                                      WorkMode = columns.Contains("WorkMode") ? dataRow[columns.IndexOf("WorkMode")].ToString() : string.Empty,
 260:                                      ADDITIONALINFO = columns.Contains("ADDITIONALINFO") ? dataRow[columns.IndexOf("ADDITIONALINFO")].ToString() : string.Empty,
 261:                                      CRTID = columns.Contains("CRTID") ? dataRow[columns.IndexOf("CRTID")].ToString() : string.Empty,
 262:                                      CRTADDR = columns.Contains("CRTADDR") ? dataRow[columns.IndexOf("CRTADDR")].ToString() : string.Empty,
 263:                                      CRTTEL = columns.Contains("CRTTEL") ? dataRow[columns.IndexOf("CRTTEL")].ToString() : string.Empty,
 264:                                      CRTDATE = columns.Contains("CRTDATE") ? dataRow[columns.IndexOf("CRTDATE")].ToString() : string.Empty,
 265:                                      REMARK = columns.Contains("REMARK") ? dataRow[columns.IndexOf("REMARK")].ToString() : string.Empty,
 266:                                      TYPE = columns.Contains("TYPE") ? dataRow[columns.IndexOf("TYPE")].ToString() : string.Empty,
 267:                                      NERATELIST = columns.Contains("NERATELIST") ? dataRow[columns.IndexOf("NERATELIST")].ToString() : string.Empty,
 268:                                      NEPROV = columns.Contains("NEPROV") ? dataRow[columns.IndexOf("NEPROV")].ToString() : string.Empty,
 269:                                      TOPXY = columns.Contains("TOPXY") ? dataRow[columns.IndexOf("TOPXY")].ToString() : string.Empty,
 270:                                      EMSID = columns.Contains("EMSID") ? dataRow[columns.IndexOf("EMSID")].ToString() : string.Empty,
 271:                                      ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
 272:                                      PCBVER = columns.Contains("PCBVER") ? dataRow[columns.IndexOf("PCBVER")].ToString() : string.Empty,
 273:                                      MAINTAINID = columns.Contains("MAINTAINID") ? dataRow[columns.IndexOf("MAINTAINID")].ToString() : string.Empty,
 274:                                      MAINTAINADDR = columns.Contains("MAINTAINADDR") ? dataRow[columns.IndexOf("MAINTAINADDR")].ToString() : string.Empty,
 275:                                      MAINTAINTEL = columns.Contains("MAINTAINTEL") ? dataRow[columns.IndexOf("MAINTAINTEL")].ToString() : string.Empty,
 276:                                      REGISTERSTAT = columns.Contains("REGISTERSTAT") ? dataRow[columns.IndexOf("REGISTERSTAT")].ToString() : string.Empty,
 277:                                  };
 278:   
 279:                                  nddOnt = Ia.Ngn.Cl.Model.Business.Default.NddOntFromHuaweiEmsAccessNameFormat(devDev);
 280:                                  if (nddOnt != null) newDev.Access = (from a in db.Accesses where a.Id == nddOnt.Access.Id select a).SingleOrDefault();
 281:   
 282:                                  if (dev == null)
 283:                                  {
 284:                                      newDev.Created = newDev.Updated = DateTime.UtcNow.AddHours(3);
 285:   
 286:                                      db.EmsDevs.Add(newDev);
 287:   
 288:                                      insertedItemCount++;
 289:                                  }
 290:                                  else // update
 291:                                  {
 292:                                      // below: copy values from newDev to dev
 293:   
 294:                                      if (dev.Update(newDev))
 295:                                      {
 296:                                          db.EmsDevs.Attach(dev);
 297:                                          db.Entry(dev).State = System.Data.Entity.EntityState.Modified;
 298:   
 299:                                          updatedItemCount++;
 300:                                      }
 301:                                  }
 302:   
 303:                                  itemIdList.Add(id); // keep at the end
 304:                              }
 305:   
 306:                              // below: this function will remove values that were not present in the reading
 307:                              if (devList.Count > 0)
 308:                              {
 309:                                  foreach (Ia.Ngn.Cl.Model.Huawei.EmsDev de in devList)
 310:                                  {
 311:                                      if (!itemIdList.Contains(de.Id))
 312:                                      {
 313:                                          /*
 314:                                           * First check that this is correct and there is no output paging issues, then I need to delete the boards and ports 
 315:                                          dev = (from ed in db.EmsDevs where ed.Id == de.Id select ed).SingleOrDefault();
 316:  
 317:                                          db.EmsDevs.Remove(dev);
 318:  
 319:                                          deletedItemCount++;
 320:                                          */
 321:                                      }
 322:                                  }
 323:                              }
 324:                          }
 325:                          else
 326:                          {
 327:                              // below: remove all values since reading was empty
 328:   
 329:                              if (devList.Count > 0)
 330:                              {
 331:                                  foreach (Ia.Ngn.Cl.Model.Huawei.EmsDev de in devList)
 332:                                  {
 333:                                      dev = (from ed in db.EmsDevs where ed.Id == de.Id select ed).SingleOrDefault();
 334:   
 335:                                      db.EmsDevs.Remove(dev);
 336:   
 337:                                      deletedItemCount++;
 338:                                  }
 339:                              }
 340:                          }
 341:                      }
 342:                      else
 343:                      {
 344:                          result.AddWarning("Ia.Ngn.Cl.Model.Data.Huawei.Dev.Update() Unknown parameters in command: " + queryCommand);
 345:                      }
 346:   
 347:                      db.SaveChanges();
 348:                  }
 349:   
 350:                  if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
 351:                  else isUpdated = false;
 352:   
 353:                  result.AddSuccess("(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
 354:              }
 355:              else
 356:              {
 357:                  result.AddWarning("response.QueryDataTable is null");
 358:              }
 359:   
 360:              return isUpdated;
 361:          }
 362:   
 363:          ////////////////////////////////////////////////////////////////////////////
 364:   
 365:          /// <summary>
 366:          ///
 367:          /// </summary>
 368:          public static List<Ia.Ngn.Cl.Model.Huawei.EmsDev> List()
 369:          {
 370:              List<Ia.Ngn.Cl.Model.Huawei.EmsDev> list;
 371:   
 372:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 373:              {
 374:                  list = (from ed in db.EmsDevs select ed).ToList();
 375:              }
 376:   
 377:              return list;
 378:          }
 379:   
 380:          ////////////////////////////////////////////////////////////////////////////
 381:   
 382:          /// <summary>
 383:          ///
 384:          /// </summary>
 385:          public static List<string> DevList()
 386:          {
 387:              List<string> list;
 388:   
 389:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 390:              {
 391:                  list = (from ed in db.EmsDevs select ed.DEV).ToList();
 392:              }
 393:   
 394:              return list;
 395:          }
 396:   
 397:          ////////////////////////////////////////////////////////////////////////////
 398:   
 399:          /// <summary>
 400:          ///
 401:          /// </summary>
 402:          public static List<Ia.Ngn.Cl.Model.Huawei.EmsDev> ListByMA5616DevType()
 403:          {
 404:              return ListByDevType("MA5616");
 405:          }
 406:   
 407:          ////////////////////////////////////////////////////////////////////////////
 408:   
 409:          /// <summary>
 410:          ///
 411:          /// </summary>
 412:          public static List<Ia.Ngn.Cl.Model.Huawei.EmsDev> ListByDevType(string devType)
 413:          {
 414:              List<Ia.Ngn.Cl.Model.Huawei.EmsDev> list;
 415:   
 416:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 417:              {
 418:                  list = (from ed in db.EmsDevs where ed.DT == devType select ed).ToList();
 419:              }
 420:   
 421:              return list;
 422:          }
 423:   
 424:          ////////////////////////////////////////////////////////////////////////////
 425:   
 426:          /// <summary>
 427:          ///
 428:          /// </summary>
 429:          public static Ia.Ngn.Cl.Model.Huawei.EmsDev Read(int id)
 430:          {
 431:              Ia.Ngn.Cl.Model.Huawei.EmsDev item;
 432:   
 433:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 434:              {
 435:                  item = (from ed in db.EmsDevs where ed.Id == id select ed).SingleOrDefault();
 436:              }
 437:   
 438:              return item;
 439:          }
 440:   
 441:          ////////////////////////////////////////////////////////////////////////////
 442:   
 443:          /// <summary>
 444:          ///
 445:          /// </summary>
 446:          public static Ia.Ngn.Cl.Model.Huawei.EmsDev ReadByEmsName(string emsName)
 447:          {
 448:              Ia.Ngn.Cl.Model.Huawei.EmsDev item;
 449:   
 450:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 451:              {
 452:                  item = (from ed in db.EmsDevs where ed.DEV == emsName select ed).SingleOrDefault();
 453:              }
 454:   
 455:              return item;
 456:          }
 457:   
 458:          ////////////////////////////////////////////////////////////////////////////
 459:   
 460:          /// <summary>
 461:          ///
 462:          /// </summary>
 463:          public static Ia.Ngn.Cl.Model.Huawei.EmsDev ReadByDev(string dev)
 464:          {
 465:              Ia.Ngn.Cl.Model.Huawei.EmsDev item;
 466:   
 467:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 468:              {
 469:                  item = (from ed in db.EmsDevs where ed.DEV == dev select ed).SingleOrDefault();
 470:              }
 471:   
 472:              return item;
 473:          }
 474:   
 475:          ////////////////////////////////////////////////////////////////////////////
 476:   
 477:          /// <summary>
 478:          ///
 479:          /// </summary>
 480:          public static Ia.Ngn.Cl.Model.Huawei.EmsDev ReadByDid(int did)
 481:          {
 482:              Ia.Ngn.Cl.Model.Huawei.EmsDev item;
 483:   
 484:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 485:              {
 486:                  item = (from ed in db.EmsDevs where ed.DID == did select ed).SingleOrDefault();
 487:              }
 488:   
 489:              return item;
 490:          }
 491:   
 492:          ////////////////////////////////////////////////////////////////////////////
 493:   
 494:          /// <summary>
 495:          /// Return Devs with similar names
 496:          /// </summary>
 497:          public static List<Ia.Ngn.Cl.Model.Huawei.EmsDev> RedundantDevList()
 498:          {
 499:              List<Ia.Ngn.Cl.Model.Huawei.EmsDev> devs;
 500:   
 501:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 502:              {
 503:                  // select * from EmsDevs ed1 left outer join EmsDevs ed2 on ed1.DEV = ed2.DEV where ed1.Id <> ed2.Id
 504:   
 505:                  devs = (from ed1 in db.EmsDevs join ed2 in db.EmsDevs on ed1.DEV equals ed2.DEV where ed2.DID != ed2.DID select ed1).ToList();
 506:              }
 507:   
 508:              return devs;
 509:          }
 510:   
 511:          ////////////////////////////////////////////////////////////////////////////
 512:          ////////////////////////////////////////////////////////////////////////////
 513:   
 514:          /// <summary>
 515:          ///
 516:          /// </summary>
 517:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Huawei.EmsDev emsDev)
 518:          {
 519:              StringBuilder sb;
 520:   
 521:              sb = new StringBuilder();
 522:   
 523:              sb.AppendLine("DID: " + emsDev.DID);
 524:              sb.AppendLine("DEV: " + emsDev.DEV);
 525:              sb.AppendLine("DEVIP: " + emsDev.DEVIP);
 526:              sb.AppendLine("DT: " + emsDev.DT);
 527:              sb.AppendLine("DVER: " + emsDev.DVER);
 528:              sb.AppendLine("DSTAT: " + emsDev.DSTAT);
 529:   
 530:              return sb.ToString();
 531:          }
 532:   
 533:          ////////////////////////////////////////////////////////////////////////////
 534:          ////////////////////////////////////////////////////////////////////////////
 535:      }
 536:   
 537:      ////////////////////////////////////////////////////////////////////////////
 538:      ////////////////////////////////////////////////////////////////////////////
 539:  }