)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   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 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:             htmlTable += "<tr class=site0><td>Site</td><td>PSTN/MSAN/SoftX</td><td>Switch/Router</td><td>Access</td><td></td><td></td></tr>";
  128:  
  129:             siteCount = 1;
  130:  
  131:             var siteList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList.OrderBy(u => u.Name);
  132:             var oltList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList;
  133:  
  134:             foreach (var site in siteList)
  135:             {
  136:                 siteOltCount = (from o in oltList
  137:                                 where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site
  138:                                 select o).Count();
  139:  
  140:                 if (site.Routers.Count > 0)
  141:                 {
  142:                     routerCount = 1;
  143:  
  144:                     foreach (var router in site.Routers)
  145:                     {
  146:                         routerOltCount = (from o in oltList
  147:                                           where o.Odf != null && o.Odf.Router == router
  148:                                           select o).Count();
  149:  
  150:                         if (router.Odfs.Count > 0)
  151:                         {
  152:                             odfCount = 1;
  153:  
  154:                             foreach (var odf in router.Odfs)
  155:                             {
  156:                                 odfOltCount = (from o in oltList
  157:                                                where o.Odf == odf
  158:                                                select o).Count();
  159:  
  160:                                 oltCount = 1;
  161:  
  162:                                 foreach (var olt in odf.Olts)
  163:                                 {
  164:                                     oltOltCount = odf.Olts.Count;
  165:  
  166:                                     htmlTable += @"<tr class=site" + siteCount + ">";
  167:  
  168:                                     if (routerCount == 1 && odfCount == 1 && oltCount == 1)
  169:                                     {
  170:                                         htmlTable += "<td class=site rowspan=" + siteOltCount + ">" + SiteStructureDataTable(site) + "</td>";
  171:                                         htmlTable += "<td class=pstn rowspan=" + siteOltCount + ">" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  172:                                     }
  173:  
  174:                                     if (odfCount == 1 && oltCount == 1) htmlTable += "<td class=router rowspan=" + routerOltCount + ">" + RouterStructureDataTable(router) + "</td>";
  175:  
  176:                                     if (oltCount == 1) htmlTable += "<td class=odf rowspan=" + odfOltCount + ">" + OdfStructureDataTable(odf) + "</td>";
  177:  
  178:                                     // field type color
  179:                                     if (olt.FieldType == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.FieldType.Green)
  180:                                     {
  181:                                         htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  182:                                     }
  183:                                     else // if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)
  184:                                     {
  185:                                         htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  186:                                     }
  187:  
  188:                                     htmlTable += @"</tr>";
  189:  
  190:                                     oltCount++;
  191:                                 }
  192:  
  193:                                 odfCount++;
  194:                             }
  195:                         }
  196:                         else
  197:                         {
  198:                             if (routerCount == 1)
  199:                             {
  200:                                 htmlTable += @"<tr class=site" + siteCount + ">";
  201:  
  202:                                 htmlTable += "<td class=site>" + SiteStructureDataTable(site) + "</td>";
  203:                                 htmlTable += "<td class=pstn>" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  204:                                 htmlTable += "<td class=router>" + RouterStructureDataTable(router) + "</td>";
  205:                                 htmlTable += "<td class=odf> </td>";
  206:                                 htmlTable += "<td> </td>";
  207:                                 htmlTable += "<td class=olt> </td>";
  208:  
  209:                                 htmlTable += "</tr>";
  210:                             }
  211:  
  212:                             routerCount--;
  213:                         }
  214:  
  215:                         routerCount++;
  216:                     }
  217:                 }
  218:                 else
  219:                 {
  220:                     htmlTable += @"<tr class=site" + siteCount + ">";
  221:  
  222:                     htmlTable += "<td class=site>" + SiteStructureDataTable(site) + "</td>";
  223:                     htmlTable += "<td class=pstn>" + PstnAndMsanAndSoftXStructureDataTable(site) + "</td>";
  224:                     htmlTable += "<td class=router> </td>";
  225:                     htmlTable += "<td class=odf> </td>";
  226:                     htmlTable += "<td> </td>";
  227:                     htmlTable += "<td class=olt> </td>";
  228:  
  229:                     htmlTable += "</tr>";
  230:                 }
  231:  
  232:                 siteCount++;
  233:             }
  234:  
  235:             htmlTable += "</table>";
  236:  
  237:             htmlTable += "</div>";
  238:  
  239:             return htmlTable;
  240:         }
  241:  
  242:         ////////////////////////////////////////////////////////////////////////////    
  243:  
  244:         /// <summary>
  245:         /// 
  246:         /// </summary>
  247:         private static string SiteStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site site)
  248:         {
  249:             string content, kuwaitFtnAreas;
  250:  
  251:             kuwaitFtnAreas = string.Empty;
  252:  
  253:             foreach (var ka in site.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "<br />";
  254:  
  255:             kuwaitFtnAreas = kuwaitFtnAreas.Trim(',');
  256:  
  257:             content = site.NameArabicName;
  258:             content += @"<br />" + string.Join(", ", site.AreaSymbolList);
  259:             content += @"<br />" + kuwaitFtnAreas;
  260:  
  261:             return content;
  262:         }
  263:  
  264:         ////////////////////////////////////////////////////////////////////////////    
  265:  
  266:         /// <summary>
  267:         /// 
  268:         /// </summary>
  269:         private static string PstnAndMsanAndSoftXStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Site site)
  270:         {
  271:             var content = string.Empty;
  272:  
  273:             var pstnList = site.Pstns.ToList();
  274:  
  275:             foreach (var pstn in pstnList)
  276:             {
  277:                 content += "PSTN (" + pstn.PstnExchangeType + "): " + pstn.Name;
  278:                 content += @"<br />";
  279:                 content += string.Join(", ", pstn.DomainList);
  280:                 content += "<br />";
  281:                 content += @" Uses NP/LNP/SPS Server?: " + Ia.Cl.Models.Default.YesNo(pstn.UsesNpServer) + " ";
  282:  
  283:                 content += @"<br />";
  284:                 content += @"<br />";
  285:             }
  286:  
  287:  
  288:             var msanList = site.Msans.ToList();
  289:  
  290:             foreach (var msan in msanList)
  291:             {
  292:                 content += "MSAN: " + msan.NameSymbol;
  293:  
  294:                 if (msan.DomainList != null)
  295:                 {
  296:                     content += @"<br />";
  297:                     content += string.Join(", ", msan.DomainList);
  298:                 }
  299:  
  300:                 content += @"<br />";
  301:                 content += @"<br />";
  302:             }
  303:  
  304:  
  305:             var softXList = site.SoftXes.ToList();
  306:  
  307:             foreach (var softX in softXList)
  308:             {
  309:                 content += "SoftX: ";
  310:  
  311:                 if (softX.DomainList != null)
  312:                 {
  313:                     content += @"<br />";
  314:                     content += string.Join(", ", softX.DomainList);
  315:                 }
  316:  
  317:                 content += @"<br />";
  318:                 content += @"<br />";
  319:             }
  320:  
  321:             return content;
  322:         }
  323:  
  324:         ////////////////////////////////////////////////////////////////////////////    
  325:  
  326:         /// <summary>
  327:         /// 
  328:         /// </summary>
  329:         private static string RouterStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Router router)
  330:         {
  331:             string content, domainList;
  332:  
  333:             domainList = string.Empty;
  334:  
  335:             foreach (int i in router.DomainList) domainList += i + ", ";
  336:  
  337:             domainList = domainList.Trim();
  338:             domainList = domainList.Trim(',');
  339:  
  340:             content = router.Vendor.Name;
  341:             content += @"<br />" + domainList;
  342:  
  343:             return content;
  344:         }
  345:  
  346:         ////////////////////////////////////////////////////////////////////////////    
  347:  
  348:         /// <summary>
  349:         /// 
  350:         /// </summary>
  351:         private static string OdfStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Odf odf)
  352:         {
  353:             string content;
  354:  
  355:             content = odf.Name + @"<br />" + odf.Vendor.Name;
  356:  
  357:             return content;
  358:         }
  359:  
  360:         ////////////////////////////////////////////////////////////////////////////    
  361:  
  362:         /// <summary>
  363:         /// 
  364:         /// </summary>
  365:         private static string OltStructureDataTable(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Olt olt)
  366:         {
  367:             string content;
  368:             List<int> ponlist, proposedPonList;
  369:             Dictionary<string, List<int>> dic;
  370:  
  371:             proposedPonList = new List<int>();
  372:             dic = new Dictionary<string, List<int>>();
  373:  
  374:             content = olt.Symbol;
  375:             content += @" (" + olt.AmsName + ") ";
  376:  
  377:             content += "<br />";
  378:             content += @" Field type: " + Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.FieldTypeColoredString(olt.FieldType) + " ";
  379:  
  380:             content += "<br />";
  381:             content += @" SIP?: " + Ia.Cl.Models.Default.YesNo(olt.IsSip) + " ";
  382:  
  383:             foreach (var ponGroup in olt.PonGroupList)
  384:             {
  385:                 ponlist = new List<int>();
  386:  
  387:                 foreach (int i in ponGroup.UsedPonInPonGroupList) if (i != 0) ponlist.Add(i);
  388:  
  389:                 if (!dic.ContainsKey(ponGroup.Symbol))
  390:                 {
  391:                     dic[ponGroup.Symbol] = ponlist;
  392:                 }
  393:                 else dic[ponGroup.Symbol].AddRange(ponlist);
  394:  
  395:                 /*
  396:                 if (ponGroup.HasNewProposedPonList) foreach (int i in ponGroup.UsedProposedPonInPonGroupList) if (i != 0) proposedPonList.Add(i);
  397: 
  398:                 if (proposedPonList.Count > 0)
  399:                 {
  400:                     content += @"(Proposed): " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(proposedPonList) + "</b>";
  401:                 }
  402:                 */
  403:             }
  404:  
  405:             foreach (var kvp in dic)
  406:             {
  407:                 content += "<br />";
  408:                 content += kvp.Key + @": " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(kvp.Value) + " ";
  409:             }
  410:  
  411:             //content += @" (" + olt.PonListString + ") ";
  412:  
  413:             return content;
  414:         }
  415:  
  416:         ////////////////////////////////////////////////////////////////////////////
  417:         ////////////////////////////////////////////////////////////////////////////
  418:  
  419:         /// <summary>
  420:         /// 
  421:         /// </summary>
  422:         public static string StructureToSimpleTextString()
  423:         {
  424:             int siteCount, routerCount, odfCount, oltCount;
  425:             int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
  426:             string content, domainList;
  427:             string kuwaitFtnAreas;
  428:             string text;
  429:  
  430:             siteCount = routerCount = odfCount = oltCount = 0;
  431:             siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
  432:  
  433:             text = "\n";
  434:  
  435:             siteCount = 1;
  436:  
  437:             foreach (var site in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList)
  438:             {
  439:                 siteOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  440:                                 where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site
  441:                                 select o).Count();
  442:  
  443:                 if (site.Routers.Count > 0)
  444:                 {
  445:                     routerCount = 1;
  446:  
  447:                     foreach (var router in site.Routers)
  448:                     {
  449:                         routerOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  450:                                           where o.Odf != null && o.Odf.Router == router
  451:                                           select o).Count();
  452:  
  453:                         if (router.Odfs.Count > 0)
  454:                         {
  455:                             odfCount = 1;
  456:  
  457:                             foreach (var odf in router.Odfs)
  458:                             {
  459:                                 odfOltCount = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList
  460:                                                where o.Odf == odf
  461:                                                select o).Count();
  462:  
  463:                                 oltCount = 1;
  464:  
  465:                                 foreach (var olt in odf.Olts)
  466:                                 {
  467:                                     oltOltCount = odf.Olts.Count;
  468:  
  469:                                     if (routerCount == 1 && odfCount == 1 && oltCount == 1)
  470:                                     {
  471:                                         text += "\n";
  472:  
  473:                                         //text += "\n";
  474:                                         //text += "\n";
  475:                                         text += @"===========================";
  476:  
  477:                                         text += "\n";
  478:  
  479:                                         kuwaitFtnAreas = string.Empty;
  480:  
  481:                                         foreach (var ka in site.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "\n";
  482:  
  483:                                         kuwaitFtnAreas = kuwaitFtnAreas.Trim();
  484:  
  485:                                         content = site.NameArabicName;
  486:                                         content += "\n";
  487:                                         content += "\n" + string.Join(", ", site.AreaSymbolList);
  488:                                         content += "\n";
  489:                                         content += "\n" + kuwaitFtnAreas;
  490:  
  491:                                         text += content.Trim();
  492:                                     }
  493:  
  494:                                     if (odfCount == 1 && oltCount == 1)
  495:                                     {
  496:                                         //text += "\n";
  497:                                         text += "\n";
  498:  
  499:                                         //text += "| --------------------------";
  500:                                         text += "\n";
  501:  
  502:                                         domainList = string.Empty;
  503:  
  504:                                         foreach (int i in router.DomainList) domainList += i + ", ";
  505:  
  506:                                         domainList = domainList.Trim();
  507:                                         domainList = domainList.Trim(',');
  508:  
  509:                                         content = router.Vendor.Name + @" " + domainList;
  510:  
  511:                                         text += "| " + content;
  512:  
  513:                                         text += "\n";
  514:                                     }
  515:  
  516:                                     if (oltCount == 1)
  517:                                     {
  518:                                         text += "\n";
  519:  
  520:                                         //text += "\t\t\t\t\t\t--------------------------";
  521:                                         text += "| | " + odf.Name + @" (" + odf.Vendor.Name + ")";
  522:                                     }
  523:  
  524:                                     /*
  525: // field type color
  526: if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
  527:     htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  528: else /*if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)* /
  529:     htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  530:     */
  531:  
  532:                                     //text += @"====================================";
  533:  
  534:                                     oltCount++;
  535:                                 }
  536:  
  537:                                 odfCount++;
  538:                             }
  539:                         }
  540:                         else routerCount--;
  541:  
  542:                         routerCount++;
  543:                     }
  544:                 }
  545:  
  546:                 siteCount++;
  547:             }
  548:  
  549:             text += "\n";
  550:  
  551:             return text.Trim();
  552:         }
  553:  
  554:         ////////////////////////////////////////////////////////////////////////////
  555:         ////////////////////////////////////////////////////////////////////////////    
  556:     }
  557: }