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