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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Default

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

Maintenance Report data support class for the Next Generation Network ui model

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Runtime.Serialization;
   5:  using System.Text;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Ui.Maintenance.Report
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Maintenance Report data support class for the Next Generation Network ui model
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2017-2018 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:      [DataContract(IsReference = true, Namespace = "kw.com.ia.ngn.api", Name = "apiMaintenanceReport")]
  29:      public partial class Default
  30:      {
  31:          private static List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> reportAccessServiceRequestList;
  32:   
  33:          /// <summary/>
  34:          [DataMember(Name = "result")]
  35:          public Ia.Cl.Model.Result Result { get; set; }
  36:   
  37:          /////////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public static void TnmdListForMail(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, out string subject, out string content)
  43:          {
  44:              string inputType, horizontalRule;
  45:              StringBuilder stringBuilder;
  46:              DateTime now;
  47:   
  48:              inputType = string.Empty;
  49:              horizontalRule = "===============================================";
  50:   
  51:              now = DateTime.UtcNow.AddHours(3);
  52:   
  53:              // subject can't have \r\n
  54:              subject = "Optical Fiber Network (OFN) Find Result (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
  55:              content = string.Empty;
  56:   
  57:              if (Ia.Ngn.Cl.Model.Business.Authority.FrameworkCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, framework))
  58:              {
  59:                  opcode = opcode.ToLower();
  60:   
  61:                  FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, operand, inputType, horizontalRule, out stringBuilder);
  62:   
  63:                  stringBuilder.AppendLine(horizontalRule);
  64:                  stringBuilder.AppendLine(@"Help? Send message with ""mail/maintenance/find/help""");
  65:                  stringBuilder.AppendLine(horizontalRule);
  66:                  stringBuilder.AppendLine();
  67:   
  68:                  content = stringBuilder.ToString();
  69:              }
  70:              else
  71:              {
  72:                  content += "\r\n";
  73:                  content += "You are not authorized to modify this value. ";
  74:                  content += "\r\n";
  75:              }
  76:          }
  77:   
  78:          /////////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static void TnmdListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
  84:          {
  85:              string inputType, horizontalRule;
  86:              StringBuilder contentStringBuilder;
  87:              DateTime now;
  88:   
  89:              inputType = string.Empty;
  90:              horizontalRule = " ";
  91:   
  92:              now = DateTime.UtcNow.AddHours(3);
  93:   
  94:              // subject can't have \r\n
  95:              subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
  96:   
  97:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
  98:              //{
  99:              opcode = opcode.ToLower();
 100:   
 101:              FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
 102:   
 103:              contentStringBuilder.AppendLine(horizontalRule);
 104:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 105:              contentStringBuilder.AppendLine(horizontalRule);
 106:              contentStringBuilder.AppendLine();
 107:   
 108:              content = contentStringBuilder.ToString();
 109:              //}
 110:              //else
 111:              //{
 112:              //    responseContent += "\r\n";
 113:              //    responseContent += "You are not authorized to modify this value. ";
 114:              //    responseContent += "\r\n";
 115:              //}
 116:          }
 117:   
 118:          /////////////////////////////////////////////////////////////////////////////////
 119:   
 120:          /// <summary>
 121:          ///
 122:          /// </summary>
 123:          public static void FieldListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, out string subject, out string content)
 124:          {
 125:              string inputType, horizontalRule;
 126:              StringBuilder contentStringBuilder;
 127:              DateTime now;
 128:   
 129:              inputType = string.Empty;
 130:              horizontalRule = " ";
 131:   
 132:              now = DateTime.UtcNow.AddHours(3);
 133:   
 134:              // subject can't have \r\n
 135:              subject = string.Empty; // "Optical Fiber Network (OFN) Field list: ";
 136:   
 137:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
 138:              //{
 139:              opcode = opcode.ToLower();
 140:              operand = operand.ToLower();
 141:   
 142:              FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, operand, inputType, horizontalRule, out contentStringBuilder);
 143:   
 144:              contentStringBuilder.AppendLine(horizontalRule);
 145:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 146:              contentStringBuilder.AppendLine(horizontalRule);
 147:              contentStringBuilder.AppendLine();
 148:   
 149:              content = contentStringBuilder.ToString();
 150:              //}
 151:              //else
 152:              //{
 153:              //    responseContent += "\r\n";
 154:              //    responseContent += "You are not authorized to modify this value. ";
 155:              //    responseContent += "\r\n";
 156:              //}
 157:          }
 158:   
 159:          /////////////////////////////////////////////////////////////////////////////////
 160:   
 161:          /// <summary>
 162:          ///
 163:          /// </summary>
 164:          public static void NokiaListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
 165:          {
 166:              string inputType, horizontalRule;
 167:              StringBuilder contentStringBuilder;
 168:              DateTime now;
 169:   
 170:              inputType = string.Empty;
 171:              horizontalRule = " ";
 172:   
 173:              now = DateTime.UtcNow.AddHours(3);
 174:   
 175:              // subject can't have \r\n
 176:              subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
 177:   
 178:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
 179:              //{
 180:              opcode = opcode.ToLower();
 181:   
 182:              FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
 183:   
 184:              contentStringBuilder.AppendLine(horizontalRule);
 185:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 186:              contentStringBuilder.AppendLine(horizontalRule);
 187:              contentStringBuilder.AppendLine();
 188:   
 189:              content = contentStringBuilder.ToString();
 190:              //}
 191:              //else
 192:              //{
 193:              //    responseContent += "\r\n";
 194:              //    responseContent += "You are not authorized to modify this value. ";
 195:              //    responseContent += "\r\n";
 196:              //}
 197:          }
 198:   
 199:          /////////////////////////////////////////////////////////////////////////////////
 200:   
 201:          /// <summary>
 202:          ///
 203:          /// </summary>
 204:          public static void HuaweiListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
 205:          {
 206:              string inputType, horizontalRule;
 207:              StringBuilder contentStringBuilder;
 208:              DateTime now;
 209:   
 210:              inputType = string.Empty;
 211:              horizontalRule = " ";
 212:   
 213:              now = DateTime.UtcNow.AddHours(3);
 214:   
 215:              // subject can't have \r\n
 216:              subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
 217:   
 218:              //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
 219:              //{
 220:              opcode = opcode.ToLower();
 221:   
 222:              FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
 223:   
 224:              contentStringBuilder.AppendLine(horizontalRule);
 225:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 226:              contentStringBuilder.AppendLine(horizontalRule);
 227:              contentStringBuilder.AppendLine();
 228:   
 229:              content = contentStringBuilder.ToString();
 230:              //}
 231:              //else
 232:              //{
 233:              //    responseContent += "\r\n";
 234:              //    responseContent += "You are not authorized to modify this value. ";
 235:              //    responseContent += "\r\n";
 236:              //}
 237:          }
 238:   
 239:          /////////////////////////////////////////////////////////////////////////////////
 240:   
 241:          /// <summary>
 242:          ///
 243:          /// </summary>
 244:          public static void NetworkDesignDocumentForTelegramBotApi(out string subject, out string content)
 245:          {
 246:              string horizontalRule;
 247:              StringBuilder contentStringBuilder;
 248:              DateTime now;
 249:   
 250:              horizontalRule = " ";
 251:              now = DateTime.UtcNow.AddHours(3);
 252:   
 253:              // subject can't have \r\n
 254:              subject = "Network Design Document (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 255:   
 256:              contentStringBuilder = new StringBuilder();
 257:   
 258:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.StructureToSimpleTextString());
 259:              contentStringBuilder.AppendLine(horizontalRule);
 260:              contentStringBuilder.AppendLine();
 261:   
 262:              contentStringBuilder.AppendLine(horizontalRule);
 263:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 264:              contentStringBuilder.AppendLine(horizontalRule);
 265:              contentStringBuilder.AppendLine();
 266:   
 267:              contentStringBuilder = contentStringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 268:   
 269:              content = contentStringBuilder.ToString();
 270:          }
 271:   
 272:          /////////////////////////////////////////////////////////////////////////////////
 273:   
 274:          /// <summary>
 275:          ///
 276:          /// </summary>
 277:          public static void ServiceRequestFromTodayForTelegramBotApi(out string subject, out string content)
 278:          {
 279:              string horizontalRule;
 280:              StringBuilder contentStringBuilder;
 281:              DateTime now;
 282:   
 283:              horizontalRule = " ";
 284:   
 285:              contentStringBuilder = new StringBuilder();
 286:   
 287:              now = DateTime.UtcNow.AddHours(3);
 288:   
 289:              // subject can't have \r\n
 290:              subject = "Service Requests from Today (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
 291:   
 292:              var serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.ForRequestDate(now).OrderBy(u => u.Id).ToList();
 293:   
 294:              if (serviceRequestList.Count > 0)
 295:              {
 296:                  if (serviceRequestList != null && serviceRequestList.Count > 0)
 297:                  {
 298:                      foreach (var sr in serviceRequestList) contentStringBuilder.AppendLine(sr.ToSimpleTextString());
 299:                      contentStringBuilder.AppendLine(horizontalRule);
 300:                      contentStringBuilder.AppendLine();
 301:                  }
 302:              }
 303:              else
 304:              {
 305:                  contentStringBuilder.AppendLine(horizontalRule);
 306:                  contentStringBuilder.AppendLine("No results. ");
 307:                  contentStringBuilder.AppendLine();
 308:              }
 309:   
 310:              contentStringBuilder.AppendLine(horizontalRule);
 311:              contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
 312:              contentStringBuilder.AppendLine(horizontalRule);
 313:              contentStringBuilder.AppendLine();
 314:   
 315:              contentStringBuilder = contentStringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 316:   
 317:              content = contentStringBuilder.ToString();
 318:          }
 319:   
 320:          ////////////////////////////////////////////////////////////////////////////
 321:   
 322:          /// <summary>
 323:          ///
 324:          /// </summary>
 325:          public static void FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
 326:          {
 327:              int siteId;
 328:              StringBuilder stringBuilder;
 329:              DateTime now;
 330:   
 331:              stringBuilder = new StringBuilder();
 332:              now = DateTime.UtcNow.AddHours(3);
 333:   
 334:              //stringBuilder.AppendLine("Optical Fiber Network (OFN) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
 335:   
 336:              //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
 337:              //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
 338:              //stringBuilder.AppendLine();
 339:   
 340:              if (opcode.Contains("field"))
 341:              {
 342:                  if (!string.IsNullOrEmpty(operand))
 343:                  {
 344:                      // get the siteId from the site name in operand
 345:                      siteId = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Name.ToLower() == operand select s.Id).SingleOrDefault();
 346:   
 347:                      if (framework.Site == null || siteId == framework.Site.Id)
 348:                      {
 349:                          _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Authority.FieldFrameworkAndStaffGuidList, siteId, "Field List:", horizontalRule, ref stringBuilder);
 350:                      }
 351:                      else
 352:                      {
 353:                          stringBuilder.AppendLine(horizontalRule);
 354:                          stringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.FrameworkNotAuthorized));
 355:                      }
 356:   
 357:                      stringBuilder.AppendLine(horizontalRule);
 358:                  }
 359:                  else
 360:                  {
 361:                      siteId = (framework.Site != null) ? framework.Site.Id : 0;
 362:   
 363:                      _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Authority.FieldFrameworkAndStaffGuidList, siteId, "Field List:", horizontalRule, ref stringBuilder);
 364:                  }
 365:              }
 366:              else if (opcode.Contains("tnmd"))
 367:              {
 368:                  siteId = (framework != null && framework.Site != null) ? framework.Site.Id : 0;
 369:   
 370:                  _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Authority.TnmdFrameworkAndStaffGuidList, siteId, "TNMD List:", horizontalRule, ref stringBuilder);
 371:              }
 372:              else if (opcode.Contains("nokia"))
 373:              {
 374:                  siteId = (framework != null && framework.Site != null) ? framework.Site.Id : 0;
 375:   
 376:                  _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Authority.NokiaFrameworkAndStaffGuidList, siteId, "Nokia List:", horizontalRule, ref stringBuilder);
 377:              }
 378:              else if (opcode.Contains("huawei"))
 379:              {
 380:                  siteId = (framework != null && framework.Site != null) ? framework.Site.Id : 0;
 381:   
 382:                  _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Authority.HuaweiFrameworkAndStaffGuidList, siteId, "Huawei List:", horizontalRule, ref stringBuilder);
 383:              }
 384:              else
 385:              {
 386:                  stringBuilder.AppendLine(horizontalRule);
 387:                  stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
 388:                  stringBuilder.AppendLine(horizontalRule);
 389:              }
 390:   
 391:              contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 392:          }
 393:   
 394:          ////////////////////////////////////////////////////////////////////////////
 395:   
 396:          /// <summary>
 397:          ///
 398:          /// </summary>
 399:          private static void _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(List<Guid> frameworkAndStaffGuidList, int siteId, string caption, string horizontalRule, ref StringBuilder stringBuilder)
 400:          {
 401:              reportAccessServiceRequestList = Ia.Ngn.Cl.Model.Ui.Report.ReadSpecificUserIdListAndSiteIdReportWithReportOpenStatusList(frameworkAndStaffGuidList, siteId);
 402:   
 403:              stringBuilder.AppendLine(horizontalRule);
 404:              stringBuilder.AppendLine(caption);
 405:              stringBuilder.AppendLine();
 406:   
 407:              if (reportAccessServiceRequestList != null && reportAccessServiceRequestList.Count > 0)
 408:              {
 409:                  foreach (var rasr in reportAccessServiceRequestList) stringBuilder.AppendLine(rasr.ToSimpleTextString());
 410:              }
 411:              else stringBuilder.AppendLine("No records were found. ");
 412:   
 413:              stringBuilder.AppendLine(horizontalRule);
 414:          }
 415:   
 416:          ////////////////////////////////////////////////////////////////////////////
 417:          ////////////////////////////////////////////////////////////////////////////    
 418:      }
 419:   
 420:      ////////////////////////////////////////////////////////////////////////////
 421:      ////////////////////////////////////////////////////////////////////////////   
 422:  }