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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Access

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

Access support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data.Entity;
   4:  using System.Linq;
   5:  using System.Text;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Access support class for Next Generation Network (NGN) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2017 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 Access
  29:      {
  30:          /// <summary/>
  31:          public Access() { }
  32:   
  33:          ////////////////////////////////////////////////////////////////////////////
  34:   
  35:          /// <summary>
  36:          ///
  37:          /// </summary>
  38:          public static void Create(Ia.Ngn.Cl.Model.Access newAccess, out Ia.Cl.Model.Result result)
  39:          {
  40:              Ia.Ngn.Cl.Model.Access access;
  41:   
  42:              result = new Ia.Cl.Model.Result();
  43:   
  44:              try
  45:              {
  46:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
  47:                  {
  48:                      // check if it exists already
  49:                      access = (from a in db.Accesses where a.Id == newAccess.Id select a).SingleOrDefault();
  50:   
  51:                      if (access == null)
  52:                      {
  53:                          newAccess.Created = newAccess.Updated = DateTime.UtcNow.AddHours(3);
  54:   
  55:                          db.Accesses.Add(newAccess);
  56:                          db.SaveChanges();
  57:   
  58:                          result.AddSuccess("Access record " + newAccess.Name + " created. ");
  59:                      }
  60:                      else
  61:                      {
  62:                          result.AddError("Access record " + newAccess.Name + " already exists. ");
  63:                      }
  64:                  }
  65:              }
  66:              catch (Exception ex)
  67:              {
  68:                  result.AddError("Exception: Access record was not created: " + ex.Message);
  69:              }
  70:          }
  71:   
  72:          ////////////////////////////////////////////////////////////////////////////
  73:   
  74:          /// <summary>
  75:          ///
  76:          /// </summary>
  77:          public static Ia.Ngn.Cl.Model.Access Read(Ia.Ngn.Cl.Model.Ngn db, string id)
  78:          {
  79:              Ia.Ngn.Cl.Model.Access access;
  80:   
  81:              access = (from a in db.Accesses where a.Id == id select a).SingleOrDefault();
  82:   
  83:              return access;
  84:          }
  85:   
  86:          ////////////////////////////////////////////////////////////////////////////
  87:   
  88:          /// <summary>
  89:          ///
  90:          /// </summary>
  91:          public static Ia.Ngn.Cl.Model.Access Read(string id)
  92:          {
  93:              Ia.Ngn.Cl.Model.Access item;
  94:   
  95:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  96:              {
  97:                  item = (from a in db.Accesses where a.Id == id select a).SingleOrDefault();
  98:              }
  99:   
 100:              return item;
 101:          }
 102:   
 103:          ////////////////////////////////////////////////////////////////////////////
 104:   
 105:          /// <summary>
 106:          ///
 107:          /// </summary>
 108:          public static Ia.Ngn.Cl.Model.Access Read(int oltId, int ponNumber, int ontNumber)
 109:          {
 110:              Ia.Ngn.Cl.Model.Access item;
 111:   
 112:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 113:              {
 114:                  item = (from a in db.Accesses where a.Olt == oltId && a.Pon == ponNumber && a.Ont == ontNumber select a).SingleOrDefault();
 115:              }
 116:   
 117:              return item;
 118:          }
 119:   
 120:          ////////////////////////////////////////////////////////////////////////////
 121:   
 122:          /// <summary>
 123:          ///
 124:          /// </summary>
 125:          public static Ia.Ngn.Cl.Model.Access Read(Ia.Ngn.Cl.Model.Ngn db, int oltId, int ponNumber, int ontNumber)
 126:          {
 127:              return (from a in db.Accesses where a.Olt == oltId && a.Pon == ponNumber && a.Ont == ontNumber select a).SingleOrDefault();
 128:          }
 129:   
 130:          ////////////////////////////////////////////////////////////////////////////
 131:   
 132:          /// <summary>
 133:          ///
 134:          /// </summary>
 135:          public static Ia.Ngn.Cl.Model.Access ReadBySerialInNote(string serial)
 136:          {
 137:              List<Ia.Ngn.Cl.Model.Access> list;
 138:   
 139:              if (!string.IsNullOrEmpty(serial))
 140:              {
 141:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 142:                  {
 143:                      list = (from a in db.Accesses where a.Note.Contains(serial) select a).ToList();
 144:                  }
 145:              }
 146:              else list = null;
 147:   
 148:              return list.FirstOrDefault();
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          public static List<Ia.Ngn.Cl.Model.Access> ReadListByAreaId(int areaId)
 157:          {
 158:              List<Ia.Ngn.Cl.Model.Access> itemList;
 159:   
 160:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 161:              {
 162:                  itemList = (from a in db.Accesses where a.AreaId == areaId select a).ToList();
 163:              }
 164:   
 165:              return itemList;
 166:          }
 167:   
 168:          ////////////////////////////////////////////////////////////////////////////
 169:   
 170:          /// <summary>
 171:          ///
 172:          /// </summary>
 173:          public static int AreaIdFromOltIdAndPon(int oltId, int ponNumber)
 174:          {
 175:              int areaId;
 176:   
 177:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 178:              {
 179:                  areaId = (from a in db.Accesses where a.Olt == oltId && a.Pon == ponNumber select a.AreaId).FirstOrDefault();
 180:   
 181:                  if (areaId == 0)
 182:                  {
 183:                      areaId = (from a in db.Accesses where a.Olt == oltId select a.AreaId).FirstOrDefault();
 184:                  }
 185:              }
 186:   
 187:              return areaId;
 188:          }
 189:   
 190:          ////////////////////////////////////////////////////////////////////////////
 191:   
 192:          /// <summary>
 193:          ///
 194:          /// </summary>
 195:          public static List<Ia.Ngn.Cl.Model.Access> List()
 196:          {
 197:              List<Ia.Ngn.Cl.Model.Access> list;
 198:   
 199:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 200:              {
 201:                  list = (from a in db.Accesses select a).ToList();
 202:              }
 203:   
 204:              return list;
 205:          }
 206:   
 207:          ////////////////////////////////////////////////////////////////////////////
 208:   
 209:          /// <summary>
 210:          ///
 211:          /// </summary>
 212:          public static List<Ia.Ngn.Cl.Model.Access> List(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 213:          {
 214:              List<Ia.Ngn.Cl.Model.Access> list;
 215:   
 216:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 217:              {
 218:                  list = (from a in db.Accesses where a.Olt == olt.Id select a).ToList();
 219:              }
 220:   
 221:              return list;
 222:          }
 223:   
 224:          ////////////////////////////////////////////////////////////////////////////
 225:   
 226:          /// <summary>
 227:          ///
 228:          /// </summary>
 229:          public static List<Ia.Ngn.Cl.Model.Access> List(int oltId, int ponNumber)
 230:          {
 231:              List<Ia.Ngn.Cl.Model.Access> itemList;
 232:   
 233:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 234:              {
 235:                  itemList = (from a in db.Accesses where a.Olt == oltId && a.Pon == ponNumber select a).ToList();
 236:              }
 237:   
 238:              return itemList;
 239:          }
 240:   
 241:          ////////////////////////////////////////////////////////////////////////////
 242:   
 243:          /// <summary>
 244:          ///
 245:          /// </summary>
 246:          public static bool Update(Ia.Ngn.Cl.Model.Access updatedAccess, out string result)
 247:          {
 248:              bool b;
 249:              Ia.Ngn.Cl.Model.Access access;
 250:   
 251:              b = false;
 252:              result = string.Empty;
 253:   
 254:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 255:              {
 256:                  access = (from a in db.Accesses where a.Id == updatedAccess.Id select a).SingleOrDefault();
 257:   
 258:                  if (access.Update(updatedAccess))
 259:                  {
 260:                      db.Accesses.Attach(access);
 261:                      db.Entry(access).State = System.Data.Entity.EntityState.Modified;
 262:                  }
 263:   
 264:                  db.SaveChanges();
 265:   
 266:                  b = true;
 267:              }
 268:   
 269:              return b;
 270:          }
 271:   
 272:          ////////////////////////////////////////////////////////////////////////////
 273:   
 274:          /// <summary>
 275:          ///
 276:          /// </summary>
 277:          public static void Delete(string id, out Ia.Cl.Model.Result result)
 278:          {
 279:              result = new Ia.Cl.Model.Result();
 280:   
 281:              try
 282:              {
 283:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 284:                  {
 285:                      var v = (from a in db.Accesses where a.Id == id select a).FirstOrDefault();
 286:   
 287:                      if (v != null)
 288:                      {
 289:                          db.Accesses.Remove(v);
 290:                          db.SaveChanges();
 291:   
 292:                          result.AddSuccess("Access record deleted. ");
 293:                      }
 294:                      else
 295:                      {
 296:                          result.AddWarning("Access record does not exist. ");
 297:                      }
 298:   
 299:                  }
 300:              }
 301:              catch (Exception ex)
 302:              {
 303:                  result.AddError("Exception: Access record was not deleted: " + ex.Message);
 304:              }
 305:          }
 306:   
 307:          ////////////////////////////////////////////////////////////////////////////
 308:          ////////////////////////////////////////////////////////////////////////////
 309:   
 310:          /// <summary>
 311:          ///
 312:          /// </summary>
 313:          public static List<int> OntsNotInAccessList(List<Ia.Ngn.Cl.Model.Access> accessList)
 314:          {
 315:              // below: produce a list of ONTs between 1 and 32 that are not in ontList
 316:              List<int> ontNotInListArrayList = new List<int>(32);
 317:   
 318:              for (int i = 1; i <= 32; i++)
 319:              {
 320:                  if (accessList != null)
 321:                  {
 322:                      if ((from a in accessList where a.Ont == i select a).SingleOrDefault() == null)
 323:                      {
 324:                          ontNotInListArrayList.Add(i);
 325:                      }
 326:                      else
 327:                      {
 328:                      }
 329:                  }
 330:                  else
 331:                  {
 332:                      ontNotInListArrayList.Add(i);
 333:                  }
 334:              }
 335:   
 336:              return ontNotInListArrayList;
 337:          }
 338:   
 339:          ////////////////////////////////////////////////////////////////////////////
 340:   
 341:          /// <summary>
 342:          ///
 343:          /// </summary>
 344:          public static List<int> OltIdDistinctList
 345:          {
 346:              get
 347:              {
 348:                  List<int> list;
 349:   
 350:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 351:                  {
 352:                      list = (from o in db.Accesses select o.Olt).Distinct().OrderBy(u => u).ToList();
 353:                  }
 354:   
 355:                  return list;
 356:              }
 357:          }
 358:   
 359:          ////////////////////////////////////////////////////////////////////////////
 360:   
 361:          /// <summary>
 362:          ///
 363:          /// </summary>
 364:          public static Ia.Ngn.Cl.Model.Access ReadByAccessName(string accessName)
 365:          {
 366:              int oltId, pon, ont;
 367:              Ia.Ngn.Cl.Model.Access access;
 368:   
 369:              // below: this expects accessName in exact format like SUR.12.3
 370:   
 371:              Ia.Ngn.Cl.Model.Business.Access.ExtractOltIdAndPonNumberAndOntNumberFromOntName(accessName, out oltId, out pon, out ont);
 372:   
 373:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 374:              {
 375:                  access = (from a in db.Accesses where a.Olt == oltId && a.Pon == pon && a.Ont == ont select a).SingleOrDefault();
 376:              }
 377:   
 378:              return access;
 379:          }
 380:   
 381:          ////////////////////////////////////////////////////////////////////////////
 382:   
 383:          /// <summary>
 384:          ///
 385:          /// </summary>
 386:          public static List<Ia.Ngn.Cl.Model.Access> ListUsingOntFamilyType(int familyTypeId)
 387:          {
 388:              // below: return access list for family type
 389:              List<Ia.Ngn.Cl.Model.Access> noList, huList, list;
 390:              List<string> equipmentTypeStringList;
 391:   
 392:              list = new List<Ia.Ngn.Cl.Model.Access>();
 393:   
 394:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 395:              {
 396:                  noList = (from a in db.Accesses join o in db.Onts on a equals o.Access where o.FamilyTypeId == familyTypeId select a).ToList();
 397:   
 398:                  equipmentTypeStringList = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentTypeStringListFromFamilyType((Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType)familyTypeId);
 399:   
 400:                  huList = (from a in db.Accesses join o in db.EmsOnts on a equals o.Access where equipmentTypeStringList.Contains(o.EQUIPMENTID) select a).ToList();
 401:              }
 402:   
 403:              list.AddRange(noList);
 404:              list.AddRange(huList);
 405:   
 406:              return list.ToList();
 407:          }
 408:   
 409:          ////////////////////////////////////////////////////////////////////////////
 410:   
 411:          /// <summary>
 412:          ///
 413:          /// </summary>
 414:          public static List<string> ReadAccessNameListUsingKuwaitNgnAreaIdAndBlock(int kuwaitAreaId, string block)
 415:          {
 416:              Dictionary<string, string> di;
 417:              List<string> accessIdList, accessNameList;
 418:   
 419:              if (kuwaitAreaId > 0 && !string.IsNullOrEmpty(block))
 420:              {
 421:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 422:                  {
 423:                      accessIdList = (from a in db.Accesses where a.AreaId == kuwaitAreaId && a.Block == block select a.Id).ToList();
 424:                      di = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
 425:   
 426:                      if (accessIdList != null && accessIdList.Count > 0)
 427:                      {
 428:                          accessNameList = new List<string>(accessIdList.Count);
 429:   
 430:                          foreach (string accessId in accessIdList)
 431:                          {
 432:                              if (di.ContainsKey(accessId)) accessNameList.Add(di[accessId]);
 433:                          }
 434:                      }
 435:                      else
 436:                      {
 437:                          accessNameList = null;
 438:                      }
 439:                  }
 440:              }
 441:              else
 442:              {
 443:                  accessNameList = null;
 444:              }
 445:   
 446:              return accessNameList;
 447:          }
 448:   
 449:          ////////////////////////////////////////////////////////////////////////////
 450:   
 451:          /// <summary>
 452:          ///
 453:          /// </summary>
 454:          public static List<Ia.Ngn.Cl.Model.Access> ListByKuwaitNgnAreaId(int kuwaitAreaId)
 455:          {
 456:              List<Ia.Ngn.Cl.Model.Access> list;
 457:   
 458:              if (kuwaitAreaId > 0)
 459:              {
 460:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 461:                  {
 462:                      list = (from a in db.Accesses where a.AreaId == kuwaitAreaId select a).ToList();
 463:                  }
 464:              }
 465:              else
 466:              {
 467:                  list = null;
 468:              }
 469:   
 470:              return list;
 471:          }
 472:   
 473:          ////////////////////////////////////////////////////////////////////////////
 474:   
 475:          /// <summary>
 476:          ///
 477:          /// </summary>
 478:          public static Dictionary<string, string> DistinctAccessKuwaitNgnAreaIdAndBlockDictionary
 479:          {
 480:              get
 481:              {
 482:                  int kuwaitNgnAreaId, block;
 483:                  string kuwaitNgnAreaIdString, blockString, kuwaitNgnAreaBlockValue, kuwaitNgnAreaNameArabicName;
 484:                  Dictionary<string, string> tempDictionary;
 485:                  Dictionary<string, string> dictionary;
 486:   
 487:                  dictionary = new Dictionary<string, string>();
 488:                  tempDictionary = new Dictionary<string, string>();
 489:   
 490:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 491:                  {
 492:                      tempDictionary = (from a in db.Accesses select new { a.AreaId, a.Block }).Distinct().OrderBy(u => u.AreaId).ThenBy(u => u.Block).ToDictionary(m => m.AreaId + "," + m.Block, m => m.AreaId + "," + m.Block);
 493:   
 494:                      if (tempDictionary != null && tempDictionary.Count > 0)
 495:                      {
 496:                          foreach (KeyValuePair<string, string> kvp in tempDictionary)
 497:                          {
 498:                              kuwaitNgnAreaIdString = kvp.Key.Split(',')[0].ToString();
 499:                              blockString = kvp.Key.Split(',')[1].ToString();
 500:   
 501:                              if (int.TryParse(kuwaitNgnAreaIdString, out kuwaitNgnAreaId) && int.TryParse(blockString, out block))
 502:                              {
 503:                                  kuwaitNgnAreaNameArabicName = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Id == kuwaitNgnAreaId select kna.NameArabicName).SingleOrDefault();
 504:   
 505:                                  kuwaitNgnAreaBlockValue = kuwaitNgnAreaNameArabicName + ", block " + block;
 506:   
 507:                                  dictionary.Add(kvp.Key, kuwaitNgnAreaBlockValue);
 508:                              }
 509:                              else
 510:                              {
 511:                              }
 512:                          }
 513:                      }
 514:                      else
 515:                      {
 516:                      }
 517:                  }
 518:   
 519:                  return dictionary;
 520:              }
 521:          }
 522:   
 523:          ////////////////////////////////////////////////////////////////////////////
 524:   
 525:          /// <summary>
 526:          ///
 527:          /// </summary>
 528:          public static Dictionary<int, string> DistinctAccessKuwaitNgnAreaIdToNameArabicNameDictionary
 529:          {
 530:              get
 531:              {
 532:                  string kuwaitNgnAreaNameArabicName;
 533:                  List<int> list;
 534:                  Dictionary<int, string> dictionary;
 535:   
 536:                  dictionary = new Dictionary<int, string>();
 537:                  list = new List<int>();
 538:   
 539:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 540:                  {
 541:                      list = (from a in db.Accesses select a.AreaId).Distinct().ToList();
 542:   
 543:                      if (list.Count > 0)
 544:                      {
 545:                          foreach (int i in list)
 546:                          {
 547:                              kuwaitNgnAreaNameArabicName = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Id == i select kna.NameArabicName).SingleOrDefault();
 548:   
 549:                              dictionary.Add(i, kuwaitNgnAreaNameArabicName);
 550:                          }
 551:                      }
 552:                      else
 553:                      {
 554:                      }
 555:                  }
 556:   
 557:                  return dictionary;
 558:              }
 559:          }
 560:   
 561:          ////////////////////////////////////////////////////////////////////////////
 562:   
 563:          /// <summary>
 564:          ///
 565:          /// </summary>
 566:          public static Dictionary<string, int> IdToKuwaitNgnAreaIdDictionary
 567:          {
 568:              get
 569:              {
 570:                  Dictionary<string, int> dictionary;
 571:   
 572:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 573:                  {
 574:                      dictionary = (from a in db.Accesses select new { a.Id, a.AreaId }).ToDictionary(u => u.Id, u => u.AreaId);
 575:                  }
 576:   
 577:                  return dictionary;
 578:              }
 579:          }
 580:   
 581:          ////////////////////////////////////////////////////////////////////////////
 582:   
 583:          /// <summary>
 584:          ///
 585:          /// </summary>
 586:          public static Dictionary<string, string> IdToKuwaitNgnAreaSymbolDictionary
 587:          {
 588:              get
 589:              {
 590:                  Dictionary<string, int> accessIdToKuwaitNgnAreaIdDictionary;
 591:                  Dictionary<int, string> areaIdToSymbolDictionary;
 592:                  Dictionary<string, string> dictionary;
 593:   
 594:                  accessIdToKuwaitNgnAreaIdDictionary = Ia.Ngn.Cl.Model.Data.Access.IdToKuwaitNgnAreaIdDictionary;
 595:                  areaIdToSymbolDictionary = Ia.Ngn.Cl.Model.Data.Service.AreaIdToSymbolDictionary;
 596:   
 597:                  dictionary = new Dictionary<string, string>(accessIdToKuwaitNgnAreaIdDictionary.Count);
 598:   
 599:                  foreach (KeyValuePair<string, int> kvp in accessIdToKuwaitNgnAreaIdDictionary)
 600:                  {
 601:                      if (areaIdToSymbolDictionary.ContainsKey(kvp.Value)) dictionary[kvp.Key] = areaIdToSymbolDictionary[kvp.Value];
 602:                  }
 603:   
 604:                  return dictionary;
 605:              }
 606:          }
 607:   
 608:          ////////////////////////////////////////////////////////////////////////////
 609:   
 610:          /// <summary>
 611:          ///
 612:          /// </summary>
 613:          public static Dictionary<string, int> IdToOltIdDictionary
 614:          {
 615:              get
 616:              {
 617:                  Dictionary<string, int> dictionary;
 618:   
 619:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 620:                  {
 621:                      dictionary = (from a in db.Accesses select new { a.Id, a.Olt }).ToDictionary(u => u.Id, u => u.Olt);
 622:                  }
 623:   
 624:                  return dictionary;
 625:              }
 626:          }
 627:   
 628:          ////////////////////////////////////////////////////////////////////////////
 629:   
 630:          /// <summary>
 631:          ///
 632:          /// </summary>
 633:          public static Dictionary<string, Ia.Ngn.Cl.Model.Access> IdToAccessDictionary
 634:          {
 635:              get
 636:              {
 637:                  Dictionary<string, Ia.Ngn.Cl.Model.Access> dictionary;
 638:   
 639:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 640:                  {
 641:                      dictionary = (from a in db.Accesses select new { AccessId = a.Id, Access = a }).ToDictionary(u => u.AccessId, u => u.Access);
 642:                  }
 643:   
 644:                  return dictionary;
 645:              }
 646:          }
 647:   
 648:          ////////////////////////////////////////////////////////////////////////////
 649:   
 650:          /// <summary>
 651:          ///
 652:          /// </summary>
 653:          public static Dictionary<string, Ia.Ngn.Cl.Model.Access> IdToHuaweiAccessDictionary
 654:          {
 655:              get
 656:              {
 657:                  List<int> oltIdList;
 658:                  Dictionary<string, Ia.Ngn.Cl.Model.Access> dictionary;
 659:   
 660:                  oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList();
 661:   
 662:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 663:                  {
 664:                      dictionary = (from a in db.Accesses where oltIdList.Contains(a.Olt) select new { AccessId = a.Id, Access = a }).ToDictionary(u => u.AccessId, u => u.Access);
 665:                  }
 666:   
 667:                  return dictionary;
 668:              }
 669:          }
 670:   
 671:          ////////////////////////////////////////////////////////////////////////////
 672:   
 673:          /// <summary>
 674:          ///
 675:          /// </summary>
 676:          public static List<string> IdList
 677:          {
 678:              get
 679:              {
 680:                  List<string> list;
 681:   
 682:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 683:                  {
 684:                      list = (from a in db.Accesses select a.Id).ToList();
 685:                  }
 686:   
 687:                  return list;
 688:              }
 689:          }
 690:   
 691:          ////////////////////////////////////////////////////////////////////////////
 692:   
 693:          /// <summary>
 694:          ///
 695:          /// </summary>
 696:          public static List<Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock> FamilyStatisticInKuwaitNgnAreaAndBlockTable
 697:          {
 698:              // FamilyType { Undefined = 0, Sfu = 1, Soho = 2, Mdu = 3 };
 699:   
 700:              get
 701:              {
 702:                  Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock item;
 703:                  List<Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock> list, sfu, soho, mdu;
 704:   
 705:                  list = new List<Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock>();
 706:   
 707:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 708:                  {
 709:                      sfu = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where o.FamilyTypeId == 1 group a by new { a.AreaId, a.Block } into g select new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock() { AreaId = g.Key.AreaId, Block = g.Key.Block, Sfu = g.Count() }).ToList();
 710:                      soho = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where o.FamilyTypeId == 2 group a by new { a.AreaId, a.Block } into g select new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock() { AreaId = g.Key.AreaId, Block = g.Key.Block, Soho = g.Count() }).ToList();
 711:                      mdu = (from a in db.Accesses join o in db.Onts on a.Id equals o.Access.Id where o.FamilyTypeId == 3 group a by new { a.AreaId, a.Block } into g select new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock() { AreaId = g.Key.AreaId, Block = g.Key.Block, Mdu = g.Count() }).ToList();
 712:   
 713:                      foreach (Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock a in sfu) list.Add(new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock { AreaId = a.AreaId, Block = a.Block, Sfu = a.Sfu });
 714:   
 715:                      foreach (Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock a in soho)
 716:                      {
 717:                          item = (from b in list where b.AreaId == a.AreaId && b.Block == a.Block select b).SingleOrDefault();
 718:   
 719:                          if (item != null) item.Soho = a.Soho;
 720:                          else list.Add(new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock { AreaId = a.AreaId, Block = a.Block, Soho = a.Soho });
 721:                      }
 722:   
 723:                      foreach (Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock a in mdu)
 724:                      {
 725:                          item = (from b in list where b.AreaId == a.AreaId && b.Block == a.Block select b).SingleOrDefault();
 726:   
 727:                          if (item != null) item.Mdu = a.Mdu;
 728:                          else list.Add(new Ia.Ngn.Cl.Model.Ui.Maintenance.AccessFamilyTypeAreaBlock { AreaId = a.AreaId, Block = a.Block, Mdu = a.Mdu });
 729:                      }
 730:   
 731:                      list = list.OrderBy(u => u.AreaId).ThenBy(u => u.Block).ToList();
 732:   
 733:                      return list;
 734:                  }
 735:              }
 736:          }
 737:   
 738:          ////////////////////////////////////////////////////////////////////////////
 739:   
 740:          /// <summary>
 741:          ///
 742:          /// </summary>
 743:          public static List<Ia.Ngn.Cl.Model.Access> ListOfAccessesWithProvisionedAndReadyOntsAndEmsOntsButDoNotExistInCustomerDepartmentDatabase()
 744:          {
 745:              return ListOfAccessesWithProvisionedAndReadyOntsButDoNotExistInCustomerDepartmentDatabaseBySiteId(0);
 746:          }
 747:   
 748:          ////////////////////////////////////////////////////////////////////////////
 749:   
 750:          /// <summary>
 751:          ///
 752:          /// </summary>
 753:          public static List<Ia.Ngn.Cl.Model.Access> ListOfAccessesWithProvisionedAndReadyOntsButDoNotExistInCustomerDepartmentDatabaseBySiteId(int siteId)
 754:          {
 755:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
 756:              List<int> nokiaOltIdList, huaweiOltIdList;
 757:              List<Ia.Ngn.Cl.Model.Access> list, nokiaList, huaweiOntList;
 758:   
 759:              // this is related to AccessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary
 760:   
 761:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 762:              {
 763:                  if (siteId == 0)
 764:                  {
 765:                      // if siteId is 0 we will return results for all sites
 766:   
 767:                      //nokiaOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltIdList();
 768:   
 769:                      // Nokia
 770:                      nokiaList = (from a in db.Accesses
 771:                                       // join oid in nokiaOltIdList on a.Olt equals oid
 772:                                   join o in db.Onts on a equals o.Access
 773:                                   join osv in db.OntServiceVoips on o equals osv.Ont
 774:                                   join sro in db.ServiceRequestOnts on a equals sro.Access into gj
 775:                                   from subsro in gj.DefaultIfEmpty()
 776:                                   where o.StateId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr
 777:                                   && o.Serial != null
 778:                                   && o.Serial != "ALCL00000000"
 779:                                   && o.FamilyTypeId != 0
 780:                                   && o.ActiveSoftware != null
 781:                                   //&& o.ActiveSoftware == o.PlannedSoftware
 782:                                   && osv.Ip != null
 783:                                   && subsro.Access.Id == null
 784:                                   select a).Distinct().Include(c => c.Onts).Include(c => c.EmsOnts).ToList();
 785:   
 786:                      // Huawei
 787:                      huaweiOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList();
 788:   
 789:                      huaweiOntList = (from a in db.Accesses
 790:                                       join o in db.EmsOnts on a equals o.Access
 791:                                       join sro in db.ServiceRequestOnts on a equals sro.Access into gj
 792:                                       from subsro in gj.DefaultIfEmpty()
 793:                                       where o.EQUIPMENTID != string.Empty //.FamilyTypeId != 0
 794:                                       && huaweiOltIdList.Contains(a.Olt)
 795:                                       && subsro.Access.Id == null
 796:                                       select a).Distinct().Include(c => c.Onts).Include(c => c.EmsOnts).ToList();
 797:   
 798:                      list = nokiaList.Union(huaweiOntList).ToList();
 799:                  }
 800:                  else
 801:                  {
 802:                      site = (from a in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where a.Id == siteId select a).SingleOrDefault();
 803:   
 804:                      nokiaOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltIdList(siteId);
 805:   
 806:                      // Nokia
 807:                      nokiaList = (from a in db.Accesses
 808:                                   join oid in nokiaOltIdList on a.Olt equals oid
 809:                                   join o in db.Onts on a equals o.Access
 810:                                   join osv in db.OntServiceVoips on o equals osv.Ont
 811:                                   join sro in db.ServiceRequestOnts on a equals sro.Access into gj
 812:                                   from subsro in gj.DefaultIfEmpty()
 813:                                   where o.StateId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr
 814:                                   && o.Serial != null
 815:                                   && o.Serial != "ALCL00000000"
 816:                                   && o.FamilyTypeId != 0
 817:                                   && o.ActiveSoftware != null
 818:                                   //&& o.ActiveSoftware == o.PlannedSoftware
 819:                                   && osv.Ip != null
 820:                                   && subsro.Access.Id == null
 821:                                   select a).Distinct().Include(c => c.Onts).Include(c => c.EmsOnts).ToList();
 822:   
 823:                      // Huawei
 824:                      huaweiOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList(siteId);
 825:   
 826:                      huaweiOntList = (from a in db.Accesses
 827:                                       join o in db.EmsOnts on a equals o.Access
 828:                                       join sro in db.ServiceRequestOnts on a equals sro.Access into gj
 829:                                       from subsro in gj.DefaultIfEmpty()
 830:                                       where o.EQUIPMENTID != string.Empty //.FamilyTypeId != 0
 831:                                       && huaweiOltIdList.Contains(a.Olt)
 832:                                       && subsro.Access.Id == null
 833:                                       select a).Distinct().Include(c => c.Onts).Include(c => c.EmsOnts).ToList();
 834:   
 835:                      list = nokiaList.Union(huaweiOntList).ToList();
 836:                  }
 837:              }
 838:   
 839:              return list.OrderBy(u => u.Id).ToList();
 840:          }
 841:   
 842:          ////////////////////////////////////////////////////////////////////////////
 843:   
 844:          /// <summary>
 845:          ///
 846:          /// </summary>
 847:          public static List<Ia.Ngn.Cl.Model.Access> AccessesWithMismatchedInfomationInServiceRequestOntList()
 848:          {
 849:              List<Ia.Ngn.Cl.Model.Access> list;
 850:              //Dictionary<int, string> areaIdToSymbolDictionary;
 851:   
 852:              //areaIdToSymbolDictionary = Ia.Ngn.Cl.Model.Data.Service.AreaIdToSymbolDictionary;
 853:   
 854:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 855:              {
 856:                  // I will ignore area because its fixed with access id, which is shared by both Access and ServiceRequestOnt
 857:   
 858:                  list = (from a in db.Accesses
 859:                          join o in db.Onts on a equals o.Access
 860:                          join osv in db.OntServiceVoips on o equals osv.Ont
 861:                          join sro in db.ServiceRequestOnts on a equals sro.Access
 862:                          //join areaSymbol in areaIdToSymbolDictionary on a.AreaId equals areaSymbol.Key
 863:                          //where sro.AreaSymbol != areaSymbol.Value
 864:                          where (sro.Block != a.Block && !string.IsNullOrEmpty(a.Block))
 865:                          || (sro.Street != a.Street && !string.IsNullOrEmpty(a.Street))
 866:                          || (sro.PremisesOld != a.PremisesOld && !string.IsNullOrEmpty(a.PremisesOld))
 867:                          || (sro.PremisesNew != a.PremisesNew && !string.IsNullOrEmpty(a.PremisesNew))
 868:                          || (sro.Paci != a.Paci && !string.IsNullOrEmpty(a.Paci))
 869:                          //|| (sro.PossibleNumberOfTd != a.PossibleNumberOfTd)
 870:                          //|| (sro.PossibleNumberOfEthernet != a.PossibleNumberOfEthernet)
 871:                          select a).Distinct().Include(c => c.Onts).Include(c => c.EmsOnts).ToList();
 872:              }
 873:   
 874:              return list.OrderBy(u => u.Id).ToList();
 875:          }
 876:   
 877:          ////////////////////////////////////////////////////////////////////////////
 878:   
 879:          /// <summary>
 880:          ///
 881:          /// </summary>
 882:          public static Dictionary<string, int> AccessesWithProvisionedAndReadyOntsIdToKuwaitNgnAreaIdDictionary
 883:          {
 884:              get
 885:              {
 886:                  Dictionary<string, int> dictionary, nokiaDictionary, huaweiDictionary;
 887:                  List<int> huaweiOltIdList;//, nokiaOltIdList;
 888:   
 889:                  // this is related to ListOfAccessesWithProvisionedAndReadyOntsButDoNotExistInCustomerDepartmentDatabaseBySiteId()
 890:   
 891:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 892:                  {
 893:                      //nokiaOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltIdList();
 894:   
 895:                      // Nokia
 896:                      nokiaDictionary = (from a in db.Accesses
 897:                                         join o in db.Onts on a equals o.Access
 898:                                         join osv in db.OntServiceVoips on o equals osv.Ont
 899:                                         join sro in db.ServiceRequestOnts on a equals sro.Access
 900:                                         where o.StateId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr // ?
 901:                                         && o.Serial != null
 902:                                         && o.Serial != "ALCL00000000"
 903:                                         && o.FamilyTypeId != 0 // ?
 904:                                         && o.ActiveSoftware != null
 905:                                         //&& o.ActiveSoftware == o.PlannedSoftware
 906:                                         && osv.Ip != null
 907:                                         select new { a.Id, a.AreaId }).Distinct().ToDictionary(u => u.Id, u => u.AreaId);
 908:   
 909:                      // Huawei
 910:                      huaweiOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList();
 911:   
 912:                      huaweiDictionary = (from a in db.Accesses
 913:                                          join o in db.EmsOnts on a equals o.Access
 914:                                          join sro in db.ServiceRequestOnts on a equals sro.Access
 915:                                          //where o.FamilyTypeId != 0
 916:                                          where o.EQUIPMENTID != "--"
 917:                                          && huaweiOltIdList.Contains(a.Olt)
 918:                                          select new { a.Id, a.AreaId }).Distinct().ToDictionary(u => u.Id, u => u.AreaId);
 919:   
 920:                      dictionary = nokiaDictionary.Union(huaweiDictionary).ToDictionary(k => k.Key, v => v.Value);
 921:                  }
 922:   
 923:                  return dictionary;
 924:              }
 925:          }
 926:   
 927:          ////////////////////////////////////////////////////////////////////////////
 928:   
 929:          /// <summary>
 930:          ///
 931:          /// </summary>
 932:          public static List<Ia.Ngn.Cl.Model.Access> NokiaAccessList
 933:          {
 934:              get
 935:              {
 936:                  List<int> oltIdList;
 937:                  List<Ia.Ngn.Cl.Model.Access> list;
 938:   
 939:                  oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltIdList();
 940:   
 941:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 942:                  {
 943:                      list = (from a in db.Accesses where oltIdList.Contains(a.Olt) select a).ToList();
 944:                  }
 945:   
 946:                  return list;
 947:              }
 948:          }
 949:   
 950:          ////////////////////////////////////////////////////////////////////////////
 951:   
 952:          /// <summary>
 953:          ///
 954:          /// </summary>
 955:          public static List<Ia.Ngn.Cl.Model.Access> HuaweiAccessList
 956:          {
 957:              get
 958:              {
 959:                  List<int> oltIdList;
 960:                  List<Ia.Ngn.Cl.Model.Access> list;
 961:   
 962:                  oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList();
 963:   
 964:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 965:                  {
 966:                      list = (from a in db.Accesses where oltIdList.Contains(a.Olt) select a).ToList();
 967:                  }
 968:   
 969:                  return list;
 970:              }
 971:          }
 972:   
 973:          ////////////////////////////////////////////////////////////////////////////
 974:   
 975:          /// <summary>
 976:          ///
 977:          /// </summary>
 978:          public static List<Ia.Ngn.Cl.Model.Access> HuaweiAccessesWithNoEmsOntList
 979:          {
 980:              get
 981:              {
 982:                  List<int> huaweiOltIdList;
 983:                  List<Ia.Ngn.Cl.Model.Access> list;
 984:   
 985:                  huaweiOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltIdList();
 986:   
 987:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 988:                  {
 989:                      list = (from a in db.Accesses
 990:                              join o in db.EmsOnts on a equals o.Access into gj
 991:                              from subsro in gj.DefaultIfEmpty()
 992:                              where huaweiOltIdList.Contains(a.Olt) && subsro.Access.Id == null
 993:                              select a).Distinct().ToList();
 994:                  }
 995:   
 996:                  return list;
 997:              }
 998:          }
 999:   
1000:          ////////////////////////////////////////////////////////////////////////////
1001:   
1002:          /// <summary>
1003:          ///
1004:          /// </summary>
1005:          public static Ia.Ngn.Cl.Model.Access ReadByIp(string ip)
1006:          {
1007:              // below: return the Access object of this ip
1008:   
1009:              Ia.Ngn.Cl.Model.Access item;
1010:   
1011:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1012:              {
1013:                  item = (from a in db.Accesses join o in db.Onts on a equals o.Access join ov in db.OntServiceVoips on o equals ov.Ont where ov.Ip == ip select a).SingleOrDefault();
1014:              }
1015:   
1016:              return item;
1017:          }
1018:   
1019:          ////////////////////////////////////////////////////////////////////////////
1020:   
1021:          /// <summary>
1022:          ///
1023:          /// </summary>
1024:          public static Ia.Ngn.Cl.Model.Access ReadByIp(Ia.Ngn.Cl.Model.Ngn db, string ip)
1025:          {
1026:              // below: return the Access object of this ip
1027:   
1028:              return (from a in db.Accesses join o in db.Onts on a equals o.Access join ov in db.OntServiceVoips on o equals ov.Ont where ov.Ip == ip select a).SingleOrDefault();
1029:          }
1030:   
1031:          ////////////////////////////////////////////////////////////////////////////
1032:   
1033:          /// <summary>
1034:          ///
1035:          /// </summary>
1036:          public static Ia.Ngn.Cl.Model.Access StatisticalAccess(Ia.Ngn.Cl.Model.Business.ServiceAddress serviceAddress, ref List<Ia.Ngn.Cl.Model.Access> accessList)
1037:          {
1038:              // below:
1039:   
1040:              Ia.Ngn.Cl.Model.Access statisticalAccess;
1041:   
1042:              statisticalAccess = (from a in accessList
1043:                                   where a.AreaId == serviceAddress.AreaId
1044:                                       && a.Block == serviceAddress.Block
1045:                                       && a.Street == serviceAddress.Street
1046:                                       && a.PremisesOld == serviceAddress.PremisesOld
1047:                                       && a.PremisesNew == serviceAddress.PremisesNew
1048:                                   select a).FirstOrDefault();
1049:   
1050:              if (statisticalAccess == null)
1051:              {
1052:                  statisticalAccess = (from a in accessList
1053:                                       where a.AreaId == serviceAddress.AreaId
1054:                                           && a.Block == serviceAddress.Block
1055:                                           && a.Street == serviceAddress.Street
1056:                                           && a.PremisesOld == serviceAddress.PremisesOld
1057:                                       select a).FirstOrDefault();
1058:   
1059:                  if (statisticalAccess == null)
1060:                  {
1061:                      statisticalAccess = (from a in accessList
1062:                                           where a.AreaId == serviceAddress.AreaId
1063:                                               && a.Block == serviceAddress.Block
1064:                                               && a.Street == serviceAddress.Street
1065:                                               && a.PremisesNew == serviceAddress.PremisesNew
1066:                                           select a).FirstOrDefault();
1067:   
1068:                      if (statisticalAccess == null)
1069:                      {
1070:                          statisticalAccess = (from a in accessList
1071:                                               where a.AreaId == serviceAddress.AreaId
1072:                                                   && a.Block == serviceAddress.Block
1073:                                                   && a.Street == serviceAddress.Street
1074:                                                   && a.PremisesOld == serviceAddress.PremisesNew
1075:                                               select a).FirstOrDefault();
1076:   
1077:                          if (statisticalAccess == null)
1078:                          {
1079:                              statisticalAccess = (from a in accessList
1080:                                                   where a.AreaId == serviceAddress.AreaId
1081:                                                       && a.Block == serviceAddress.Block
1082:                                                       && a.Street == serviceAddress.Street
1083:                                                       && a.PremisesNew == serviceAddress.PremisesOld
1084:                                                   select a).FirstOrDefault();
1085:   
1086:                              if (statisticalAccess == null)
1087:                              {
1088:                                  statisticalAccess = (from a in accessList
1089:                                                       where a.AreaId == serviceAddress.AreaId
1090:                                                           && a.Block == serviceAddress.Block
1091:                                                           && a.Street == serviceAddress.Street
1092:                                                           && a.PremisesNew == serviceAddress.Boulevard
1093:                                                       select a).FirstOrDefault();
1094:   
1095:                                  if (statisticalAccess == null)
1096:                                  {
1097:                                      statisticalAccess = (from a in accessList
1098:                                                           where a.AreaId == serviceAddress.AreaId
1099:                                                               && a.Block == serviceAddress.Block
1100:                                                               && a.Street == serviceAddress.Street
1101:                                                               && a.PremisesOld == serviceAddress.Boulevard
1102:                                                           select a).FirstOrDefault();
1103:   
1104:                                      if (statisticalAccess == null)
1105:                                      {
1106:                                          statisticalAccess = (from a in accessList
1107:                                                               where a.AreaId == serviceAddress.AreaId
1108:                                                                   && a.Block == serviceAddress.Block
1109:                                                                   && a.PremisesOld == serviceAddress.PremisesOld
1110:                                                               select a).FirstOrDefault();
1111:   
1112:                                          if (statisticalAccess == null)
1113:                                          {
1114:                                              statisticalAccess = (from a in accessList
1115:                                                                   where a.AreaId == serviceAddress.AreaId
1116:                                                                       && a.Block == serviceAddress.Block
1117:                                                                       && a.PremisesNew == serviceAddress.PremisesNew
1118:                                                                   select a).FirstOrDefault();
1119:   
1120:                                              if (statisticalAccess == null)
1121:                                              {
1122:                                                  statisticalAccess = (from a in accessList
1123:                                                                       where a.AreaId == serviceAddress.AreaId
1124:                                                                           && a.Block == serviceAddress.Block
1125:                                                                           && a.PremisesOld == serviceAddress.PremisesNew
1126:                                                                       select a).FirstOrDefault();
1127:   
1128:                                                  if (statisticalAccess == null)
1129:                                                  {
1130:                                                      statisticalAccess = (from a in accessList
1131:                                                                           where a.AreaId == serviceAddress.AreaId
1132:                                                                               && a.Block == serviceAddress.Block
1133:                                                                               && a.PremisesNew == serviceAddress.PremisesOld
1134:                                                                           select a).FirstOrDefault();
1135:   
1136:                                                      if (statisticalAccess == null)
1137:                                                      {
1138:                                                          statisticalAccess = (from a in accessList
1139:                                                                               where a.AreaId == serviceAddress.AreaId
1140:                                                                                   && a.Block == serviceAddress.Block
1141:                                                                                   && a.Street == serviceAddress.Street
1142:                                                                                   && serviceAddress.PremisesOld != null && a.PremisesOld != null && a.PremisesOld.Contains(serviceAddress.PremisesOld)
1143:                                                                                   && a.PremisesNew == serviceAddress.PremisesNew
1144:                                                                               select a).FirstOrDefault();
1145:   
1146:                                                          if (statisticalAccess == null)
1147:                                                          {
1148:                                                              statisticalAccess = (from a in accessList
1149:                                                                                   where a.AreaId == serviceAddress.AreaId
1150:                                                                                       && a.Block == serviceAddress.Block
1151:                                                                                       && a.Street == serviceAddress.Street
1152:                                                                                       && a.PremisesOld == serviceAddress.PremisesOld
1153:                                                                                       && serviceAddress.PremisesNew != null && a.PremisesNew != null && a.PremisesNew.Contains(serviceAddress.PremisesNew)
1154:                                                                                   select a).FirstOrDefault();
1155:   
1156:                                                              if (statisticalAccess == null)
1157:                                                              {
1158:                                                                  statisticalAccess = (from a in accessList
1159:                                                                                       where a.AreaId == serviceAddress.AreaId
1160:                                                                                           && a.Block == serviceAddress.Block
1161:                                                                                           && a.Street == serviceAddress.Street
1162:                                                                                           && serviceAddress.PremisesOld != null && a.PremisesOld != null && a.PremisesOld.Contains(serviceAddress.PremisesOld)
1163:                                                                                       select a).FirstOrDefault();
1164:   
1165:                                                                  if (statisticalAccess == null)
1166:                                                                  {
1167:                                                                      statisticalAccess = (from a in accessList
1168:                                                                                           where a.AreaId == serviceAddress.AreaId
1169:                                                                                               && a.Block == serviceAddress.Block
1170:                                                                                               && a.Street == serviceAddress.Street
1171:                                                                                               && serviceAddress.PremisesNew != null && a.PremisesNew != null && a.PremisesNew.Contains(serviceAddress.PremisesNew)
1172:                                                                                           select a).FirstOrDefault();
1173:   
1174:                                                                      if (statisticalAccess == null)
1175:                                                                      {
1176:                                                                          statisticalAccess = (from a in accessList
1177:                                                                                               where a.AreaId == serviceAddress.AreaId
1178:                                                                                                   && a.Block == serviceAddress.Block
1179:                                                                                                   && serviceAddress.PremisesOld != null && a.PremisesOld != null && a.PremisesOld.Contains(serviceAddress.PremisesOld)
1180:                                                                                                   && a.PremisesNew == serviceAddress.PremisesNew
1181:                                                                                               select a).FirstOrDefault();
1182:   
1183:                                                                          if (statisticalAccess == null)
1184:                                                                          {
1185:                                                                              statisticalAccess = (from a in accessList
1186:                                                                                                   where a.AreaId == serviceAddress.AreaId
1187:                                                                                                       && a.Block == serviceAddress.Block
1188:                                                                                                       && a.PremisesOld == serviceAddress.PremisesOld
1189:                                                                                                       && serviceAddress.PremisesNew != null && serviceAddress.PremisesNew != null && a.PremisesNew.Contains(serviceAddress.PremisesNew)
1190:                                                                                                   select a).FirstOrDefault();
1191:   
1192:                                                                              if (statisticalAccess == null)
1193:                                                                              {
1194:                                                                                  statisticalAccess = (from a in accessList
1195:                                                                                                       where a.AreaId == serviceAddress.AreaId
1196:                                                                                                           && a.Block == serviceAddress.Block
1197:                                                                                                           && serviceAddress.PremisesOld != null && a.PremisesOld != null && a.PremisesOld.Contains(serviceAddress.PremisesOld)
1198:                                                                                                       select a).FirstOrDefault();
1199:   
1200:                                                                                  if (statisticalAccess == null)
1201:                                                                                  {
1202:                                                                                      statisticalAccess = (from a in accessList
1203:                                                                                                           where a.AreaId == serviceAddress.AreaId
1204:                                                                                                               && a.Block == serviceAddress.Block
1205:                                                                                                               && serviceAddress.PremisesNew != null && a.PremisesNew != null && a.PremisesNew.Contains(serviceAddress.PremisesNew)
1206:                                                                                                           select a).FirstOrDefault();
1207:                                                                                  }
1208:                                                                              }
1209:                                                                          }
1210:                                                                      }
1211:                                                                  }
1212:                                                              }
1213:                                                          }
1214:                                                      }
1215:                                                  }
1216:                                              }
1217:                                          }
1218:                                      }
1219:                                  }
1220:                              }
1221:                          }
1222:                      }
1223:                  }
1224:              }
1225:   
1226:              return statisticalAccess;
1227:          }
1228:   
1229:          ////////////////////////////////////////////////////////////////////////////
1230:          ////////////////////////////////////////////////////////////////////////////
1231:   
1232:          /// <summary>
1233:          ///
1234:          /// </summary>
1235:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Access access)
1236:          {
1237:              StringBuilder sb;
1238:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
1239:   
1240:              sb = new StringBuilder();
1241:   
1242:              vendor = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Id == access.Id select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
1243:   
1244:              sb.AppendLine("Vendor: " + vendor.Name);
1245:              sb.AppendLine("Name: " + access.Name);
1246:              sb.AppendLine("Address: " + access.Address);
1247:   
1248:              if (!string.IsNullOrEmpty(access.Paci)) sb.AppendLine("Paci: " + access.Paci);
1249:              if (!string.IsNullOrEmpty(access.Note)) sb.AppendLine("Note: " + access.Note);
1250:   
1251:              return sb.ToString();
1252:          }
1253:   
1254:          ////////////////////////////////////////////////////////////////////////////
1255:          ////////////////////////////////////////////////////////////////////////////
1256:      }
1257:   
1258:      ////////////////////////////////////////////////////////////////////////////
1259:      ////////////////////////////////////////////////////////////////////////////
1260:  }