Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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.Text;
   3:  using System.Collections.Generic;
   4:  using System.Runtime.Serialization;
   5:  using System.Linq;
   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 TndListForMail(Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact, string opcode, out string subject, out string content)
  43:          {
  44:              string inputType, horizontalRule;
  45:              StringBuilder contentStringBuilder;
  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.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
  58:              {
  59:                  opcode = opcode.ToLower();
  60:   
  61:                  FieldTndListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out contentStringBuilder);
  62:   
  63:                  contentStringBuilder.AppendLine(horizontalRule);
  64:                  contentStringBuilder.AppendLine(@"Help? Send message with ""mail/maintenance/find/help""");
  65:                  contentStringBuilder.AppendLine(horizontalRule);
  66:                  contentStringBuilder.AppendLine();
  67:   
  68:                  content = contentStringBuilder.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 TndListForTelegramBotApi(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) TND 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:              FieldTndListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out contentStringBuilder);
 102:   
 103:              contentStringBuilder.AppendLine(horizontalRule);
 104:              contentStringBuilder.AppendLine(@"Help? Send the command /help");
 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(string opcode, 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:   
 141:              FieldTndListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out contentStringBuilder);
 142:   
 143:              contentStringBuilder.AppendLine(horizontalRule);
 144:              contentStringBuilder.AppendLine(@"Help? Send the command /help");
 145:              contentStringBuilder.AppendLine(horizontalRule);
 146:              contentStringBuilder.AppendLine();
 147:   
 148:              content = contentStringBuilder.ToString();
 149:              //}
 150:              //else
 151:              //{
 152:              //    responseContent += "\r\n";
 153:              //    responseContent += "You are not authorized to modify this value. ";
 154:              //    responseContent += "\r\n";
 155:              //}
 156:          }
 157:   
 158:          ////////////////////////////////////////////////////////////////////////////
 159:   
 160:          /// <summary>
 161:          ///
 162:          /// </summary>
 163:          public static void FieldTndListForTelegramBotApiAndMailSimpleText(string opcode, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
 164:          {
 165:              StringBuilder stringBuilder;
 166:              DateTime now;
 167:   
 168:              stringBuilder = new StringBuilder();
 169:              now = DateTime.UtcNow.AddHours(3);
 170:   
 171:              //stringBuilder.AppendLine("Optical Fiber Network (OFN) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
 172:   
 173:              //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
 174:              //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
 175:              //stringBuilder.AppendLine();
 176:   
 177:              if (opcode.Contains("tnd"))
 178:              {
 179:                  reportAccessServiceRequestList = Ia.Ngn.Cl.Model.Data.Report.ReadSpecificUserIdAndAreaIdReportWithReportOpenStatusList(Ia.Ngn.Cl.Model.Data.Contact.TndUserGuid, 0);
 180:   
 181:                  reportAccessServiceRequestList = reportAccessServiceRequestList.OrderBy(u => u.Access.AreaId).ThenBy(u => u.Access.Block).ThenBy(u => u.Access.Street).ThenBy(u => u.Access.PremisesOld).ToList();
 182:   
 183:                  if (reportAccessServiceRequestList != null && reportAccessServiceRequestList.Count > 0)
 184:                  {
 185:                      stringBuilder.AppendLine(horizontalRule);
 186:                      stringBuilder.AppendLine("TND List:");
 187:                      stringBuilder.AppendLine();
 188:                      foreach (var rasr in reportAccessServiceRequestList) stringBuilder.AppendLine(rasr.ToSimpleTextString());
 189:                      stringBuilder.AppendLine(horizontalRule);
 190:                      stringBuilder.AppendLine();
 191:                  }
 192:                  else
 193:                  {
 194:                      stringBuilder.AppendLine(horizontalRule);
 195:                      stringBuilder.AppendLine();
 196:                  }
 197:              }
 198:              else if (opcode.Contains("field"))
 199:              {
 200:                  reportAccessServiceRequestList = Ia.Ngn.Cl.Model.Data.Report.ReadSpecificUserIdAndAreaIdReportWithReportOpenStatusList(Ia.Ngn.Cl.Model.Data.Contact.FieldUserGuid, 0);
 201:   
 202:                  reportAccessServiceRequestList = reportAccessServiceRequestList.OrderBy(u => u.Access.AreaId).ThenBy(u => u.Access.Block).ThenBy(u => u.Access.Street).ThenBy(u => u.Access.PremisesOld).ToList();
 203:   
 204:                  if (reportAccessServiceRequestList != null && reportAccessServiceRequestList.Count > 0)
 205:                  {
 206:                      stringBuilder.AppendLine(horizontalRule);
 207:                      stringBuilder.AppendLine("Field List:");
 208:                      stringBuilder.AppendLine();
 209:                      foreach (var rasr in reportAccessServiceRequestList) stringBuilder.AppendLine(rasr.ToSimpleTextString());
 210:                      stringBuilder.AppendLine(horizontalRule);
 211:                      stringBuilder.AppendLine();
 212:                  }
 213:                  else
 214:                  {
 215:                      stringBuilder.AppendLine(horizontalRule);
 216:                      stringBuilder.AppendLine();
 217:                  }
 218:              }
 219:              else
 220:              {
 221:                  stringBuilder.AppendLine(horizontalRule);
 222:                  stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
 223:                  stringBuilder.AppendLine(horizontalRule);
 224:                  stringBuilder.AppendLine();
 225:              }
 226:   
 227:              contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
 228:          }
 229:   
 230:          ////////////////////////////////////////////////////////////////////////////
 231:          ////////////////////////////////////////////////////////////////////////////    
 232:      }
 233:   
 234:      ////////////////////////////////////////////////////////////////////////////
 235:      ////////////////////////////////////////////////////////////////////////////   
 236:  }