Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » NetworkDesignDocument

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

Network Design Document support class for Next Generation Network (NGN) business model.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml.Linq;
   4:  using System.IO;
   5:  using System.Data;
   6:  using System.Collections;
   7:  using System.Collections.Generic;
   8:  using System.Reflection;
   9:  using System.Linq;
  10:  using System.Text;
  11:  using System.Text.RegularExpressions;
  12:   
  13:  namespace Ia.Ngn.Cl.Model.Business
  14:  {
  15:      ////////////////////////////////////////////////////////////////////////////
  16:   
  17:      /// <summary publish="true">
  18:      /// Network Design Document support class for Next Generation Network (NGN) business model.
  19:      /// </summary>
  20:      /// 
  21:      /// <remarks> 
  22:      /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  23:      ///
  24:      /// 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
  25:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  26:      ///
  27:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  28:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  29:      /// 
  30:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  31:      /// 
  32:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  33:      /// </remarks> 
  34:      public partial class NetworkDesignDocument
  35:      {
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public NetworkDesignDocument() { }
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////
  44:   
  45:          /// <summary>
  46:          ///
  47:          /// </summary>
  48:          public class Vendor
  49:          {
  50:              public int Id { get; set; }
  51:              public string Name { get; set; }
  52:              public string ShortName { get; set; }
  53:              public string ArabicName { get; set; }
  54:              public string ImageUrl { get; set; }
  55:   
  56:              public Vendor(int id, string name, string shortName, string arabicName, string imageUrl)
  57:              {
  58:                  this.Id = id;
  59:                  this.Name = name;
  60:                  this.ShortName = shortName;
  61:                  this.ArabicName = arabicName;
  62:                  this.ImageUrl = imageUrl;
  63:              }
  64:   
  65:              public virtual ICollection<Router> Routers
  66:              {
  67:                  get
  68:                  {
  69:                      return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Vendor == this select r).ToList();
  70:                  }
  71:              }
  72:   
  73:              public virtual ICollection<Odf> Odfs
  74:              {
  75:                  get
  76:                  {
  77:                      return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where o.Vendor == this select o).ToList();
  78:                  }
  79:              }
  80:   
  81:              public virtual ICollection<Msan> Msans
  82:              {
  83:                  get
  84:                  {
  85:                      return (from m in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.MsanList where m.Vendor == this select m).ToList();
  86:                  }
  87:              }
  88:   
  89:              public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Nokia
  90:              {
  91:                  get
  92:                  {
  93:                      return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "No" select v).Single();
  94:                  }
  95:              }
  96:   
  97:              public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Huawei
  98:              {
  99:                  get
 100:                  {
 101:                      return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Hu" select v).Single();
 102:                  }
 103:              }
 104:   
 105:              public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Undefined
 106:              {
 107:                  get
 108:                  {
 109:                      return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Un" select v).Single();
 110:                  }
 111:              }
 112:   
 113:              ////////////////////////////////////////////////////////////////////////////
 114:   
 115:              /// <summary>
 116:              ///
 117:              /// </summary>
 118:              public static string VendorNameFromId(int id)
 119:              {
 120:                  return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.Id == id select v.Name).SingleOrDefault();
 121:              }
 122:   
 123:              ////////////////////////////////////////////////////////////////////////////
 124:   
 125:              /// <summary>
 126:              ///
 127:              /// </summary>
 128:              public static int VendorIdFromName(string name)
 129:              {
 130:                  int id;
 131:   
 132:                  switch (name)
 133:                  {
 134:                      case "Nokia": id = 1; break;
 135:                      case "ALCL": id = 1; break;
 136:                      case "Huawei": id = 2; break;
 137:                      case "Nokia-Siemens": id = 3; break;
 138:                      default: id = 0; break;
 139:                  }
 140:   
 141:                  return id;
 142:              }
 143:   
 144:              ////////////////////////////////////////////////////////////////////////////
 145:              ////////////////////////////////////////////////////////////////////////////
 146:          }
 147:   
 148:          ////////////////////////////////////////////////////////////////////////////    
 149:   
 150:          public class Network
 151:          {
 152:              public int Id { get; set; }
 153:              public string Name { get; set; }
 154:   
 155:              public Network(int id, string name)
 156:              {
 157:                  this.Id = id;
 158:                  this.Name = name;
 159:              }
 160:   
 161:              public virtual ICollection<Site> Sites
 162:              {
 163:                  get
 164:                  {
 165:                      return (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Network == this select s).ToList();
 166:                  }
 167:              }
 168:          }
 169:   
 170:          ////////////////////////////////////////////////////////////////////////////
 171:   
 172:          /// <summary>
 173:          ///
 174:          /// </summary>
 175:          public class Site
 176:          {
 177:              public Site() { }
 178:   
 179:              public int Id { get; set; }
 180:              public string Name { get; set; }
 181:              public string ArabicName { get; set; }
 182:              public string NameArabicName
 183:              {
 184:                  get
 185:                  {
 186:                      return Name + " (" + ArabicName + ")";
 187:                  }
 188:              }
 189:              public string AreaSymbolList { get; set; }
 190:              public virtual Network Network { get; set; }
 191:   
 192:              public virtual ICollection<Router> Routers
 193:              {
 194:                  get
 195:                  {
 196:                      return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site == this select r).ToList();
 197:                  }
 198:              }
 199:   
 200:              public virtual ICollection<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> KuwaitNgnAreas
 201:              {
 202:                  get
 203:                  {
 204:                      ICollection<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> ic;
 205:   
 206:                      ic = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where this.AreaSymbolList.Contains(kna.Symbol) select kna).ToList();
 207:   
 208:                      return ic;
 209:                  }
 210:              }
 211:   
 212:              public int SiteId(int networkId, int siteId)
 213:              {
 214:                  return networkId * 100 + siteId;
 215:              }
 216:          }
 217:   
 218:          ////////////////////////////////////////////////////////////////////////////
 219:   
 220:          /// <summary>
 221:          ///
 222:          /// </summary>
 223:          public class Router
 224:          {
 225:              public Router() { }
 226:   
 227:              public int Id { get; set; }
 228:              public string Name { get; set; }
 229:              public string DomainListString { get; set; }
 230:              public List<int> DomainList { get; set; }
 231:              public virtual Vendor Vendor { get; set; }
 232:              public virtual Site Site { get; set; }
 233:              public virtual ICollection<Oam> Oams
 234:              {
 235:                  get
 236:                  {
 237:                      return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OamList where r.Router == this select r).ToList();
 238:                  }
 239:              }
 240:   
 241:              public virtual ICollection<Odf> Odfs
 242:              {
 243:                  get
 244:                  {
 245:                      return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where o.Router == this select o).ToList();
 246:                  }
 247:              }
 248:   
 249:              public virtual ICollection<Msan> Msans
 250:              {
 251:                  get
 252:                  {
 253:                      return (from m in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.MsanList where m.Router == this select m).ToList();
 254:                  }
 255:              }
 256:   
 257:              public int RouterId(int siteId, int routerId)
 258:              {
 259:                  return siteId * 100 + routerId;
 260:              }
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:   
 265:          /// <summary>
 266:          ///
 267:          /// </summary>
 268:          public class Oam
 269:          {
 270:              public Oam() { }
 271:   
 272:              public int Id { get; set; }
 273:              public string Network { get; set; }
 274:              public string Gateway { get; set; }
 275:              public int Vlan { get; set; }
 276:              public int Vpls { get; set; }
 277:              public string FtpIp { get; set; }
 278:              public string ConfigFile { get; set; }
 279:              public virtual Router Router { get; set; }
 280:   
 281:              public int OamId(int routerId, int oamId)
 282:              {
 283:                  return routerId * 100 + oamId;
 284:              }
 285:          }
 286:   
 287:          ////////////////////////////////////////////////////////////////////////////
 288:   
 289:          /// <summary>
 290:          ///
 291:          /// </summary>
 292:          public class Odf
 293:          {
 294:              public Odf() { }
 295:   
 296:              public int Id { get; set; }
 297:              public string Name { get; set; }
 298:              public string GatewayIp { get; set; }
 299:              public string MgcIp { get; set; }
 300:              public virtual Vendor Vendor { get; set; }
 301:              public virtual Router Router { get; set; }
 302:              public virtual ICollection<Olt> Olts
 303:              {
 304:                  get
 305:                  {
 306:                      return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf == this select o).ToList();
 307:                  }
 308:              }
 309:   
 310:              public int OdfId(int routerId, int odfId)
 311:              {
 312:                  return routerId * 100 + odfId;
 313:              }
 314:          }
 315:   
 316:          ////////////////////////////////////////////////////////////////////////////
 317:   
 318:          /// <summary>
 319:          ///
 320:          /// </summary>
 321:          public class Msan
 322:          {
 323:              public Msan() { }
 324:   
 325:              public int Id { get; set; }
 326:              public string Name { get; set; }
 327:              public string Symbol { get; set; }
 328:              public virtual Vendor Vendor { get; set; }
 329:              public virtual Router Router { get; set; }
 330:              public int MsanId(int routerId, int msanId)
 331:              {
 332:                  return routerId * 100 + msanId;
 333:              }
 334:          }
 335:   
 336:          ////////////////////////////////////////////////////////////////////////////
 337:   
 338:          /// <summary>
 339:          ///
 340:          /// </summary>
 341:          public class Olt
 342:          {
 343:              public Olt() { }
 344:   
 345:              public int Id { get; set; }
 346:              public string Type { get; set; }
 347:              public int StateId { get; set; }
 348:              public bool IsSip { get; set; }
 349:              public int Rack { get; set; }
 350:              public int Sub { get; set; }
 351:              public string GatewayIp { get; set; }
 352:              public string MgcIp { get; set; }
 353:              public string Name { get; set; }
 354:              public string AmsName { get; set; }
 355:              public string EmsName
 356:              {
 357:                  get
 358:                  {
 359:                      return this.AmsName;
 360:                  }
 361:   
 362:                  set
 363:                  {
 364:                      this.AmsName = value;
 365:                  }
 366:              }
 367:              public int Did { get; set; }
 368:              public string Symbol { get; set; }
 369:              public int NumberOfLts { get; set; }
 370:              public int NumberOfPonsPerLt { get; set; }
 371:              public int NumberOfPons { get; set; }
 372:              public int NumberOfOntsInPon { get; set; }
 373:              public int NumberOfFirstSlot { get; set; }
 374:              public virtual Odf Odf { get; set; }
 375:              public virtual ICollection<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
 376:              {
 377:                  get
 378:                  {
 379:                      return (from l in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList where l.Olt == this select l).ToList();
 380:                  }
 381:              }
 382:   
 383:              public int OltId(int odfId, int oltId)
 384:              {
 385:                  return odfId * 100 + oltId;
 386:              }
 387:          }
 388:   
 389:          ////////////////////////////////////////////////////////////////////////////
 390:   
 391:          /// <summary>
 392:          ///
 393:          /// </summary>
 394:          public class PonGroup
 395:          {
 396:              public PonGroup() { }
 397:   
 398:              public long Id { get; set; }
 399:              public string Symbol { get; set; }
 400:              public int Number { get; set; }
 401:              public string PonListString { get; set; }
 402:              public string ProposedPonListString { get; set; }
 403:              public List<int> UsedPonInPonGroupList { get; set; }
 404:              public List<int> UsedProposedPonInPonGroupList { get; set; }
 405:              public string NetworkNumber { get; set; }
 406:              public string GatewayIp { get; set; }
 407:              public string MgcIp { get; set; }
 408:              public virtual Olt Olt { get; set; }
 409:              public virtual ICollection<Pon> PonList
 410:              {
 411:                  get
 412:                  {
 413:                      return (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup == this select p).ToList();
 414:                  }
 415:              }
 416:   
 417:              public bool HasNewProposedPonList
 418:              {
 419:                  get
 420:                  {
 421:                      return !string.IsNullOrEmpty(this.ProposedPonListString) && this.ProposedPonListString != this.PonListString;
 422:                  }
 423:              }
 424:   
 425:              public long PonGroupId(int oltId, int ponGroupId)
 426:              {
 427:                  return (long)oltId * 100 + ponGroupId;
 428:              }
 429:          }
 430:   
 431:          ////////////////////////////////////////////////////////////////////////////
 432:   
 433:          /// <summary>
 434:          ///
 435:          /// </summary>
 436:          public class Pon
 437:          {
 438:              private const int FixedLengthOfId = 14;
 439:   
 440:              public Pon() { }
 441:   
 442:              public string Id { get; set; }
 443:              public int Index { get; set; }
 444:              public int PonGroupPonIndex { get; set; }
 445:              public int Rack { get; set; }
 446:              public int Sub { get; set; }
 447:              public int CardSlot { get; set; }
 448:              public int Port { get; set; }
 449:              public int Number { get; set; }
 450:              public int ProposedNumber { get; set; }
 451:              public string Position { get; set; }
 452:              public string Name { get; set; }
 453:              public string ProposedName { get; set; }
 454:              public virtual PonGroup PonGroup { get; set; }
 455:              public virtual ICollection<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
 456:              {
 457:                  get
 458:                  {
 459:                      return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon == this select o).ToList();
 460:                  }
 461:              }
 462:   
 463:              public string PonId(int oltId, int oltPonIndex)
 464:              {
 465:                  string id;
 466:   
 467:                  // "01" to indicate PonGroup 1. This is the case in almost all PONs. I will remove 01 later
 468:                  id = oltId.ToString() + "01" + oltPonIndex.ToString().PadLeft(3, '0');
 469:   
 470:                  if (id.Length != FixedLengthOfId)
 471:                  {
 472:                      throw new ArgumentOutOfRangeException(@"PonId(): Id length is not " + FixedLengthOfId);
 473:                  }
 474:   
 475:                  return id;
 476:              }
 477:          }
 478:   
 479:          ////////////////////////////////////////////////////////////////////////////
 480:   
 481:          /// <summary>
 482:          ///
 483:          /// </summary>
 484:          public class Ont
 485:          {
 486:              public Ont() { }
 487:   
 488:              public string Id { get; set; }
 489:              public int Rack { get; set; }
 490:              public int Sub { get; set; }
 491:              public int CardSlot { get; set; }
 492:              public int Port { get; set; }
 493:              public int Number { get; set; }
 494:              public int InternalNumber { get; set; }
 495:              public string Position { get; set; }
 496:              public string Ip { get; set; }
 497:   
 498:              public Ia.Ngn.Cl.Model.Business.Ims.ImsBasicService ImsBasicService { get; set; }
 499:   
 500:              public string MgcIp
 501:              {
 502:                  get
 503:                  {
 504:                      return ImsBasicService.MgcIp;
 505:                  }
 506:              }
 507:              public string MgcSecondaryIp
 508:              {
 509:                  get
 510:                  {
 511:                      return ImsBasicService.MgcSecondaryIp;
 512:                  }
 513:              }
 514:              public string MgcSubnetMask
 515:              {
 516:                  get
 517:                  {
 518:                      return ImsBasicService.MgcSubnetMask;
 519:                  }
 520:              }
 521:              public int ImsService
 522:              {
 523:                  get
 524:                  {
 525:                      return ImsBasicService.Service;
 526:                  }
 527:              }
 528:              public string ImsFsdb
 529:              {
 530:                  get
 531:                  {
 532:                      return ImsBasicService.Fsdb;
 533:                  }
 534:              }
 535:              public string PrimarySwitch
 536:              {
 537:                  get
 538:                  {
 539:                      return ImsBasicService.PrimarySwitch;
 540:                  }
 541:              }
 542:   
 543:              public virtual Pon Pon { get; set; }
 544:              public virtual Access Access { get; set; }
 545:   
 546:              ////////////////////////////////////////////////////////////////////////////
 547:   
 548:              /// <summary>
 549:              ///
 550:              /// </summary>
 551:              public string ToSimpleTextString()
 552:              {
 553:                  StringBuilder sb;
 554:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 555:   
 556:                  sb = new StringBuilder();
 557:   
 558:                  switchVendor = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == this.Id select o.Pon.PonGroup.Olt.Odf.Router.Vendor).SingleOrDefault();
 559:                  accessVendor = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == this.Id select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
 560:   
 561:                  sb.AppendLine("SwitchVendor: " + switchVendor.Name);
 562:                  sb.AppendLine("AccessVendor: " + accessVendor.Name);
 563:                  sb.AppendLine("AccessName: " + ((this.Access != null) ? this.Access.Name : string.Empty));
 564:                  sb.AppendLine("Position: " + this.Position);
 565:                  sb.AppendLine("Ip: " + this.Ip);
 566:                  sb.AppendLine("Site Name: " + this.Pon.PonGroup.Olt.Odf.Router.Site.Name);
 567:                  sb.AppendLine("PrimarySwitch: " + this.PrimarySwitch);
 568:                  sb.AppendLine("Olt IsSip: " + Ia.Cl.Model.Default.YesNoText(this.Pon.PonGroup.Olt.IsSip));
 569:                  sb.AppendLine("NetworkNumber: " + this.Pon.PonGroup.NetworkNumber);
 570:                  sb.AppendLine("GatewayIp: " + this.Pon.PonGroup.GatewayIp);
 571:                  sb.AppendLine("MgcIp: " + this.MgcIp);
 572:                  sb.AppendLine("MgcSecondaryIp: " + this.MgcSecondaryIp);
 573:                  sb.AppendLine("ImsService: " + this.ImsService);
 574:                  sb.AppendLine("ImsFsdb: " + this.ImsFsdb);
 575:   
 576:                  return sb.ToString();
 577:              }
 578:          }
 579:   
 580:          ////////////////////////////////////////////////////////////////////////////
 581:   
 582:          /// <summary>
 583:          ///
 584:          /// </summary>
 585:          public class Onu
 586:          {
 587:              public Onu() { }
 588:   
 589:              public string Id { get; set; }
 590:              public int Slot { get; set; }
 591:              public int Port { get; set; }
 592:              public int Number { get; set; }
 593:              public string Position { get; set; }
 594:              public string Ip { get; set; }
 595:              public virtual Pon Pon { get; set; }
 596:              public virtual Access Access { get; set; }
 597:          }
 598:   
 599:          ////////////////////////////////////////////////////////////////////////////
 600:   
 601:          /// <summary>
 602:          ///
 603:          /// </summary>
 604:          public class Access
 605:          {
 606:              public Access() { }
 607:   
 608:              public string Id { get; set; }
 609:              public string Name { get; set; }
 610:              public string ProposedName { get; set; }
 611:              public int Ont { get; set; }
 612:              public int Pon { get; set; }
 613:              public int ProposedPon { get; set; }
 614:              public string Symbol { get; set; }
 615:   
 616:              public string AccessId(int oltId, int ponNumber, int ontNumber)
 617:              {
 618:                  return Ia.Ngn.Cl.Model.Business.Access.AccessId(oltId, ponNumber, ontNumber);
 619:              }
 620:          }
 621:   
 622:          ////////////////////////////////////////////////////////////////////////////
 623:          ////////////////////////////////////////////////////////////////////////////    
 624:      }
 625:  }