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

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 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: Normal\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:              content += "\r\n";
 239:              content += "\r\n";
 240:   
 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:              content += "\r\n";
 259:   
 260:   
 261:              content += "SubParties' PrimaryPUIDCPEProfileNumber count distribution: ";
 262:   
 263:              content += "\r\n";
 264:              content += "\r\n";
 265:   
 266:              list.Clear();
 267:   
 268:              foreach (KeyValuePair<int, int> w in Ia.Ngn.Cl.Model.Data.Nokia.SubParty.PrimaryPuidCpeProfileNumberCountDistributionDictionary)
 269:              {
 270:                  list.Add(w.Key + "\t" + w.Value);
 271:              }
 272:   
 273:              content += string.Join("\r\n", list.ToArray());
 274:   
 275:              content += "\r\n";
 276:              content += "\r\n";
 277:   
 278:   
 279:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 280:          }
 281:   
 282:          /////////////////////////////////////////////////////////////////////////////////
 283:   
 284:          /// <summary>
 285:          ///
 286:          /// </summary>
 287:          public static void EmailWeeklyOfnHuaweiReport(string name, string email, out Ia.Cl.Model.Result result)
 288:          {
 289:              string content, subject;
 290:              DateTime now;
 291:   
 292:              now = DateTime.UtcNow.AddHours(3);
 293:   
 294:              // subject can't have \r\n
 295:              subject = "Weekly Optical Fiber Network (OFN) Huawei Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 296:   
 297:              content = "Weekly Optical Fiber Network (OFN) Huawei Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
 298:                  + "Status:.\r\n"
 299:                  + @"Please contact Jasem for any specific data that you may need on a weekly bases." + "\r\n";
 300:   
 301:              Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
 302:          }
 303:   
 304:          ////////////////////////////////////////////////////////////////////////////
 305:   
 306:          /// <summary>
 307:          ///
 308:          /// </summary>
 309:          public static void StatisticsOfSiteAndAccessAndServiceUsage(out DataTable siteDataTable, out DataTable serviceDataTable)
 310:          {
 311:              // below:
 312:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> siteList;
 313:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> serviceList;
 314:   
 315:              siteList = Ia.Ngn.Cl.Model.Data.Administration.SiteStatistic();
 316:              serviceList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnArea;
 317:   
 318:              siteDataTable = Ia.Cl.Model.Default.GenerateDataTableFromListOfGenericClass<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site>(siteList, "Name", "KuwaitAreaNameListString", "DomainListString", "SymbolListString", "AccessCapacity");
 319:              serviceDataTable = Ia.Cl.Model.Default.GenerateDataTableFromListOfGenericClass<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea>(serviceList, "Name", "Symbol", "ServiceRequestServiceService", "AccessTotalNokiaHuawei", "OntTotalNokiaHuawei");
 320:          }
 321:   
 322:          ////////////////////////////////////////////////////////////////////////////    
 323:          ////////////////////////////////////////////////////////////////////////////    
 324:   
 325:          /// <summary>
 326:          /// 
 327:          /// </summary>
 328:          public static string FrameworkStructureDataTable()
 329:          {
 330:              string htmlTable;
 331:              List<Ia.Ngn.Cl.Model.Data.Administration.Framework> frameworkList;
 332:   
 333:              frameworkList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList where f.Type == "ministry" || f.Type == "supplier" select f).ToList();
 334:   
 335:              htmlTable = @"<div id=""framework-structure"">";
 336:   
 337:              foreach (Ia.Ngn.Cl.Model.Data.Administration.Framework framework in frameworkList)
 338:              {
 339:                  htmlTable += FrameworkStructureDataTableIteration(framework);
 340:              }
 341:   
 342:              htmlTable += "</div>";
 343:   
 344:              return htmlTable;
 345:          }
 346:   
 347:          ////////////////////////////////////////////////////////////////////////////    
 348:   
 349:          /// <summary>
 350:          /// 
 351:          /// </summary>
 352:          private static string FrameworkStructureDataTableIteration(Ia.Ngn.Cl.Model.Data.Administration.Framework framework)
 353:          {
 354:              string htmlTable;
 355:              Ia.Ngn.Cl.Model.Staff headStaff;
 356:              List<Ia.Ngn.Cl.Model.Staff> staffList;
 357:   
 358:              htmlTable = null;
 359:   
 360:              if (framework != null)
 361:              {
 362:                  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();
 363:   
 364:                  htmlTable = "<table>";
 365:   
 366:                  if (framework.Children != null && framework.Children.Count > 0)
 367:                  {
 368:                      htmlTable += "<tr>";
 369:   
 370:                      htmlTable += @"<td class=""" + framework.Type + @""" colspan=""" + framework.Children.Count + @""">" + framework.ArabicName;
 371:                      if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
 372:                      htmlTable += @"</td>";
 373:   
 374:                      htmlTable += "</tr>";
 375:   
 376:                      htmlTable += "<tr>";
 377:   
 378:                      foreach (Ia.Ngn.Cl.Model.Data.Administration.Framework f in framework.Children)
 379:                      {
 380:                          htmlTable += @"<td class=""" + f.Type + @""">" + FrameworkStructureDataTableIteration(f) + "</td>";
 381:                      }
 382:   
 383:                      htmlTable += "</tr>";
 384:                  }
 385:                  else
 386:                  {
 387:                      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();
 388:   
 389:                      htmlTable += "<tr>";
 390:   
 391:                      htmlTable += @"<td class=""" + framework.Type + @""">" + framework.ArabicName;
 392:                      if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
 393:   
 394:                      foreach(Ia.Ngn.Cl.Model.Staff staff in staffList)
 395:                      {
 396:                          htmlTable += @"<span class=""staff"">" + staff.FirstAndMiddleName + "</span>";
 397:                      }
 398:   
 399:                      htmlTable += @"</td>";
 400:   
 401:                      htmlTable += "</tr>";
 402:                  }
 403:   
 404:                  htmlTable += "</table>";
 405:              }
 406:   
 407:              return htmlTable;
 408:          }
 409:   
 410:          /////////////////////////////////////////////////////////////////////////////////
 411:          /////////////////////////////////////////////////////////////////////////////////
 412:   
 413:          /// <summary>
 414:          ///
 415:          /// </summary>
 416:          public static void StatisticsListForTelegramBotApi(string opcode, out string subject, out string content)
 417:          {
 418:              string inputType, horizontalRule;
 419:              StringBuilder contentStringBuilder;
 420:              DateTime now;
 421:   
 422:              inputType = string.Empty;
 423:              horizontalRule = " ";
 424:   
 425:              now = DateTime.UtcNow.AddHours(3);
 426:   
 427:              // subject can't have \r\n
 428:              subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
 429:   
 430:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
 431:              //{
 432:              opcode = opcode.ToLower();
 433:   
 434:              StatisticListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out contentStringBuilder);
 435:   
 436:              contentStringBuilder.AppendLine(horizontalRule);
 437:              contentStringBuilder.AppendLine(@"Help? Send the command /help");
 438:              contentStringBuilder.AppendLine(horizontalRule);
 439:              contentStringBuilder.AppendLine();
 440:   
 441:              content = contentStringBuilder.ToString();
 442:              //}
 443:              //else
 444:              //{
 445:              //    responseContent += "\r\n";
 446:              //    responseContent += "You are not authorized to modify this value. ";
 447:              //    responseContent += "\r\n";
 448:              //}
 449:          }
 450:   
 451:          ////////////////////////////////////////////////////////////////////////////
 452:   
 453:          /// <summary>
 454:          ///
 455:          /// </summary>
 456:          public static void StatisticListForTelegramBotApiAndMailSimpleText(string opcode, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
 457:          {
 458:              StringBuilder stringBuilder;
 459:              DateTime now;
 460:              List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> statisticList;
 461:   
 462:              stringBuilder = new StringBuilder();
 463:              now = DateTime.UtcNow.AddHours(3);
 464:   
 465:              //stringBuilder.AppendLine("Optical Fiber Network (OFN) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
 466:   
 467:              //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
 468:              //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
 469:              //stringBuilder.AppendLine();
 470:   
 471:              if (opcode.Contains("statistics"))
 472:              {
 473:                  statisticList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnAreaCachedDaily;
 474:   
 475:                  if (statisticList != null && statisticList.Count > 0)
 476:                  {
 477:                      stringBuilder.AppendLine(horizontalRule);
 478:                      stringBuilder.AppendLine("Statistics:");
 479:                      stringBuilder.AppendLine();
 480:                      foreach (var s in statisticList) stringBuilder.AppendLine(s.ToSimpleTextString());
 481:                      stringBuilder.AppendLine(horizontalRule);
 482:                      stringBuilder.AppendLine();
 483:                  }
 484:                  else
 485:                  {
 486:                      stringBuilder.AppendLine(horizontalRule);
 487:                      stringBuilder.AppendLine();
 488:                  }
 489:              }
 490:              else
 491:              {
 492:                  stringBuilder.AppendLine(horizontalRule);
 493:                  stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
 494:                  stringBuilder.AppendLine(horizontalRule);
 495:                  stringBuilder.AppendLine();
 496:              }
 497:   
 498:              contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 499:          }
 500:   
 501:          ////////////////////////////////////////////////////////////////////////////
 502:          ////////////////////////////////////////////////////////////////////////////    
 503:      }
 504:   
 505:      ////////////////////////////////////////////////////////////////////////////
 506:      ////////////////////////////////////////////////////////////////////////////   
 507:  }