)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » NetworkDesignDocument (Ia.Ftn.Cl.Models.Ui)

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

Network Design Document support class for Fixed Telecommunications Network (FTN) UI model.

    1: using System.Collections.Generic;
    2: using System.Data;
    3: using System.Linq;
    4: using System.Runtime.Serialization;
    5:  
    6: namespace Ia.Ftn.Cl.Models.Ui
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Network Design Document support class for Fixed Telecommunications Network (FTN) 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:     /// </remarks> 
   17:     public class NetworkDesignDocument
   18:     {
   19:         ////////////////////////////////////////////////////////////////////////////
   20:  
   21:         /// <summary>
   22:         ///
   23:         /// </summary>
   24:         public NetworkDesignDocument() { }
   25:  
   26:         ////////////////////////////////////////////////////////////////////////////
   27:  
   28:         /// <summary>
   29:         /// 
   30:         /// </summary>
   31:         [DataContract(IsReference = true, Name = "apiOnt")]
   32:         public class Ont
   33:         {
   34:             /// <summary/>
   35:             [DataMember(Name = "id")]
   36:             public string Id { get; set; }
   37:  
   38:             /// <summary/>
   39:             [DataMember(Name = "rack")]
   40:             public int Rack { get; set; }
   41:  
   42:             /// <summary/>
   43:             [DataMember(Name = "sub")]
   44:             public int Sub { get; set; }
   45:  
   46:             /// <summary/>
   47:             [DataMember(Name = "card")]
   48:             public int Card { get; set; }
   49:  
   50:             /// <summary/>
   51:             [DataMember(Name = "port")]
   52:             public int Port { get; set; }
   53:  
   54:             /// <summary/>
   55:             [DataMember(Name = "number")]
   56:             public int Number { get; set; }
   57:  
   58:             /// <summary/>
   59:             [DataMember(Name = "position")]
   60:             public string Position { get; set; }
   61:  
   62:             /// <summary/>
   63:             [DataMember(Name = "ip")]
   64:             public string Ip { get; set; }
   65:  
   66:             /// <summary/>
   67:             [DataMember(Name = "mgcIp")]
   68:             public string MgcIp { get; set; }
   69:  
   70:             /// <summary/>
   71:             [DataMember(Name = "mgcSecondaryIp")]
   72:             public string MgcSecondaryIp { get; set; }
   73:  
   74:             /// <summary/>
   75:             [DataMember(Name = "mgcSubnetMask")]
   76:             public string MgcSubnetMask { get; set; }
   77:  
   78:             /// <summary/>
   79:             [DataMember(Name = "imsService")]
   80:             public int ImsService { get; set; }
   81:  
   82:             /// <summary/>
   83:             [DataMember(Name = "imsFsdb")]
   84:             public string ImsFsdb { get; set; }
   85:  
   86:             /// <summary/>
   87:             [DataMember(Name = "primarySwitch")]
   88:             public string PrimarySwitch { get; set; }
   89:  
   90:             /// <summary/>
   91:             [DataMember(Name = "ponName")]
   92:             public string PonName { get; set; }
   93:  
   94:             /// <summary/>
   95:             [DataMember(Name = "accessName")]
   96:             public string AccessName { get; set; }
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////    
  100:  
  101:         /// <summary>
  102:         /// 
  103:         /// </summary>
  104:         public static string StructureDataTable()
  105:         {
  106:             int siteCount, routerCount, odfCount, oltCount;
  107:             int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
  108:             string htmlTable;
  109:  
  110:             siteCount = routerCount = odfCount = oltCount = 0;
  111:             siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
  112:  
  113:             htmlTable = @"<div id=""network-design-document-structure"">";
  114:  
  115:             htmlTable += "<table>";
  116:  
  117:             htmlTable += "<tr class=site0><td>Site</td><td>PSTN/MSAN/SoftX</td><td>Switch/Router</td><td>Access</td><td></td><td></td></tr>";
  118:  
  119:             siteCount = 1;
  120:  
  121:             var siteList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList.OrderBy(u => u.Name);
  122:             var oltList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList;
  123:  
  124:             foreach (var site in siteList)
  125:             {
  126:                 siteOltCount = (from o in oltList
  127:                                 where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site
  128:                                 select o).Count();
  129:  
  130:                 if (site.Routers.Count > 0)
  131:                 {
  132:                     routerCount = 1;
  133:  
  134:                     foreach (var router in site.Routers)
  135:                     {
  136:                         routerOltCount = (from o in oltList
  137:                                           where o.Odf != null && o.Odf.Router == router
  138:                                           select o).Count();
  139:  
  140:                         if (router.Odfs.Count > 0)
  141:                         {
  142:                             odfCount = 1;
  143:  
  144:                             foreach (var odf in router.Odfs)
  145:                             {
  146:                                 odfOltCount = (from o in oltList
  147:                                                where o.Odf == odf
  148:                                                select o).Count();
  149:  
  150:                                 oltCount = 1;
  151:  
  152:                                 foreach (var olt in odf.Olts)
  153:                                 {
  154:                                     oltOltCount = odf.Olts.Count;
  155:  
  156:                                     htmlTable += @"<tr class=site" + siteCount + ">";
  157:  
  158:                                     if (routerCount == 1 && odfCount == 1 && oltCount == 1)
  159:                                     {
  160:                                         htmlTable += "<td class=site rowspan=" + siteOltCount + ">" + SiteStructureDataTable(site) + "</td>";
  161:                                         htmlTable += "<td class=pstn rowspan=" + siteOltCount + ">" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  162:                                     }
  163:  
  164:                                     if (odfCount == 1 && oltCount == 1) htmlTable += "<td class=router rowspan=" + routerOltCount + ">" + RouterStructureDataTable(router) + "</td>";
  165:  
  166:                                     if (oltCount == 1) htmlTable += "<td class=odf rowspan=" + odfOltCount + ">" + OdfStructureDataTable(odf) + "</td>";
  167:  
  168:                                     // field type color
  169:                                     if (olt.FieldType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.FieldType.Green)
  170:                                     {
  171:                                         htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  172:                                     }
  173:                                     else // if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)
  174:                                     {
  175:                                         htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  176:                                     }
  177:  
  178:                                     htmlTable += @"</tr>";
  179:  
  180:                                     oltCount++;
  181:                                 }
  182:  
  183:                                 odfCount++;
  184:                             }
  185:                         }
  186:                         else
  187:                         {
  188:                             if (routerCount == 1)
  189:                             {
  190:                                 htmlTable += @"<tr class=site" + siteCount + ">";
  191:  
  192:                                 htmlTable += "<td class=site>" + SiteStructureDataTable(site) + "</td>";
  193:                                 htmlTable += "<td class=pstn>" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  194:                                 htmlTable += "<td class=router>" + RouterStructureDataTable(router) + "</td>";
  195:                                 htmlTable += "<td class=odf> </td>";
  196:                                 htmlTable += "<td> </td>";
  197:                                 htmlTable += "<td class=olt> </td>";
  198:  
  199:                                 htmlTable += "</tr>";
  200:                             }
  201:  
  202:                             routerCount--;
  203:                         }
  204:  
  205:                         routerCount++;
  206:                     }
  207:                 }
  208:                 else
  209:                 {
  210:                     htmlTable += @"<tr class=site" + siteCount + ">";
  211:  
  212:                     htmlTable += "<td class=site>" + SiteStructureDataTable(site) + "</td>";
  213:                     htmlTable += "<td class=pstn>" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  214:                     htmlTable += "<td class=router> </td>";
  215:                     htmlTable += "<td class=odf> </td>";
  216:                     htmlTable += "<td> </td>";
  217:                     htmlTable += "<td class=olt> </td>";
  218:  
  219:                     htmlTable += "</tr>";
  220:                 }
  221:  
  222:                 siteCount++;
  223:             }
  224:  
  225:             htmlTable += "</table>";
  226:  
  227:             htmlTable += "</div>";
  228:  
  229:             return htmlTable;
  230:         }
  231:  
  232:         ////////////////////////////////////////////////////////////////////////////    
  233:  
  234:         /// <summary>
  235:         /// 
  236:         /// </summary>
  237:         private static string SiteStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site site)
  238:         {
  239:             string content, kuwaitFtnAreas;
  240:  
  241:             kuwaitFtnAreas = string.Empty;
  242:  
  243:             foreach (var ka in site.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "<br />";
  244:  
  245:             kuwaitFtnAreas = kuwaitFtnAreas.Trim(',');
  246:  
  247:             content = site.NameArabicName;
  248:             content += @"<br />" + string.Join(", ", site.AreaSymbolList);
  249:             content += @"<br />" + kuwaitFtnAreas;
  250:  
  251:             return content;
  252:         }
  253:  
  254:         ////////////////////////////////////////////////////////////////////////////    
  255:  
  256:         /// <summary>
  257:         /// 
  258:         /// </summary>
  259:         private static string PstnAndMsanAndSoftXStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site site)
  260:         {
  261:             var content = string.Empty;
  262:  
  263:             var pstnList = site.Pstns.ToList();
  264:  
  265:             foreach (var pstn in pstnList)
  266:             {
  267:                 content += "PSTN (" + pstn.PstnExchangeType + "): " + pstn.Name;
  268:                 content += @"<br />";
  269:                 content += string.Join(", ", pstn.DomainList);
  270:                 content += "<br />";
  271:                 content += @" Uses NP/LNP/SPS Server?: " + Ia.Cl.Models.Default.YesNo(pstn.UsesNpServer) + " ";
  272:  
  273:                 content += @"<br />";
  274:                 content += @"<br />";
  275:             }
  276:  
  277:  
  278:             var msanList = site.Msans.ToList();
  279:  
  280:             foreach (var msan in msanList)
  281:             {
  282:                 content += "MSAN: " + msan.NameSymbol;
  283:  
  284:                 if (msan.DomainList != null)
  285:                 {
  286:                     content += @"<br />";
  287:                     content += string.Join(", ", msan.DomainList);
  288:                 }
  289:  
  290:                 content += @"<br />";
  291:                 content += @"<br />";
  292:             }
  293:  
  294:  
  295:             var softXList = site.SoftXes.ToList();
  296:  
  297:             foreach (var softX in softXList)
  298:             {
  299:                 content += "SoftX: ";
  300:  
  301:                 if (softX.DomainList != null)
  302:                 {
  303:                     content += @"<br />";
  304:                     content += string.Join(", ", softX.DomainList);
  305:                 }
  306:  
  307:                 content += @"<br />";
  308:                 content += @"<br />";
  309:             }
  310:  
  311:             return content;
  312:         }
  313:  
  314:         ////////////////////////////////////////////////////////////////////////////    
  315:  
  316:         /// <summary>
  317:         /// 
  318:         /// </summary>
  319:         private static string RouterStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Router router)
  320:         {
  321:             string content, domainList;
  322:  
  323:             domainList = string.Empty;
  324:  
  325:             foreach (int i in router.DomainList) domainList += i + ", ";
  326:  
  327:             domainList = domainList.Trim();
  328:             domainList = domainList.Trim(',');
  329:  
  330:             content = router.Vendor.Name;
  331:             content += @"<br />" + domainList;
  332:  
  333:             return content;
  334:         }
  335:  
  336:         ////////////////////////////////////////////////////////////////////////////    
  337:  
  338:         /// <summary>
  339:         /// 
  340:         /// </summary>
  341:         private static string OdfStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Odf odf)
  342:         {
  343:             string content;
  344:  
  345:             content = odf.Name + @"<br />" + odf.Vendor.Name;
  346:  
  347:             return content;
  348:         }
  349:  
  350:         ////////////////////////////////////////////////////////////////////////////    
  351:  
  352:         /// <summary>
  353:         /// 
  354:         /// </summary>
  355:         private static string OltStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  356:         {
  357:             string content;
  358:             List<int> ponlist, proposedPonList;
  359:             Dictionary<string, List<int>> dic;
  360:  
  361:             proposedPonList = new List<int>();
  362:             dic = new Dictionary<string, List<int>>();
  363:  
  364:             content = olt.Symbol;
  365:             content += @" (" + olt.AmsName + ") ";
  366:  
  367:             content += "<br />";
  368:             content += @" Field type: " + Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.FieldTypeColoredString(olt.FieldType) + " ";
  369:  
  370:             content += "<br />";
  371:             content += @" SIP?: " + Ia.Cl.Models.Default.YesNo(olt.IsSip) + " ";
  372:  
  373:             foreach (var ponGroup in olt.PonGroupList)
  374:             {
  375:                 ponlist = new List<int>();
  376:  
  377:                 foreach (int i in ponGroup.UsedPonInPonGroupList) if (i != 0) ponlist.Add(i);
  378:  
  379:                 if (!dic.ContainsKey(ponGroup.Symbol))
  380:                 {
  381:                     dic[ponGroup.Symbol] = ponlist;
  382:                 }
  383:                 else dic[ponGroup.Symbol].AddRange(ponlist);
  384:  
  385:                 /*
  386:                 if (ponGroup.HasNewProposedPonList) foreach (int i in ponGroup.UsedProposedPonInPonGroupList) if (i != 0) proposedPonList.Add(i);
  387: 
  388:                 if (proposedPonList.Count > 0)
  389:                 {
  390:                     content += @"(Proposed): " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(proposedPonList) + "</b>";
  391:                 }
  392:                 */
  393:             }
  394:  
  395:             foreach (var kvp in dic)
  396:             {
  397:                 content += "<br />";
  398:                 content += kvp.Key + @": " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(kvp.Value) + " ";
  399:             }
  400:  
  401:             //content += @" (" + olt.PonListString + ") ";
  402:  
  403:             return content;
  404:         }
  405:  
  406:         ////////////////////////////////////////////////////////////////////////////
  407:         ////////////////////////////////////////////////////////////////////////////
  408:  
  409:         /// <summary>
  410:         /// 
  411:         /// </summary>
  412:         public static string StructureToSimpleTextString()
  413:         {
  414:             int siteCount, routerCount, odfCount, oltCount;
  415:             int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
  416:             string content, domainList;
  417:             string kuwaitFtnAreas;
  418:             string text;
  419:  
  420:             siteCount = routerCount = odfCount = oltCount = 0;
  421:             siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
  422:  
  423:             text = "\n";
  424:  
  425:             siteCount = 1;
  426:  
  427:             foreach (var site in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList)
  428:             {
  429:                 siteOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  430:                                 where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site
  431:                                 select o).Count();
  432:  
  433:                 if (site.Routers.Count > 0)
  434:                 {
  435:                     routerCount = 1;
  436:  
  437:                     foreach (var router in site.Routers)
  438:                     {
  439:                         routerOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  440:                                           where o.Odf != null && o.Odf.Router == router
  441:                                           select o).Count();
  442:  
  443:                         if (router.Odfs.Count > 0)
  444:                         {
  445:                             odfCount = 1;
  446:  
  447:                             foreach (var odf in router.Odfs)
  448:                             {
  449:                                 odfOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  450:                                                where o.Odf == odf
  451:                                                select o).Count();
  452:  
  453:                                 oltCount = 1;
  454:  
  455:                                 foreach (var olt in odf.Olts)
  456:                                 {
  457:                                     oltOltCount = odf.Olts.Count;
  458:  
  459:                                     if (routerCount == 1 && odfCount == 1 && oltCount == 1)
  460:                                     {
  461:                                         text += "\n";
  462:  
  463:                                         //text += "\n";
  464:                                         //text += "\n";
  465:                                         text += @"===========================";
  466:  
  467:                                         text += "\n";
  468:  
  469:                                         kuwaitFtnAreas = string.Empty;
  470:  
  471:                                         foreach (var ka in site.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "\n";
  472:  
  473:                                         kuwaitFtnAreas = kuwaitFtnAreas.Trim();
  474:  
  475:                                         content = site.NameArabicName;
  476:                                         content += "\n";
  477:                                         content += "\n" + string.Join(", ", site.AreaSymbolList);
  478:                                         content += "\n";
  479:                                         content += "\n" + kuwaitFtnAreas;
  480:  
  481:                                         text += content.Trim();
  482:                                     }
  483:  
  484:                                     if (odfCount == 1 && oltCount == 1)
  485:                                     {
  486:                                         //text += "\n";
  487:                                         text += "\n";
  488:  
  489:                                         //text += "| --------------------------";
  490:                                         text += "\n";
  491:  
  492:                                         domainList = string.Empty;
  493:  
  494:                                         foreach (int i in router.DomainList) domainList += i + ", ";
  495:  
  496:                                         domainList = domainList.Trim();
  497:                                         domainList = domainList.Trim(',');
  498:  
  499:                                         content = router.Vendor.Name + @" " + domainList;
  500:  
  501:                                         text += "| " + content;
  502:  
  503:                                         text += "\n";
  504:                                     }
  505:  
  506:                                     if (oltCount == 1)
  507:                                     {
  508:                                         text += "\n";
  509:  
  510:                                         //text += "\t\t\t\t\t\t--------------------------";
  511:                                         text += "| | " + odf.Name + @" (" + odf.Vendor.Name + ")";
  512:                                     }
  513:  
  514:                                     /*
  515: // field type color
  516: if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
  517:     htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  518: else /*if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)* /
  519:     htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  520:     */
  521:  
  522:                                     //text += @"====================================";
  523:  
  524:                                     oltCount++;
  525:                                 }
  526:  
  527:                                 odfCount++;
  528:                             }
  529:                         }
  530:                         else routerCount--;
  531:  
  532:                         routerCount++;
  533:                     }
  534:                 }
  535:  
  536:                 siteCount++;
  537:             }
  538:  
  539:             text += "\n";
  540:  
  541:             return text.Trim();
  542:         }
  543:  
  544:         ////////////////////////////////////////////////////////////////////////////
  545:         ////////////////////////////////////////////////////////////////////////////    
  546:     }
  547: }