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