)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Script (Ia.Ftn.Wa.Models.Business.Maintenance)

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

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