Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Script

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

Script support class for Next Generation Network (NGN) web application (Intranet) 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:   
  17:  namespace Ia.Ngn.Ofn.Wa.Model.Business.Maintenance
  18:  {
  19:      ////////////////////////////////////////////////////////////////////////////
  20:   
  21:      /// <summary publish="true">
  22:      /// Script support class for Next Generation Network (NGN) web application (Intranet) model.
  23:      /// </summary>
  24:      /// 
  25:      /// <remarks> 
  26:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  27:      ///
  28:      /// 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
  29:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  30:      ///
  31:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  32:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  33:      /// 
  34:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  35:      /// 
  36:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  37:      /// </remarks> 
  38:      public class Script
  39:      {
  40:          ////////////////////////////////////////////////////////////////////////////
  41:   
  42:          /// <summary>
  43:          ///
  44:          /// </summary>
  45:          public Script() { }
  46:   
  47:          ////////////////////////////////////////////////////////////////////////////
  48:   
  49:          /// <summary>
  50:          ///
  51:          /// </summary>
  52:          public static void ProduceAmsCommandsToEditOntServiceHsiEntriesInAmsToDowngradeQualitynetBandwidthRateFrom50MbTo20Mb(ref StringBuilder sb, out int count, ref string result)
  53:          {
  54:              List<string> list;
  55:   
  56:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToEditOntServiceHsiList(out count);
  57:   
  58:              Ia.Ngn.Cl.Model.Ui.Default.ConvertArrayListContentToString(list, ref sb, ref result);
  59:          }
  60:   
  61:          ////////////////////////////////////////////////////////////////////////////
  62:   
  63:          /// <summary>
  64:          ///
  65:          /// </summary>
  66:          public static void PreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOlt(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
  67:          {
  68:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
  69:              List<string> list;
  70:   
  71:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
  72:   
  73:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(olt, false, edServiceVoipIsOos, out count);
  74:   
  75:              Ia.Ngn.Cl.Model.Ui.Default.ConvertArrayListContentToString(list, ref sb, ref result);
  76:          }
  77:   
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static void PreprovisionAllOntsAsDefinedInNddDocumentWithinOlt(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
  84:          {
  85:              List<string> list;
  86:   
  87:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToPreprovisionAllOntsAsDefinedInNddDocumentWithinOltList(oltId, edServiceVoipIsOos, out count);
  88:   
  89:              Ia.Ngn.Cl.Model.Ui.Default.ConvertArrayListContentToString(list, ref sb, ref result);
  90:          }
  91:   
  92:          /*
  93:          ////////////////////////////////////////////////////////////////////////////    
  94:  
  95:          /// <summary>
  96:          ///
  97:          /// </summary>
  98:          public static DataTable ReturnEntriesInAmsOfQualitynetWithBandwidthRateOf50Mb()
  99:          {
 100:              sql = @"SELECT st.olt, st.olt_rack, st.olt_sub, st.olt_card, st.olt_port, st.ont, oh.card, oh.port, oh.service, oh.svlan, oh.label, oh.customer_id
 101:  FROM ia_ont_hsi AS oh INNER JOIN ia_ont AS o ON o.id = oh.ia_ont_id INNER JOIN ia_standard AS st ON st.ia_ont_id = o.id
 102:  WHERE
 103:  ( (oh.svlan = 301 OR oh.svlan = 401) )
 104:  ORDER BY st.id
 105:  ";          //  AND ((oh.upstream_bandwidth_profile_id <> 20) OR (oh.downstream_bandwidth_profile_id <> 20))
 106:          }
 107:           */
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          ///
 113:          /// </summary>
 114:          public static void DeleteAndReCreateVoipsAndOntpotsForAllPossibleCompleteSetOfOntsInAOltToSetVoipsMgcPrimaryAndSecondaryIpsAccordingToNgnDocument(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 115:          {
 116:              // below:
 117:              string sa;
 118:              Ia.Ngn.Cl.Model.Ont ont;
 119:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 120:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 121:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 122:   
 123:              sb = new StringBuilder();
 124:   
 125:              count = 0;
 126:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
 127:   
 128:              if (olt != null)
 129:              {
 130:                  ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ReadListIncludeOntServiceVoipsAndAccess((int)olt.Id);
 131:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 132:   
 133:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 134:                  {
 135:                      ont = (from o in ontList where o.Access.Pon == nddOnt.Pon.Number && o.Access.Ont == nddOnt.Number select o).SingleOrDefault();
 136:   
 137:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToDeleteAndCreateServiceVoipUsingNdd(olt, ont, nddOnt, edServiceVoipIsOos);
 138:   
 139:                      sb.Append(sa);
 140:                      count++;
 141:                  }
 142:              }
 143:              else
 144:              {
 145:                  throw new Exception(@"Error: olt is null. ") { };
 146:              }
 147:          }
 148:   
 149:          ////////////////////////////////////////////////////////////////////////////
 150:   
 151:          /// <summary>
 152:          ///
 153:          /// </summary>
 154:          public static void DeleteAndReCreateVoipsAndOntpotsToHaveErrorsInMgcPrimaryAndOrSecondaryIpValuesWithinAOltToMakeThemMatchTheNgnDocumentMgcIpSpecification(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 155:          {
 156:              // below:
 157:              bool b;
 158:              string sa;
 159:              Ia.Ngn.Cl.Model.Ont ont;
 160:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 161:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 162:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 163:   
 164:              sb = new StringBuilder();
 165:   
 166:              count = 0;
 167:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
 168:   
 169:              if (olt != null)
 170:              {
 171:                  ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ReadListIncludeOntServiceVoipsAndAccess((int)olt.Id);
 172:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 173:   
 174:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 175:                  {
 176:                      ont = (from a in ontList where a.Access.Olt == nddOnt.Pon.PonGroup.Olt.Id && a.Access.Pon == nddOnt.Pon.Number && a.Access.Ont == nddOnt.Number select a).SingleOrDefault();
 177:   
 178:                      if(ont != null)
 179:                      {
 180:                         b = (from osv in ont.OntServiceVoips where osv.MgcIp != nddOnt.MgcIp || osv.MgcSecondaryIp != nddOnt.MgcSecondaryIp select true).SingleOrDefault();
 181:   
 182:                         if (b)
 183:                         {
 184:                             sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToDeleteAndCreateServiceVoipUsingNdd(olt, ont, nddOnt, edServiceVoipIsOos);
 185:   
 186:                             sb.Append(sa);
 187:                             count++;
 188:                         }
 189:                         else
 190:                         {
 191:                         }
 192:                      }
 193:                      else
 194:                      {
 195:                      }
 196:                  }
 197:              }
 198:              else
 199:              {
 200:                  throw new Exception(@"Error: olt is null. ") { };
 201:              }
 202:          }
 203:   
 204:          ////////////////////////////////////////////////////////////////////////////
 205:   
 206:          /// <summary>
 207:          ///
 208:          /// </summary>
 209:          public static void CreateMissingOntpotsForDefinedOntsWithValidAccess(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 210:          {
 211:              string sa;
 212:              ArrayList al;
 213:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 214:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 215:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 216:              List<Ia.Ngn.Cl.Model.Ont> ontList, ontWithMissingPotsList;
 217:   
 218:              sb = new StringBuilder();
 219:   
 220:              count = 0;
 221:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).Single();
 222:   
 223:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ListIncludeAccessAndOntOntPots(oltId);
 224:              ontWithMissingPotsList = new List<Ia.Ngn.Cl.Model.Ont>(ontList.Count);
 225:   
 226:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 227:              {
 228:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 229:   
 230:                  if (familyType != (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined)
 231:                  {
 232:                      al = Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(familyType);
 233:   
 234:                      if (ont.OntOntPotses.Count != al.Count && ont.Access != null) ontWithMissingPotsList.Add(ont);
 235:                  }
 236:              }
 237:   
 238:              if (ontWithMissingPotsList.Count > 0)
 239:              {
 240:                  foreach (Ia.Ngn.Cl.Model.Ont ont in ontWithMissingPotsList)
 241:                  {
 242:                      nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ont.Id select o).SingleOrDefault();
 243:   
 244:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToCreateOntPots(olt, ont, nddOnt, edServiceVoipIsOos);
 245:   
 246:                      sb.Append(sa);
 247:                      count++;
 248:                  }
 249:              }
 250:              else
 251:              {
 252:                  result = @"Success: No missing POTS in network. ";
 253:              }
 254:          }
 255:   
 256:          ////////////////////////////////////////////////////////////////////////////
 257:   
 258:          /// <summary>
 259:          ///
 260:          /// </summary>
 261:          public static void CreateOntPotsForAllPossibleCompleteSetOfOntWithValidAccess(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 262:          {
 263:              string sa;
 264:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 265:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 266:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 267:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 268:   
 269:              sb = new StringBuilder();
 270:   
 271:              count = 0;
 272:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).Single();
 273:   
 274:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ListIncludeAccessAndOntOntPots(oltId);
 275:   
 276:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 277:              {
 278:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 279:   
 280:                  if (familyType == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined)
 281:                      familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 282:   
 283:                  ont.FamilyTypeId = (int)familyType;
 284:   
 285:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ont.Id select o).SingleOrDefault();
 286:   
 287:                  sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToCreateOntPots(olt, ont, nddOnt, edServiceVoipIsOos);
 288:   
 289:                  sb.Append(sa);
 290:                  count++;
 291:              }
 292:          }
 293:   
 294:          ////////////////////////////////////////////////////////////////////////////
 295:   
 296:          /// <summary>
 297:          ///
 298:          /// </summary>
 299:          public static void PreprovisionAllOntsAsDefinedInNddDocumentWithinOltUsingConfigureCommand(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 300:          {
 301:              // below:
 302:              string sa;
 303:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 304:   
 305:              count = 0;
 306:   
 307:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 308:              {
 309:                  sb = new StringBuilder();
 310:   
 311:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 312:   
 313:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 314:                  {
 315:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOltUsingConfigureCommand(nddOnt, edServiceVoipIsOos);
 316:   
 317:                      sb.Append(sa);
 318:                      count++;
 319:                  }
 320:              }
 321:          }
 322:   
 323:          ////////////////////////////////////////////////////////////////////////////
 324:          ////////////////////////////////////////////////////////////////////////////   
 325:      }
 326:   
 327:      ////////////////////////////////////////////////////////////////////////////
 328:      ////////////////////////////////////////////////////////////////////////////   
 329:  }