شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

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 DateTime SqlFriendlyJanuary1st1753NullDateTime = new DateTime(1753, 1, 1);
  57:   
  58:          /// <summary/>
  59:          public static DateTime EarliestRequestDateTime = new DateTime(1970, 1, 1); 
  60:   
  61:          /// <summary/>
  62:          public static int InitialFrameworkListLength { get { return initialFrameworkListLength; } }
  63:   
  64:          ////////////////////////////////////////////////////////////////////////////
  65:   
  66:          /// <summary>
  67:          ///
  68:          /// </summary>
  69:          public class Statistic
  70:          {
  71:              /// <summary/>
  72:              public Statistic() { }
  73:   
  74:              public class Site
  75:              {
  76:                  /// <summary/>
  77:                  public string Id { get; set; }
  78:                  /// <summary/>
  79:                  public string Name { get; set; }
  80:                  /// <summary/>
  81:                  public string Symbol { get; set; }
  82:                  /// <summary/>
  83:                  public string KuwaitAreaNameListString { get; set; }
  84:                  /// <summary/>
  85:                  public string DomainListString { get; set; }
  86:                  /// <summary/>
  87:                  public string SymbolListString { get; set; }
  88:   
  89:                  /// <summary/>
  90:                  public int SiteAccessCapacity { get; set; }
  91:   
  92:                  /// <summary/>
  93:                  public int NddOntNokiaAccessCount { get; set; }
  94:                  /// <summary/>
  95:                  public int NddOntHuaweiAccessCount { get; set; }
  96:                  /// <summary/>
  97:                  public int NddOntAccessCount { get; set; }
  98:   
  99:   
 100:   
 101:                  /// <summary/>
 102:                  public int AccessCapacity { get; set; }
 103:                  /// <summary/>
 104:                  public int AccessInstalledContractor { get; set; }
 105:                  /// <summary/>
 106:                  public int AccessInstalledContractorWithSerial { get; set; }
 107:                  /// <summary/>
 108:                  public int AccessProvisioned { get; set; }
 109:                  /// <summary/>
 110:                  public int AccessReadyForService { get; set; }
 111:                  /// <summary/>
 112:                  public int AccessDefinedInCustomerDepartment { get; set; }
 113:                  /// <summary/>
 114:                  public int AccessUtilized { get; set; }
 115:                  /// <summary/>
 116:                  public int AccessUtilizedNoService { get; set; }
 117:                  /// <summary/>
 118:                  public int AccessUtilizedOneService { get; set; }
 119:                  /// <summary/>
 120:                  public int AccessUtilizedTwoServices { get; set; }
 121:                  /// <summary/>
 122:                  public int AccessUtilizedThreeServices { get; set; }
 123:                  /// <summary/>
 124:                  public int AccessUtilizedFourServices { get; set; }
 125:                  /// <summary/>
 126:                  public int AccessUtilizedFiveOrMoreServices { get; set; }
 127:              }
 128:   
 129:              public class KuwaitArea
 130:              {
 131:                  /// <summary/>
 132:                  public KuwaitArea() { }
 133:   
 134:                  /// <summary/>
 135:                  public KuwaitArea(string name, string arabicName)
 136:                  {
 137:                      this.Name = name + " (" + arabicName + ")";
 138:                  }
 139:   
 140:                  /// <summary/>
 141:                  public string Id { get; set; }
 142:                  /// <summary/>
 143:                  public string Name { get; set; }
 144:                  /// <summary/>
 145:                  public string Symbol { get; set; }
 146:   
 147:                  /// <summary/>
 148:                  public int NokiaOnt { get; set; }
 149:                  /// <summary/>
 150:                  public int HuaweiOnt { get; set; }
 151:                  /// <summary/>
 152:                  public string OntTotalNokiaHuawei { get; set; }
 153:   
 154:                  /// <summary/>
 155:                  public int NokiaAccess { get; set; }
 156:                  /// <summary/>
 157:                  public int HuaweiAccess { get; set; }
 158:                  /// <summary/>
 159:                  public string AccessTotalNokiaHuawei { get; set; }
 160:   
 161:                  /// <summary/>
 162:                  public int ServiceRequestService { get; set; }
 163:                  /// <summary/>
 164:                  public int Service { get; set; }
 165:                  /// <summary/>
 166:                  public string ServiceRequestServiceService { get; set; }
 167:   
 168:                  /// <summary/>
 169:                  public int AccessReadyForService { get; set; }
 170:   
 171:                  ////////////////////////////////////////////////////////////////////////////
 172:   
 173:                  /// <summary>
 174:                  ///
 175:                  /// </summary>
 176:                  public string ToSimpleTextString()
 177:                  {
 178:                      StringBuilder sb;
 179:   
 180:                      sb = new StringBuilder();
 181:   
 182:                      sb.AppendLine("Name: " + this.Name);
 183:                      sb.AppendLine("Symbol: " + this.Symbol);
 184:                      sb.AppendLine("Service: " + this.Service);
 185:                      sb.AppendLine("Access: " + this.AccessTotalNokiaHuawei);
 186:                      //sb.AppendLine("ONT: " + this.OntTotalNokiaHuawei);
 187:                      //sb.AppendLine("Ready: " + this.AccessReadyForService);
 188:   
 189:                      return sb.ToString();
 190:                  }
 191:   
 192:                  ////////////////////////////////////////////////////////////////////////////
 193:                  ////////////////////////////////////////////////////////////////////////////
 194:              }
 195:   
 196:          }
 197:   
 198:          ////////////////////////////////////////////////////////////////////////////
 199:   
 200:          /// <summary>
 201:          ///
 202:          /// </summary>
 203:          public Administration() { }
 204:   
 205:          /// <summary/>
 206:          public static bool NowIsOfficialWorkingTime
 207:          {
 208:              get
 209:              {
 210:                  bool b;
 211:                  DateTime now;
 212:   
 213:                  now = DateTime.UtcNow.AddHours(3);
 214:   
 215:                  b = now.DayOfWeek != DayOfWeek.Friday && now.DayOfWeek != DayOfWeek.Saturday &&
 216:                      (
 217:                      now.TimeOfDay >= OfficialMorningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialMorningEndOfWorkTime.TimeOfDay
 218:                      ||
 219:                      now.TimeOfDay >= OfficialEveningStartOfWorkTime.TimeOfDay && now.TimeOfDay < OfficialEveningEndOfWorkTime.TimeOfDay
 220:                      );
 221:   
 222:                  return b;
 223:              }
 224:          }
 225:   
 226:          ////////////////////////////////////////////////////////////////////////////    
 227:   
 228:          /// <summary>
 229:          /// 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
 230:          /// </summary>
 231:          public static bool IsFrameworkGuid(Guid guid)
 232:          {
 233:              bool isFrameworkGuid;
 234:   
 235:              isFrameworkGuid = (guid.ToString().Substring(0, 9) == "00000000-") ? true : false;
 236:   
 237:              return isFrameworkGuid;
 238:          }
 239:   
 240:          ////////////////////////////////////////////////////////////////////////////    
 241:   
 242:          /// <summary>
 243:          ///
 244:          /// </summary>
 245:          public static List<Ia.Ngn.Cl.Model.Data.Administration.Framework> FrameworkListOfAllowedReportAssignsByStaff(Ia.Ngn.Cl.Model.Staff staff)
 246:          {
 247:              List<Ia.Ngn.Cl.Model.Data.Administration.Framework> frameworkList;
 248:   
 249:              frameworkList = new List<Ia.Ngn.Cl.Model.Data.Administration.Framework>();
 250:   
 251:              frameworkList.AddRange(staff.Framework.Children);
 252:              frameworkList.AddRange(staff.Framework.Siblings);
 253:   
 254:              return frameworkList;
 255:          }
 256:   
 257:          ////////////////////////////////////////////////////////////////////////////    
 258:   
 259:          /// <summary>
 260:          ///
 261:          /// </summary>
 262:          public static bool StaffHasResponsibilityReport(Ia.Ngn.Cl.Model.Staff staff)
 263:          {
 264:              bool hasOpenReport;
 265:              List<Ia.Ngn.Cl.Model.Report> reportList;
 266:   
 267:              reportList = Ia.Ngn.Cl.Model.Data.Report.ResponsibilityReportList(staff);
 268:   
 269:              hasOpenReport = (reportList.Count > 0) ? true : false;
 270:   
 271:              return hasOpenReport;
 272:          }
 273:   
 274:          ////////////////////////////////////////////////////////////////////////////    
 275:   
 276:          /// <summary>
 277:          ///
 278:          /// </summary>
 279:          public static List<Ia.Ngn.Cl.Model.Data.Administration.Framework> FrameworkWithOpenStatusAndClosedStatusWithinLast24HourReportList(List<Ia.Ngn.Cl.Model.Report> defaultReportList)
 280:          {
 281:              Hashtable frameworkGuidHashtable;
 282:              //Ia.Ngn.Cl.Model.Staff staff;
 283:              List<Guid> userIdList;
 284:              List<Ia.Ngn.Cl.Model.Data.Administration.StaffFramework> list;
 285:              List<Ia.Ngn.Cl.Model.Report> reportList;
 286:   
 287:              frameworkGuidHashtable = new Hashtable();
 288:              userIdList = new List<Guid>();
 289:   
 290:              foreach (Ia.Ngn.Cl.Model.Data.Administration.StaffFramework sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList)
 291:              {
 292:                  //if (sf.IsStaff)
 293:                  //{
 294:                  //staff = Ia.Ngn.Cl.Model.Data.Staff.MembershipUser2(sf.Guid);
 295:   
 296:                  //reportList = Ia.Ngn.Cl.Model.Data.Report.StaffReadabilityReportList(staff);
 297:   
 298:                  //if (reportList.Count > 0) userIdHashtable[sf.Guid] = 1;
 299:                  //}
 300:                  /*else*/
 301:                  if (sf.IsFramework)
 302:                  {
 303:                      reportList = Ia.Ngn.Cl.Model.Data.Report.FrameworkReadabilityReportList(sf.Guid);
 304:   
 305:                      if (reportList.Count > 0) frameworkGuidHashtable[sf.Guid] = 1;
 306:                  }
 307:              }
 308:   
 309:              foreach (Guid userId in frameworkGuidHashtable.Keys) userIdList.Add(userId);
 310:   
 311:              list = (from u in userIdList
 312:                      join sf in Ia.Ngn.Cl.Model.Data.Administration.StaffFrameworkList on u equals sf.Guid
 313:                      where sf.IsFramework == true && Ia.Ngn.Cl.Model.Business.Authority.FrameworkParentOfAllReportsThatWillBeHandledInReportSection.Descendants.Any(u => u.Guid == sf.Guid)
 314:                      select sf).OrderBy(c => c.Name).ToList(); //.OrderByDescending(c => c.IsStaff).ThenBy(c => c.FrameworkId).ToList();
 315:   
 316:              // convert StaffFramework to Framework
 317:              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();
 318:   
 319:              return list2;
 320:          }
 321:   
 322:          ////////////////////////////////////////////////////////////////////////////
 323:   
 324:          /// <summary>
 325:          ///
 326:          /// </summary>
 327:          public class StaffContact
 328:          {
 329:              private Ia.Ngn.Cl.Model.Staff staff;
 330:              private Ia.Ngn.Cl.Model.Contact contact;
 331:              private string email;
 332:              private string apiKey;
 333:              private Guid userId;
 334:   
 335:              /// <summary/>
 336:              public StaffContact() { }
 337:   
 338:              /// <summary/>
 339:              public Ia.Ngn.Cl.Model.Staff Staff
 340:              {
 341:                  get
 342:                  {
 343:                      return staff;
 344:                  }
 345:   
 346:                  set
 347:                  {
 348:                      staff = value;
 349:   
 350:                      var v = this.FullName;
 351:                      var w = this.Email;
 352:                      var x = this.UserId;
 353:                      var y = this.ApiKey;
 354:                  }
 355:              }
 356:   
 357:              /// <summary/>
 358:              public Ia.Ngn.Cl.Model.Contact Contact
 359:              {
 360:                  get
 361:                  {
 362:                      return contact;
 363:                  }
 364:   
 365:                  set
 366:                  {
 367:                      contact = value;
 368:   
 369:                      var v = this.FullName;
 370:                      var w = this.Email;
 371:                      var x = this.UserId;
 372:                      var y = this.ApiKey;
 373:                  }
 374:              }
 375:   
 376:              /// <summary/>
 377:              public string FullName
 378:              {
 379:                  get
 380:                  {
 381:                      string name;
 382:   
 383:                      if (staff != null) name = staff.FullName;
 384:                      else if (contact != null) name = contact.FullName;
 385:                      else name = string.Empty;
 386:   
 387:                      return name;
 388:                  }
 389:              }
 390:   
 391:              /// <summary/>
 392:              public string Email
 393:              {
 394:                  get
 395:                  {
 396:                      if (staff != null && staff.User != null) email = staff.User.Email;
 397:                      else if (contact != null) email = contact.Email;
 398:                      else email = string.Empty;
 399:   
 400:                      return email;
 401:                  }
 402:              }
 403:   
 404:              /// <summary/>
 405:              public Guid UserId
 406:              {
 407:                  get
 408:                  {
 409:                      if (staff != null) userId = staff.UserId;
 410:                      else if (contact != null) userId = contact.UserId;
 411:                      else userId = Guid.Empty;
 412:   
 413:                      return userId;
 414:                  }
 415:              }
 416:   
 417:              /// <summary/>
 418:              public string ApiKey
 419:              {
 420:                  get
 421:                  {
 422:                      if (staff != null && staff.User != null) apiKey = UserId.ToString().Substring(0, 8);
 423:                      else if (contact != null) apiKey = UserId.ToString().Substring(0, 8);
 424:                      else apiKey = string.Empty;
 425:   
 426:                      return apiKey;
 427:                  }
 428:              }
 429:   
 430:              /// <summary/>
 431:              public bool IsApproved
 432:              {
 433:                  get
 434:                  {
 435:                      return !string.IsNullOrEmpty(email); // && contact.IsApproved;
 436:                  }
 437:              }
 438:   
 439:              ////////////////////////////////////////////////////////////////////////////
 440:              ////////////////////////////////////////////////////////////////////////////    
 441:          }
 442:      }
 443:   
 444:      ////////////////////////////////////////////////////////////////////////////
 445:      ////////////////////////////////////////////////////////////////////////////   
 446:  }