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

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:                  content += "<br />";
 236:                  content += @" Uses LNP Server?: " + Ia.Cl.Model.Default.YesNo(pstn.UsesLnpServer) + " ";
 237:   
 238:                  content += @"<br />";
 239:                  content += @"<br />";
 240:              }
 241:   
 242:              return content;
 243:          }
 244:   
 245:          ////////////////////////////////////////////////////////////////////////////    
 246:   
 247:          /// <summary>
 248:          /// 
 249:          /// </summary>
 250:          private static string RouterStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router)
 251:          {
 252:              string content, domainList;
 253:   
 254:              domainList = string.Empty;
 255:   
 256:              foreach (int i in router.DomainList) domainList += i + ", ";
 257:   
 258:              domainList = domainList.Trim();
 259:              domainList = domainList.Trim(',');
 260:   
 261:              content = router.Vendor.Name;
 262:              content += @"<br />" + domainList;
 263:   
 264:              return content;
 265:          }
 266:   
 267:          ////////////////////////////////////////////////////////////////////////////    
 268:   
 269:          /// <summary>
 270:          /// 
 271:          /// </summary>
 272:          private static string OdfStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf)
 273:          {
 274:              string content;
 275:   
 276:              content = odf.Name + @"<br />" + odf.Vendor.Name;
 277:   
 278:              return content;
 279:          }
 280:   
 281:          ////////////////////////////////////////////////////////////////////////////    
 282:   
 283:          /// <summary>
 284:          /// 
 285:          /// </summary>
 286:          private static string OltStructureDataTable(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 287:          {
 288:              string content;
 289:              List<int> ponlist, proposedPonList;
 290:              Dictionary<string, List<int>> dic;
 291:   
 292:              proposedPonList = new List<int>();
 293:              dic = new Dictionary<string, List<int>>();
 294:   
 295:              content = olt.Symbol;
 296:              content += @" (" + olt.AmsName + ") ";
 297:   
 298:              content += "<br />";
 299:              content += @" SIP?: " + Ia.Cl.Model.Default.YesNo(olt.IsSip) + " ";
 300:   
 301:              foreach (var ponGroup in olt.PonGroupList)
 302:              {
 303:                  ponlist = new List<int>();
 304:   
 305:                  foreach (int i in ponGroup.UsedPonInPonGroupList) if (i != 0) ponlist.Add(i);
 306:   
 307:                  if (!dic.ContainsKey(ponGroup.Symbol))
 308:                  {
 309:                      dic[ponGroup.Symbol] = ponlist;
 310:                  }
 311:                  else dic[ponGroup.Symbol].AddRange(ponlist);
 312:   
 313:                  /*
 314:                  if (ponGroup.HasNewProposedPonList) foreach (int i in ponGroup.UsedProposedPonInPonGroupList) if (i != 0) proposedPonList.Add(i);
 315:  
 316:                  if (proposedPonList.Count > 0)
 317:                  {
 318:                      content += @"(Proposed): " + Ia.Cl.Model.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(proposedPonList) + "</b>";
 319:                  }
 320:                  */
 321:              }
 322:   
 323:              foreach (var kvp in dic)
 324:              {
 325:                  content += "<br />";
 326:                  content += kvp.Key + @": " + Ia.Cl.Model.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(kvp.Value) + " ";
 327:              }
 328:   
 329:              //content += @" (" + olt.PonListString + ") ";
 330:   
 331:              return content;
 332:          }
 333:   
 334:          ////////////////////////////////////////////////////////////////////////////
 335:          ////////////////////////////////////////////////////////////////////////////
 336:   
 337:          /// <summary>
 338:          /// 
 339:          /// </summary>
 340:          public static string StructureToSimpleTextString()
 341:          {
 342:              int siteCount, routerCount, odfCount, oltCount;
 343:              int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
 344:              string content, domainList;
 345:              string kuwaitNgnAreas;
 346:              string text;
 347:   
 348:              siteCount = routerCount = odfCount = oltCount = 0;
 349:              siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
 350:   
 351:              text = "\n";
 352:   
 353:              siteCount = 1;
 354:   
 355:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList)
 356:              {
 357:                  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();
 358:   
 359:                  if (site.Routers.Count > 0)
 360:                  {
 361:                      routerCount = 1;
 362:   
 363:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router in site.Routers)
 364:                      {
 365:                          routerOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Router == router select o).Count();
 366:   
 367:                          if (router.Odfs.Count > 0)
 368:                          {
 369:                              odfCount = 1;
 370:   
 371:                              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf in router.Odfs)
 372:                              {
 373:                                  odfOltCount = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf == odf select o).Count();
 374:   
 375:                                  oltCount = 1;
 376:   
 377:                                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in odf.Olts)
 378:                                  {
 379:                                      oltOltCount = odf.Olts.Count;
 380:   
 381:                                      if (routerCount == 1 && odfCount == 1 && oltCount == 1)
 382:                                      {
 383:                                          text += "\n";
 384:   
 385:                                          //text += "\n";
 386:                                          //text += "\n";
 387:                                          text += @"===========================";
 388:   
 389:                                          text += "\n";
 390:   
 391:                                          kuwaitNgnAreas = string.Empty;
 392:   
 393:                                          foreach (Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea ka in site.KuwaitNgnAreas) kuwaitNgnAreas += ka.NameArabicName + "\n";
 394:   
 395:                                          kuwaitNgnAreas = kuwaitNgnAreas.Trim();
 396:   
 397:                                          content = site.NameArabicName;
 398:                                          content += "\n";
 399:                                          content += "\n" + string.Join(", ", site.AreaSymbolList);
 400:                                          content += "\n";
 401:                                          content += "\n" + kuwaitNgnAreas;
 402:   
 403:                                          text += content.Trim();
 404:                                      }
 405:   
 406:                                      if (odfCount == 1 && oltCount == 1)
 407:                                      {
 408:                                          //text += "\n";
 409:                                          text += "\n";
 410:   
 411:                                          //text += "| --------------------------";
 412:                                          text += "\n";
 413:   
 414:                                          domainList = string.Empty;
 415:   
 416:                                          foreach (int i in router.DomainList) domainList += i + ", ";
 417:   
 418:                                          domainList = domainList.Trim();
 419:                                          domainList = domainList.Trim(',');
 420:   
 421:                                          content = router.Vendor.Name + @" " + domainList;
 422:   
 423:                                          text += "| " + content;
 424:   
 425:                                          text += "\n";
 426:                                      }
 427:   
 428:                                      if (oltCount == 1)
 429:                                      {
 430:                                          text += "\n";
 431:   
 432:                                          //text += "\t\t\t\t\t\t--------------------------";
 433:                                          text += "| | " + odf.Name + @" (" + odf.Vendor.Name + ")";
 434:                                      }
 435:   
 436:                                      /*
 437:  // field type color
 438:  if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
 439:      htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 440:  else /*if (olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)* /
 441:      htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
 442:      */
 443:   
 444:                                      //text += @"====================================";
 445:   
 446:                                      oltCount++;
 447:                                  }
 448:   
 449:                                  odfCount++;
 450:                              }
 451:                          }
 452:                          else routerCount--;
 453:   
 454:                          routerCount++;
 455:                      }
 456:                  }
 457:   
 458:                  siteCount++;
 459:              }
 460:   
 461:              text += "\n";
 462:   
 463:              return text.Trim();
 464:          }
 465:   
 466:          ////////////////////////////////////////////////////////////////////////////
 467:          ////////////////////////////////////////////////////////////////////////////    
 468:      }
 469:  }