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 PreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOlt(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
  53:          {
  54:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
  55:              List<string> list;
  56:   
  57:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
  58:   
  59:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(olt, false, edServiceVoipIsOos, out count);
  60:   
  61:              Ia.Ngn.Cl.Model.Ui.Default.ConvertArrayListContentToString(list, ref sb, ref result);
  62:          }
  63:   
  64:          ////////////////////////////////////////////////////////////////////////////
  65:   
  66:          /// <summary>
  67:          ///
  68:          /// </summary>
  69:          public static void PreprovisionAllOntsAsDefinedInNddDocumentWithinOlt(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
  70:          {
  71:              List<string> list;
  72:   
  73:              list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToPreprovisionAllOntsAsDefinedInNddDocumentWithinOltList(oltId, 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 DeleteAndReCreateVoipsAndOntpotsForAllPossibleCompleteSetOfOntsInAOltToSetVoipsMgcPrimaryAndSecondaryIpsAccordingToNgnDocument(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
  84:          {
  85:              // below:
  86:              string sa;
  87:              Ia.Ngn.Cl.Model.Ont ont;
  88:              List<Ia.Ngn.Cl.Model.Ont> ontList;
  89:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
  90:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
  91:   
  92:              sb = new StringBuilder();
  93:   
  94:              count = 0;
  95:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
  96:   
  97:              if (olt != null)
  98:              {
  99:                  ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ReadListIncludeOntServiceVoipsAndAccess((int)olt.Id);
 100:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 101:   
 102:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 103:                  {
 104:                      ont = (from o in ontList where o.Access.Pon == nddOnt.Pon.Number && o.Access.Ont == nddOnt.Number select o).SingleOrDefault();
 105:   
 106:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToDeleteAndCreateServiceVoipUsingNdd(olt, ont, nddOnt, edServiceVoipIsOos);
 107:   
 108:                      sb.Append(sa);
 109:                      count++;
 110:                  }
 111:              }
 112:              else
 113:              {
 114:                  throw new Exception(@"Error: olt is null. ") { };
 115:              }
 116:          }
 117:   
 118:          ////////////////////////////////////////////////////////////////////////////
 119:   
 120:          /// <summary>
 121:          ///
 122:          /// </summary>
 123:          public static void DeleteAndReCreateVoipsAndOntpotsToHaveErrorsInMgcPrimaryAndOrSecondaryIpValuesWithinAOltToMakeThemMatchTheNgnDocumentMgcIpSpecification(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 124:          {
 125:              // below:
 126:              bool b;
 127:              string sa;
 128:              Ia.Ngn.Cl.Model.Ont ont;
 129:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 130:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 131:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 132:   
 133:              sb = new StringBuilder();
 134:   
 135:              count = 0;
 136:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).SingleOrDefault();
 137:   
 138:              if (olt != null)
 139:              {
 140:                  ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ReadListIncludeOntServiceVoipsAndAccess((int)olt.Id);
 141:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 142:   
 143:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 144:                  {
 145:                      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();
 146:   
 147:                      if(ont != null)
 148:                      {
 149:                         b = (from osv in ont.OntServiceVoips where osv.MgcIp != nddOnt.MgcIp || osv.MgcSecondaryIp != nddOnt.MgcSecondaryIp select true).SingleOrDefault();
 150:   
 151:                         if (b)
 152:                         {
 153:                             sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToDeleteAndCreateServiceVoipUsingNdd(olt, ont, nddOnt, edServiceVoipIsOos);
 154:   
 155:                             sb.Append(sa);
 156:                             count++;
 157:                         }
 158:                         else
 159:                         {
 160:                         }
 161:                      }
 162:                      else
 163:                      {
 164:                      }
 165:                  }
 166:              }
 167:              else
 168:              {
 169:                  throw new Exception(@"Error: olt is null. ") { };
 170:              }
 171:          }
 172:   
 173:          ////////////////////////////////////////////////////////////////////////////
 174:   
 175:          /// <summary>
 176:          ///
 177:          /// </summary>
 178:          public static void CreateMissingOntpotsForDefinedOntsWithValidAccess(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 179:          {
 180:              string sa;
 181:              ArrayList al;
 182:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 183:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 184:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 185:              List<Ia.Ngn.Cl.Model.Ont> ontList, ontWithMissingPotsList;
 186:   
 187:              sb = new StringBuilder();
 188:   
 189:              count = 0;
 190:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).Single();
 191:   
 192:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ListIncludeAccessAndOntOntPots(oltId);
 193:              ontWithMissingPotsList = new List<Ia.Ngn.Cl.Model.Ont>(ontList.Count);
 194:   
 195:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 196:              {
 197:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 198:   
 199:                  if (familyType != (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined)
 200:                  {
 201:                      al = Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(familyType);
 202:   
 203:                      if (ont.OntOntPotses.Count != al.Count && ont.Access != null) ontWithMissingPotsList.Add(ont);
 204:                  }
 205:              }
 206:   
 207:              if (ontWithMissingPotsList.Count > 0)
 208:              {
 209:                  foreach (Ia.Ngn.Cl.Model.Ont ont in ontWithMissingPotsList)
 210:                  {
 211:                      nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ont.Id select o).SingleOrDefault();
 212:   
 213:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToCreateOntPots(olt, ont, nddOnt, edServiceVoipIsOos);
 214:   
 215:                      sb.Append(sa);
 216:                      count++;
 217:                  }
 218:              }
 219:              else
 220:              {
 221:                  result = @"Success: No missing POTS in network. ";
 222:              }
 223:          }
 224:   
 225:          ////////////////////////////////////////////////////////////////////////////
 226:   
 227:          /// <summary>
 228:          ///
 229:          /// </summary>
 230:          public static void CreateOntPotsForAllPossibleCompleteSetOfOntWithValidAccess(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 231:          {
 232:              string sa;
 233:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 234:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 235:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 236:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 237:   
 238:              sb = new StringBuilder();
 239:   
 240:              count = 0;
 241:              olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Id == oltId select o).Single();
 242:   
 243:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.ListIncludeAccessAndOntOntPots(oltId);
 244:   
 245:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 246:              {
 247:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 248:   
 249:                  if (familyType == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined)
 250:                      familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 251:   
 252:                  ont.FamilyTypeId = (int)familyType;
 253:   
 254:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ont.Id select o).SingleOrDefault();
 255:   
 256:                  sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToCreateOntPots(olt, ont, nddOnt, edServiceVoipIsOos);
 257:   
 258:                  sb.Append(sa);
 259:                  count++;
 260:              }
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:   
 265:          /// <summary>
 266:          ///
 267:          /// </summary>
 268:          public static void PreprovisionAllOntsAsDefinedInNddDocumentWithinOltUsingConfigureCommand(int oltId, bool edServiceVoipIsOos, ref StringBuilder sb, out int count, ref string result)
 269:          {
 270:              // below:
 271:              string sa;
 272:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 273:   
 274:              count = 0;
 275:   
 276:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 277:              {
 278:                  sb = new StringBuilder();
 279:   
 280:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 281:   
 282:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 283:                  {
 284:                      sa = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOltUsingConfigureCommand(nddOnt, edServiceVoipIsOos);
 285:   
 286:                      sb.Append(sa);
 287:                      count++;
 288:                  }
 289:              }
 290:          }
 291:   
 292:          ////////////////////////////////////////////////////////////////////////////
 293:          ////////////////////////////////////////////////////////////////////////////   
 294:      }
 295:   
 296:      ////////////////////////////////////////////////////////////////////////////
 297:      ////////////////////////////////////////////////////////////////////////////   
 298:  }