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

Integrated Applications Programming Company

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 Optical Fiber Network (OFN) web application (Intranet) model.

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