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