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 for Next Generation Network (NGN) ui model.

   1:  using System;
   2:  using System.Text;
   3:  using System.Data;
   4:  using System.Collections.Generic;
   5:  using System.Linq;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Ui
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Administration support class for Next Generation Network (NGN) ui model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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:          ////////////////////////////////////////////////////////////////////////////
  31:   
  32:          /// <summary>
  33:          ///
  34:          /// </summary>
  35:          public Administration() { }
  36:   
  37:          /////////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public static void EmailDailyOfnStatusReport(string name, string email, out Ia.Cl.Model.Result result)
  43:          {
  44:              //bool b;
  45:              string content, subject;
  46:              DateTime now;
  47:   
  48:              now = DateTime.UtcNow.AddHours(3);
  49:   
  50:              // subject can't have \r\n
  51:              subject = "Daily Optical Fiber Network (OFN) Status Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
  52:   
  53:              content = "Daily Optical Fiber Network (OFN) Status Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
  54:                  + "Status: undefined.\r\n"
  55:                  + @"For help send ""help"" in an email." + "\r\n";
  56:   
  57:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
  58:          }
  59:   
  60:          /////////////////////////////////////////////////////////////////////////////////
  61:   
  62:          /// <summary>
  63:          ///
  64:          /// </summary>
  65:          public static void EmailListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabase(string name, string email, out Ia.Cl.Model.Result result)
  66:          {
  67:              //bool b;
  68:              string content, subject;
  69:              DataTable accessDataTable;
  70:              DateTime now;
  71:   
  72:              now = DateTime.UtcNow.AddHours(3);
  73:   
  74:              subject = "Table of latest 100 ONTs that are provisioned and ready within NGN access network but do not exist in the Customer Department's database (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
  75:   
  76:              accessDataTable = Ia.Ngn.Cl.Model.Ui.Access.ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable(100);
  77:   
  78:              content = "Table of latest 100 ONTs that are provisioned and ready within NGN access network but do not exist in the Customer Department's database (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
  79:   
  80:              content += "\r\n";
  81:              content += "\r\n";
  82:   
  83:              content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDataTable(accessDataTable);
  84:   
  85:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
  86:          }
  87:   
  88:          /////////////////////////////////////////////////////////////////////////////////
  89:   
  90:          /// <summary>
  91:          ///
  92:          /// </summary>
  93:          public static void EmailStatistic(string name, string email, out Ia.Cl.Model.Result result)
  94:          {
  95:              //bool b;
  96:              string content, subject;
  97:              DataTable siteDataTable, serviceDataTable;
  98:              DateTime now;
  99:   
 100:              now = DateTime.UtcNow.AddHours(3);
 101:   
 102:              subject = "Statistics of Site, Access, and Service usage within the Optical Fiber Network (OFN) (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 103:   
 104:              Ia.Ngn.Cl.Model.Ui.Administration.StatisticsOfSiteAndAccessAndServiceUsage(out siteDataTable, out serviceDataTable);
 105:   
 106:              content = "Statistics of Site, Access, and Service usage within the Optical Fiber Network (OFN) (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 107:   
 108:              content += "\r\n";
 109:              content += "\r\n";
 110:   
 111:              content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDataTable(siteDataTable);
 112:   
 113:              content += "\r\n";
 114:              content += "\r\n";
 115:   
 116:              content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDataTable(serviceDataTable);
 117:   
 118:              content += "\r\n";
 119:              content += "\r\n";
 120:   
 121:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 122:          }
 123:   
 124:          /////////////////////////////////////////////////////////////////////////////////
 125:   
 126:          /// <summary>
 127:          ///
 128:          /// </summary>
 129:          public static void EmailListOfNumberOfAgcfGatewayRecordInGroupOfMgcIp(string name, string email, out Ia.Cl.Model.Result result)
 130:          {
 131:              string content, subject;
 132:              Dictionary<string, int> dictionary;
 133:              DateTime now;
 134:   
 135:              now = DateTime.UtcNow.AddHours(3);
 136:   
 137:              subject = "List of the number of AGCF gateway records in groups of MGC IP (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 138:   
 139:              dictionary = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary.OrderBy(u => u.Key).ToDictionary(u => u.Key, u => u.Value);
 140:   
 141:              content = "List of the number of AGCF gateway records in groups of MGC IP  (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 142:   
 143:              content += "\r\n";
 144:              content += "\r\n";
 145:   
 146:              content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(dictionary);
 147:   
 148:              content += "\r\n";
 149:              content += "Total number of AGCF gateway records: " + dictionary.Sum(u => u.Value) + ". ";
 150:   
 151:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 152:          }
 153:   
 154:          /////////////////////////////////////////////////////////////////////////////////
 155:   
 156:          /// <summary>
 157:          ///
 158:          /// </summary>
 159:          public static void EmailWeeklyOfnNokiaReport(string name, string email, out Ia.Cl.Model.Result result)
 160:          {
 161:              string content, subject;
 162:              DateTime now;
 163:              List<string> list;
 164:              SortedDictionary<string, int> sortedDictionary;
 165:   
 166:              now = DateTime.UtcNow.AddHours(3);
 167:   
 168:              // subject can't have \r\n
 169:              subject = "Weekly Optical Fiber Network (OFN) Nokia Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 170:   
 171:              content = "Weekly Optical Fiber Network (OFN) Nokia Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
 172:                  + "Status:\r\n"
 173:                  + @"Please contact Jasem for any specific data that you may need on a weekly bases." + "\r\n";
 174:   
 175:              content += "\r\n";
 176:              content += "\r\n";
 177:   
 178:   
 179:              content += "List of the number of AGCF gateway records in groups of MGC IP: ";
 180:   
 181:              content += "\r\n";
 182:              content += "\r\n";
 183:   
 184:              sortedDictionary = new SortedDictionary<string, int>(Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary);
 185:   
 186:              content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(sortedDictionary);
 187:   
 188:              content += "\r\n";
 189:              content += "\r\n";
 190:   
 191:   
 192:              content += "List of the number of AGCF gateway records in IMS pairs of MGC IP: ";
 193:   
 194:              content += "\r\n";
 195:              content += "\r\n";
 196:   
 197:              foreach (Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicService imsBasicService in Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
 198:              {
 199:                  content += imsBasicService.MgcIp + ", " + imsBasicService.MgcSecondaryIp + "\t" + (sortedDictionary[imsBasicService.MgcIp] + sortedDictionary[imsBasicService.MgcSecondaryIp]);
 200:                  content += "\r\n";
 201:              }
 202:   
 203:              content += "\r\n";
 204:              content += "\r\n";
 205:   
 206:   
 207:              content += "Number of Nokia subscribers per FSDB: ";
 208:   
 209:              content += "\r\n";
 210:              content += "\r\n";
 211:   
 212:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfNokiaSubsribersPerFsdb();
 213:   
 214:              content += string.Join("\r\n", list.ToArray());
 215:   
 216:              content += "\r\n";
 217:              content += "\r\n";
 218:   
 219:   
 220:              content += "Service and access name list where subscriber's AlternateOtasRealm group number is not equal to subparties AssocOtasRealm group number: ";
 221:   
 222:              content += "\r\n";
 223:              content += "\r\n";
 224:   
 225:              list.Clear();
 226:   
 227:              foreach (var w in Ia.Ngn.Cl.Model.Data.Nokia.Ims.ServiceWhereSubscriberAlternateOtasRealmGroupNumberDoesNotEqualSubPartyAssocOtasRealmGroupNumberList())
 228:              {
 229:                  if (w.Access != null)
 230:                  {
 231:                      list.Add(w.Service + ": " + w.Access.Name);
 232:                  }
 233:                  else list.Add(w.Service + ": ");
 234:              }
 235:   
 236:              content += string.Join("\r\n", list.ToArray());
 237:   
 238:   
 239:              content += "\r\n";
 240:              content += "\r\n";
 241:   
 242:              content += "AGCF gateway records within NDD ONT list with wrong secondary IP: ";
 243:   
 244:              content += "\r\n";
 245:              content += "\r\n";
 246:   
 247:              list.Clear();
 248:   
 249:              foreach (var w in Ia.Ngn.Cl.Model.Data.Nokia.Ims.AgcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList())
 250:              {
 251:                  list.Add(w.GwId.ToString());
 252:              }
 253:   
 254:              content += string.Join(", ", list.ToArray());
 255:   
 256:              content += "\r\n";
 257:              content += "\r\n";
 258:   
 259:   
 260:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 261:          }
 262:   
 263:          /////////////////////////////////////////////////////////////////////////////////
 264:   
 265:          /// <summary>
 266:          ///
 267:          /// </summary>
 268:          public static void EmailWeeklyOfnHuaweiReport(string name, string email, out Ia.Cl.Model.Result result)
 269:          {
 270:              string content, subject;
 271:              DateTime now;
 272:   
 273:              now = DateTime.UtcNow.AddHours(3);
 274:   
 275:              // subject can't have \r\n
 276:              subject = "Weekly Optical Fiber Network (OFN) Huawei Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 277:   
 278:              content = "Weekly Optical Fiber Network (OFN) Huawei Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
 279:                  + "Status:.\r\n"
 280:                  + @"Please contact Jasem for any specific data that you may need on a weekly bases." + "\r\n";
 281:   
 282:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 283:          }
 284:   
 285:          ////////////////////////////////////////////////////////////////////////////
 286:   
 287:          /// <summary>
 288:          ///
 289:          /// </summary>
 290:          public static void StatisticsOfSiteAndAccessAndServiceUsage(out DataTable siteDataTable, out DataTable serviceDataTable)
 291:          {
 292:              // below:
 293:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> siteList;
 294:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> serviceList;
 295:   
 296:              siteList = Ia.Ngn.Cl.Model.Data.Administration.SiteStatistic();
 297:              serviceList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnArea;
 298:   
 299:              siteDataTable = Ia.Cl.Model.Default.GenerateDataTableFromListOfGenericClass<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site>(siteList, "Name", "KuwaitAreaNameListString", "DomainListString", "SymbolListString", "AccessCapacity");
 300:              serviceDataTable = Ia.Cl.Model.Default.GenerateDataTableFromListOfGenericClass<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea>(serviceList, "Name", "Symbol", "ServiceRequestServiceService", "AccessTotalNokiaHuawei", "OntTotalNokiaHuawei");
 301:          }
 302:   
 303:          ////////////////////////////////////////////////////////////////////////////    
 304:          ////////////////////////////////////////////////////////////////////////////    
 305:   
 306:          /// <summary>
 307:          /// 
 308:          /// </summary>
 309:          public static string FrameworkStructureDataTable()
 310:          {
 311:              string htmlTable;
 312:              List<Ia.Ngn.Cl.Model.Data.Administration.Framework> frameworkList;
 313:   
 314:              frameworkList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList where f.Type == "ministry" || f.Type == "supplier" select f).ToList();
 315:   
 316:              htmlTable = @"<div id=""framework-structure"">";
 317:   
 318:              foreach (Ia.Ngn.Cl.Model.Data.Administration.Framework framework in frameworkList)
 319:              {
 320:                  htmlTable += FrameworkStructureDataTableIteration(framework);
 321:              }
 322:   
 323:              htmlTable += "</div>";
 324:   
 325:              return htmlTable;
 326:          }
 327:   
 328:          ////////////////////////////////////////////////////////////////////////////    
 329:   
 330:          /// <summary>
 331:          /// 
 332:          /// </summary>
 333:          private static string FrameworkStructureDataTableIteration(Ia.Ngn.Cl.Model.Data.Administration.Framework framework)
 334:          {
 335:              string htmlTable;
 336:              Ia.Ngn.Cl.Model.Staff headStaff;
 337:              List<Ia.Ngn.Cl.Model.Staff> staffList;
 338:   
 339:              htmlTable = null;
 340:   
 341:              if (framework != null)
 342:              {
 343:                  headStaff = (from s in Ia.Ngn.Cl.Model.Data.Staff.List where s.Framework != null && s.Framework.Id == framework.Id && s.IsHead select s).SingleOrDefault();
 344:   
 345:                  htmlTable = "<table>";
 346:   
 347:                  if (framework.Children != null && framework.Children.Count > 0)
 348:                  {
 349:                      htmlTable += "<tr>";
 350:   
 351:                      htmlTable += @"<td class=""" + framework.Type + @""" colspan=""" + framework.Children.Count + @""">" + framework.ArabicName;
 352:                      if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
 353:                      htmlTable += @"</td>";
 354:   
 355:                      htmlTable += "</tr>";
 356:   
 357:                      htmlTable += "<tr>";
 358:   
 359:                      foreach (Ia.Ngn.Cl.Model.Data.Administration.Framework f in framework.Children)
 360:                      {
 361:                          htmlTable += @"<td class=""" + f.Type + @""">" + FrameworkStructureDataTableIteration(f) + "</td>";
 362:                      }
 363:   
 364:                      htmlTable += "</tr>";
 365:                  }
 366:                  else
 367:                  {
 368:                      staffList = (from s in Ia.Ngn.Cl.Model.Data.Staff.List where s.Framework != null && s.Framework.Id == framework.Id && !s.IsHead select s).ToList();
 369:   
 370:                      htmlTable += "<tr>";
 371:   
 372:                      htmlTable += @"<td class=""" + framework.Type + @""">" + framework.ArabicName;
 373:                      if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
 374:   
 375:                      foreach(Ia.Ngn.Cl.Model.Staff staff in staffList)
 376:                      {
 377:                          htmlTable += @"<span class=""staff"">" + staff.FirstAndMiddleName + "</span>";
 378:                      }
 379:   
 380:                      htmlTable += @"</td>";
 381:   
 382:                      htmlTable += "</tr>";
 383:                  }
 384:   
 385:                  htmlTable += "</table>";
 386:              }
 387:   
 388:              return htmlTable;
 389:          }
 390:   
 391:          /////////////////////////////////////////////////////////////////////////////////
 392:          /////////////////////////////////////////////////////////////////////////////////
 393:   
 394:          /// <summary>
 395:          ///
 396:          /// </summary>
 397:          public static void StatisticsListForTelegramBotApi(string opcode, out string subject, out string content)
 398:          {
 399:              string inputType, horizontalRule;
 400:              StringBuilder contentStringBuilder;
 401:              DateTime now;
 402:   
 403:              inputType = string.Empty;
 404:              horizontalRule = " ";
 405:   
 406:              now = DateTime.UtcNow.AddHours(3);
 407:   
 408:              // subject can't have \r\n
 409:              subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
 410:   
 411:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
 412:              //{
 413:              opcode = opcode.ToLower();
 414:   
 415:              StatisticListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out contentStringBuilder);
 416:   
 417:              contentStringBuilder.AppendLine(horizontalRule);
 418:              contentStringBuilder.AppendLine(@"Help? Send the command /help");
 419:              contentStringBuilder.AppendLine(horizontalRule);
 420:              contentStringBuilder.AppendLine();
 421:   
 422:              content = contentStringBuilder.ToString();
 423:              //}
 424:              //else
 425:              //{
 426:              //    responseContent += "\r\n";
 427:              //    responseContent += "You are not authorized to modify this value. ";
 428:              //    responseContent += "\r\n";
 429:              //}
 430:          }
 431:   
 432:          ////////////////////////////////////////////////////////////////////////////
 433:   
 434:          /// <summary>
 435:          ///
 436:          /// </summary>
 437:          public static void StatisticListForTelegramBotApiAndMailSimpleText(string opcode, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
 438:          {
 439:              StringBuilder stringBuilder;
 440:              DateTime now;
 441:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> statisticList;
 442:   
 443:              stringBuilder = new StringBuilder();
 444:              now = DateTime.UtcNow.AddHours(3);
 445:   
 446:              //stringBuilder.AppendLine("Optical Fiber Network (OFN) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
 447:   
 448:              //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
 449:              //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
 450:              //stringBuilder.AppendLine();
 451:   
 452:              if (opcode.Contains("statistics"))
 453:              {
 454:                  statisticList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnAreaCachedDaily;
 455:   
 456:                  if (statisticList != null && statisticList.Count > 0)
 457:                  {
 458:                      stringBuilder.AppendLine(horizontalRule);
 459:                      stringBuilder.AppendLine("Statistics:");
 460:                      stringBuilder.AppendLine();
 461:                      foreach (var s in statisticList) stringBuilder.AppendLine(s.ToSimpleTextString());
 462:                      stringBuilder.AppendLine(horizontalRule);
 463:                      stringBuilder.AppendLine();
 464:                  }
 465:                  else
 466:                  {
 467:                      stringBuilder.AppendLine(horizontalRule);
 468:                      stringBuilder.AppendLine();
 469:                  }
 470:              }
 471:              else
 472:              {
 473:                  stringBuilder.AppendLine(horizontalRule);
 474:                  stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
 475:                  stringBuilder.AppendLine(horizontalRule);
 476:                  stringBuilder.AppendLine();
 477:              }
 478:   
 479:              contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 480:          }
 481:   
 482:          ////////////////////////////////////////////////////////////////////////////
 483:          ////////////////////////////////////////////////////////////////////////////    
 484:      }
 485:   
 486:      ////////////////////////////////////////////////////////////////////////////
 487:      ////////////////////////////////////////////////////////////////////////////   
 488:  }