Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Administration

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

Administration support class of Next Generation Network'a (NGN's) business model.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.Linq;
   5:  using System.IO;
   6:  using System.Configuration;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.SqlClient;
  11:  using System.Web.UI;
  12:  using System.Web.UI.WebControls;
  13:  using System.Collections;
  14:  using System.Collections.Generic;
  15:  using System.Linq;
  16:  using System.Reflection;
  17:   
  18:  namespace Ia.Ngn.Cl.Model.Business
  19:  {
  20:      ////////////////////////////////////////////////////////////////////////////
  21:   
  22:      /// <summary publish="true">
  23:      /// Administration support class of Next Generation Network'a (NGN's) business model.
  24:      /// </summary>
  25:      /// 
  26:      /// <remarks> 
  27:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  28:      ///
  29:      /// 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
  30:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  31:      ///
  32:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  33:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  34:      /// 
  35:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  36:      /// 
  37:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  38:      /// </remarks> 
  39:      public class Administration
  40:      {
  41:          private const int initialFrameworkListLength = 100;
  42:   
  43:          /// <summary/>
  44:          public static DateTime OfficialMorningStartOfWorkTime = DateTime.Parse("07:00");
  45:          /// <summary/>
  46:          public static DateTime OfficialMorningEndOfWorkTime = DateTime.Parse("14:00");
  47:          /// <summary/>
  48:          public static DateTime OfficialEveningStartOfWorkTime = DateTime.Parse("16:00");
  49:          /// <summary/>
  50:          public static DateTime OfficialEveningEndOfWorkTime = DateTime.Parse("20:00");
  51:   
  52:          /// <summary/>
  53:          public static DateTime EarliestServiceRequestDate = DateTime.Parse("2000-01-01");
  54:   
  55:          /// <summary/>
  56:          public static int InitialFrameworkListLength { get { return initialFrameworkListLength; } }
  57:   
  58:          ////////////////////////////////////////////////////////////////////////////
  59:   
  60:          /// <summary>
  61:          ///
  62:          /// </summary>
  63:          public class Statistic
  64:          {
  65:              /// <summary/>
  66:              public Statistic() { }
  67:   
  68:              public class Site
  69:              {
  70:                  /// <summary/>
  71:                  public string Id { get; set; }
  72:                  /// <summary/>
  73:                  public string Name { get; set; }
  74:                  /// <summary/>
  75:                  public string Symbol { get; set; }
  76:                  /// <summary/>
  77:                  public string KuwaitAreaNameListString { get; set; }
  78:                  /// <summary/>
  79:                  public string DomainListString { get; set; }
  80:                  /// <summary/>
  81:                  public string SymbolListString { get; set; }
  82:   
  83:                  /// <summary/>
  84:                  public int SiteAccessCapacity { get; set; }
  85:   
  86:                  /// <summary/>
  87:                  public int NddOntNokiaAccessCount { get; set; }
  88:                  /// <summary/>
  89:                  public int NddOntHuaweiAccessCount { get; set; }
  90:                  /// <summary/>
  91:                  public int NddOntAccessCount { get; set; }
  92:   
  93:   
  94:   
  95:                  /// <summary/>
  96:                  public int AccessCapacity { get; set; }
  97:                  /// <summary/>
  98:                  public int AccessInstalledContractor { get; set; }
  99:                  /// <summary/>
 100:                  public int AccessInstalledContractorWithSerial { get; set; }
 101:                  /// <summary/>
 102:                  public int AccessProvisioned { get; set; }
 103:                  /// <summary/>
 104:                  public int AccessReadyForService { get; set; }
 105:                  /// <summary/>
 106:                  public int AccessDefinedInCustomerDepartment { get; set; }
 107:                  /// <summary/>
 108:                  public int AccessUtilized { get; set; }
 109:                  /// <summary/>
 110:                  public int AccessUtilizedNoService { get; set; }
 111:                  /// <summary/>
 112:                  public int AccessUtilizedOneService { get; set; }
 113:                  /// <summary/>
 114:                  public int AccessUtilizedTwoServices { get; set; }
 115:                  /// <summary/>
 116:                  public int AccessUtilizedThreeServices { get; set; }
 117:                  /// <summary/>
 118:                  public int AccessUtilizedFourServices { get; set; }
 119:                  /// <summary/>
 120:                  public int AccessUtilizedFiveOrMoreServices { get; set; }
 121:              }
 122:   
 123:              public class KuwaitArea
 124:              {
 125:                  /// <summary/>
 126:                  public KuwaitArea() { }
 127:   
 128:                  /// <summary/>
 129:                  public KuwaitArea(string name, string arabicName)
 130:                  {
 131:                      this.Name = name + " (" + arabicName + ")";
 132:                  }
 133:   
 134:                  /// <summary/>
 135:                  public string Id { get; set; }
 136:                  /// <summary/>
 137:                  public string Name { get; set; }
 138:                  /// <summary/>
 139:                  public string Symbol { get; set; }
 140:   
 141:                  /// <summary/>
 142:                  public int NokiaOnt { get; set; }
 143:                  /// <summary/>
 144:                  public int HuaweiOnt { get; set; }
 145:                  /// <summary/>
 146:                  public string OntTotalNokiaHuawei { get; set; }
 147:   
 148:                  /// <summary/>
 149:                  public int NokiaAccess { get; set; }
 150:                  /// <summary/>
 151:                  public int HuaweiAccess { get; set; }
 152:                  /// <summary/>
 153:                  public string AccessTotalNokiaHuawei { get; set; }
 154:   
 155:                  /// <summary/>
 156:                  public int ServiceRequestService { get; set; }
 157:                  /// <summary/>
 158:                  public int Service { get; set; }
 159:                  /// <summary/>
 160:                  public string ServiceRequestServiceService { get; set; }
 161:   
 162:                  /// <summary/>
 163:                  public int AccessReadyForService { get; set; }
 164:   
 165:                  ////////////////////////////////////////////////////////////////////////////
 166:   
 167:                  /// <summary>
 168:                  ///
 169:                  /// </summary>
 170:                  public string ToSimpleTextString()
 171:                  {
 172:                      StringBuilder sb;
 173:   
 174:                      sb = new StringBuilder();
 175:   
 176:                      sb.AppendLine("Name: " + this.Name);
 177:                      sb.AppendLine("Symbol: " + this.Symbol);
 178:                      sb.AppendLine("Service: " + this.Service);
 179:                      sb.AppendLine("Access: " + this.AccessTotalNokiaHuawei);
 180:                      //sb.AppendLine("ONT: " + this.OntTotalNokiaHuawei);
 181:                      //sb.AppendLine("Ready: " + this.AccessReadyForService);
 182:   
 183:                      return sb.ToString();
 184:                  }
 185:   
 186:                  ////////////////////////////////////////////////////////////////////////////
 187:                  ////////////////////////////////////////////////////////////////////////////
 188:              }
 189:   
 190:          }
 191:   
 192:          ////////////////////////////////////////////////////////////////////////////
 193:   
 194:          /// <summary>
 195:          ///
 196:          /// </summary>
 197:          public Administration() { }
 198:   
 199:          /// <summary/>
 200:          public static bool NowIsOfficialWorkingTime
 201:          {
 202:              get
 203:              {
 204:                  bool b;
 205:                  DateTime now;
 206:   
 207:                  now = DateTime.UtcNow.AddHours(3);
 208:   
 209:                  b = now.DayOfWeek != DayOfWeek.Friday && now.DayOfWeek != DayOfWeek.Saturday && 
 210:                      (
 211:                      now.TimeOfDay >= OfficialMorningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialMorningEndOfWorkTime.TimeOfDay
 212:                      ||
 213:                      now.TimeOfDay >= OfficialEveningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialEveningEndOfWorkTime.TimeOfDay
 214:                      );
 215:   
 216:                  return b;
 217:              }
 218:          }
 219:   
 220:          ////////////////////////////////////////////////////////////////////////////    
 221:   
 222:          /// <summary>
 223:          /// Tests a given Guid value to see if it has a special format used in framework items. Framework ites will have 00000000- prefixed to them
 224:          /// </summary>
 225:          public static bool IsFrameworkGuid(Guid guid)
 226:          {
 227:              bool isFrameworkGuid;
 228:   
 229:              isFrameworkGuid = (guid.ToString().Substring(0, 9) == "00000000-") ? true : false;
 230:   
 231:              return isFrameworkGuid;
 232:          }
 233:   
 234:          ////////////////////////////////////////////////////////////////////////////    
 235:   
 236:          /// <summary>
 237:          ///
 238:          /// </summary>
 239:          public static List<Ia.Ngn.Cl.Model.Data.Administration.Framework> FrameworkListOfAllowedReportAssignsByStaff(Ia.Ngn.Cl.Model.Staff staff)
 240:          {
 241:              List<Ia.Ngn.Cl.Model.Data.Administration.Framework> frameworkList;
 242:   
 243:              frameworkList = new List<Ia.Ngn.Cl.Model.Data.Administration.Framework>();
 244:   
 245:              frameworkList.AddRange(staff.Framework.Children);
 246:              frameworkList.AddRange(staff.Framework.Siblings);
 247:   
 248:              return frameworkList;
 249:          }
 250:   
 251:          ////////////////////////////////////////////////////////////////////////////    
 252:   
 253:          /// <summary>
 254:          ///
 255:          /// </summary>
 256:          public static bool StaffHasResponsibilityReport(Ia.Ngn.Cl.Model.Staff staff)
 257:          {
 258:              bool hasOpenReport;
 259:              List<Ia.Ngn.Cl.Model.Report> reportList;
 260:   
 261:              reportList = Ia.Ngn.Cl.Model.Data.Report.ResponsibilityReportList(staff);
 262:   
 263:              hasOpenReport = (reportList.Count > 0) ? true : false;
 264:   
 265:              return hasOpenReport;
 266:          }
 267:   
 268:          ////////////////////////////////////////////////////////////////////////////    
 269:   
 270:          /// <summary>
 271:          ///
 272:          /// </summary>
 273:          public static List<Ia.Ngn.Cl.Model.Data.Administration.Framework> FrameworkWithOpenStatusAndClosedStatusWithinLast24HourReportList(List<Ia.Ngn.Cl.Model.Report> defaultReportList)
 274:          {
 275:              Hashtable frameworkGuidHashtable;
 276:              //Ia.Ngn.Cl.Model.Staff staff;
 277:              List<Guid> userIdList;
 278:              List<Ia.Ngn.Cl.Model.Data.Administration.StaffFramework> list;
 279:              List<Ia.Ngn.Cl.Model.Report> reportList;
 280:   
 281:              frameworkGuidHashtable = new Hashtable();
 282:              userIdList = new List<Guid>();
 283:   
 284:              foreach (Ia.Ngn.Cl.Model.Data.Administration.StaffFramework sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList)
 285:              {
 286:                  //if (sf.IsStaff)
 287:                  //{
 288:                  //staff = Ia.Ngn.Cl.Model.Data.Staff.MembershipUser2(sf.Guid);
 289:   
 290:                  //reportList = Ia.Ngn.Cl.Model.Data.Report.StaffReadabilityReportList(staff);
 291:   
 292:                  //if (reportList.Count > 0) userIdHashtable[sf.Guid] = 1;
 293:                  //}
 294:                  /*else*/
 295:                  if (sf.IsFramework)
 296:                  {
 297:                      reportList = Ia.Ngn.Cl.Model.Data.Report.FrameworkReadabilityReportList(sf.Guid);
 298:   
 299:                      if (reportList.Count > 0) frameworkGuidHashtable[sf.Guid] = 1;
 300:                  }
 301:              }
 302:   
 303:              foreach (Guid userId in frameworkGuidHashtable.Keys) userIdList.Add(userId);
 304:   
 305:              list = (from u in userIdList
 306:                      join sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList on u equals sf.Guid
 307:                      where sf.IsFramework == true && Ia.Ngn.Cl.Model.Business.Authority.FrameworkParentOfAllReportsThatWillBeHandledInReportSection.Descendants.Any(u => u.Guid == sf.Guid)
 308:                      select sf).OrderBy(c => c.Name).ToList(); //.OrderByDescending(c => c.IsStaff).ThenBy(c => c.FrameworkId).ToList();
 309:   
 310:              // convert StaffFramework to Framework
 311:              var list2 = (from l in list join f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList on l.FrameworkId equals f.Id select f).ToList();
 312:   
 313:              return list2;
 314:          }
 315:   
 316:          ////////////////////////////////////////////////////////////////////////////
 317:   
 318:          /// <summary>
 319:          ///
 320:          /// </summary>
 321:          public class StaffContact
 322:          {
 323:              private Ia.Ngn.Cl.Model.Staff staff;
 324:              private Ia.Ngn.Cl.Model.Contact contact;
 325:              private string email;
 326:              private string apiKey;
 327:              private Guid userId;
 328:   
 329:              /// <summary/>
 330:              public StaffContact() { }
 331:   
 332:              /// <summary/>
 333:              public Ia.Ngn.Cl.Model.Staff Staff
 334:              {
 335:                  get
 336:                  {
 337:                      return staff;
 338:                  }
 339:   
 340:                  set
 341:                  {
 342:                      staff = value;
 343:   
 344:                      var v = this.FullName;
 345:                      var w = this.Email;
 346:                      var x = this.UserId;
 347:                      var y = this.ApiKey;
 348:                  }
 349:              }
 350:   
 351:              /// <summary/>
 352:              public Ia.Ngn.Cl.Model.Contact Contact
 353:              {
 354:                  get
 355:                  {
 356:                      return contact;
 357:                  }
 358:   
 359:                  set
 360:                  {
 361:                      contact = value;
 362:   
 363:                      var v = this.FullName;
 364:                      var w = this.Email;
 365:                      var x = this.UserId;
 366:                      var y = this.ApiKey;
 367:                  }
 368:              }
 369:   
 370:              /// <summary/>
 371:              public string FullName
 372:              {
 373:                  get
 374:                  {
 375:                      string name;
 376:   
 377:                      if (staff != null) name = staff.FullName;
 378:                      else if (contact != null) name = contact.FullName;
 379:                      else name = string.Empty;
 380:   
 381:                      return name;
 382:                  }
 383:              }
 384:   
 385:              /// <summary/>
 386:              public string Email
 387:              {
 388:                  get
 389:                  {
 390:                      if (staff != null && staff.User != null) email = staff.User.Email;
 391:                      else if (contact != null) email = contact.Email;
 392:                      else email = string.Empty;
 393:   
 394:                      return email;
 395:                  }
 396:              }
 397:   
 398:              /// <summary/>
 399:              public Guid UserId
 400:              {
 401:                  get
 402:                  {
 403:                      if (staff != null) userId = staff.UserId;
 404:                      else if (contact != null) userId = contact.UserId;
 405:                      else userId = Guid.Empty;
 406:   
 407:                      return userId;
 408:                  }
 409:              }
 410:   
 411:              /// <summary/>
 412:              public string ApiKey
 413:              {
 414:                  get
 415:                  {
 416:                      if (staff != null && staff.User != null) apiKey = UserId.ToString().Substring(0, 8);
 417:                      else if (contact != null) apiKey = UserId.ToString().Substring(0, 8);
 418:                      else apiKey = string.Empty;
 419:   
 420:                      return apiKey;
 421:                  }
 422:              }
 423:   
 424:              /// <summary/>
 425:              public bool IsApproved
 426:              {
 427:                  get
 428:                  {
 429:                      return !string.IsNullOrEmpty(email); // && contact.IsApproved;
 430:                  }
 431:              }
 432:   
 433:              ////////////////////////////////////////////////////////////////////////////
 434:              ////////////////////////////////////////////////////////////////////////////    
 435:          }
 436:      }
 437:   
 438:      ////////////////////////////////////////////////////////////////////////////
 439:      ////////////////////////////////////////////////////////////////////////////   
 440:  }