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

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

Administration support class of Fixed Telecommunications Network (FTN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Linq;
    4: using System.Text;
    5:  
    6: namespace Ia.Ftn.Cl.Model.Business
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Administration support class of Fixed Telecommunications Network (FTN) business 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 Administration
   28:     {
   29:         private const int initialFrameworkListLength = 100;
   30:  
   31:         /// <summary/>
   32:         public static DateTime OfficialMorningStartOfWorkTime = DateTime.Parse("08:00"); // DateTime.Parse("07:00");
   33:  
   34:         /// <summary/>
   35:         public static DateTime OfficialMorningEndOfWorkTime = DateTime.Parse("14:00");
   36:  
   37:         /// <summary/>
   38:         public static DateTime OfficialEveningStartOfWorkTime = DateTime.MinValue;// DateTime.Parse("16:00");
   39:  
   40:         /// <summary/>
   41:         public static DateTime OfficialEveningEndOfWorkTime = DateTime.MinValue; // DateTime.Parse("20:00");
   42:  
   43:  
   44:         /// <summary/>
   45:         public static DateTime EarliestServiceRequestDate = DateTime.Parse("2000-01-01");
   46:  
   47:         /// <summary/>
   48:         public static DateTime SqlFriendlyJanuary1st1753NullDateTime = new DateTime(1753, 1, 1);
   49:  
   50:         /// <summary/>
   51:         public static DateTime EarliestRequestDateTime = new DateTime(1970, 1, 1);
   52:  
   53:         /// <summary/>
   54:         public static int InitialFrameworkListLength { get { return initialFrameworkListLength; } }
   55:  
   56:         /// <summary/>
   57:         public static bool ServiceSuspensionIsEnabled = true;
   58:  
   59:         ////////////////////////////////////////////////////////////////////////////
   60:  
   61:         /// <summary>
   62:         ///
   63:         /// </summary>
   64:         private static string LogoImagePng
   65:         {
   66:             get
   67:             {
   68:                 return "9.png";
   69:             }
   70:         }
   71:  
   72:         ////////////////////////////////////////////////////////////////////////////
   73:  
   74:         /// <summary>
   75:         ///
   76:         /// </summary>
   77:         public static string LogoImageUrl
   78:         {
   79:             get
   80:             {
   81:                 return "~/image/telegram/ftth-logo/" + LogoImagePng;
   82:             }
   83:         }
   84:  
   85:         ////////////////////////////////////////////////////////////////////////////
   86:  
   87:         /// <summary>
   88:         ///
   89:         /// </summary>
   90:         public static string LogoHtmlImageUrl
   91:         {
   92:             get
   93:             {
   94:                 return "../../image/telegram/ftth-logo/" + LogoImagePng;
   95:             }
   96:         }
   97:  
   98:         ////////////////////////////////////////////////////////////////////////////
   99:  
  100:         /// <summary>
  101:         ///
  102:         /// </summary>
  103:         public static string LogoImageAbsolutePathUrl
  104:         {
  105:             get
  106:             {
  107:                 return Ia.Cl.Models.Default.AbsolutePath() + @"image\telegram\ftth-logo\" + LogoImagePng;
  108:             }
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public static string OfficialWorkingTimeString()
  117:         {
  118:             string officialMorningStartOfWorkTime, officialMorningEndOfWorkTime, officialEveningStartOfWorkTime, officialEveningEndOfWorkTime;
  119:             string officialMorningWorkTime, officialEveningWorkTime;
  120:  
  121:             officialMorningStartOfWorkTime = Ia.Ftn.Cl.Model.Business.Administration.OfficialMorningStartOfWorkTime != DateTime.MinValue ? Ia.Ftn.Cl.Model.Business.Administration.OfficialMorningStartOfWorkTime.ToString("HH:mm") : string.Empty;
  122:             officialMorningEndOfWorkTime = Ia.Ftn.Cl.Model.Business.Administration.OfficialMorningEndOfWorkTime != DateTime.MinValue ? Ia.Ftn.Cl.Model.Business.Administration.OfficialMorningEndOfWorkTime.ToString("HH:mm") : string.Empty;
  123:             officialEveningStartOfWorkTime = Ia.Ftn.Cl.Model.Business.Administration.OfficialEveningStartOfWorkTime != DateTime.MinValue ? Ia.Ftn.Cl.Model.Business.Administration.OfficialEveningStartOfWorkTime.ToString("HH:mm") : string.Empty;
  124:             officialEveningEndOfWorkTime = Ia.Ftn.Cl.Model.Business.Administration.OfficialEveningEndOfWorkTime != DateTime.MinValue ? Ia.Ftn.Cl.Model.Business.Administration.OfficialEveningEndOfWorkTime.ToString("HH:mm") : string.Empty;
  125:  
  126:             if (!string.IsNullOrEmpty(officialMorningStartOfWorkTime) && !string.IsNullOrEmpty(officialMorningEndOfWorkTime))
  127:             {
  128:                 officialMorningWorkTime = officialMorningStartOfWorkTime + "-" + officialMorningEndOfWorkTime;
  129:             }
  130:             else officialMorningWorkTime = string.Empty;
  131:  
  132:             if (!string.IsNullOrEmpty(officialEveningStartOfWorkTime) && !string.IsNullOrEmpty(officialEveningEndOfWorkTime))
  133:             {
  134:                 officialEveningWorkTime = officialEveningStartOfWorkTime + "-" + officialEveningEndOfWorkTime;
  135:             }
  136:             else officialEveningWorkTime = string.Empty;
  137:  
  138:             var officialWorkingTimeString = (officialMorningWorkTime + " " + officialEveningWorkTime).Trim();
  139:  
  140:             return officialWorkingTimeString;
  141:         }
  142:  
  143:         ////////////////////////////////////////////////////////////////////////////
  144:  
  145:         /// <summary>
  146:         ///
  147:         /// </summary>
  148:         public class Framework
  149:         {
  150:             public Framework() { }
  151:  
  152:             public enum TestType
  153:             {
  154:                 وزارة_المواصلات,
  155:                 قطاع_الاتصالات_والخدمات_المساندة,
  156:                 إدارة_شبكة_الألياف_الضوئية,
  157:                 مراقبة_الدعم_الفنى_للشبكة,
  158:                 قسم_الدعم_الفني_للشبكة
  159:             };
  160:  
  161:             /// <summary/>
  162:             public string Id { get; set; }
  163:  
  164:             /// <summary/>
  165:             public int Level { get; set; }
  166:  
  167:             /// <summary/>
  168:             public string Type { get; set; }
  169:  
  170:             /// <summary/>
  171:             public string Name { get; set; }
  172:  
  173:             /// <summary/>
  174:             public string ArabicName { get; set; }
  175:  
  176:             /// <summary/>
  177:             public string Phone { get; set; }
  178:  
  179:             /// <summary/>
  180:             public string ColoredArabicName { get; set; }
  181:  
  182:             /// <summary/>
  183:             public Framework Parent { get; set; }
  184:  
  185:             /// <summary/>
  186:             public List<Framework> Ancestors { get; set; }
  187:  
  188:             /// <summary/>
  189:             public List<Framework> AncestorsOrSelf { get; set; }
  190:  
  191:             /// <summary/>
  192:             public List<Framework> Siblings { get; set; }
  193:  
  194:             /// <summary/>
  195:             public List<Framework> SiblingsOrSelf { get; set; }
  196:  
  197:             /// <summary/>
  198:             public List<Framework> Children { get; set; }
  199:  
  200:             /// <summary/>
  201:             public List<Framework> ChildrenOrSelf { get; set; }
  202:  
  203:             /// <summary/>
  204:             public List<Framework> Descendants { get; set; }
  205:  
  206:             /// <summary/>
  207:             public List<Framework> DescendantsOrSelf { get; set; }
  208:  
  209:             /// <summary/>
  210:             public List<Authority> Authorities { get; set; }
  211:  
  212:             /// <summary/>
  213:             public List<Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Site> Sites { get; set; }
  214:  
  215:             /// <summary/>
  216:             //public Ia.Cl.Models.Identity.User Role { get; set; }
  217:  
  218:             ////////////////////////////////////////////////////////////////////////////    
  219:  
  220:             /// <summary>
  221:             ///
  222:             /// </summary>
  223:             public static bool operator ==(Framework fa, Framework fb)
  224:             {
  225:                 bool b;
  226:  
  227:                 // if both are null, or both are same instance, return true.
  228:                 if (System.Object.ReferenceEquals(fa, fb)) b = true;
  229:                 // if one is null, but not both, return false.
  230:                 else if (((object)fa == null) || ((object)fb == null)) b = false;
  231:                 // true if the fields match:
  232:                 else b = fa.Id == fb.Id;
  233:  
  234:                 return b;
  235:             }
  236:  
  237:             ////////////////////////////////////////////////////////////////////////////    
  238:  
  239:             /// <summary>
  240:             ///
  241:             /// </summary>
  242:             public static bool operator !=(Framework fa, Framework fb)
  243:             {
  244:                 return !(fa == fb);
  245:             }
  246:  
  247:             ////////////////////////////////////////////////////////////////////////////    
  248:  
  249:             /// <summary>
  250:             ///
  251:             /// </summary>
  252:             public string FullyQualifiedArabicName
  253:             {
  254:                 get
  255:                 {
  256:                     string s;
  257:  
  258:                     s = string.Empty;
  259:  
  260:                     foreach (var f in this.Ancestors) s += f.ArabicName + " | ";
  261:  
  262:                     s = s + this.ArabicName;
  263:  
  264:                     return s;
  265:                 }
  266:             }
  267:  
  268:             ////////////////////////////////////////////////////////////////////////////
  269:  
  270:             /// <summary>
  271:             ///
  272:             /// </summary>
  273:             public override bool Equals(object value)
  274:             {
  275:                 return value != null && Equals(value as Framework);
  276:             }
  277:  
  278:             ////////////////////////////////////////////////////////////////////////////    
  279:  
  280:             /// <summary>
  281:             ///
  282:             /// </summary>
  283:             public int FrameworkId(int parentId, int frameworkId)
  284:             {
  285:                 return parentId * 10 + frameworkId;
  286:             }
  287:  
  288:             ////////////////////////////////////////////////////////////////////////////    
  289:  
  290:             /// <summary>
  291:             ///
  292:             /// </summary>
  293:             public static string ParentId(string frameworkId)
  294:             {
  295:                 var parentId = string.Empty;
  296:  
  297:                 if (frameworkId.Length > 2)
  298:                 {
  299:                     parentId = frameworkId.Substring(0, parentId.Length - 2);
  300:                 }
  301:  
  302:                 return parentId;
  303:             }
  304:  
  305:             ////////////////////////////////////////////////////////////////////////////    
  306:  
  307:             /// <summary>
  308:             ///
  309:             /// </summary>
  310:             public string ArabicNameBracketParentArabicNameBracket
  311:             {
  312:                 get
  313:                 {
  314:                     string name;
  315:  
  316:                     if (Parent != null) name = ArabicName + " (" + Parent.ArabicName + ")";
  317:                     else name = ArabicName;
  318:  
  319:                     return name;
  320:                 }
  321:             }
  322:  
  323:             ////////////////////////////////////////////////////////////////////////////    
  324:  
  325:             /// <summary>
  326:             ///
  327:             /// </summary>
  328:             public static List<string> CustomerServiceSectorSectionDivisionFrameworkAndStaffIdList()
  329:             {
  330:                 return FrameworkAndStaffIdByArabicNameList("قطاع خدمات المشتركين");
  331:             }
  332:  
  333:             ////////////////////////////////////////////////////////////////////////////    
  334:  
  335:             /// <summary>
  336:             ///
  337:             /// </summary>
  338:             public static List<string> TelephoneNetworkMaintenanceDepartmentFrameworkAndStaffIdList()
  339:             {
  340:                 return FrameworkAndStaffIdByArabicNameList("إدارة صيانة الشبكة الهاتفية");
  341:             }
  342:  
  343:             ////////////////////////////////////////////////////////////////////////////    
  344:  
  345:             /// <summary>
  346:             ///
  347:             /// </summary>
  348:             public static List<string> NokiaFrameworkAndStaffdList()
  349:             {
  350:                 return FrameworkAndStaffIdByArabicNameList("نوكيا");
  351:             }
  352:  
  353:             ////////////////////////////////////////////////////////////////////////////    
  354:  
  355:             /// <summary>
  356:             ///
  357:             /// </summary>
  358:             public static List<string> HuaweiFrameworkAndStaffIdList()
  359:             {
  360:                 return FrameworkAndStaffIdByArabicNameList("هواوي");
  361:             }
  362:  
  363:             ////////////////////////////////////////////////////////////////////////////    
  364:  
  365:             /// <summary>
  366:             ///
  367:             /// </summary>
  368:             public static List<string> FrameworkAndStaffIdByArabicNameList(string frameworkArabicName)
  369:             {
  370:                 var frameworkList = (from f in Ia.Ftn.Cl.Model.Data.Administration.FrameworkList
  371:                                      where f.ArabicName == frameworkArabicName || f.Ancestors.Any(u => u.ArabicName == frameworkArabicName)
  372:                                      select f.Id).ToList();
  373:  
  374:                 var staffList = (from s in Ia.Ftn.Cl.Model.Data.Staff.List
  375:                                  where frameworkList.Contains(s.Framework.Id) || s.Framework.Ancestors.Any(u => frameworkList.Contains(u.Id))
  376:                                  select s.Id).ToList();
  377:  
  378:                 var list = frameworkList.Union(staffList).ToList();
  379:  
  380:                 return list;
  381:             }
  382:  
  383:             ////////////////////////////////////////////////////////////////////////////    
  384:  
  385:             /// <summary>
  386:             ///
  387:             /// </summary>
  388:             public static List<string> FrameworkAndStaffIdList(string frameworkId)
  389:             {
  390:                 var frameworkList = (from f in Ia.Ftn.Cl.Model.Data.Administration.FrameworkList
  391:                                      where f.Id == frameworkId || f.Ancestors.Any(u => u.Id == frameworkId)
  392:                                      select f.Id).ToList();
  393:  
  394:                 var staffList = (from s in Ia.Ftn.Cl.Model.Data.Staff.List
  395:                                  where frameworkList.Contains(s.Framework.Id) || s.Framework.Ancestors.Any(u => frameworkList.Contains(u.Id))
  396:                                  select s.Id).ToList();
  397:  
  398:                 var list = frameworkList.Union(staffList).ToList();
  399:  
  400:                 return list;
  401:             }
  402:  
  403:             ////////////////////////////////////////////////////////////////////////////    
  404:  
  405:             /// <summary>
  406:             ///
  407:             /// </summary>
  408:             public static List<string> FrameworkAndStaffIdList()
  409:             {
  410:                 var frameworkList = (from f in Ia.Ftn.Cl.Model.Data.Administration.FrameworkList
  411:                                      select f.Id).ToList();
  412:  
  413:                 var staffList = (from s in Ia.Ftn.Cl.Model.Data.Staff.List
  414:                                  where frameworkList.Contains(s.Framework.Id) || s.Framework.Ancestors.Any(u => frameworkList.Contains(u.Id))
  415:                                  select s.Id).ToList();
  416:  
  417:                 var list = frameworkList.Union(staffList).ToList();
  418:  
  419:                 return list;
  420:             }
  421:  
  422:             ////////////////////////////////////////////////////////////////////////////    
  423:             ////////////////////////////////////////////////////////////////////////////    
  424:         }
  425:  
  426:         ////////////////////////////////////////////////////////////////////////////
  427:  
  428:         /// <summary>
  429:         ///
  430:         /// </summary>
  431:         public class Category
  432:         {
  433:             /// <summary/>
  434:             public Category() { }
  435:             /// <summary/>
  436:             public string Name { get; set; }
  437:             /// <summary/>
  438:             public string Description { get; set; }
  439:             /// <summary/>
  440:             public string Regex { get; set; }
  441:             /// <summary/>
  442:             public string Color { get; set; }
  443:         }
  444:  
  445:         ////////////////////////////////////////////////////////////////////////////
  446:  
  447:         /// <summary>
  448:         ///
  449:         /// </summary>
  450:         public class StaffFramework
  451:         {
  452:             private bool isStaff;
  453:  
  454:             /// <summary/>
  455:             public StaffFramework() { }
  456:  
  457:             /// <summary/>
  458:             public string Id { get; set; }
  459:  
  460:             /// <summary/>
  461:             public string FrameworkId { get; set; }
  462:  
  463:             /// <summary/>
  464:             public string Name { get; set; }
  465:  
  466:             /// <summary/>
  467:             public bool IsStaff
  468:             {
  469:                 get { return isStaff; }
  470:                 set { isStaff = true; }
  471:             }
  472:  
  473:             /// <summary/>
  474:             public bool IsFramework
  475:             {
  476:                 get { return !isStaff; }
  477:                 set { isStaff = false; }
  478:             }
  479:         }
  480:  
  481:         ////////////////////////////////////////////////////////////////////////////
  482:         ////////////////////////////////////////////////////////////////////////////
  483:  
  484:         /// <summary>
  485:         ///
  486:         /// </summary>
  487:         public class Statistic
  488:         {
  489:             /// <summary/>
  490:             public Statistic() { }
  491:  
  492:             public class Site
  493:             {
  494:                 /// <summary/>
  495:                 public string Id { get; set; }
  496:  
  497:                 /// <summary/>
  498:                 public string Name { get; set; }
  499:  
  500:                 /// <summary/>
  501:                 public string NameArabicName { get; set; }
  502:  
  503:                 /// <summary/>
  504:                 public string KuwaitAreaNameListString { get; set; }
  505:  
  506:                 /// <summary/>
  507:                 public string PstnDomainListString { get; set; }
  508:  
  509:                 /// <summary/>
  510:                 public string DomainListString { get; set; }
  511:  
  512:                 /// <summary/>
  513:                 public string SymbolListString { get; set; }
  514:  
  515:                 /// <summary/>
  516:                 public int FiberAccessCapacity { get; set; }
  517:  
  518:                 /// <summary/>
  519:                 public int FiberServiceCapacity { get; set; }
  520:  
  521:                 /// <summary/>
  522:                 public int FiberService { get; set; }
  523:  
  524:                 /// <summary/>
  525:                 public int NokiaService { get; set; }
  526:  
  527:                 /// <summary/>
  528:                 public int HuaweiService { get; set; }
  529:  
  530:                 /// <summary/>
  531:                 public string FiberServiceText { get; set; }
  532:  
  533:                 /// <summary/>
  534:                 public int Service { get; set; }
  535:  
  536:                 /// <summary/>
  537:                 public string ServiceText { get; set; }
  538:  
  539:                 /// <summary/>
  540:                 public string MsanDomainListString { get; set; }
  541:  
  542:                 /// <summary/>
  543:                 public int MsanServiceCapacity { get; set; }
  544:  
  545:                 /// <summary/>
  546:                 public int MsanService { get; set; }
  547:  
  548:                 /// <summary/>
  549:                 public string MsanServiceText { get; set; }
  550:  
  551:                 /// <summary/>
  552:                 public int PstnService { get; set; }
  553:  
  554:                 /// <summary/>
  555:                 public int EricssonPstnService { get; set; }
  556:  
  557:                 /// <summary/>
  558:                 public int SiemensPstnService { get; set; }
  559:  
  560:                 /// <summary/>
  561:                 public string EricssonSiemensPstnServiceText { get; set; }
  562:  
  563:                 ////////////////////////////////////////////////////////////////////////////
  564:  
  565:                 /// <summary>
  566:                 ///
  567:                 /// </summary>
  568:                 public string ToSimpleTextString()
  569:                 {
  570:                     StringBuilder sb;
  571:  
  572:                     sb = new StringBuilder();
  573:  
  574:                     sb.AppendLine("Site: " + this.NameArabicName);
  575:                     sb.AppendLine("Areas: " + this.KuwaitAreaNameListString);
  576:                     sb.AppendLine("PSTN Domains: " + this.PstnDomainListString);
  577:                     sb.AppendLine("PSTN Service (Ericsson/Siemens): " + this.EricssonSiemensPstnServiceText);
  578:                     sb.AppendLine("MSAN Domains: " + this.MsanDomainListString);
  579:                     sb.AppendLine("MSAN Service Capacity: " + this.MsanServiceCapacity);
  580:                     sb.AppendLine("MSAN Service: " + this.MsanServiceText);
  581:                     sb.AppendLine("Domains: " + this.DomainListString);
  582:                     sb.AppendLine("Symbols: " + this.SymbolListString);
  583:                     sb.AppendLine("Fiber Access Capacity: " + this.FiberAccessCapacity);
  584:                     sb.AppendLine("Fiber Service Capacity: " + this.FiberServiceCapacity);
  585:                     sb.AppendLine("Fiber Service (Nokia/Huawei): " + this.FiberServiceText);
  586:                     sb.AppendLine("Service: " + this.ServiceText);
  587:  
  588:                     return sb.ToString();
  589:                 }
  590:  
  591:                 ////////////////////////////////////////////////////////////////////////////
  592:                 ////////////////////////////////////////////////////////////////////////////
  593:             }
  594:  
  595:             public class KuwaitArea
  596:             {
  597:                 /// <summary/>
  598:                 public KuwaitArea() { }
  599:  
  600:                 /// <summary/>
  601:                 public KuwaitArea(string name, string arabicName)
  602:                 {
  603:                     this.Name = name + " (" + arabicName + ")";
  604:                 }
  605:  
  606:                 /// <summary/>
  607:                 public string Id { get; set; }
  608:  
  609:                 /// <summary/>
  610:                 public string Name { get; set; }
  611:  
  612:                 /// <summary/>
  613:                 public string Symbol { get; set; }
  614:  
  615:                 /// <summary/>
  616:                 public int AccessCapacity { get; set; }
  617:  
  618:                 /// <summary/>
  619:  
  620:                 public int NokiaOnt { get; set; }
  621:                 /// <summary/>
  622:  
  623:                 public int HuaweiOnt { get; set; }
  624:                 /// <summary/>
  625:  
  626:                 public string NokiaHuaweiOnt { get; set; }
  627:  
  628:                 /// <summary/>
  629:                 public int NokiaAccess { get; set; }
  630:  
  631:                 /// <summary/>
  632:                 public int HuaweiAccess { get; set; }
  633:  
  634:                 /// <summary/>
  635:                 public string NokiaHuaweiAccess { get; set; }
  636:  
  637:                 /// <summary/>
  638:                 public int ServiceRequestService { get; set; }
  639:  
  640:                 /// <summary/>
  641:                 public int Service { get; set; }
  642:  
  643:                 /// <summary/>
  644:                 public int NokiaService { get; set; }
  645:  
  646:                 /// <summary/>
  647:                 public int HuaweiService { get; set; }
  648:  
  649:                 /// <summary/>
  650:                 public string NokiaHuaweiService { get; set; }
  651:  
  652:                 /// <summary/>
  653:                 public int AccessReady { get; set; }
  654:  
  655:                 /// <summary/>
  656:                 public int AccessUsed { get; set; }
  657:  
  658:                 /// <summary/>
  659:                 public string AccessReadyUsed { get; set; }
  660:  
  661:                 ////////////////////////////////////////////////////////////////////////////
  662:  
  663:                 /// <summary>
  664:                 ///
  665:                 /// </summary>
  666:                 public string ToSimpleTextString()
  667:                 {
  668:                     StringBuilder sb;
  669:  
  670:                     sb = new StringBuilder();
  671:  
  672:                     sb.AppendLine("Name: " + this.Name);
  673:                     sb.AppendLine("Symbol: " + this.Symbol);
  674:                     sb.AppendLine("Access Capacity: " + this.AccessCapacity);
  675:                     sb.AppendLine("Access (Nokia/Huawei): " + this.NokiaHuaweiAccess);
  676:                     sb.AppendLine("ONT/ONU (Nokia/Huawei): " + this.NokiaHuaweiOnt);
  677:                     sb.AppendLine("Access (Ready/Used): " + this.AccessReadyUsed);
  678:                     sb.AppendLine("Service Request Services: " + this.ServiceRequestService);
  679:                     sb.AppendLine("Service (Nokia/Huawei): " + this.NokiaHuaweiService);
  680:  
  681:                     return sb.ToString();
  682:                 }
  683:  
  684:                 ////////////////////////////////////////////////////////////////////////////
  685:                 ////////////////////////////////////////////////////////////////////////////
  686:             }
  687:         }
  688:  
  689:         ////////////////////////////////////////////////////////////////////////////
  690:  
  691:         /// <summary>
  692:         ///
  693:         /// </summary>
  694:         public Administration() { }
  695:  
  696:         /// <summary/>
  697:         public static bool NowIsOfficialWorkingTime
  698:         {
  699:             get
  700:             {
  701:                 bool b;
  702:                 DateTime now;
  703:  
  704:                 now = DateTime.UtcNow.AddHours(3);
  705:  
  706:                 b = now.DayOfWeek != DayOfWeek.Friday && now.DayOfWeek != DayOfWeek.Saturday &&
  707:                     (
  708:                     now.TimeOfDay >= OfficialMorningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialMorningEndOfWorkTime.TimeOfDay
  709:                     ||
  710:                     now.TimeOfDay >= OfficialEveningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialEveningEndOfWorkTime.TimeOfDay
  711:                     );
  712:  
  713:                 return b;
  714:             }
  715:         }
  716:  
  717:         ////////////////////////////////////////////////////////////////////////////    
  718:  
  719:         /// <summary>
  720:         ///
  721:         /// </summary>
  722:         public static bool IsFrameworkId(string id)
  723:         {
  724:             bool isFrameworkId;
  725:  
  726:             isFrameworkId = (id.ToString().Substring(0, 9) == "00000000-") ? true : false;
  727:  
  728:             return isFrameworkId;
  729:         }
  730:  
  731:         ////////////////////////////////////////////////////////////////////////////    
  732:  
  733:         /// <summary>
  734:         ///
  735:         /// </summary>
  736:         public static List<Ia.Ftn.Cl.Model.Business.Administration.Framework> FrameworkListOfAllowedReportAssignsByStaff(Ia.Ftn.Cl.Model.Staff staff)
  737:         {
  738:             List<Ia.Ftn.Cl.Model.Business.Administration.Framework> frameworkList;
  739:  
  740:             frameworkList = new List<Ia.Ftn.Cl.Model.Business.Administration.Framework>();
  741:  
  742:             frameworkList.AddRange(staff.Framework.Children);
  743:             frameworkList.AddRange(staff.Framework.Siblings);
  744:  
  745:             return frameworkList;
  746:         }
  747:  
  748:         ////////////////////////////////////////////////////////////////////////////    
  749:  
  750:         /// <summary>
  751:         ///
  752:         /// </summary>
  753:         public static bool FrameworkHasAHead(Ia.Ftn.Cl.Model.Business.Administration.Framework framework)
  754:         {
  755:             bool hasHead;
  756:  
  757:             if (framework != null)
  758:             {
  759:                 hasHead = (from s in Ia.Ftn.Cl.Model.Data.Staff.List where s.Framework.Id == framework.Id select s).Any(u => u.IsHead);
  760:             }
  761:             else hasHead = false;
  762:  
  763:             return hasHead;
  764:         }
  765:  
  766:         ////////////////////////////////////////////////////////////////////////////
  767:  
  768:         /// <summary>
  769:         ///
  770:         /// </summary>
  771:         public class StaffContact
  772:         {
  773:             private Ia.Ftn.Cl.Model.Staff staff;
  774:             private Ia.Ftn.Cl.Model.Contact contact;
  775:             private string email;
  776:             private string apiKey;
  777:             private string userId;
  778:  
  779:             /// <summary/>
  780:             public StaffContact() { }
  781:  
  782:             /// <summary/>
  783:             public Ia.Ftn.Cl.Model.Staff Staff
  784:             {
  785:                 get
  786:                 {
  787:                     return staff;
  788:                 }
  789:  
  790:                 set
  791:                 {
  792:                     staff = value;
  793:  
  794:                     var v = this.FullName;
  795:                     var w = this.Email;
  796:                     var x = this.UserId;
  797:                     var y = this.ApiKey;
  798:                 }
  799:             }
  800:  
  801:             /// <summary/>
  802:             public Ia.Ftn.Cl.Model.Contact Contact
  803:             {
  804:                 get
  805:                 {
  806:                     return contact;
  807:                 }
  808:  
  809:                 set
  810:                 {
  811:                     contact = value;
  812:  
  813:                     var v = this.FullName;
  814:                     var w = this.Email;
  815:                     var x = this.UserId;
  816:                     var y = this.ApiKey;
  817:                 }
  818:             }
  819:  
  820:             /// <summary/>
  821:             public string FullName
  822:             {
  823:                 get
  824:                 {
  825:                     string name;
  826:  
  827:                     if (staff != null) name = staff.FullName;
  828:                     else if (contact != null) name = contact.FullName;
  829:                     else name = string.Empty;
  830:  
  831:                     return name;
  832:                 }
  833:             }
  834:  
  835:             /// <summary/>
  836:             public string Email
  837:             {
  838:                 get
  839:                 {
  840:                     if (staff != null && staff.IdentityUser != null) email = staff.IdentityUser.Email;
  841:                     else if (contact != null) email = contact.Email;
  842:                     else email = string.Empty;
  843:  
  844:                     return email;
  845:                 }
  846:             }
  847:  
  848:             /// <summary/>
  849:             public string UserId
  850:             {
  851:                 get
  852:                 {
  853:                     if (staff != null) userId = staff.Id;
  854:                     else if (contact != null) userId = contact.UserId;
  855:                     else userId = string.Empty;
  856:  
  857:                     return userId;
  858:                 }
  859:             }
  860:  
  861:             /// <summary/>
  862:             public string ApiKey
  863:             {
  864:                 get
  865:                 {
  866:                     if (staff != null && staff.IdentityUser != null) apiKey = UserId.ToString().Substring(0, 8);
  867:                     else if (contact != null) apiKey = UserId.ToString().Substring(0, 8);
  868:                     else apiKey = string.Empty;
  869:  
  870:                     return apiKey;
  871:                 }
  872:             }
  873:  
  874:             /// <summary/>
  875:             public bool IsApproved
  876:             {
  877:                 get
  878:                 {
  879:                     return !string.IsNullOrEmpty(email); // && contact.IsApproved;
  880:                 }
  881:             }
  882:  
  883:             ////////////////////////////////////////////////////////////////////////////
  884:             ////////////////////////////////////////////////////////////////////////////    
  885:         }
  886:     }
  887:  
  888:     ////////////////////////////////////////////////////////////////////////////
  889:     ////////////////////////////////////////////////////////////////////////////   
  890: }