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

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.Model.Ui.Administration
    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-2021 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 Framework
   28:     {
   29:         private static Ia.Ftn.Cl.Model.Staff headStaff;
   30:         private static List<Ia.Ftn.Cl.Model.Staff> staffList;
   31:  
   32:         ////////////////////////////////////////////////////////////////////////////
   33:  
   34:         /// <summary>
   35:         ///
   36:         /// </summary>
   37:         public Framework() { }
   38:  
   39:         ////////////////////////////////////////////////////////////////////////////    
   40:  
   41:         /// <summary>
   42:         /// 
   43:         /// </summary>
   44:         public static string FrameworkStructureDataTable()
   45:         {
   46:             string htmlTable;
   47:             List<Ia.Ftn.Cl.Model.Business.Administration.Framework> frameworkList;
   48:  
   49:             frameworkList = (from f in Ia.Ftn.Cl.Model.Data.Administration.FrameworkList
   50:                              where f.Type == "ministry" || f.Type == "supplier"
   51:                              select f).ToList();
   52:  
   53:             htmlTable = @"<div id=""framework-structure"">";
   54:  
   55:             foreach (Ia.Ftn.Cl.Model.Business.Administration.Framework framework in frameworkList)
   56:             {
   57:                 htmlTable += FrameworkStructureDataTableIteration(framework);
   58:             }
   59:  
   60:             htmlTable += "</div>";
   61:  
   62:             return htmlTable;
   63:         }
   64:  
   65:         ////////////////////////////////////////////////////////////////////////////    
   66:  
   67:         /// <summary>
   68:         /// 
   69:         /// </summary>
   70:         private static string FrameworkStructureDataTableIteration(Ia.Ftn.Cl.Model.Business.Administration.Framework framework)
   71:         {
   72:             string htmlTable;
   73:             Ia.Ftn.Cl.Model.Staff headStaff;
   74:             List<Ia.Ftn.Cl.Model.Staff> staffList;
   75:  
   76:             htmlTable = null;
   77:  
   78:             if (framework != null)
   79:             {
   80:                 headStaff = (from s in Ia.Ftn.Cl.Model.Data.Staff.List where s.Framework != null && s.Framework.Id == framework.Id && s.IsHead select s).SingleOrDefault();
   81:  
   82:                 htmlTable = "<table>";
   83:  
   84:                 if (framework.Children.Count > 0)
   85:                 {
   86:                     htmlTable += "<tr>";
   87:  
   88:                     htmlTable += @"<td class=""" + framework.Type + @""" colspan=""" + framework.Children.Count + @""">" + framework.ArabicName;
   89:                     if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
   90:                     htmlTable += @"</td>";
   91:  
   92:                     htmlTable += "</tr>";
   93:  
   94:                     htmlTable += "<tr>";
   95:  
   96:                     foreach (Ia.Ftn.Cl.Model.Business.Administration.Framework f in framework.Children)
   97:                     {
   98:                         htmlTable += @"<td class=""" + f.Type + @""">" + FrameworkStructureDataTableIteration(f) + "</td>";
   99:                     }
  100:  
  101:                     htmlTable += "</tr>";
  102:                 }
  103:                 else
  104:                 {
  105:                     staffList = (from s in Ia.Ftn.Cl.Model.Data.Staff.List
  106:                                  where s.Framework != null && s.Framework.Id == framework.Id && !s.IsHead
  107:                                  select s).ToList();
  108:  
  109:                     htmlTable += "<tr>";
  110:  
  111:                     htmlTable += @"<td class=""" + framework.Type + @""">" + framework.ArabicName;
  112:                     if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
  113:  
  114:                     foreach (Ia.Ftn.Cl.Model.Staff staff in staffList)
  115:                     {
  116:                         htmlTable += @"<span class=""staff"">" + staff.FirstAndMiddleName + "</span>";
  117:                     }
  118:  
  119:                     htmlTable += @"</td>";
  120:  
  121:                     htmlTable += "</tr>";
  122:                 }
  123:  
  124:                 htmlTable += "</table>";
  125:             }
  126:  
  127:             return htmlTable;
  128:         }
  129:  
  130:         ////////////////////////////////////////////////////////////////////////////
  131:         ////////////////////////////////////////////////////////////////////////////    
  132:  
  133:         /// <summary>
  134:         /// 
  135:         /// </summary>
  136:         public static string StructureDataTable()
  137:         {
  138:             int companyCount, sectorCount, departmentCount, divisionCount, sectionCount;
  139:             int companySectionCount, sectorSectionCount, departmentSectionCount, divisionSectionCount, sectionSectionCount;
  140:             string htmlTable;
  141:  
  142:             companyCount = sectorCount = departmentCount = divisionCount = sectionCount = 0;
  143:             companySectionCount = sectorSectionCount = departmentSectionCount = divisionSectionCount = sectionSectionCount = 0;
  144:  
  145:             staffList = Ia.Ftn.Cl.Model.Data.Staff.List;
  146:  
  147:             htmlTable = @"<div id=""framework-structure"">";
  148:  
  149:             htmlTable += "<table>";
  150:  
  151:             companyCount = 1;
  152:  
  153:             var companyList = Ia.Ftn.Cl.Model.Data.Administration.FrameworkList.Where(u => u.Type == "ministry" || u.Type == "supplier").ToList();
  154:  
  155:             foreach (var company in companyList)
  156:             {
  157:                 companySectionCount = (from d in company.Descendants where d.Type == "section" select d).Count();
  158:  
  159:                 var sectorList = (from d in company.Children where d.Type == "sector" select d).ToList();
  160:  
  161:                 if (sectorList.Count > 0)
  162:                 {
  163:                     sectorCount = 1;
  164:  
  165:                     foreach (var sector in sectorList)
  166:                     {
  167:                         sectorSectionCount = (from d in sector.Descendants where d.Type == "section" select d).Count();
  168:  
  169:                         var departmentList = (from d in sector.Children where d.Type == "department" select d).ToList();
  170:  
  171:                         if (departmentList.Count > 0)
  172:                         {
  173:                             departmentCount = 1;
  174:  
  175:                             foreach (var department in departmentList)
  176:                             {
  177:                                 departmentSectionCount = (from d in department.Descendants where d.Type == "section" select d).Count();
  178:  
  179:                                 var divisionList = (from d in department.Children where d.Type == "division" select d).ToList();
  180:  
  181:                                 if (divisionList.Count > 0)
  182:                                 {
  183:                                     divisionCount = 1;
  184:  
  185:                                     foreach (var division in divisionList)
  186:                                     {
  187:                                         divisionSectionCount = (from d in division.Descendants where d.Type == "section" select d).Count();
  188:  
  189:                                         var sectionList = (from d in division.Children where d.Type == "section" select d).ToList();
  190:  
  191:                                         if (sectionList.Count > 0)
  192:                                         {
  193:                                             sectionCount = 1;
  194:  
  195:                                             foreach (var section in sectionList)
  196:                                             {
  197:                                                 sectionSectionCount = sectionList.Count;
  198:  
  199:                                                 htmlTable += @"<tr class=company" + companyCount + ">";
  200:  
  201:                                                 if (sectorCount == 1 && departmentCount == 1 && divisionCount == 1 && sectionCount == 1)
  202:                                                 {
  203:                                                     htmlTable += "<td class=company rowspan=" + companySectionCount + ">" + CompanyStructureDataTable(company) + "</td>";
  204:                                                     //htmlTable += "<td class=pstn rowspan=" + companySectionCount + ">" + PstnStructureDataTable(company.Pstns) + "</td>";
  205:                                                 }
  206:  
  207:                                                 if (departmentCount == 1 && divisionCount == 1 && sectionCount == 1) htmlTable += "<td class=sector rowspan=" + sectorSectionCount + ">" + SectorStructureDataTable(sector) + "</td>";
  208:  
  209:                                                 if (divisionCount == 1 && sectionCount == 1) htmlTable += "<td class=department rowspan=" + departmentSectionCount + ">" + DepartmentStructureDataTable(department) + "</td>";
  210:  
  211:                                                 if (sectionCount == 1) htmlTable += "<td class=division rowspan=" + divisionSectionCount + ">" + DivisionStructureDataTable(division) + "</td>";
  212:  
  213:                                                 // field type color
  214:                                                 //if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
  215:                                                 htmlTable += @"<td class=section>" + SectionStructureDataTable(section) + "</td>";
  216:                                                 //else /*if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)*/
  217:                                                 //    htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  218:  
  219:                                                 htmlTable += @"</tr>";
  220:  
  221:                                                 sectionCount++;
  222:                                             }
  223:                                         }
  224:                                         else divisionCount--;
  225:  
  226:                                         divisionCount++;
  227:                                     }
  228:                                 }
  229:                                 else departmentCount--;
  230:  
  231:                                 departmentCount++;
  232:                             }
  233:                         }
  234:                         else sectorCount--;
  235:  
  236:                         sectorCount++;
  237:                     }
  238:                 }
  239:                 else companyCount--;
  240:  
  241:                 companyCount++;
  242:             }
  243:  
  244:             htmlTable += "</table>";
  245:  
  246:             htmlTable += "</div>";
  247:  
  248:             return htmlTable;
  249:         }
  250:  
  251:         ////////////////////////////////////////////////////////////////////////////    
  252:  
  253:         /// <summary>
  254:         /// 
  255:         /// </summary>
  256:         private static string CompanyStructureDataTable(Ia.Ftn.Cl.Model.Business.Administration.Framework company)
  257:         {
  258:             string content; //, kuwaitFtnAreas;
  259:  
  260:             //kuwaitFtnAreas = string.Empty;
  261:  
  262:             //foreach (Ia.Ftn.Cl.Model.Business.Service.KuwaitFtnArea ka in company.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "<br />";
  263:  
  264:             //kuwaitFtnAreas = kuwaitFtnAreas.Trim(',');
  265:  
  266:             content = company.ArabicName;
  267:  
  268:             headStaff = (from s in staffList where s.Framework.Id == company.Id && s.IsHead select s).SingleOrDefault();
  269:             if (headStaff != null) content += @"<br />" + headStaff.FullName;
  270:  
  271:             //string.Join(", ", company.AreaSymbolList);
  272:             //content += @"<br />" + kuwaitFtnAreas;
  273:  
  274:             return content;
  275:         }
  276:  
  277:         ////////////////////////////////////////////////////////////////////////////    
  278:  
  279:         /// <summary>
  280:         /// 
  281:         /// </summary>
  282:         private static string PstnStructureDataTable(ICollection<Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Pstn> pstnList)
  283:         {
  284:             string content;
  285:  
  286:             var list = pstnList.ToList();
  287:  
  288:             content = string.Empty;
  289:  
  290:             foreach (var pstn in list)
  291:             {
  292:                 content += pstn.Name + " (نحاس) (" + pstn.PstnExchangeType + ")";
  293:                 content += @"<br />";
  294:                 content += string.Join(", ", pstn.DomainList);
  295:                 content += "<br />";
  296:                 content += @" Uses NP/LNP/SPS Server?: " + Ia.Cl.Models.Default.YesNo(pstn.UsesNpServer) + " ";
  297:  
  298:                 content += @"<br />";
  299:                 content += @"<br />";
  300:             }
  301:  
  302:             return content;
  303:         }
  304:  
  305:         ////////////////////////////////////////////////////////////////////////////    
  306:  
  307:         /// <summary>
  308:         /// 
  309:         /// </summary>
  310:         private static string SectorStructureDataTable(Ia.Ftn.Cl.Model.Business.Administration.Framework sector)
  311:         {
  312:             string content;//, domainList;
  313:  
  314:             //domainList = string.Empty;
  315:  
  316:             //foreach (int i in sector.DomainList) domainList += i + ", ";
  317:  
  318:             //domainList = domainList.Trim();
  319:             //domainList = domainList.Trim(',');
  320:  
  321:             content = sector.ArabicName; //.Vendor.Name;
  322:  
  323:             headStaff = (from s in staffList where s.Framework.Id == sector.Id && s.IsHead select s).SingleOrDefault();
  324:             if (headStaff != null) content += @"<br />" + headStaff.FullName;
  325:  
  326:             //content += @"<br />" + domainList;
  327:  
  328:             return content;
  329:         }
  330:  
  331:         ////////////////////////////////////////////////////////////////////////////    
  332:  
  333:         /// <summary>
  334:         /// 
  335:         /// </summary>
  336:         private static string DepartmentStructureDataTable(Ia.Ftn.Cl.Model.Business.Administration.Framework department)
  337:         {
  338:             string content;
  339:  
  340:             content = department.ArabicName; //.Name + @"<br />" + department.Vendor.Name;
  341:  
  342:             headStaff = (from s in staffList where s.Framework.Id == department.Id && s.IsHead select s).SingleOrDefault();
  343:             if (headStaff != null) content += @"<br />" + headStaff.FullName;
  344:  
  345:             return content;
  346:         }
  347:  
  348:         ////////////////////////////////////////////////////////////////////////////    
  349:  
  350:         /// <summary>
  351:         /// 
  352:         /// </summary>
  353:         private static string DivisionStructureDataTable(Ia.Ftn.Cl.Model.Business.Administration.Framework division)
  354:         {
  355:             string content;
  356:  
  357:             content = division.ArabicName; //.Name + @"<br />" + department.Vendor.Name;
  358:  
  359:             headStaff = (from s in staffList where s.Framework.Id == division.Id && s.IsHead select s).SingleOrDefault();
  360:             if (headStaff != null) content += @"<br />" + headStaff.FullName;
  361:  
  362:             return content;
  363:         }
  364:  
  365:         ////////////////////////////////////////////////////////////////////////////    
  366:  
  367:         /// <summary>
  368:         /// 
  369:         /// </summary>
  370:         private static string SectionStructureDataTable(Ia.Ftn.Cl.Model.Business.Administration.Framework section)
  371:         {
  372:             string content;
  373:             List<int> ponlist, proposedPonList;
  374:             Dictionary<string, List<int>> dic;
  375:  
  376:             proposedPonList = new List<int>();
  377:             dic = new Dictionary<string, List<int>>();
  378:  
  379:             content = section.ArabicName; //.Symbol;
  380:  
  381:             headStaff = (from s in staffList where s.Framework.Id == section.Id && s.IsHead select s).SingleOrDefault();
  382:             if (headStaff != null) content += @"<br />" + headStaff.FullName;
  383:  
  384:             var sectionStaffList = (from s in staffList where s.Framework.Id == section.Id && !s.IsHead select s).ToList();
  385:             if (sectionStaffList.Count > 0) content += @"<br /><br />" + string.Join("<br />", sectionStaffList.Select(u => u.FullName));
  386:  
  387:             /*
  388:             content += @" (" + section.AmsName + ") ";
  389: 
  390:             content += "<br />";
  391:             content += @" SIP?: " + Ia.Cl.Models.Default.YesNo(section.IsSip) + " ";
  392: 
  393:             foreach (var ponGroup in section.PonGroupList)
  394:             {
  395:                 ponlist = new List<int>();
  396: 
  397:                 foreach (int i in ponGroup.UsedPonInPonGroupList) if (i != 0) ponlist.Add(i);
  398: 
  399:                 if (!dic.ContainsKey(ponGroup.Symbol))
  400:                 {
  401:                     dic[ponGroup.Symbol] = ponlist;
  402:                 }
  403:                 else dic[ponGroup.Symbol].AddRange(ponlist);
  404: 
  405:                 /*
  406:                 if (ponGroup.HasNewProposedPonList) foreach (int i in ponGroup.UsedProposedPonInPonGroupList) if (i != 0) proposedPonList.Add(i);
  407: 
  408:                 if (proposedPonList.Count > 0)
  409:                 {
  410:                     content += @"(Proposed): " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(proposedPonList) + "</b>";
  411:                 }
  412:                 * /
  413:             }
  414: 
  415:             foreach (var kvp in dic)
  416:             {
  417:                 content += "<br />";
  418:                 content += kvp.Key + @": " + Ia.Cl.Models.Default.ConvertNumberListToHyphenAndCommaSeperatedNumberString(kvp.Value) + " ";
  419:             }
  420:             */
  421:  
  422:             //content += @" (" + olt.PonListString + ") ";
  423:  
  424:             return content;
  425:         }
  426:  
  427:         ////////////////////////////////////////////////////////////////////////////
  428:         ////////////////////////////////////////////////////////////////////////////
  429:  
  430:         /// <summary>
  431:         /// 
  432:         /// </summary>
  433:         public static string StructureToSimpleTextString()
  434:         {
  435:             int siteCount, routerCount, odfCount, oltCount;
  436:             int siteOltCount, routerOltCount, odfOltCount, oltOltCount;
  437:             string content, domainList;
  438:             string kuwaitFtnAreas;
  439:             string text;
  440:  
  441:             siteCount = routerCount = odfCount = oltCount = 0;
  442:             siteOltCount = routerOltCount = odfOltCount = oltOltCount = 0;
  443:  
  444:             text = "\n";
  445:  
  446:             siteCount = 1;
  447:  
  448:             foreach (Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Site site in Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.SiteList)
  449:             {
  450:                 siteOltCount = (from o in Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OltList
  451:                                 where o.Odf != null && o.Odf.Router != null && o.Odf.Router.Site == site
  452:                                 select o).Count();
  453:  
  454:                 if (site.Routers.Count > 0)
  455:                 {
  456:                     routerCount = 1;
  457:  
  458:                     foreach (Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Router router in site.Routers)
  459:                     {
  460:                         routerOltCount = (from o in Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OltList
  461:                                           where o.Odf != null && o.Odf.Router == router
  462:                                           select o).Count();
  463:  
  464:                         if (router.Odfs.Count > 0)
  465:                         {
  466:                             odfCount = 1;
  467:  
  468:                             foreach (Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Odf odf in router.Odfs)
  469:                             {
  470:                                 odfOltCount = (from o in Ia.Ftn.Cl.Model.Data.NetworkDesignDocument.OltList
  471:                                                where o.Odf == odf
  472:                                                select o).Count();
  473:  
  474:                                 oltCount = 1;
  475:  
  476:                                 foreach (Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Olt olt in odf.Olts)
  477:                                 {
  478:                                     oltOltCount = odf.Olts.Count;
  479:  
  480:                                     if (routerCount == 1 && odfCount == 1 && oltCount == 1)
  481:                                     {
  482:                                         text += "\n";
  483:  
  484:                                         //text += "\n";
  485:                                         //text += "\n";
  486:                                         text += @"===========================";
  487:  
  488:                                         text += "\n";
  489:  
  490:                                         kuwaitFtnAreas = string.Empty;
  491:  
  492:                                         foreach (Ia.Ftn.Cl.Model.Business.Service.KuwaitFtnArea ka in site.KuwaitFtnAreas) kuwaitFtnAreas += ka.NameArabicName + "\n";
  493:  
  494:                                         kuwaitFtnAreas = kuwaitFtnAreas.Trim();
  495:  
  496:                                         content = site.NameArabicName;
  497:                                         content += "\n";
  498:                                         content += "\n" + string.Join(", ", site.AreaSymbolList);
  499:                                         content += "\n";
  500:                                         content += "\n" + kuwaitFtnAreas;
  501:  
  502:                                         text += content.Trim();
  503:                                     }
  504:  
  505:                                     if (odfCount == 1 && oltCount == 1)
  506:                                     {
  507:                                         //text += "\n";
  508:                                         text += "\n";
  509:  
  510:                                         //text += "| --------------------------";
  511:                                         text += "\n";
  512:  
  513:                                         domainList = string.Empty;
  514:  
  515:                                         foreach (int i in router.DomainList) domainList += i + ", ";
  516:  
  517:                                         domainList = domainList.Trim();
  518:                                         domainList = domainList.Trim(',');
  519:  
  520:                                         content = router.Vendor.Name + @" " + domainList;
  521:  
  522:                                         text += "| " + content;
  523:  
  524:                                         text += "\n";
  525:                                     }
  526:  
  527:                                     if (oltCount == 1)
  528:                                     {
  529:                                         text += "\n";
  530:  
  531:                                         //text += "\t\t\t\t\t\t--------------------------";
  532:                                         text += "| | " + odf.Name + @" (" + odf.Vendor.Name + ")";
  533:                                     }
  534:  
  535:                                     /*
  536: // field type color
  537: if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green)
  538:     htmlTable += @"<td style=""background-color:green""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  539: else /*if (olt.FieldType == Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown)* /
  540:     htmlTable += @"<td style=""background-color:brown""> </td><td class=olt>" + OltStructureDataTable(olt) + "</td>";
  541:     */
  542:  
  543:                                     //text += @"====================================";
  544:  
  545:                                     oltCount++;
  546:                                 }
  547:  
  548:                                 odfCount++;
  549:                             }
  550:                         }
  551:                         else routerCount--;
  552:  
  553:                         routerCount++;
  554:                     }
  555:                 }
  556:  
  557:                 siteCount++;
  558:             }
  559:  
  560:             text += "\n";
  561:  
  562:             return text.Trim();
  563:         }
  564:  
  565:         ////////////////////////////////////////////////////////////////////////////
  566:         ////////////////////////////////////////////////////////////////////////////    
  567:     }
  568: }