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

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) UI model.

   1:  using System.Collections.Generic;
   2:  using System.Data;
   3:  using System.Linq;
   4:  using System.Runtime.Serialization;
   5:   
   6:  namespace Ia.Ngn.Cl.Model.Ui
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// Network Design Document support class for Next Generation Network (NGN) UI model.
  12:      /// </summary>
  13:      /// 
  14:      /// <remarks> 
  15:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  16:      ///
  17:      /// 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
  18:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  19:      ///
  20:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  21:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  22:      /// 
  23:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  24:      /// 
  25:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  26:      /// </remarks> 
  27:      public partial class NetworkDesignDocument
  28:      {
  29:          ////////////////////////////////////////////////////////////////////////////
  30:   
  31:          /// <summary>
  32:          ///
  33:          /// </summary>
  34:          public NetworkDesignDocument() { }
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          /// 
  40:          /// </summary>
  41:          [DataContract(IsReference = true, Name = "apiOnt")]
  42:          public class Ont
  43:          {
  44:              /// <summary/>
  45:              [DataMember(Name = "id")]
  46:              public string Id { get; set; }
  47:   
  48:              /// <summary/>
  49:              [DataMember(Name = "rack")]
  50:              public int Rack { get; set; }
  51:   
  52:              /// <summary/>
  53:              [DataMember(Name = "sub")]
  54:              public int Sub { get; set; }
  55:   
  56:              /// <summary/>
  57:              [DataMember(Name = "card")]
  58:              public int Card { get; set; }
  59:   
  60:              /// <summary/>
  61:              [DataMember(Name = "port")]
  62:              public int Port { get; set; }
  63:   
  64:              /// <summary/>
  65:              [DataMember(Name = "number")]
  66:              public int Number { get; set; }
  67:   
  68:              /// <summary/>
  69:              [DataMember(Name = "position")]
  70:              public string Position { get; set; }
  71:   
  72:              /// <summary/>
  73:              [DataMember(Name = "ip")]
  74:              public string Ip { get; set; }
  75:   
  76:              /// <summary/>
  77:              [DataMember(Name = "mgcIp")]
  78:              public string MgcIp { get; set; }
  79:   
  80:              /// <summary/>
  81:              [DataMember(Name = "mgcSecondaryIp")]
  82:              public string MgcSecondaryIp { get; set; }
  83:   
  84:              /// <summary/>
  85:              [DataMember(Name = "mgcSubnetMask")]
  86:              public string MgcSubnetMask { get; set; }
  87:   
  88:              /// <summary/>
  89:              [DataMember(Name = "imsService")]
  90:              public int ImsService { get; set; }
  91:   
  92:              /// <summary/>
  93:              [DataMember(Name = "imsFsdb")]
  94:              public string ImsFsdb { get; set; }
  95:   
  96:              /// <summary/>
  97:              [DataMember(Name = "primarySwitch")]
  98:              public string PrimarySwitch { get; set; }
  99:   
 100:              /// <summary/>
 101:              [DataMember(Name = "ponName")]
 102:              public string PonName { get; set; }
 103:   
 104:              /// <summary/>
 105:              [DataMember(Name = "accessName")]
 106:              public string AccessName { get; set; }
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////    
 110:   
 111:          /// <summary>
 112:          /// 
 113:          /// </summary>
 114:          public static string StructureDataTable()
 115:          {
 116:              int siteCount, routerCount, odfCount, oltCount;
 117:              int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
 118:              string htmlTable;
 119:   
 120:              siteCount = routerCount = odfCount = oltCount = 0;
 121:              siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
 122:   
 123:              htmlTable = @"<div id=""network-design-document-structure"">";
 124:   
 125:              htmlTable += "<table>";
 126:   
 127:              siteCount = 1;
 128:   
 129:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList)
 130:              {
 131:                  siteOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site select o).Count();
 132:   
 133:                  if (site.Routers.Count > 0)
 134:                  {
 135:                      routerCount = 1;
 136:   
 137:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router in site.Routers)
 138:                      {
 139:                          routerOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Router == router select o).Count();
 140:   
 141:                          if (router.Odfs.Count > 0)
 142:                          {
 143:                              odfCount = 1;
 144:   
 145:                              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf in router.Odfs)
 146:                              {
 147:                                  odfOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf == odf select o).Count();
 148:   
 149:                                  oltCount = 1;
 150:   
 151:                                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in odf.Olts)
 152:                                  {
 153:                                      oltOltCount = odf.Olts.Count;
 154:   
 155:                                      htmlTable += @"<tr class=site" + siteCount + ">";
 156:   
 157:                                      if (routerCount == 1 && odfCount == 1 && oltCount == 1)
 158:                                      {
 159:                                          htmlTable += "<td class=site rowspan=" + siteOltCount + ">" + SiteStructureDataTable(site) + "</td>";
 160:                                          htmlTable += "<td class=pstn rowspan=" + siteOltCount + ">" + PstnStructureDataTable(site.Pstns) + "</td>";
 161:                                      }
 162:                                      if (odfCount == 1 && oltCount == 1) htmlTable += "<td class=router rowspan=" + routerOltCount + ">" + RouterStructureDataTable(router) + "</td>";
 163:                                      if (oltCount == 1) htmlTable += "<td class=odf rowspan=" + odfOltCount + ">" + OdfStructureDataTable(odf) + "</td>";
 164:   
 165:                                      // field type color
 166:                                      if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
 167:                                          htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 168:                                      else /*if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)*/
 169:                                          htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 170:   
 171:                                      htmlTable += @"</tr>";
 172:   
 173:                                      oltCount++;
 174:                                  }
 175:   
 176:                                  odfCount++;
 177:                              }
 178:                          }
 179:                          else routerCount--;
 180:   
 181:                          routerCount++;
 182:                      }
 183:                  }
 184:   
 185:                  siteCount++;
 186:              }
 187:   
 188:              htmlTable += "</table>";
 189:   
 190:              htmlTable += "</div>";
 191:   
 192:              return htmlTable;
 193:          }
 194:   
 195:          ////////////////////////////////////////////////////////////////////////////    
 196:   
 197:          /// <summary>
 198:          /// 
 199:          /// </summary>
 200:          private static string SiteStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site)
 201:          {
 202:              string content, kuwaitNgnAreas;
 203:   
 204:              kuwaitNgnAreas = string.Empty;
 205:   
 206:              foreach (Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea ka in site.KuwaitNgnAreas) kuwaitNgnAreas += ka.NameArabicName + "<br />";
 207:   
 208:              kuwaitNgnAreas = kuwaitNgnAreas.Trim(',');
 209:   
 210:              content = site.NameArabicName;
 211:              content += @"<br />" + string.Join(", ", site.AreaSymbolList);
 212:              content += @"<br />" + kuwaitNgnAreas;
 213:   
 214:              return content;
 215:          }
 216:   
 217:          ////////////////////////////////////////////////////////////////////////////    
 218:   
 219:          /// <summary>
 220:          /// 
 221:          /// </summary>
 222:          private static string PstnStructureDataTable(ICollection<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> pstnList)
 223:          {
 224:              string content;
 225:   
 226:              var list = pstnList.ToList();
 227:   
 228:              content = string.Empty;
 229:   
 230:              foreach (var pstn in list)
 231:              {
 232:                  content += pstn.Name + " (نحاس) (" + pstn.PstnExchangeType + ")";
 233:                  content += @"<br />";
 234:                  content += string.Join(", ", pstn.DomainList);
 235:   
 236:                  content += @"<br />";
 237:                  content += @"<br />";
 238:              }
 239:   
 240:              return content;
 241:          }
 242:   
 243:          ////////////////////////////////////////////////////////////////////////////    
 244:   
 245:          /// <summary>
 246:          /// 
 247:          /// </summary>
 248:          private static string RouterStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router)
 249:          {
 250:              string content, domainList;
 251:   
 252:              domainList = string.Empty;
 253:   
 254:              foreach (int i in router.DomainList) domainList += i + ", ";
 255:   
 256:              domainList = domainList.Trim();
 257:              domainList = domainList.Trim(',');
 258:   
 259:              content = router.Vendor.Name;
 260:              content += @"<br />" + domainList;
 261:   
 262:              return content;
 263:          }
 264:   
 265:          ////////////////////////////////////////////////////////////////////////////    
 266:   
 267:          /// <summary>
 268:          /// 
 269:          /// </summary>
 270:          private static string OdfStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf)
 271:          {
 272:              string content;
 273:   
 274:              content = odf.Name + @"<br />" + odf.Vendor.Name;
 275:   
 276:              return content;
 277:          }
 278:   
 279:          ////////////////////////////////////////////////////////////////////////////    
 280:   
 281:          /// <summary>
 282:          /// 
 283:          /// </summary>
 284:          private static string OltStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 285:          {
 286:              string content;
 287:              List<int> ponlist, proposedPonList;
 288:              Dictionary<string, List<int>> dic;
 289:   
 290:              proposedPonList = new List<int>();
 291:              dic = new Dictionary<string, List<int>>();
 292:   
 293:              content = olt.Symbol;
 294:              content += @" (" + olt.AmsName + ") ";
 295:   
 296:              content += "<br />";
 297:              content += @" SIP?: " + Ia.Cl.Model.Default.YesNo(olt.IsSip) + " ";
 298:   
 299:              foreach (var ponGroup in olt.PonGroupList)
 300:              {
 301:                  ponlist = new List<int>();
 302:   
 303:                  foreach (int i in ponGroup.UsedPonInPonGroupList) if (i != 0) ponlist.Add(i);
 304:   
 305:                  if (!dic.ContainsKey(ponGroup.Symbol))
 306:                  {
 307:                      dic[ponGroup.Symbol] = ponlist;
 308:                  }
 309:                  else dic[ponGroup.Symbol].AddRange(ponlist);
 310:   
 311:                  /*
 312:                  if (ponGroup.HasNewProposedPonList) foreach (int i in ponGroup.UsedProposedPonInPonGroupList) if (i != 0) proposedPonList.Add(i);
 313:  
 314:                  if (proposedPonList.Count > 0)
 315:                  {
 316:                      content += @"(Proposed): " + Ia.Cl.Model.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(proposedPonList) + "</b>";
 317:                  }
 318:                  */
 319:              }
 320:   
 321:              foreach (var kvp in dic)
 322:              {
 323:                  content += "<br />";
 324:                  content += kvp.Key + @": " + Ia.Cl.Model.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(kvp.Value) + " ";
 325:              }
 326:   
 327:              //content += @" (" + olt.PonListString + ") ";
 328:   
 329:              return content;
 330:          }
 331:   
 332:          ////////////////////////////////////////////////////////////////////////////
 333:          ////////////////////////////////////////////////////////////////////////////
 334:   
 335:          /// <summary>
 336:          /// 
 337:          /// </summary>
 338:          public static string StructureToSimpleTextString()
 339:          {
 340:              int siteCount, routerCount, odfCount, oltCount;
 341:              int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
 342:              string content, domainList;
 343:              string kuwaitNgnAreas;
 344:              string text;
 345:   
 346:              siteCount = routerCount = odfCount = oltCount = 0;
 347:              siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
 348:   
 349:              text = "\n";
 350:   
 351:              siteCount = 1;
 352:   
 353:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList)
 354:              {
 355:                  siteOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site select o).Count();
 356:   
 357:                  if (site.Routers.Count > 0)
 358:                  {
 359:                      routerCount = 1;
 360:   
 361:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router in site.Routers)
 362:                      {
 363:                          routerOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Router == router select o).Count();
 364:   
 365:                          if (router.Odfs.Count > 0)
 366:                          {
 367:                              odfCount = 1;
 368:   
 369:                              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf in router.Odfs)
 370:                              {
 371:                                  odfOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf == odf select o).Count();
 372:   
 373:                                  oltCount = 1;
 374:   
 375:                                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in odf.Olts)
 376:                                  {
 377:                                      oltOltCount = odf.Olts.Count;
 378:   
 379:                                      if (routerCount == 1 && odfCount == 1 && oltCount == 1)
 380:                                      {
 381:                                          text += "\n";
 382:   
 383:                                          //text += "\n";
 384:                                          //text += "\n";
 385:                                          text += @"===========================";
 386:   
 387:                                          text += "\n";
 388:   
 389:                                          kuwaitNgnAreas = string.Empty;
 390:   
 391:                                          foreach (Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea ka in site.KuwaitNgnAreas) kuwaitNgnAreas += ka.NameArabicName + "\n";
 392:   
 393:                                          kuwaitNgnAreas = kuwaitNgnAreas.Trim();
 394:   
 395:                                          content = site.NameArabicName;
 396:                                          content += "\n";
 397:                                          content += "\n" + string.Join(", ", site.AreaSymbolList);
 398:                                          content += "\n";
 399:                                          content += "\n" + kuwaitNgnAreas;
 400:   
 401:                                          text += content.Trim();
 402:                                      }
 403:   
 404:                                      if (odfCount == 1 && oltCount == 1)
 405:                                      {
 406:                                          //text += "\n";
 407:                                          text += "\n";
 408:   
 409:                                          //text += "| --------------------------";
 410:                                          text += "\n";
 411:   
 412:                                          domainList = string.Empty;
 413:   
 414:                                          foreach (int i in router.DomainList) domainList += i + ", ";
 415:   
 416:                                          domainList = domainList.Trim();
 417:                                          domainList = domainList.Trim(',');
 418:   
 419:                                          content = router.Vendor.Name + @" " + domainList;
 420:   
 421:                                          text += "| " + content;
 422:   
 423:                                          text += "\n";
 424:                                      }
 425:   
 426:                                      if (oltCount == 1)
 427:                                      {
 428:                                          text += "\n";
 429:   
 430:                                          //text += "\t\t\t\t\t\t--------------------------";
 431:                                          text += "| | " + odf.Name + @" (" + odf.Vendor.Name + ")";
 432:                                      }
 433:   
 434:                                      /*
 435:  // field type color
 436:  if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
 437:      htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 438:  else /*if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)* /
 439:      htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 440:      */
 441:   
 442:                                      //text += @"====================================";
 443:   
 444:                                      oltCount++;
 445:                                  }
 446:   
 447:                                  odfCount++;
 448:                              }
 449:                          }
 450:                          else routerCount--;
 451:   
 452:                          routerCount++;
 453:                      }
 454:                  }
 455:   
 456:                  siteCount++;
 457:              }
 458:   
 459:              text += "\n";
 460:   
 461:              return text.Trim();
 462:          }
 463:   
 464:          ////////////////////////////////////////////////////////////////////////////
 465:          ////////////////////////////////////////////////////////////////////////////    
 466:      }
 467:  }