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

Integrated Applications Programming Company

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