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

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

Access Management System (AMS) support class for Nokia's Next Generation Network (NGN) business model.

   1:  using System;
   2:  using System.Configuration;
   3:  using System.Text.RegularExpressions;
   4:  using System.Data;
   5:  using System.Collections;
   6:  using System.Collections.Generic;
   7:  using System.Linq;
   8:   
   9:  namespace Ia.Ngn.Cl.Model.Business.Nokia
  10:  {
  11:      ////////////////////////////////////////////////////////////////////////////
  12:   
  13:      /// <summary publish="true">
  14:      /// Access Management System (AMS) support class for Nokia's Next Generation Network (NGN) business model.
  15:      /// </summary>
  16:      /// 
  17:      /// <value>
  18:      ///   <appSettings>
  19:      ///       <add key="amsServerHost" value="*" />
  20:      ///       <add key="amsServerPort" value="*" />
  21:      ///       <add key="amsServerActUser" value="ACT-USER:{amsName}:*:::*;" />
  22:      ///       <add key="amsServerCancUser" value="CANC-USER:{amsName}:*:;" />
  23:      ///   </appSettings>
  24:      /// </value>
  25:      /// 
  26:      /// <remarks> 
  27:      /// Copyright © 2007-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  28:      ///
  29:      /// 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
  30:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  31:      ///
  32:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  33:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  34:      /// 
  35:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  36:      /// 
  37:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  38:      /// </remarks> 
  39:      public partial class Ams
  40:      {
  41:          // below: access data for AMS
  42:          private const string textToSkipInTelnetEndReceive = "IP 0\r\n<";
  43:   
  44:          private static Queue<string> priorityAmsCommandQueue = new Queue<string>(), amsCommandQueue = new Queue<string>(), amsCreateOntCommandQueue = new Queue<string>();
  45:   
  46:          /// <summary/>
  47:          public enum AmsOpcode
  48:          {
  49:              RtrvHdr, RtrvOnt, InitSys, RtrvServiceHsi, RtrvServiceVoip, RtrvOntPots, EdServiceHsi, RtrvAlmPon, EdOntDesc1, EdOntDesc1Annul, EdOntPotsCustinfo
  50:          }
  51:   
  52:          /// <summary/>
  53:          public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
  54:   
  55:          /// <summary/>
  56:          public static string Host { get { return ConfigurationManager.AppSettings["amsServerHost"].ToString(); } }
  57:          /// <summary/>
  58:          public static int Port { get { return int.Parse(ConfigurationManager.AppSettings["amsServerPort"].ToString()); } }
  59:   
  60:          /// <summary/>
  61:          public static string ActUser(string amsName)
  62:          {
  63:              return PrepareCtaggedCommand(ConfigurationManager.AppSettings["amsServerActUser"].ToString().Replace("{amsName}", amsName));
  64:          }
  65:          /// <summary/>
  66:          public static string CancUser(string amsName)
  67:          {
  68:              return PrepareCtaggedCommand(ConfigurationManager.AppSettings["amsServerCancUser"].ToString().Replace("{amsName}", amsName));
  69:          }
  70:   
  71:          /// <summary/>
  72:          public static string TextToSkipInTelnetEndReceive { get { return textToSkipInTelnetEndReceive; } }
  73:   
  74:          ////////////////////////////////////////////////////////////////////////////
  75:   
  76:          /// <summary>
  77:          ///
  78:          /// </summary>
  79:          public Ams() { }
  80:   
  81:          ////////////////////////////////////////////////////////////////////////////
  82:          ////////////////////////////////////////////////////////////////////////////
  83:   
  84:          /// <summary>
  85:          ///
  86:          /// </summary>
  87:          private static List<string> PrepareCtaggedCommand(List<string> commandList)
  88:          {
  89:              List<string> ctaggedCommandList;
  90:   
  91:              if (commandList.Count > 0)
  92:              {
  93:                  ctaggedCommandList = new List<string>(commandList.Count);
  94:   
  95:                  foreach (string command in commandList)
  96:                  {
  97:                      ctaggedCommandList.Add(PrepareCtaggedCommand(command));
  98:                  }
  99:              }
 100:              else ctaggedCommandList = new List<string>();
 101:   
 102:              return ctaggedCommandList;
 103:          }
 104:   
 105:          ////////////////////////////////////////////////////////////////////////////
 106:   
 107:          /// <summary>
 108:          ///
 109:          /// </summary>
 110:          private static string PrepareCtaggedCommand(string command)
 111:          {
 112:              string ctaggedCommand, ctag;
 113:   
 114:              if (command.Contains("{ctag}"))
 115:              {
 116:                  ctag = Ia.Cl.Model.Default.RandomNumber(6);
 117:                  // CTAG: The value of the CTAG is a non-zero integer of up to six characters. 
 118:                  // CTAG comes before ; or ::
 119:   
 120:                  Ia.Ngn.Cl.Model.Data.Nokia.Ams.CorrelationTagDictionary[ctag] = command;
 121:   
 122:                  ctaggedCommand = command.Replace("{ctag}", ctag);
 123:              }
 124:              else
 125:              {
 126:                  ctaggedCommand = string.Empty;
 127:              }
 128:   
 129:              return ctaggedCommand;
 130:          }
 131:   
 132:          ////////////////////////////////////////////////////////////////////////////
 133:          ////////////////////////////////////////////////////////////////////////////
 134:   
 135:          /// <summary>
 136:          ///
 137:          /// </summary>
 138:          public static string AmsKeepAliveCommand(string amsName)
 139:          {
 140:              return FormatAmsCommand(AmsOpcode.RtrvHdr, amsName);
 141:          }
 142:   
 143:          ////////////////////////////////////////////////////////////////////////////
 144:   
 145:          /// <summary>
 146:          ///
 147:          /// </summary>
 148:          public static string ResetOntCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 149:          {
 150:              return FormatAmsOntCommand(AmsOpcode.InitSys, ont);
 151:          }
 152:   
 153:          ////////////////////////////////////////////////////////////////////////////
 154:   
 155:          /// <summary>
 156:          ///
 157:          /// </summary>
 158:          public static string AmsCommandOfARandomAmsKeepAlive()
 159:          {
 160:              string command, amsName;
 161:   
 162:              amsName = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select o.AmsName).ToList().PickRandom();
 163:   
 164:              command = FormatAmsCommand(AmsOpcode.RtrvHdr, amsName);
 165:   
 166:              return command;
 167:          }
 168:   
 169:          ////////////////////////////////////////////////////////////////////////////
 170:   
 171:          /// <summary>
 172:          ///
 173:          /// </summary>
 174:          public static void EnqueuePriorityAmsCommandQueue(string command)
 175:          {
 176:              priorityAmsCommandQueue.Enqueue(command);
 177:          }
 178:   
 179:          ////////////////////////////////////////////////////////////////////////////
 180:   
 181:          /// <summary>
 182:          ///
 183:          /// </summary>
 184:          public static void EnqueuePriorityAmsCommandQueue(List<string> amsCommandList)
 185:          {
 186:              if (amsCommandList != null && amsCommandList.Count > 0)
 187:              {
 188:                  foreach (string s in amsCommandList) priorityAmsCommandQueue.Enqueue(s);
 189:              }
 190:          }
 191:   
 192:          ////////////////////////////////////////////////////////////////////////////
 193:   
 194:          /// <summary>
 195:          ///
 196:          /// </summary>
 197:          public static string ProperlySelectedSingleAmsCommandToManageOntVoipPotsHsiNetworkElements
 198:          {
 199:              get
 200:              {
 201:                  string command;
 202:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
 203:                  List<string> list;
 204:   
 205:                  command = null;
 206:   
 207:                  if (priorityAmsCommandQueue.Count > 0)
 208:                  {
 209:                      command = priorityAmsCommandQueue.Dequeue();
 210:                  }
 211:                  else
 212:                  {
 213:                      /*
 214:                      if (false && command == null && randomPercent < 60)
 215:                      {
 216:                          if (amsCreateOntCommandQueue.Count == 0)
 217:                          {
 218:                              olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltList.Where(o => o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr).PickRandom();
 219:  
 220:                              list = AmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(olt, true, false, out count);
 221:  
 222:                              amsCreateOntCommandQueue = new Queue<string>(list);
 223:                          }
 224:  
 225:                          if (amsCreateOntCommandQueue.Count > 0) command = amsCreateOntCommandQueue.Dequeue();
 226:                      }
 227:                      */
 228:   
 229:                      if (amsCommandQueue.Count == 0)
 230:                      {
 231:                          olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOltList.Where(o => /*(o.Symbol == "SBN" || o.Symbol == "QRW" || o.Symbol == "SJA") &&*/ o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr).PickRandom();
 232:   
 233:                          list = AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyType_AmsCommandsToRetrieveOntsDefinedInNddDocument_AmsCommandsToUpdateAndDisplayOntDescriptionWithItsAccessName_AmsCommandsToUpdateOntOntPotsCustomerWithItsConnectedServiceNumberList(olt);
 234:   
 235:                          amsCommandQueue = new Queue<string>(list);
 236:                      }
 237:   
 238:                      if (amsCommandQueue.Count > 0) command = amsCommandQueue.Dequeue();
 239:   
 240:                      if (command == null) command = AmsCommandOfARandomAmsKeepAlive();
 241:                  }
 242:   
 243:                  return command;
 244:              }
 245:          }
 246:   
 247:          ////////////////////////////////////////////////////////////////////////////
 248:   
 249:          /// <summary>
 250:          ///
 251:          /// </summary>
 252:          private static List<string> FormatAmsRtrvCommand(AmsOpcode amsOpcode, string position)
 253:          {
 254:              return FormatAmsRtrvCommand(amsOpcode, 0, position);
 255:          }
 256:   
 257:          ////////////////////////////////////////////////////////////////////////////
 258:   
 259:          /// <summary>
 260:          ///
 261:          /// </summary>
 262:          private static List<string> FormatAmsRtrvCommand(AmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, string position)
 263:          {
 264:              // Use this command with variable number of parameters
 265:              string command, amsName, pon;
 266:              List<string> list;
 267:   
 268:              command = null;
 269:   
 270:              list = new List<string>(10);
 271:   
 272:              if (!string.IsNullOrEmpty(position))
 273:              {
 274:                  AmsNameAndCardPortOntSquenceFromOntPosition(position, out amsName, out pon);
 275:   
 276:                  if (amsOpcode == AmsOpcode.RtrvOnt)
 277:                  {
 278:                      command = "RTRV-ONT:" + amsName + ":ONT-1-1-" + pon + ";";
 279:                      list.Add(command);
 280:                  }
 281:                  else if (amsOpcode == AmsOpcode.RtrvServiceHsi)
 282:                  {
 283:                      foreach (string ontHsiCardPortService in Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList(familyType))
 284:                      {
 285:                          command = "RTRV-SERVICE-HSI:" + amsName + ":HSI-1-1-" + pon + "-" + ontHsiCardPortService + ":" + ";";
 286:                          list.Add(command);
 287:                      }
 288:                  }
 289:                  else if (amsOpcode == AmsOpcode.RtrvServiceVoip)
 290:                  {
 291:                      command = "RTRV-SERVICE-VOIP:" + amsName + ":VOIP-1-1-" + pon + "-1;";
 292:                      list.Add(command);
 293:                  }
 294:                  else if (amsOpcode == AmsOpcode.RtrvOntPots)
 295:                  {
 296:                      foreach (string ontPotsCardPort in Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(familyType))
 297:                      {
 298:                          command = "RTRV-ONTPOTS:" + amsName + ":ONTPOTS-1-1-" + pon + "-" + ontPotsCardPort + ";";
 299:                          list.Add(command);
 300:                      }
 301:                  }
 302:              }
 303:   
 304:              return list;
 305:          }
 306:   
 307:          ////////////////////////////////////////////////////////////////////////////
 308:   
 309:          /// <summary>
 310:          ///
 311:          /// </summary>
 312:          private static string FormatAmsOntCommand(AmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 313:          {
 314:              string command, amsName, pon;
 315:   
 316:              command = string.Empty;
 317:   
 318:              if (!string.IsNullOrEmpty(ont.Position))
 319:              {
 320:                  AmsNameAndCardPortOntSquenceFromOntPosition(ont.Position, out amsName, out pon);
 321:   
 322:                  if (amsOpcode == AmsOpcode.EdOntDesc1)
 323:                  {
 324:                      command = "ED-ONT:" + amsName + @":ONT-1-1-" + pon + "::::DESC1=" + ont.Access.Name + @":;";
 325:                      // ED-ONT:ESH-1-1:ONT-1-1-2-2-26::::DESC1=ESH.4.26:;
 326:                  }
 327:                  else if (amsOpcode == AmsOpcode.EdOntDesc1Annul)
 328:                  {
 329:                      command = "ED-ONT:" + amsName + @":ONT-1-1-" + pon + "::::DESC1=:;";
 330:                      // ED-ONT:ESH-1-1:ONT-1-1-2-2-26::::DESC1=:;
 331:                  }
 332:                  else if (amsOpcode == AmsOpcode.InitSys)
 333:                  {
 334:                      command = "INIT-SYS:" + amsName + @":ONT-1-1-" + pon + ":::6;";
 335:                      // INIT-SYS:SHD-SUR-LAG17:ONT-1-1-1-1-1:::6;
 336:                  }
 337:              }
 338:   
 339:              return command;
 340:          }
 341:   
 342:          ////////////////////////////////////////////////////////////////////////////
 343:   
 344:          /// <summary>
 345:          ///
 346:          /// </summary>
 347:          private static List<string> FormatAmsOntOntPotsCommandList(AmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, string termination, string customer)
 348:          {
 349:              int card, port, td;
 350:              string command, amsName, pon;
 351:              List<string> list;
 352:   
 353:              command = null;
 354:   
 355:              list = new List<string>(10);
 356:   
 357:              if (!string.IsNullOrEmpty(ont.Position))
 358:              {
 359:                  AmsNameAndCardPortOntSquenceFromOntPosition(ont.Position, out amsName, out pon);
 360:   
 361:                  termination = termination.Replace("td", "");
 362:   
 363:                  if (int.TryParse(termination, out td))
 364:                  {
 365:                      ReturnOntPotsCardAndPortFromFamilyTypeAndTd(familyType, td, out card, out port);
 366:   
 367:                      if (amsOpcode == AmsOpcode.EdOntPotsCustinfo)
 368:                      {
 369:                          command = "ED-ONTPOTS:" + amsName + @":ONTPOTS-1-1-" + pon + "-" + card + "-" + port + "::::CUSTINFO=" + customer + @":;";
 370:                          // ED-ONTPOTS:ESH-1-1:ONTPOTS-1-1-1-1-1-2-1::::CUSTINFO=23632222:;\n";
 371:   
 372:                          list.Add(command);
 373:                      }
 374:                  }
 375:              }
 376:   
 377:              return list;
 378:          }
 379:   
 380:          ////////////////////////////////////////////////////////////////////////////
 381:   
 382:          /// <summary>
 383:          ///
 384:          /// </summary>
 385:          private static string FormatAmsCommand(AmsOpcode amsOpcode, string amsName)
 386:          {
 387:              string command;
 388:   
 389:              if (amsOpcode == AmsOpcode.RtrvAlmPon)
 390:              {
 391:                  command = "RTRV-ALM-PON:" + amsName + ":ALL:::MN,,NSA;";
 392:   
 393:              }
 394:              else if (amsOpcode == AmsOpcode.RtrvHdr)
 395:              {
 396:                  command = "RTRV-HDR:" + amsName + ":;";
 397:              }
 398:              else command = null;
 399:   
 400:              return command;
 401:          }
 402:   
 403:          ////////////////////////////////////////////////////////////////////////////
 404:   
 405:          /// <summary>
 406:          ///
 407:          /// </summary>
 408:          private static List<string> FormatAmsCommand(AmsOpcode amsOpcode, string ontServiceHsiPosition, Ia.Ngn.Cl.Model.Data.Hsi.Profile downloadProfile, Ia.Ngn.Cl.Model.Data.Hsi.Profile uploadProfile)
 409:          {
 410:              string command, amsName, cardPortOntCardPortServiceSequence;
 411:              List<string> list;
 412:   
 413:              command = null;
 414:   
 415:              list = new List<string>(10);
 416:   
 417:              AmsNameAndCardPortOntSquenceFromOntServiceHsiPosition(ontServiceHsiPosition, out amsName, out cardPortOntCardPortServiceSequence);
 418:   
 419:              if (amsOpcode == AmsOpcode.EdServiceHsi)
 420:              {
 421:                  command = "ED-SERVICE-HSI:" + amsName + ":HSI-1-1-" + cardPortOntCardPortServiceSequence + "::::BWPROFUPID=" + uploadProfile.Id + ",BWPROFDNID=" + downloadProfile.Id + ":;\n";
 422:   
 423:                  // ED-SERVICE-HSI:SUR-1-1:HSI-1-1-1-1-5-1-1-1::::BWPROFUPID=50,BWPROFDNID=50:;
 424:   
 425:                  // below: maybe use this
 426:                  // ed-service-hsi::hsi-1-1-7-2-6-1-1-1::::BWPROFUPID=,BWPROFUPNM=,BWPROFDNID=,BWPROFDNNM=,LABEL=:oos;
 427:                  // dlt-service-hsi::hsi-1-1-7-2-6-1-1-1::;
 428:                  // ent-service-hsi::hsi-1-1-7-2-6-1-1-1::::BWPROFUPID=50,BWPROFDNID=50,PQPROFID=2,SVLAN=305:IS;
 429:   
 430:                  list.Add(command);
 431:              }
 432:   
 433:              return list;
 434:          }
 435:   
 436:          ////////////////////////////////////////////////////////////////////////////
 437:   
 438:          /// <summary>
 439:          ///
 440:          /// </summary>
 441:          private static void AmsNameAndCardPortOntSquenceFromOntServiceHsiPosition(string ontPosition, out string amsName, out string cardPortOntCardPortServiceSequence)
 442:          {
 443:              Match match;
 444:   
 445:              // SUR-1-1-1-1-1-1-1-1;
 446:              match = Regex.Match(ontPosition, @"([a-zA-Z]{3}\-\d{1,2}\-\d{1,2})\-(\d{1,2}\-\d{1,2}\-\d{1,2}\-\d{1,2}\-\d{1,2}\-\d{1,2})");
 447:   
 448:              amsName = match.Groups[1].Value;
 449:              cardPortOntCardPortServiceSequence = match.Groups[2].Value;
 450:          }
 451:   
 452:          ////////////////////////////////////////////////////////////////////////////
 453:   
 454:          /// <summary>
 455:          ///
 456:          /// </summary>
 457:          private static void AmsNameAndCardPortOntSquenceFromOntPosition(string ontPosition, out string amsName, out string pon)
 458:          {
 459:              Match match;
 460:   
 461:              if (!string.IsNullOrEmpty(ontPosition))
 462:              {
 463:                  // SBN-ARD-Lag1-1-1-1;
 464:                  match = Regex.Match(ontPosition, @"^([\w\d\-]+)\-(\d{1,2}\-\d{1,2}\-\d{1,2})$");
 465:   
 466:                  if (match.Success)
 467:                  {
 468:                      amsName = match.Groups[1].Value;
 469:                      pon = match.Groups[2].Value;
 470:                  }
 471:                  else
 472:                  {
 473:                      amsName = string.Empty;
 474:                      pon = string.Empty;
 475:                  }
 476:              }
 477:              else
 478:              {
 479:                  amsName = string.Empty;
 480:                  pon = string.Empty;
 481:              }
 482:          }
 483:   
 484:          ////////////////////////////////////////////////////////////////////////////
 485:   
 486:          /// <summary>
 487:          /// Extract OLT Id, Card, Port, and ONT from ONT Position
 488:          /// </summary>
 489:          [Obsolete]
 490:          public static void OltIdCardPortOntFromOntPosition(string ontPosition, out int oltId, out int card, out int port, out int ont)
 491:          {
 492:              string amsName;
 493:              Match match;
 494:   
 495:              if (!string.IsNullOrEmpty(ontPosition))
 496:              {
 497:                  // SBN-ARD-Lag1-1-1-1;
 498:                  match = Regex.Match(ontPosition, @"^([\w\d\-]+)\-(\d{1,2})\-(\d{1,2})\-(\d{1,2})$");
 499:   
 500:                  if (match.Success)
 501:                  {
 502:                      amsName = match.Groups[1].Value;
 503:                      card = int.Parse(match.Groups[2].Value);
 504:                      port = int.Parse(match.Groups[3].Value);
 505:                      ont = int.Parse(match.Groups[4].Value);
 506:   
 507:                      oltId = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.AmsName == amsName select o.Id).FirstOrDefault();
 508:                  }
 509:                  else
 510:                  {
 511:                      amsName = string.Empty;
 512:                      card = port = ont = 0;
 513:   
 514:                      oltId = 0;
 515:                  }
 516:              }
 517:              else
 518:              {
 519:                  amsName = string.Empty;
 520:                  card = port = ont = 0;
 521:   
 522:                  oltId = 0;
 523:              }
 524:          }
 525:   
 526:          ////////////////////////////////////////////////////////////////////////////
 527:   
 528:          /// <summary>
 529:          ///
 530:          /// </summary>
 531:          public static string OntPositionFromAmsNameAndCardPortOntSquence(string amsName, string cardPortOnt)
 532:          {
 533:              string ontPosition;
 534:   
 535:              ontPosition = amsName + "-" + cardPortOnt;
 536:   
 537:              return ontPosition;
 538:          }
 539:   
 540:          ////////////////////////////////////////////////////////////////////////////
 541:   
 542:          /// <summary>
 543:          ///
 544:          /// </summary>
 545:          public static List<string> AmsCommandsToUpdateOntDescriptionWithItsAccessNameList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 546:          {
 547:              string accessName, ontId, ontDescription1;
 548:              List<string> list;
 549:              Hashtable ontIdToAccessNameHashtable, ontIdWithNullAccessHashtable;
 550:              //Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 551:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 552:              //List<Ia.Ngn.Cl.Model.Ont> ontList;
 553:              Dictionary<string, string> ontIdToDescription1ForNonNullAccessDictionary;
 554:              Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontIdToOntDictionary;
 555:              list = null;
 556:   
 557:              ontIdToAccessNameHashtable = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToAccessNameHashtable;
 558:   
 559:              ontIdToDescription1ForNonNullAccessDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdToDescription1ForNonNullAccessDictionary;
 560:   
 561:              ontIdWithNullAccessHashtable = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdWithNullAccessHashtable;
 562:   
 563:              ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 564:   
 565:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 566:              {
 567:                  list = new List<string>();
 568:   
 569:                  //ontList = (from o in db.Onts where o.Access != null select o).ToList();
 570:   
 571:                  // insert descriptions for missing entries
 572:                  if (ontIdToDescription1ForNonNullAccessDictionary.Count > 0)
 573:                  {
 574:                      foreach (KeyValuePair<string, string> kvp in ontIdToDescription1ForNonNullAccessDictionary) //Ia.Ngn.Cl.Model.Ont ont in ontList)
 575:                      {
 576:                          ontId = kvp.Key;
 577:                          ontDescription1 = kvp.Value;
 578:   
 579:                          if (ontIdToAccessNameHashtable.ContainsKey(ontId))
 580:                          {
 581:                              accessName = ontIdToAccessNameHashtable[ontId].ToString();
 582:   
 583:                              if (ontDescription1 != accessName)
 584:                              {
 585:                                  // below: too slow needs to be changed
 586:                                  nddOnt = ontIdToOntDictionary[ontId]; // (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where nddo.Id == ont.Id select nddo).SingleOrDefault();
 587:   
 588:                                  if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 589:                                  {
 590:                                      //familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 591:   
 592:                                      list.Add(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntCommand(AmsOpcode.EdOntDesc1, nddOnt));
 593:                                  }
 594:                              }
 595:                              else
 596:                              {
 597:                              }
 598:                          }
 599:                      }
 600:                  }
 601:   
 602:                  // delete descriptions ONTs with missing access info
 603:                  if (ontIdWithNullAccessHashtable.Count > 0)
 604:                  {
 605:                      foreach (string _ontId in ontIdWithNullAccessHashtable.Keys)
 606:                      {
 607:                          if (ontIdToOntDictionary.ContainsKey(_ontId))
 608:                          {
 609:                              nddOnt = ontIdToOntDictionary[_ontId];
 610:   
 611:                              if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 612:                              {
 613:                                  list.Add(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntCommand(AmsOpcode.EdOntDesc1Annul, nddOnt));
 614:                              }
 615:                          }
 616:                      }
 617:                  }
 618:              }
 619:   
 620:              return list.ToList();
 621:          }
 622:   
 623:          ////////////////////////////////////////////////////////////////////////////
 624:   
 625:          /// <summary>
 626:          ///
 627:          /// </summary>
 628:          public static List<string> AmsCommandsToInsertCorrectCustomerIntoOntPotsList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 629:          {
 630:              List<string> list;
 631:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 632:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 633:              Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontIdToOntDictionary;
 634:   
 635:              ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 636:   
 637:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 638:              {
 639:                  var ontOntPotsServiceList = (from sp in db.SubParties
 640:                                               join e in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals e.Id
 641:                                               join gr in db.AgcfGatewayRecords on e.GwId equals gr.GwId
 642:                                               join osv in db.OntServiceVoips on gr.IP1 equals osv.Ip
 643:                                               join o in db.Onts on osv.Ont.Id equals o.Id
 644:                                               join oop in db.OntOntPotses on o.Id equals oop.Ont.Id
 645:                                               where oop.Customer != sp.DisplayName && oop.Termination == "td" + e.FlatTermID.ToString()
 646:                                               select new
 647:                                               {
 648:                                                   Service = sp.DisplayName,
 649:                                                   oop.Termination,
 650:                                                   OntId = o.Id,
 651:                                                   OntFamilyTypeId = o.FamilyTypeId
 652:                                               }).ToList();
 653:   
 654:                  list = new List<string>(ontOntPotsServiceList.Count);
 655:   
 656:                  foreach (var ontOntPotsService in ontOntPotsServiceList)
 657:                  {
 658:                      if (ontIdToOntDictionary.ContainsKey(ontOntPotsService.OntId))
 659:                      {
 660:                          nddOnt = ontIdToOntDictionary[ontOntPotsService.OntId];
 661:   
 662:                          if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 663:                          {
 664:                              familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ontOntPotsService.OntFamilyTypeId;
 665:   
 666:                              list.AddRange(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntOntPotsCommandList(AmsOpcode.EdOntPotsCustinfo, nddOnt, familyType, ontOntPotsService.Termination, ontOntPotsService.Service));
 667:                          }
 668:                      }
 669:                  }
 670:              }
 671:   
 672:              return list;
 673:          }
 674:   
 675:          ////////////////////////////////////////////////////////////////////////////
 676:   
 677:          /// <summary>
 678:          ///
 679:          /// </summary>
 680:          public static List<string> AmsCommandsToEditOntServiceHsiList(out int count)
 681:          {
 682:              string amsName, ontServiceHsiPosition;
 683:              Ia.Ngn.Cl.Model.Data.Hsi.Isp isp;
 684:              Ia.Ngn.Cl.Model.Data.Hsi.Profile profile;
 685:              List<string> list;
 686:              List<Ia.Ngn.Cl.Model.OntServiceHsi> oshList;
 687:   
 688:              count = 0;
 689:              list = null;
 690:   
 691:              isp = (from i in Ia.Ngn.Cl.Model.Data.Hsi.IspList where i.Name == "QualityNet" select i).SingleOrDefault();
 692:              profile = (from p in Ia.Ngn.Cl.Model.Data.Hsi.ProfileList where p.Name == "20Mb/s" select p).SingleOrDefault();
 693:   
 694:              if (isp != null && profile != null)
 695:              {
 696:                  oshList = Ia.Ngn.Cl.Model.Business.Nokia.OntServiceHsi.ReturnOntServiceHsiAndOntAndAccessListForIspAndBandwidth(isp, profile);
 697:   
 698:                  if (oshList != null && oshList.Count > 0)
 699:                  {
 700:                      list = new List<string>(oshList.Count);
 701:   
 702:                      foreach (Ia.Ngn.Cl.Model.OntServiceHsi osh in oshList)
 703:                      {
 704:                          amsName = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AmsNameFromOltId(osh.Ont.Access.Olt);
 705:   
 706:                          //ontServiceHsiPosition = amsName + "-" + osh.Ont.Access.Card + "-" + osh.Ont.Access.Port + "-" + osh.Ont.Access.Ont + "-" + osh.Card + "-" + osh.Port + "-" + osh.Service;
 707:                          ontServiceHsiPosition = osh.Ont.Access.Position + "-" + osh.Card + "-" + osh.Port + "-" + osh.Service;
 708:   
 709:                          // below: set bandwidth to 20Mb
 710:                          list.AddRange(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsCommand(AmsOpcode.EdServiceHsi, ontServiceHsiPosition, profile, profile));
 711:                          count++;
 712:                      }
 713:                  }
 714:                  else
 715:                  {
 716:                      //result = @"Error: OntServiceHsi query result is null or empty. ";
 717:                  }
 718:              }
 719:              else
 720:              {
 721:                  //result = @"Error: isp and/or profile are/is null. ";
 722:              }
 723:   
 724:              return list;
 725:          }
 726:   
 727:          ////////////////////////////////////////////////////////////////////////////
 728:   
 729:          /// <summary>
 730:          ///
 731:          /// </summary>
 732:          public static List<string> AmsCommandsToPreprovisionAllOntsAsDefinedInNddDocumentWithinOltList(int oltId, bool edServiceVoipIsOos, out int count)
 733:          {
 734:              List<string> l, list;
 735:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 736:   
 737:              count = 0;
 738:              list = null;
 739:   
 740:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 741:              {
 742:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 743:   
 744:                  if (nddOntList != null && nddOntList.Count > 0)
 745:                  {
 746:                      list = new List<string>(nddOntList.Count);
 747:   
 748:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 749:                      {
 750:                          l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOlt(nddOnt, edServiceVoipIsOos);
 751:   
 752:                          list.AddRange(l);
 753:                          count++;
 754:                      }
 755:                  }
 756:                  else
 757:                  {
 758:                      //result = @"Error: OntServiceHsi query result is null or empty. ";
 759:                  }
 760:              }
 761:   
 762:              return list;
 763:          }
 764:   
 765:          ////////////////////////////////////////////////////////////////////////////
 766:   
 767:          /// <summary>
 768:          ///
 769:          /// </summary>
 770:          public static List<string> AmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, bool includeDisplayCommand, bool edServiceVoipIsOos, out int count)
 771:          {
 772:              List<string> l, list;
 773:              List<string> ontIdList;
 774:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 775:   
 776:              count = 0;
 777:              list = null;
 778:   
 779:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 780:              {
 781:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 782:   
 783:                  ontIdList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdList(olt.Id); //.ReadListByOltId(olt.Id);
 784:   
 785:                  if (nddOntList != null && nddOntList.Count > 0)
 786:                  {
 787:                      list = new List<string>(nddOntList.Count);
 788:   
 789:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 790:                      {
 791:                          if (!ontIdList.Contains(nddOnt.Id))
 792:                          {
 793:                              l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOlt(nddOnt, edServiceVoipIsOos);
 794:                              list.AddRange(l);
 795:   
 796:                              if (includeDisplayCommand)
 797:                              {
 798:                                  l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToRetrieveOntVoipPotsHsiForSingleOntsWithDefinedFamilyTypeList(nddOnt.Access.Name);
 799:                                  list.AddRange(l);
 800:                              }
 801:   
 802:                              count++;
 803:                          }
 804:                      }
 805:                  }
 806:              }
 807:   
 808:              return list;
 809:          }
 810:   
 811:          ////////////////////////////////////////////////////////////////////////////
 812:   
 813:          /// <summary>
 814:          ///
 815:          /// </summary>
 816:          public static List<string> AmsCommandsToRetrieveOntVoipPotsHsiForASingleOntWithDefinedFamilyTypeAndForItIfThisSingleOntDefinedInNddDocumentList(string accessName)
 817:          {
 818:              Random r;
 819:              List<string> l1, l2, list;
 820:   
 821:              r = new Random();
 822:   
 823:              l1 = AmsCommandToRetrieveSingleOntDefinedInNddDocumentList(accessName);
 824:   
 825:              l2 = AmsCommandsToRetrieveOntVoipPotsHsiForSingleOntsWithDefinedFamilyTypeList(accessName);
 826:   
 827:              list = new List<string>(l1.Count + l2.Count);
 828:   
 829:              foreach (var item in l1) list.Add(item);
 830:              foreach (var item in l2) list.Add(item);
 831:   
 832:              return list.Distinct().ToList();
 833:          }
 834:   
 835:          ////////////////////////////////////////////////////////////////////////////
 836:   
 837:          /// <summary>
 838:          ///
 839:          /// </summary>
 840:          public static List<string> AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyTypeAndForOtherOntsDefinedInNddDocumentList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 841:          {
 842:              List<string> l1, l2, list;
 843:   
 844:              l1 = AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyTypeList(olt);
 845:   
 846:              l2 = AmsCommandsToRetrieveOntsDefinedInNddDocumentList(olt);
 847:   
 848:              list = new List<string>(l1.Count + l2.Count);
 849:   
 850:              foreach (var item in l1) list.Add(item);
 851:              foreach (var item in l2) list.Add(item);
 852:   
 853:              return list.Distinct().Shuffle().ToList();
 854:          }
 855:   
 856:          ////////////////////////////////////////////////////////////////////////////
 857:   
 858:          /// <summary>
 859:          ///
 860:          /// </summary>
 861:          public static List<string> AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyType_AmsCommandsToRetrieveOntsDefinedInNddDocument_AmsCommandsToUpdateAndDisplayOntDescriptionWithItsAccessName_AmsCommandsToUpdateOntOntPotsCustomerWithItsConnectedServiceNumberList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 862:          {
 863:              List<string> l1, l2, l3, l4, list;
 864:   
 865:              l1 = AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyTypeList(olt);
 866:   
 867:              l2 = AmsCommandsToRetrieveOntsDefinedInNddDocumentList(olt);
 868:   
 869:              l3 = AmsCommandsToUpdateOntDescriptionWithItsAccessNameList(olt);
 870:   
 871:              l4 = AmsCommandsToInsertCorrectCustomerIntoOntPotsList(olt);
 872:   
 873:              list = new List<string>(l1.Count + l2.Count + l3.Count + l4.Count);
 874:   
 875:              foreach (var i in l1) list.Add(i);
 876:              foreach (var i in l2) list.Add(i);
 877:              foreach (var i in l3) list.Add(i);
 878:              foreach (var i in l4) list.Add(i);
 879:   
 880:              return list.Distinct().Shuffle().ToList();
 881:          }
 882:   
 883:          ////////////////////////////////////////////////////////////////////////////
 884:   
 885:          /// <summary>
 886:          ///
 887:          /// </summary>
 888:          private static List<string> AmsCommandToRetrieveSingleOntDefinedInNddDocumentList(string accessName)
 889:          {
 890:              List<string> list;
 891:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 892:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 893:   
 894:              list = new List<string>(5); // 5 is max number of commands from this function
 895:   
 896:              if (!string.IsNullOrEmpty(accessName))
 897:              {
 898:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
 899:   
 900:                  if (nddOnt != null)
 901:                  {
 902:                      familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 903:   
 904:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
 905:                  }
 906:              }
 907:   
 908:              return list;
 909:          }
 910:   
 911:          ////////////////////////////////////////////////////////////////////////////
 912:   
 913:          /// <summary>
 914:          ///
 915:          /// </summary>
 916:          private static List<string> AmsCommandsToRetrieveOntsDefinedInNddDocumentList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 917:          {
 918:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 919:              List<string> list;
 920:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList;
 921:   
 922:              ontList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 923:   
 924:              familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 925:   
 926:              list = new List<string>(ontList.Count);
 927:   
 928:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in ontList)
 929:              {
 930:                  list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, ont.Position));
 931:              }
 932:   
 933:              return list;
 934:          }
 935:   
 936:          ////////////////////////////////////////////////////////////////////////////
 937:   
 938:          /// <summary>
 939:          ///
 940:          /// </summary>
 941:          private static List<string> AmsCommandsToRetrieveOntVoipPotsHsiForSingleOntsWithDefinedFamilyTypeList(string accessName)
 942:          {
 943:              List<string> list;
 944:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 945:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 946:              Ia.Ngn.Cl.Model.Ont ont;
 947:   
 948:              list = new List<string>(5); // 5 is max number of commands from this function
 949:   
 950:              if (!string.IsNullOrEmpty(accessName))
 951:              {
 952:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
 953:   
 954:                  if (nddOnt != null)
 955:                  {
 956:                      ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 957:   
 958:                      if (ont != null)
 959:                      {
 960:                          familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 961:   
 962:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
 963:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceHsi, familyType, nddOnt.Position));
 964:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceVoip, familyType, nddOnt.Position));
 965:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOntPots, familyType, nddOnt.Position));
 966:                      }
 967:                  }
 968:              }
 969:   
 970:              return list;
 971:          }
 972:   
 973:          ////////////////////////////////////////////////////////////////////////////
 974:   
 975:          /// <summary>
 976:          ///
 977:          /// </summary>
 978:          private static List<string> AmsCommandsToRetrieveOntVoipPotsHsiForOntsWithDefinedFamilyTypeList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 979:          {
 980:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 981:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 982:              List<string> list;
 983:              Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontIdToOntDictionary;
 984:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 985:   
 986:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.NonNullAccessList(olt.Id);
 987:   
 988:              ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 989:   
 990:              list = new List<string>(ontList.Count);
 991:   
 992:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 993:              {
 994:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 995:   
 996:                  if (ontIdToOntDictionary.ContainsKey(ont.Id))
 997:                  {
 998:                      nddOnt = ontIdToOntDictionary[ont.Id];
 999:   
1000:                      //if (ont.Access != null) access is already non null
1001:                      //{
1002:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
1003:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceHsi, familyType, nddOnt.Position));
1004:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceVoip, familyType, nddOnt.Position));
1005:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOntPots, familyType, nddOnt.Position));
1006:                      //}
1007:                  }
1008:              }
1009:   
1010:              return list;
1011:          }
1012:   
1013:          ////////////////////////////////////////////////////////////////////////////
1014:   
1015:          /// <summary>
1016:          ///
1017:          /// </summary>
1018:          public static ArrayList AmsCommandsToRetrieveNewOntAlarmsForOltArrayList()
1019:          {
1020:              ArrayList amsCommandArrayList;
1021:   
1022:              amsCommandArrayList = new ArrayList(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1023:   
1024:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1025:              {
1026:                  amsCommandArrayList.Add(FormatAmsCommand(AmsOpcode.RtrvAlmPon, olt.AmsName));
1027:              }
1028:   
1029:              return amsCommandArrayList;
1030:          }
1031:   
1032:          ////////////////////////////////////////////////////////////////////////////
1033:   
1034:          /// <summary>
1035:          ///
1036:          /// </summary>
1037:          public static ArrayList AmsCommandsToDowngradeOntServiceHsiForQualityNetBandwidthRateFrom50MbTo20MbThenDisplayArrayList()
1038:          {
1039:              string ontPosition;
1040:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
1041:              ArrayList amsCommandArrayList;
1042:              List<Ia.Ngn.Cl.Model.OntServiceHsi> ontServiceHsiList;
1043:   
1044:              ontServiceHsiList = null; // Ia.Ngn.Cl.Model.Business.Nokia.OntServiceHsi.ReturnOntServiceHsiListForIspAndBandwidthAndTakeN(Ia.Ngn.Cl.Model.Data.Hsi.IspName.QualityNet, Ia.Ngn.Cl.Model.Data.Hsi.ProfileName.bw50Mbs, 1000);
1045:   
1046:              amsCommandArrayList = new ArrayList(ontServiceHsiList.Count);
1047:   
1048:              foreach (Ia.Ngn.Cl.Model.OntServiceHsi ontServiceHsi in ontServiceHsiList)
1049:              {
1050:                  ontPosition = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntPositionFromOntId(ontServiceHsi.Id);
1051:   
1052:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ontServiceHsi.Ont.FamilyTypeId;
1053:   
1054:                  amsCommandArrayList.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, ontPosition));
1055:                  amsCommandArrayList.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceHsi, familyType, ontPosition));
1056:                  amsCommandArrayList.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceVoip, familyType, ontPosition));
1057:                  amsCommandArrayList.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOntPots, familyType, ontPosition));
1058:              }
1059:   
1060:              return amsCommandArrayList;
1061:          }
1062:   
1063:          ////////////////////////////////////////////////////////////////////////////
1064:   
1065:          /// <summary>
1066:          ///
1067:          /// </summary>
1068:          public static ArrayList AmsCommandsToUpdateOntServiceHsiDescriptionWithItsIspNameArrayList()
1069:          {
1070:              ArrayList amsCommandArrayList;
1071:   
1072:              amsCommandArrayList = new ArrayList(100);
1073:   
1074:              return amsCommandArrayList;
1075:          }
1076:   
1077:          ////////////////////////////////////////////////////////////////////////////
1078:   
1079:          /// <summary>
1080:          /// 
1081:          /// </summary>
1082:          public static int PossibleNumberOfTdForOntFamilyType(int familyTypeId)
1083:          {
1084:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
1085:   
1086:              familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyTypeId;
1087:   
1088:              return PossibleNumberOfTdForOntFamilyType(familyType);
1089:          }
1090:   
1091:          ////////////////////////////////////////////////////////////////////////////
1092:   
1093:          /// <summary>
1094:          /// 
1095:          /// </summary>
1096:          public static int PossibleNumberOfTdForOntFamilyType(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1097:          {
1098:              int number;
1099:   
1100:              switch (familyType)
1101:              {
1102:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu: number = 4; break;
1103:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho: number = 8; break;
1104:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu: number = 24; break;
1105:                  default: number = 0; break;
1106:              }
1107:   
1108:              return number;
1109:          }
1110:   
1111:          ////////////////////////////////////////////////////////////////////////////
1112:   
1113:          /// <summary>
1114:          /// Get the number of card-port for a parameter of familyType and td
1115:          /// </summary>
1116:          public static void ReturnOntPotsCardAndPortFromFamilyTypeAndTd(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, int td, out int card, out int port)
1117:          {
1118:              card = port = 0;
1119:   
1120:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
1121:              {
1122:                  if (td >= 1 && td <= 4)
1123:                  {
1124:                      card = 2; port = td;
1125:                  }
1126:              }
1127:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1128:              {
1129:                  if (td >= 1 && td <= 8)
1130:                  {
1131:                      card = 2; port = td;
1132:                  }
1133:              }
1134:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1135:              {
1136:                  if (td >= 1 && td <= 24)
1137:                  {
1138:                      if (td >= 1 && td <= 4 || td >= 13 && td <= 16)
1139:                      {
1140:                          card = 1;
1141:                          if (td <= 4) port = td;
1142:                          else port = td - 8;
1143:                      }
1144:                      else if (td >= 5 && td <= 8 || td >= 17 && td <= 20)
1145:                      {
1146:                          card = 2;
1147:                          if (td <= 8) port = td - 4;
1148:                          else port = td - 12;
1149:                      }
1150:                      else if (td >= 9 && td <= 12 || td >= 21 && td <= 24)
1151:                      {
1152:                          card = 3;
1153:                          if (td <= 12) port = td - 8;
1154:                          else port = td - 16;
1155:                      }
1156:                  }
1157:              }
1158:          }
1159:   
1160:          ////////////////////////////////////////////////////////////////////////////
1161:   
1162:          /// <summary>
1163:          /// 
1164:          /// </summary>
1165:          public static ArrayList PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1166:          {
1167:              ArrayList al;
1168:   
1169:              al = new ArrayList(100);
1170:   
1171:              // 1-1
1172:   
1173:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
1174:              {
1175:                  al.Add("2-1");
1176:                  al.Add("2-2");
1177:                  al.Add("2-3");
1178:                  al.Add("2-4");
1179:              }
1180:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1181:              {
1182:                  al.Add("2-1");
1183:                  al.Add("2-2");
1184:                  al.Add("2-3");
1185:                  al.Add("2-4");
1186:                  al.Add("2-5");
1187:                  al.Add("2-6");
1188:                  al.Add("2-7");
1189:                  al.Add("2-8");
1190:              }
1191:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1192:              {
1193:                  al.Add("1-1");
1194:                  al.Add("1-2");
1195:                  al.Add("1-3");
1196:                  al.Add("1-4");
1197:                  al.Add("1-5");
1198:                  al.Add("1-6");
1199:                  al.Add("1-7");
1200:                  al.Add("1-8");
1201:   
1202:                  al.Add("2-1");
1203:                  al.Add("2-2");
1204:                  al.Add("2-3");
1205:                  al.Add("2-4");
1206:                  al.Add("2-5");
1207:                  al.Add("2-6");
1208:                  al.Add("2-7");
1209:                  al.Add("2-8");
1210:   
1211:                  al.Add("3-1");
1212:                  al.Add("3-2");
1213:                  al.Add("3-3");
1214:                  al.Add("3-4");
1215:                  al.Add("3-5");
1216:                  al.Add("3-6");
1217:                  al.Add("3-7");
1218:                  al.Add("3-8");
1219:              }
1220:   
1221:              return al;
1222:          }
1223:   
1224:          ////////////////////////////////////////////////////////////////////////////
1225:   
1226:          /// <summary>
1227:          /// 
1228:          /// </summary>
1229:          public static List<string> PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1230:          {
1231:              List<string> list;
1232:   
1233:              list = new List<string>(100);
1234:   
1235:              // 1-1-1
1236:   
1237:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu || familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1238:              {
1239:                  list.Add("1-1-1");
1240:                  list.Add("1-2-1");
1241:              }
1242:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1243:              {
1244:                  // ???
1245:                  list.Add("1-1-1");
1246:                  list.Add("1-2-1");
1247:                  list.Add("1-3-1");
1248:                  list.Add("1-4-1");
1249:                  list.Add("1-5-1");
1250:                  list.Add("1-6-1");
1251:                  list.Add("1-7-1");
1252:                  list.Add("1-8-1");
1253:                  list.Add("1-9-1");
1254:                  list.Add("1-10-1");
1255:                  list.Add("1-11-1");
1256:                  list.Add("1-12-1");
1257:              }
1258:   
1259:              return list;
1260:          }
1261:   
1262:          ////////////////////////////////////////////////////////////////////////////
1263:   
1264:          /// <summary>
1265:          /// 
1266:          /// </summary>
1267:          public static int PossibleNumberOfHsiCardPortServiceConfigurationForOntFamilyType(int familyType)
1268:          {
1269:              List<string> list;
1270:   
1271:              list = PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList((Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyType);
1272:   
1273:              return list.Count;
1274:          }
1275:   
1276:          ////////////////////////////////////////////////////////////////////////////
1277:   
1278:          /// <summary>
1279:          /// 
1280:          /// </summary>
1281:          public static int PositionOfHsiServiceForCardAndPortAndOntFamilyType(int card, int port, Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1282:          {
1283:              int position;
1284:   
1285:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu || familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1286:              {
1287:                  position = port;
1288:              }
1289:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1290:              {
1291:                  position = (card - 1) * 4 + port;
1292:              }
1293:              else position = 0;
1294:   
1295:              return position;
1296:          }
1297:   
1298:          ////////////////////////////////////////////////////////////////////////////
1299:   
1300:          /// <summary>
1301:          /// Return the ONT family type from the software version
1302:          /// </summary>
1303:          private static Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType FamilyType(string activeSoftware, string plannedSoftware)
1304:          {
1305:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
1306:   
1307:              if (activeSoftware != null)
1308:              {
1309:                  if (activeSoftware == plannedSoftware || plannedSoftware == "auto" || plannedSoftware == "AUTO")
1310:                  {
1311:                      if (activeSoftware.StartsWith("3FE508")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
1312:                      else if (activeSoftware.StartsWith("3FE511")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho;
1313:                      else if (activeSoftware.StartsWith("3FE514")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu;
1314:                      else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1315:                  }
1316:                  else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1317:              }
1318:              else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1319:   
1320:              return familyType;
1321:          }
1322:   
1323:          ////////////////////////////////////////////////////////////////////////////
1324:   
1325:          /// <summary>
1326:          ///
1327:          /// </summary>
1328:          public static bool UpdateDatabaseWithAmsCommandOutput(string rowData, out Ia.Cl.Model.Result result)
1329:          {
1330:              bool b;
1331:              string accessId, ontId, ontPosition;
1332:              string line, amsName, cardPortOnt;
1333:              DateTime eventTime;
1334:              Match match;
1335:              MatchCollection matchCollection;
1336:              Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState state;
1337:   
1338:              //ponNameToPonIdHashtable = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonNameToPonIdHashtable;
1339:   
1340:              b = false;
1341:              result = new Ia.Cl.Model.Result();
1342:              //result.Content = rowData;
1343:   
1344:              // below: remove all '\' characters from rowData and reset NULL comments to ""
1345:              rowData = rowData.Replace(@"\", "");
1346:              rowData = rowData.Replace(@"NULL", "");
1347:   
1348:              if (rowData.Contains("RTRV-ONT:"))
1349:              {
1350:                  #region RTRV-ONT
1351:                  Ia.Ngn.Cl.Model.Ont ont, dataOnt;
1352:   
1353:                  /*
1354:         SUR-1-1 08-07-10 09:35:07
1355:      M  0 COMPLD
1356:         / * RTRV-ONT:SUR-1-1:ONT-1-1-1-1-1&ONT-1-1-1-1-10&ONT-1-1-1-1-2&ONT-1-1-1 * /
1357:         / * -1-3&ONT-1-1-1-1-4&ONT-1-1-1-1-5&ONT-1-1-1-1-6&ONT-1-1-1-1-7&ONT-1-1- * /
1358:         / * 1-1-8&ONT-1-1-1-1-9 * /
1359:         "ONT-1-1-1-1-1::BTRYBKUP=NO,BERINT=8000,DESC1="SLA.1.1",
1360:         DESC2="all is well",PROVVERSION="*",SERNUM=ALCLA0A1A5F8,
1361:         SUBSLOCID="WILDCARD",SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,
1362:         SCHEDPROFID=1,SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,
1363:         POWERSHEDPROFNM="NULL",ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,
1364:         SWVERACT=3FE50853AFMA07,SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,
1365:         EQUIPID=BVM3G00CRAO420EB    ,NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:
1366:         IS-NR"
1367:         "ONT-1-1-1-1-10::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1368:         PROVVERSION="*",SERNUM=ALCLA0A1A479,SUBSLOCID="WILDCARD",
1369:         SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1370:         SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1371:         ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1372:         SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1373:         NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1374:         "ONT-1-1-1-1-2::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1375:         PROVVERSION="*",SERNUM=ALCLA0A261BB,SUBSLOCID="WILDCARD",
1376:         SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1377:         SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1378:         ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1379:         SWVERPSV=3FE50853AAAA22,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1380:         NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1381:                   */
1382:   
1383:                  // below: information from the definition of "RTRV-ONT" in "AMS TL1 Commands Reference"
1384:   
1385:                  /*
1386:  IP 0
1387:  <
1388:   
1389:     SUR-1-1 08-07-10 09:35:07
1390:  M  0 COMPLD
1391:     / * RTRV-ONT:SUR-1-1:ONT-1-1-1-1-1&ONT-1-1-1-1-10&ONT-1-1-1-1-2&ONT-1-1-1 * /
1392:     / * -1-3&ONT-1-1-1-1-4&ONT-1-1-1-1-5&ONT-1-1-1-1-6&ONT-1-1-1-1-7&ONT-1-1- * /
1393:     / * 1-1-8&ONT-1-1-1-1-9 * /
1394:     "ONT-1-1-1-1-1::BTRYBKUP=NO,BERINT=8000,DESC1="SLA.1.1",
1395:     DESC2="all is well",PROVVERSION="*",SERNUM=ALCLA0A1A5F8,
1396:     SUBSLOCID="WILDCARD",SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,
1397:     SCHEDPROFID=1,SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,
1398:     POWERSHEDPROFNM="NULL",ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,
1399:     SWVERACT=3FE50853AFMA07,SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,
1400:     EQUIPID=BVM3G00CRAO420EB    ,NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:
1401:     IS-NR"
1402:     "ONT-1-1-1-1-10::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1403:     PROVVERSION="*",SERNUM=ALCLA0A1A479,SUBSLOCID="WILDCARD",
1404:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1405:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1406:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1407:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1408:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1409:     "ONT-1-1-1-1-2::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1410:     PROVVERSION="*",SERNUM=ALCLA0A261BB,SUBSLOCID="WILDCARD",
1411:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1412:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1413:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1414:     SWVERPSV=3FE50853AAAA22,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1415:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1416:   
1417:     / * More Output Follows * /
1418:  >
1419:   
1420:     SUR-1-1 08-07-10 09:35:07
1421:  M  0 COMPLD
1422:     / * RTRV-ONT:SUR-1-1:ONT-1-1-1-1-1&ONT-1-1-1-1-10&ONT-1-1-1-1-2&ONT-1-1-1-1-3&ONT-1-1-1-1-4&ONT-1-1-1-1-5&ONT-1-1-1-1-6&ONT-1-1-1-1-7&ONT-1-1-1-1-8&ONT-1-1-1-1-9 * /
1423:     "ONT-1-1-1-1-3::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1424:     PROVVERSION="*",SERNUM=ALCLA0A1C9BC,SUBSLOCID="WILDCARD",
1425:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1426:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1427:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1428:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1429:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1430:     "ONT-1-1-1-1-4::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1431:     PROVVERSION="*",SERNUM=ALCLA0A1A47A,SUBSLOCID="WILDCARD",
1432:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1433:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1434:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1435:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1436:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1437:     "ONT-1-1-1-1-5::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1438:     PROVVERSION="*",SERNUM=ALCLA0A1AE44,SUBSLOCID="WILDCARD",
1439:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1440:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1441:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1442:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1443:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1444:   
1445:     / * More Output Follows * /
1446:  >
1447:   
1448:     SUR-1-1 08-07-10 09:35:08
1449:  M  0 COMPLD
1450:     / * RTRV-ONT:SUR-1-1:ONT-1-1-1-1-1&ONT-1-1-1-1-10&ONT-1-1-1-1-2&ONT-1-1-1-1-3&ONT-1-1-1-1-4&ONT-1-1-1-1-5&ONT-1-1-1-1-6&ONT-1-1-1-1-7&ONT-1-1-1-1-8&ONT-1-1-1-1-9 * /
1451:     "ONT-1-1-1-1-6::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1452:     PROVVERSION="*",SERNUM=ALCLA0A1BE26,SUBSLOCID="WILDCARD",
1453:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1454:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1455:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1456:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1457:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1458:     "ONT-1-1-1-1-7::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1459:     PROVVERSION="*",SERNUM=ALCLA0A1C94B,SUBSLOCID="WILDCARD",
1460:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1461:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1462:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1463:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1464:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1465:     "ONT-1-1-1-1-8::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1466:     PROVVERSION="*",SERNUM=ALCLA0A1A484,SUBSLOCID="WILDCARD",
1467:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1468:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1469:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1470:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1471:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1472:   
1473:     / * More Output Follows * /
1474:  >
1475:   
1476:     SUR-1-1 08-07-10 09:35:08
1477:  M  0 COMPLD
1478:     / * RTRV-ONT:SUR-1-1:ONT-1-1-1-1-1&ONT-1-1-1-1-10&ONT-1-1-1-1-2&ONT-1-1-1-1-3&ONT-1-1-1-1-4&ONT-1-1-1-1-5&ONT-1-1-1-1-6&ONT-1-1-1-1-7&ONT-1-1-1-1-8&ONT-1-1-1-1-9 * /
1479:     "ONT-1-1-1-1-9::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1480:     PROVVERSION="*",SERNUM=ALCLA0A1A43E,SUBSLOCID="WILDCARD",
1481:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1482:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1483:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1484:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1485:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1486:  ;
1487:                  */
1488:   
1489:                  // below: read OntPosition
1490:                  match = Regex.Match(rowData, @"RTRV-ONT:([\w\d\-]+)", RegexOptions.Singleline);
1491:   
1492:                  amsName = match.Groups[1].Value;
1493:   
1494:                  match = Regex.Match(rowData, @"ONT-1-1-(\d{1,2}-\d{1,2}-\d{1,2})::(.+?):\s*(IS-NR|OOS-AU|OOS-MA|OOS-AUMA)", RegexOptions.Singleline);
1495:   
1496:                  if (match.Success)
1497:                  {
1498:                      cardPortOnt = match.Groups[1].Value;
1499:   
1500:                      line = match.Groups[2].Value;
1501:   
1502:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1503:   
1504:                      if (!string.IsNullOrEmpty(ontId))
1505:                      {
1506:                          dataOnt = new Ia.Ngn.Cl.Model.Ont();
1507:   
1508:                          dataOnt.Id = ontId;
1509:                          dataOnt.BatteryBackupAvailable = (Ia.Cl.Model.Default.Match(line, @"BTRYBKUP=(\w+)") == "YES") ? true : false;
1510:                          dataOnt.Description1 = Ia.Cl.Model.Default.Match(line, @"DESC1=""([^""]{1,64})""");
1511:                          dataOnt.Description2 = Ia.Cl.Model.Default.Match(line, @"DESC2=""([^""]{1,64})""");
1512:                          dataOnt.Serial = Ia.Cl.Model.Default.Match(line, @"SERNUM=(\w{12})");
1513:                          dataOnt.PlannedSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERPLND=""(auto|AUTO|\w{14})""");
1514:                          dataOnt.ActiveSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERACT=(\w{14})");
1515:                          dataOnt.PassiveSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERPSV=(\w{14})");
1516:                          dataOnt.FamilyTypeId = (int)FamilyType(dataOnt.ActiveSoftware, dataOnt.PlannedSoftware);
1517:                          dataOnt.VendorId = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.VendorIdFromName(Ia.Cl.Model.Default.Match(line, @"VENDORID=(\w+)"));
1518:                          dataOnt.EquipmentId = Ia.Cl.Model.Default.Match(line, @"EQUIPID=(\w{16})");
1519:   
1520:                          switch (match.Groups[3].Value)
1521:                          {
1522:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1523:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1524:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1525:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1526:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1527:                          }
1528:   
1529:                          dataOnt.StateId = (int)state;
1530:   
1531:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1532:                          {
1533:                              accessId = Ia.Ngn.Cl.Model.Business.Access.AccessId(ontId);
1534:   
1535:                              if (accessId != null) dataOnt.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
1536:   
1537:                              ont = (from o in db.Onts where o.Id == dataOnt.Id select o).SingleOrDefault();
1538:   
1539:                              if (ont == null)
1540:                              {
1541:                                  dataOnt.Created = dataOnt.Updated = DateTime.UtcNow.AddHours(3);
1542:   
1543:                                  db.Onts.Add(dataOnt);
1544:                              }
1545:                              else
1546:                              {
1547:                                  // below: copy values from dataOnt to ont
1548:   
1549:                                  if (ont.Update(dataOnt))
1550:                                  {
1551:                                      db.Onts.Attach(ont);
1552:                                      db.Entry(ont).State = System.Data.Entity.EntityState.Modified;
1553:                                  }
1554:                              }
1555:   
1556:                              db.SaveChanges();
1557:   
1558:                              b = true;
1559:                          }
1560:                      }
1561:                      else
1562:                      {
1563:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1564:                      }
1565:                  }
1566:                  else
1567:                  {
1568:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1569:                  }
1570:                  #endregion
1571:              }
1572:              else if (rowData.Contains("ED-ONT:"))
1573:              {
1574:                  #region ED-ONT
1575:                  Ia.Ngn.Cl.Model.Ont ont, dataOnt;
1576:   
1577:                  /*
1578:     SUR-5-2 14-11-23 05:22:08
1579:  M  0 COMPLD
1580:     / * ED-ONT:SUR-5-2:ONT-1-1-1-2-6::::DESC1=ZAH.2.6: * /
1581:   
1582:  M  0 COMPLD
1583:     / * ED-ONT:QRW-SLB-LAG2:ONT-1-1-3-2-10:98499:::DESC1=QRW.33.10: * /
1584:  ;
1585:                  */
1586:   
1587:                  // below: read OntPosition
1588:                  match = Regex.Match(rowData, @"ED-ONT:([\w\d\-]+)", RegexOptions.Singleline);
1589:   
1590:                  amsName = match.Groups[1].Value;
1591:   
1592:                  match = Regex.Match(rowData, @"ONT-1-1-(\d{1,2}-\d{1,2}-\d{1,2}):\d{0,6}:::(.+?):", RegexOptions.Singleline);
1593:   
1594:                  if (match.Success)
1595:                  {
1596:                      cardPortOnt = match.Groups[1].Value;
1597:   
1598:                      line = match.Groups[2].Value;
1599:   
1600:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1601:   
1602:                      if (!string.IsNullOrEmpty(ontId))
1603:                      {
1604:                          dataOnt = new Ia.Ngn.Cl.Model.Ont();
1605:   
1606:                          dataOnt.Id = ontId;
1607:                          dataOnt.Description1 = Ia.Cl.Model.Default.Match(line, @"DESC1=(.{1,64})");
1608:                          dataOnt.Description2 = Ia.Cl.Model.Default.Match(line, @"DESC2=(.{1,64})");
1609:   
1610:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1611:                          {
1612:                              ont = (from o in db.Onts where o.Id == dataOnt.Id select o).SingleOrDefault();
1613:   
1614:                              if (ont == null)
1615:                              {
1616:                                  // below: Don't create a new ONT in this ED-ONT function
1617:                                  //dataOnt.Created = dataOnt.Updated = DateTime.UtcNow.AddHours(3);
1618:   
1619:                                  //db.Onts.Add(dataOnt);
1620:                              }
1621:                              else
1622:                              {
1623:                                  // below: copy values from dataOnt to ont
1624:   
1625:                                  if (ont.Update(dataOnt))
1626:                                  {
1627:                                      db.Onts.Attach(ont);
1628:                                      db.Entry(ont).State = System.Data.Entity.EntityState.Modified;
1629:                                  }
1630:                              }
1631:   
1632:                              db.SaveChanges();
1633:   
1634:                              b = true;
1635:                          }
1636:                      }
1637:                      else
1638:                      {
1639:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1640:                      }
1641:                  }
1642:                  else
1643:                  {
1644:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1645:                  }
1646:                  #endregion
1647:              }
1648:              else if (rowData.Contains("RTRV-SERVICE-VOIP:"))
1649:              {
1650:                  #region RTRV-SERVICE-VOIP
1651:   
1652:                  string ontServiceVoipId;
1653:                  int card;
1654:                  Ia.Ngn.Cl.Model.OntServiceVoip ontServiceVoip, dataOntServiceVoip;
1655:   
1656:                  // below: information from the definition of "RTRV-SERVICE-VOIP" in "AMS TL1 Commands Reference"
1657:   
1658:                  /*
1659:   
1660:     SUR-1-1 08-07-09 09:43:13
1661:  M  0 COMPLD
1662:     / * RTRV-SERVICE-VOIP:SUR-1-1:VOIP-1-1-1-1-1-1&VOIP-1-1-1-1-10-1&VOIP-1-1 * /
1663:     / * -1-1-2-1&VOIP-1-1-1-1-3-1&VOIP-1-1-1-1-4-1&VOIP-1-1-1-1-5-1&VOIP-1-1- * /
1664:     / * 1-1-6-1&VOIP-1-1-1-1-7-1&VOIP-1-1-1-1-8-1&VOIP-1-1-1-1-9-1 * /
1665:     "VOIP-1-1-1-1-1-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1666:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1667:     IPADDRLOC=10.3.144.1,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1668:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1669:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1670:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1671:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1672:     SRCVLANID=0:IS-NR"
1673:     "VOIP-1-1-1-1-10-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1674:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1675:     IPADDRLOC=10.3.144.10,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1676:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1677:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1678:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1679:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1680:     SRCVLANID=0:IS-NR"
1681:     "VOIP-1-1-1-1-2-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1682:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1683:     IPADDRLOC=10.3.144.2,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1684:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1685:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1686:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1687:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1688:     SRCVLANID=0:IS-NR"
1689:   
1690:     / * More Output Follows * /
1691:  >
1692:                  */
1693:   
1694:                  // below: read OntPosition
1695:                  match = Regex.Match(rowData, @"RTRV-SERVICE-VOIP:([\w\d\-]+)", RegexOptions.Singleline);
1696:   
1697:                  amsName = match.Groups[1].Value;
1698:   
1699:                  match = Regex.Match(rowData, @"VOIP-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})::(.+?):\s*(IS-NR|OOS-AU|OOS-MA|OOS-AUMA)", RegexOptions.Singleline);
1700:   
1701:                  if (match.Success)
1702:                  {
1703:                      cardPortOnt = match.Groups[1].Value;
1704:                      card = int.Parse(match.Groups[2].Value);
1705:   
1706:                      line = match.Groups[3].Value;
1707:   
1708:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1709:   
1710:                      if (!string.IsNullOrEmpty(ontId))
1711:                      {
1712:                          ontServiceVoipId = Ia.Ngn.Cl.Model.Business.Nokia.OntServiceVoip.OntServiceVoipId(ontId, card);
1713:   
1714:                          dataOntServiceVoip = new Ia.Ngn.Cl.Model.OntServiceVoip();
1715:   
1716:                          dataOntServiceVoip.Id = ontServiceVoipId;
1717:   
1718:                          dataOntServiceVoip.ConfiguratinFile = Ia.Cl.Model.Default.Match(line, @"CONFIGFILE=(\w{1,}\.xml)");
1719:                          dataOntServiceVoip.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTOMERID=""([^""]{1,62})""");
1720:                          dataOntServiceVoip.FtpIp = Ia.Cl.Model.Default.Match(line, @"IPADDRFTP=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1721:                          dataOntServiceVoip.Ip = Ia.Cl.Model.Default.Match(line, @"IPADDRLOC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1722:                          dataOntServiceVoip.Label = Ia.Cl.Model.Default.Match(line, @"LABEL=""([^""]{1,80})""");
1723:                          dataOntServiceVoip.MgcIp = Ia.Cl.Model.Default.Match(line, @"IPADDRMGC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1724:                          dataOntServiceVoip.MgcSecondaryIp = Ia.Cl.Model.Default.Match(line, @"IPADDRMGCSEC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1725:   
1726:                          switch (match.Groups[4].Value)
1727:                          {
1728:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1729:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1730:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1731:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1732:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1733:                          }
1734:   
1735:                          dataOntServiceVoip.StateId = (int)state;
1736:   
1737:                          dataOntServiceVoip.Svlan = int.Parse(Ia.Cl.Model.Default.Match(line, @"SVLAN=(\d{1,3})"));
1738:   
1739:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1740:                          {
1741:                              dataOntServiceVoip.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1742:   
1743:                              ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == dataOntServiceVoip.Id select osv).SingleOrDefault();
1744:   
1745:                              if (ontServiceVoip == null)
1746:                              {
1747:                                  dataOntServiceVoip.Created = dataOntServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
1748:   
1749:                                  db.OntServiceVoips.Add(dataOntServiceVoip);
1750:                              }
1751:                              else
1752:                              {
1753:                                  // below: copy values from dataOnt to ont
1754:   
1755:                                  if (ontServiceVoip.Update(dataOntServiceVoip))
1756:                                  {
1757:                                      db.OntServiceVoips.Attach(ontServiceVoip);
1758:                                      db.Entry(ontServiceVoip).State = System.Data.Entity.EntityState.Modified;
1759:                                  }
1760:                              }
1761:   
1762:                              db.SaveChanges();
1763:   
1764:                              b = true;
1765:                          }
1766:                      }
1767:                      else
1768:                      {
1769:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1770:                      }
1771:                  }
1772:                  else
1773:                  {
1774:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1775:                  }
1776:                  #endregion
1777:              }
1778:              else if (rowData.Contains("RTRV-ONTPOTS:"))
1779:              {
1780:                  #region RTRV-ONTPOTS
1781:   
1782:                  string ontOntPotsId;
1783:                  int card, port, svlan;
1784:                  Ia.Ngn.Cl.Model.OntOntPots ontOntPots, dataOntOntPots;
1785:   
1786:                  // below: information from the definition of "RTRV-ONTPOTS" in "AMS TL1 Commands Reference"
1787:   
1788:                  /*
1789:                   * ;RTRV-ONTPOTS:SUR-1-1:ONTPOTS-1-1-1-1-1-2-1;
1790:   
1791:     SUR-1-1 14-03-13 08:15:46
1792:  M  0 COMPLD
1793:     /* RTRV-ONTPOTS:SUR-1-1:ONTPOTS-1-1-1-1-1-2-1 * /
1794:     "ONTPOTS-1-1-1-1-1-2-1::VOIPSERV=1,TERMID=td1,POTSDSCP=46,POTSPWR=0,
1795:     CALLHIST=DISABLED,PWROVERRIDE=FALSE,SIPMSGTOTH=0,BRRPKTLOSSTH=0,XJTTRTH=0,
1796:     RXGAIN=0,TXGAIN=0:IS-NR"
1797:  ;
1798:  */
1799:   
1800:                  // below: read OntPosition
1801:                  match = Regex.Match(rowData, @"RTRV-ONTPOTS:([\w\d\-]+)", RegexOptions.Singleline);
1802:   
1803:                  amsName = match.Groups[1].Value;
1804:   
1805:                  match = Regex.Match(rowData, @"ONTPOTS-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})-(\d{1,2})::(.+?):\s*(IS-NR|OOS-AU|OOS-MA|OOS-AUMA)", RegexOptions.Singleline);
1806:   
1807:                  if (match.Success)
1808:                  {
1809:                      cardPortOnt = match.Groups[1].Value;
1810:                      card = int.Parse(match.Groups[2].Value);
1811:                      port = int.Parse(match.Groups[3].Value);
1812:   
1813:                      line = match.Groups[4].Value;
1814:   
1815:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1816:   
1817:                      if (!string.IsNullOrEmpty(ontId))
1818:                      {
1819:                          ontOntPotsId = Ia.Ngn.Cl.Model.Business.Nokia.OntOntPots.OntOntPotsId(ontId, card, port);
1820:   
1821:                          dataOntOntPots = new Ia.Ngn.Cl.Model.OntOntPots();
1822:   
1823:                          dataOntOntPots.Id = ontOntPotsId;
1824:   
1825:                          dataOntOntPots.Card = card;
1826:                          dataOntOntPots.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTINFO=(\w{1,80})");
1827:                          dataOntOntPots.Port = port;
1828:   
1829:                          switch (match.Groups[5].Value)
1830:                          {
1831:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1832:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1833:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1834:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1835:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1836:                          }
1837:   
1838:                          dataOntOntPots.StateId = (int)state;
1839:   
1840:                          if (int.TryParse(Ia.Cl.Model.Default.Match(line, @"SVLAN=(\d{1,3})"), out svlan)) dataOntOntPots.Svlan = svlan;
1841:   
1842:                          dataOntOntPots.Termination = Ia.Cl.Model.Default.Match(line, @"TERMID=(\w{1,20})");
1843:                          dataOntOntPots.Tn = Ia.Cl.Model.Default.Match(line, @"TN=(\w{1,16})");
1844:                          dataOntOntPots.VoipClientIp = Ia.Cl.Model.Default.Match(line, @"VOIPCLIENTADDR=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1845:   
1846:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1847:                          {
1848:                              dataOntOntPots.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1849:   
1850:                              ontOntPots = (from oop in db.OntOntPotses where oop.Id == dataOntOntPots.Id select oop).SingleOrDefault();
1851:   
1852:                              if (ontOntPots == null)
1853:                              {
1854:                                  dataOntOntPots.Created = dataOntOntPots.Updated = DateTime.UtcNow.AddHours(3);
1855:   
1856:                                  db.OntOntPotses.Add(dataOntOntPots);
1857:                              }
1858:                              else
1859:                              {
1860:                                  // below: copy values from dataOnt to ont
1861:   
1862:                                  if (ontOntPots.Update(dataOntOntPots))
1863:                                  {
1864:                                      db.OntOntPotses.Attach(ontOntPots);
1865:                                      db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
1866:                                  }
1867:                              }
1868:   
1869:                              db.SaveChanges();
1870:   
1871:                              b = true;
1872:                          }
1873:                      }
1874:                      else
1875:                      {
1876:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1877:                      }
1878:                  }
1879:                  else
1880:                  {
1881:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1882:                  }
1883:   
1884:                  #endregion
1885:              }
1886:              else if (rowData.Contains("ED-ONTPOTS:"))
1887:              {
1888:                  #region ED-ONTPOTS
1889:   
1890:                  string ontOntPotsId;
1891:                  int card, port;
1892:                  Ia.Ngn.Cl.Model.OntOntPots ontOntPots, dataOntOntPots;
1893:   
1894:                  /* ED-ONTPOTS:SUL-1-1:ONTPOTS-1-1-9-1-1-2-1:14614:::CUSTINFO=24977777: */
1895:   
1896:                  // below: read OntPosition
1897:                  match = Regex.Match(rowData, @"ED-ONTPOTS:([\w\d\-]+)", RegexOptions.Singleline);
1898:   
1899:                  amsName = match.Groups[1].Value;
1900:   
1901:                  match = Regex.Match(rowData, @"ONTPOTS-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})-(\d{1,2}):(.+?):", RegexOptions.Singleline);
1902:   
1903:                  if (match.Success)
1904:                  {
1905:                      cardPortOnt = match.Groups[1].Value;
1906:                      card = int.Parse(match.Groups[2].Value);
1907:                      port = int.Parse(match.Groups[3].Value);
1908:   
1909:                      line = match.Groups[4].Value;
1910:   
1911:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1912:   
1913:                      if (!string.IsNullOrEmpty(ontId))
1914:                      {
1915:                          ontOntPotsId = Ia.Ngn.Cl.Model.Business.Nokia.OntOntPots.OntOntPotsId(ontId, card, port);
1916:   
1917:                          dataOntOntPots = new Ia.Ngn.Cl.Model.OntOntPots();
1918:   
1919:                          dataOntOntPots.Id = ontOntPotsId;
1920:   
1921:                          dataOntOntPots.Card = card;
1922:                          dataOntOntPots.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTINFO=(\w{1,80})");
1923:                          dataOntOntPots.Port = port;
1924:   
1925:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1926:                          {
1927:                              dataOntOntPots.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1928:   
1929:                              ontOntPots = (from oop in db.OntOntPotses where oop.Id == dataOntOntPots.Id select oop).SingleOrDefault();
1930:   
1931:                              if (ontOntPots == null)
1932:                              {
1933:                                  dataOntOntPots.Created = dataOntOntPots.Updated = DateTime.UtcNow.AddHours(3);
1934:   
1935:                                  db.OntOntPotses.Add(dataOntOntPots);
1936:                              }
1937:                              else
1938:                              {
1939:                                  if (ontOntPots.Update(dataOntOntPots))
1940:                                  {
1941:                                      db.OntOntPotses.Attach(ontOntPots);
1942:                                      db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
1943:                                  }
1944:                              }
1945:   
1946:                              db.SaveChanges();
1947:   
1948:                              b = true;
1949:                          }
1950:                      }
1951:                      else
1952:                      {
1953:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1954:                      }
1955:                  }
1956:                  else
1957:                  {
1958:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1959:                  }
1960:   
1961:                  #endregion
1962:              }
1963:              else if (rowData.Contains("RTRV-SERVICE-HSI:"))
1964:              {
1965:                  #region RTRV-SERVICE-HSI
1966:   
1967:                  string ontServiceHsiId;
1968:                  int hsiCard, hsiPort, hsiService;
1969:                  Ia.Ngn.Cl.Model.OntServiceHsi ontServiceHsi, dataOntServiceHsi;
1970:   
1971:                  /*
1972:                 / * RTRV-SERVICE-HSI:JHR-3-2:ALL * /
1973:                 ""HSI-1-1-2-1-19-1-1-1::BWPROFUPID=6,BWPROFUPNM=BW_1024KB_MOC,BWPROFDNID=6,
1974:                 BWPROFDNNM=BW_1024KB_MOC,PQPROFID=2,PQPROFNM=PQ_HSI_MOC,AESENABLE=DISABLE,
1975:                 LABEL=\""qnet\"",SVLAN=301,CUSTOMERID=\""24530145\"",ETHERTYPE=UNUSED,
1976:                 UNISIDEVLAN=0,NETWORKSIDEVLAN=0:OOS-AU""
1977:   
1978:                 ""HSI-1-1-8-2-26-1-1-1::BWPROFUPID=6,BWPROFUPNM=BW_1024KB_MOC,BWPROFDNID=6,
1979:                 BWPROFDNNM=BW_1024KB_MOC,PQPROFID=2,PQPROFNM=PQ_HSI_MOC,AESENABLE=DISABLE,
1980:                 LABEL=\""qnet\"",SVLAN=301,CUSTOMERID=\""24531014\"",ETHERTYPE=UNUSED,
1981:                 UNISIDEVLAN=0,NETWORKSIDEVLAN=0:OOS-AU""
1982:   
1983:                 ""HSI-1-1-10-2-22-1-1-1::BWPROFUPID=6,BWPROFUPNM=BW_1024KB_MOC,BWPROFDNID=6,
1984:                 BWPROFDNNM=BW_1024KB_MOC,PQPROFID=2,PQPROFNM=PQ_HSI_MOC,AESENABLE=DISABLE,
1985:                 LABEL=\""fast\"",SVLAN=302,CUSTOMERID=\""24530630\"",ETHERTYPE=UNUSED,
1986:                 UNISIDEVLAN=0,NETWORKSIDEVLAN=0:OOS-AU""
1987:   
1988:                 ""HSI-1-1-15-2-1-1-1-1::BWPROFUPID=6,BWPROFUPNM=BW_1024KB_MOC,BWPROFDNID=6,
1989:                 BWPROFDNNM=BW_1024KB_MOC,PQPROFID=2,PQPROFNM=PQ_HSI_MOC,AESENABLE=DISABLE,
1990:                 LABEL=\""Qnet\"",SVLAN=301,CUSTOMERID=\""\"",ETHERTYPE=UNUSED,UNISIDEVLAN=0,
1991:                 NETWORKSIDEVLAN=0:IS-NR""
1992:   
1993:                 ""HSI-1-1-16-2-1-1-1-1::BWPROFUPID=7,BWPROFUPNM=BW_8192KB_MOC,BWPROFDNID=7,
1994:                 BWPROFDNNM=BW_8192KB_MOC,PQPROFID=2,PQPROFNM=PQ_HSI_MOC,AESENABLE=DISABLE,
1995:                 SVLAN=301,CUSTOMERID=\""\"",ETHERTYPE=UNUSED,UNISIDEVLAN=0,NETWORKSIDEVLAN=0:
1996:                 OOS-AU""
1997:                 */
1998:   
1999:                  // below: read OntPosition
2000:                  match = Regex.Match(rowData, @"RTRV-SERVICE-HSI:([\w\d\-]+)", RegexOptions.Singleline);
2001:   
2002:                  amsName = match.Groups[1].Value;
2003:   
2004:                  match = Regex.Match(rowData, @"HSI-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})::(.+?):\s*(IS-NR|OOS-AU|OOS-MA|OOS-AUMA)", RegexOptions.Singleline);
2005:   
2006:                  if (match.Success)
2007:                  {
2008:                      cardPortOnt = match.Groups[1].Value;
2009:   
2010:                      hsiCard = int.Parse(match.Groups[2].Value);
2011:                      hsiPort = int.Parse(match.Groups[3].Value);
2012:                      hsiService = int.Parse(match.Groups[4].Value);
2013:   
2014:                      line = match.Groups[5].Value;
2015:   
2016:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
2017:   
2018:                      if (!string.IsNullOrEmpty(ontId))
2019:                      {
2020:                          ontServiceHsiId = Ia.Ngn.Cl.Model.Business.Nokia.OntServiceHsi.OntServiceHsiId(ontId, hsiCard, hsiPort, hsiService);
2021:   
2022:                          dataOntServiceHsi = new Ia.Ngn.Cl.Model.OntServiceHsi();
2023:   
2024:                          dataOntServiceHsi.Id = ontServiceHsiId;
2025:   
2026:                          dataOntServiceHsi.Aes = (Ia.Cl.Model.Default.Match(line, @"AESENABLE=(\w+)") == "ENABLE") ? true : false;
2027:   
2028:                          dataOntServiceHsi.Card = hsiCard;
2029:                          dataOntServiceHsi.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTOMERID=""([^""]{1,64})""");
2030:                          dataOntServiceHsi.DownstreamBandwidthProfileId = int.Parse(Ia.Cl.Model.Default.Match(line, @"BWPROFDNID=(\d{1,2})"));
2031:                          dataOntServiceHsi.Label = Ia.Cl.Model.Default.Match(line, @"LABEL=""([^""]{1,20})""");
2032:   
2033:                          dataOntServiceHsi.Port = hsiPort;
2034:                          dataOntServiceHsi.PriorityQueueProfileId = int.Parse(Ia.Cl.Model.Default.Match(line, @"PQPROFID=(\d{1,2})"));
2035:                          dataOntServiceHsi.Service = hsiService;
2036:   
2037:                          switch (match.Groups[6].Value)
2038:                          {
2039:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
2040:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
2041:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
2042:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
2043:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
2044:                          }
2045:   
2046:                          dataOntServiceHsi.StateId = (int)state;
2047:   
2048:                          dataOntServiceHsi.Svlan = int.Parse(Ia.Cl.Model.Default.Match(line, @"SVLAN=(\d{1,3})"));
2049:                          dataOntServiceHsi.UpstreamBandwidthProfileId = int.Parse(Ia.Cl.Model.Default.Match(line, @"BWPROFUPID=(\d{1,2})"));
2050:   
2051:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
2052:                          {
2053:                              dataOntServiceHsi.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
2054:   
2055:                              ontServiceHsi = (from osh in db.OntServiceHsis where osh.Id == dataOntServiceHsi.Id select osh).SingleOrDefault();
2056:   
2057:                              if (ontServiceHsi == null)
2058:                              {
2059:                                  dataOntServiceHsi.Created = dataOntServiceHsi.Updated = DateTime.UtcNow.AddHours(3);
2060:   
2061:                                  db.OntServiceHsis.Add(dataOntServiceHsi);
2062:                              }
2063:                              else
2064:                              {
2065:                                  // below: copy values from dataOnt to ont
2066:   
2067:                                  if (ontServiceHsi.Update(dataOntServiceHsi))
2068:                                  {
2069:                                      db.OntServiceHsis.Attach(ontServiceHsi);
2070:                                      db.Entry(ontServiceHsi).State = System.Data.Entity.EntityState.Modified;
2071:                                  }
2072:                              }
2073:   
2074:                              db.SaveChanges();
2075:   
2076:                              b = true;
2077:                          }
2078:                      }
2079:                      else
2080:                      {
2081:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
2082:                      }
2083:                  }
2084:                  else
2085:                  {
2086:                      /*
2087:                       * ABM-2-1 18-06-13 11:09:22
2088:                       * M  0 COMPLD
2089:                       * / * RTRV-SERVICE-HSI:ABM-2-1:HSI-1-1-11-2-4-1-2-1:97960 * /
2090:                       */
2091:   
2092:                      match = Regex.Match(rowData, @"HSI-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2}):\d{1,6}", RegexOptions.Singleline);
2093:   
2094:                      if (match.Success)
2095:                      {
2096:                          // Hsi empty
2097:   
2098:                      }
2099:                      else
2100:                      {
2101:                          result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
2102:                      }
2103:                  }
2104:                  #endregion
2105:              }
2106:              else if (rowData.Contains("RTRV-ALM-PON:"))
2107:              {
2108:                  #region RTRV-ALM-PON
2109:   
2110:                  Ia.Ngn.Cl.Model.Event @event;
2111:   
2112:                  // below: important, remove all ''' char from string
2113:                  rowData = rowData.Replace(@"'", "");
2114:   
2115:                  // below: read eventTime and amsName
2116:                  // QRW-1-1 14-03-31 06:15:20
2117:                  match = Regex.Match(rowData, @"([\w\d\-]+) ((\d{2})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))", RegexOptions.Singleline);
2118:   
2119:                  amsName = match.Groups[1].Value;
2120:                  eventTime = DateTime.ParseExact(match.Groups[2].Captures[0].Value, "yy-MM-dd HH:mm:ss", null);
2121:   
2122:                  // "PON-1-1-9-2,PON:MN,NEWONT,NSA,,,,: \"SERNUM =ALCLA0A2D17A, SLID =DEFAULT,\""
2123:                  matchCollection = Regex.Matches(rowData, @"""(PON-\d{1,2}-\d{1,2}-\d{1,2}-\d{1,2}),PON:MN,NEWONT,NSA,,,,:\s*\r\n\s*""(SERNUM\s*=\s*(ALCL\w{8}), SLID\s*=\s*DEFAULT,)""""", RegexOptions.Singleline);
2124:   
2125:                  if (matchCollection.Count > 0)
2126:                  {
2127:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
2128:                      {
2129:                          foreach (Match m in matchCollection)
2130:                          {
2131:                              if (m.Success)
2132:                              {
2133:                                  @event = new Ia.Ngn.Cl.Model.Event();
2134:   
2135:                                  @event.Aid = m.Groups[1].Value;
2136:                                  @event.Cause = "NEWONT";
2137:                                  @event.Class = "ONT";
2138:                                  @event.Detail = m.Groups[2].Value;
2139:                                  @event.EventTime = eventTime;
2140:                                  @event.NodeTime = null;
2141:                                  @event.Number = 0;
2142:                                  @event.SeverityEffect = "NSA";
2143:                                  @event.Severity = "MN";
2144:                                  @event.System = amsName;
2145:                                  @event.TypeId = 0;
2146:   
2147:                                  @event.Created = @event.Updated = DateTime.UtcNow.AddHours(3);
2148:                                  db.Events.Add(@event);
2149:   
2150:                                  b = true;
2151:                              }
2152:                          }
2153:   
2154:                          db.SaveChanges();
2155:                      }
2156:                  }
2157:                  else
2158:                  {
2159:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
2160:                  }
2161:   
2162:                  #endregion
2163:              }
2164:              else if (rowData.Contains("REPT ALM"))
2165:              {
2166:                  #region REPT ALM
2167:   
2168:                  string _class, aid;
2169:                  Ia.Ngn.Cl.Model.Event @event;
2170:   
2171:                  // below: important, remove all ''' char from string
2172:                  rowData = rowData.Replace(@"'", "");
2173:   
2174:                  // SUR-1-2 08-07-18 11:24:06 * 491 REPT ALM ONT "ONT-1-1-9-2-5:MN,INACT,SA,7-18,11-24-6:\"ONT is inactive\"" ;
2175:   
2176:                  /*
2177:     SLA-SUR-LAG16 18-06-24 18:21:01
2178:  A  37211 REPT ALM ONT
2179:     "ONT-1-1-5-9-20:CL,DG,SA,6-24,18-21-1:
2180:     "Received Dying Gasp indication from ONT","
2181:  ;                 */
2182:                  match = Regex.Match(rowData, @"([\w\d\-]+) ((\d{2})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))\r\n(.{1,10})\s+(\d{1,6}) REPT (ALM|EVT|ALM ENV|SW) (\w{1,20})\r\n\s+""(\w{1,20})-(\d{1,2})-(\d{1,2})-([^:]+?):(CR|MJ|MN|CL),(\w{1,20}),(SA|NSA|NR|Ind NR),((\d{1,2})-(\d{1,2})),((\d{1,2})-(\d{1,2})-(\d{1,2})).*:[\r\n\s]*""(.+?)""""\r\n;", RegexOptions.Singleline);
2183:   
2184:                  if (match.Success)
2185:                  {
2186:                      amsName = match.Groups[1].Value;
2187:   
2188:                      _class = match.Groups[12].Captures[0].Value;
2189:                      aid = match.Groups[13].Captures[0].Value + "-" + match.Groups[14].Captures[0].Value + "-" + match.Groups[15].Captures[0].Value + "-" + match.Groups[16].Captures[0].Value;
2190:   
2191:                      ontPosition = CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(amsName, _class, aid);
2192:                      ontId = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdFromPosition(ontPosition);
2193:   
2194:                      @event = new Ia.Ngn.Cl.Model.Event();
2195:   
2196:                      @event.Aid = aid;
2197:                      @event.Cause = match.Groups[18].Captures[0].Value;
2198:                      @event.Class = _class;
2199:                      @event.Detail = match.Groups[27].Captures[0].Value.Replace(@"""", "");
2200:                      @event.EventTime = DateTime.ParseExact(match.Groups[2].Captures[0].Value, "yy-MM-dd HH:mm:ss", null);
2201:                      @event.NodeTime = DateTime.ParseExact(match.Groups[3].Captures[0].Value + "-" + match.Groups[21].Captures[0].Value.PadLeft(2, '0') + "-" + match.Groups[22].Captures[0].Value.PadLeft(2, '0') + " " + match.Groups[24].Captures[0].Value.PadLeft(2, '0') + ":" + match.Groups[25].Captures[0].Value.PadLeft(2, '0') + ":" + match.Groups[26].Captures[0].Value.PadLeft(2, '0'), "yy-MM-dd HH:mm:ss", null);
2202:                      @event.Number = int.Parse(match.Groups[10].Captures[0].Value);
2203:                      @event.SeverityEffect = match.Groups[19].Captures[0].Value;
2204:                      @event.Severity = match.Groups[17].Captures[0].Value;
2205:                      @event.System = amsName;
2206:                      @event.TypeId = 0;
2207:   
2208:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
2209:                      {
2210:                          if (ontId != null) @event.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
2211:   
2212:                          @event.Created = @event.Updated = DateTime.UtcNow.AddHours(3);
2213:                          db.Events.Add(@event);
2214:                          db.SaveChanges();
2215:   
2216:                          b = true;
2217:                      }
2218:                  }
2219:                  else
2220:                  {
2221:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
2222:                  }
2223:   
2224:                  #endregion
2225:              }
2226:   
2227:              return b;
2228:          }
2229:   
2230:          ////////////////////////////////////////////////////////////////////////////
2231:   
2232:          /// <summary>
2233:          /// 
2234:          /// </summary>
2235:          private static string CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(string amsName, string _class, string aid)
2236:          {
2237:              /*
2238:  --BRGPORT    BRGPORT-1-1-11-2-6-1-1
2239:  --PON    PON-1-1-13-1
2240:  --EQPT    LT-1-1-14
2241:  --ONTPOTS    ONTPOTS-1-1-8-1-17-2-2
2242:  --ONTVOIP    VOIP-1-1-13-2-22-1
2243:  --ONT    ONT-1-1-13-1-10
2244:  --ONTENET    ONTENET-1-1-2-1-20-1-1
2245:  --ONTCARD    ONTCARD-1-1-9-2-8-1
2246:  --ONTHSI    HSI-1-1-2-1-8-1-2-2
2247:              */
2248:   
2249:              string ontPosition;
2250:              Match match;
2251:   
2252:              ontPosition = string.Empty;
2253:   
2254:              if (!string.IsNullOrEmpty(aid) && !string.IsNullOrEmpty(_class))
2255:              {
2256:                  if (_class == "BRGPORT")
2257:                  {
2258:                      // BRGPORT    BRGPORT-1-1-11-2-6-1-1
2259:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2260:   
2261:                      if (match.Success)
2262:                      {
2263:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2264:                      }
2265:                      else
2266:                      {
2267:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2268:                      }
2269:                  }
2270:                  else if (_class == "PON")
2271:                  {
2272:                      // PON    PON-1-1-13-1
2273:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2274:   
2275:                      if (match.Success)
2276:                      {
2277:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-1"; // I will assign the first ONT in the PON as indication to the PON
2278:                      }
2279:                      else
2280:                      {
2281:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2282:                      }
2283:                  }
2284:                  else if (_class == "EQPT")
2285:                  {
2286:                      // EQPT    LT-1-1-14
2287:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2288:   
2289:                      if (match.Success)
2290:                      {
2291:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-1"; // I will assign the first PON ONT in the PON as indication to the PON
2292:                      }
2293:                      else
2294:                      {
2295:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2296:                      }
2297:                  }
2298:                  else if (_class == "ONTPOTS")
2299:                  {
2300:                      // ONTPOTS    ONTPOTS-1-1-8-1-17-2-2
2301:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2302:   
2303:                      if (match.Success)
2304:                      {
2305:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2306:                      }
2307:                      else
2308:                      {
2309:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2310:                      }
2311:                  }
2312:                  else if (_class == "ONTVOIP")
2313:                  {
2314:                      // ONTVOIP    VOIP-1-1-13-2-22-1
2315:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2316:   
2317:                      if (match.Success)
2318:                      {
2319:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2320:                      }
2321:                      else
2322:                      {
2323:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2324:                      }
2325:                  }
2326:                  else if (_class == "ONT")
2327:                  {
2328:                      // ONT    ONT-1-1-13-1-10
2329:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2330:   
2331:                      if (match.Success)
2332:                      {
2333:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2334:                      }
2335:                      else
2336:                      {
2337:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2338:                      }
2339:                  }
2340:                  else if (_class == "ONTENET")
2341:                  {
2342:                      // ONTENET    ONTENET-1-1-2-1-20-1-1
2343:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2344:   
2345:                      if (match.Success)
2346:                      {
2347:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2348:                      }
2349:                      else
2350:                      {
2351:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2352:                      }
2353:                  }
2354:                  else if (_class == "ONTCARD")
2355:                  {
2356:                      // ONTCARD    ONTCARD-1-1-9-2-8-1
2357:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2358:   
2359:                      if (match.Success)
2360:                      {
2361:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2362:                      }
2363:                      else
2364:                      {
2365:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2366:                      }
2367:                  }
2368:                  else if (_class == "ONTHSI")
2369:                  {
2370:                      // ONTHSI    HSI-1-1-2-1-8-1-2-2
2371:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2372:   
2373:                      if (match.Success)
2374:                      {
2375:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2376:                      }
2377:                      else
2378:                      {
2379:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2380:                      }
2381:                  }
2382:                  else
2383:                  {
2384:                      throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): Unknown class. ") { };
2385:                  }
2386:              }
2387:              else
2388:              {
2389:                  throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): aid and/or class are null. ") { };
2390:              }
2391:   
2392:              return ontPosition;
2393:          }
2394:   
2395:          ////////////////////////////////////////////////////////////////////////////
2396:   
2397:          /// <summary>
2398:          ///
2399:          /// </summary>
2400:          public bool AddPot(string td)
2401:          {
2402:              bool b;
2403:   
2404:              b = true;
2405:   
2406:   
2407:              return b;
2408:          }
2409:   
2410:          ////////////////////////////////////////////////////////////////////////////
2411:   
2412:          /// <summary>
2413:          ///
2414:          /// </summary>
2415:          public static string CommandsToDeleteAndCreateServiceVoipUsingNdd(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, Ia.Ngn.Cl.Model.Ont ont, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2416:          {
2417:              string sa, cardPortOnt, voipServiceState;
2418:   
2419:              sa = "";
2420:   
2421:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
2422:              {
2423:                  cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2424:   
2425:                  if (edServiceVoipIsOos) voipServiceState = "OOS";
2426:                  else voipServiceState = "IS";
2427:   
2428:                  sa = @"
2429:  # Delete then create VOIP and associated ONTPOTS: " + nddOnt.Access.Name + @" " + nddOnt.Position;
2430:   
2431:                  if (ont != null)
2432:                  {
2433:                      if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu || ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined)
2434:                      {
2435:                          sa += @"
2436:   
2437:  # Delete ONTPOTS
2438:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4:::::OOS;
2439:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4::;
2440:   
2441:  # Delete VOIP
2442:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2443:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2444:   
2445:  # Create VOIP
2446:  ENT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1::::BWPROFUPID=1,BWPROFDNID=1,PQPROFID=1,LABEL=" + nddOnt.Access.Name + @",SVLAN=" /*+ ponGroup.Olt.Vlan*/ + @",IPADDRLOC=" + nddOnt.Ip + @",NETMASKLOC=" + nddOnt.MgcSubnetMask + @",DEFROUTER=" + ponGroup.GatewayIp + @",IPADDRMGC=" + nddOnt.MgcIp + @",IPADDRMGCSEC=" + nddOnt.MgcSecondaryIp + @",VOIPMODE=SSH248,CONFIGFILE=" + olt.Odf.Router.Oams.FirstOrDefault().ConfigFile + @":IS;
2447:   
2448:  # Create ONTPOTS
2449:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2450:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2451:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2452:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2453:   
2454:  # VOIP service state
2455:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2456:   
2457:   
2458:  ";
2459:                      }
2460:                      else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
2461:                      {
2462:                          sa += @"
2463:   
2464:  # Delete ONTPOTS
2465:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8:::::OOS;
2466:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8::;
2467:   
2468:  # Delete VOIP
2469:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2470:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2471:   
2472:  # Create VOIP
2473:  ENT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1::::BWPROFUPID=1,BWPROFDNID=1,PQPROFID=1,LABEL=" + nddOnt.Access.Name + @",SVLAN=" /*+ ponGroup.Vlan*/ + @",IPADDRLOC=" + nddOnt.Ip + @",NETMASKLOC=" + nddOnt.MgcSubnetMask + @",DEFROUTER=" + ponGroup.GatewayIp + @",IPADDRMGC=" + nddOnt.MgcIp + @",IPADDRMGCSEC=" + nddOnt.MgcSecondaryIp + @",VOIPMODE=SSH248,CONFIGFILE=" + olt.Odf.Router.Oams.FirstOrDefault().ConfigFile + @":IS;
2474:   
2475:  # Create ONTPOTS
2476:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2477:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2478:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2479:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2480:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td5:IS;
2481:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td6:IS;
2482:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td7:IS;
2483:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td8:IS;
2484:   
2485:  # VOIP service state
2486:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2487:   
2488:   
2489:  ";
2490:                      }
2491:                      else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
2492:                      {
2493:                          sa += @"
2494:   
2495:  # Delete ONTPOTS
2496:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1&&-8:::::OOS;
2497:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8:::::OOS;
2498:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1&&-8:::::OOS;
2499:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1&&-8::;
2500:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8::;
2501:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1&&-8::;
2502:   
2503:  # Delete VOIP
2504:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2505:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2506:   
2507:  # Create VOIP
2508:  ENT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1::::BWPROFUPID=8,BWPROFDNID=8,PQPROFID=1,AESENABLE=DISABLE,LABEL=" + nddOnt.Access.Name + @",SVLAN=" /*+ ponGroup.Vlan*/ + @",IPADDRLOC=" + nddOnt.Ip + @",NETMASKLOC=" + nddOnt.MgcSubnetMask + @",DEFROUTER=" + ponGroup.GatewayIp + @",IPADDRMGC=" + nddOnt.MgcIp + @",IPADDRMGCSEC=" + nddOnt.MgcSecondaryIp + @",IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=" + olt.Odf.Router.Oams.FirstOrDefault().ConfigFile + @":IS;
2509:   
2510:  # Create ONTPOTS
2511:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1::::VOIPSERV=1,TERMID=td1:IS;
2512:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-2::::VOIPSERV=1,TERMID=td2:IS;
2513:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-3::::VOIPSERV=1,TERMID=td3:IS;
2514:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-4::::VOIPSERV=1,TERMID=td4:IS;
2515:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-5::::VOIPSERV=1,TERMID=td13:IS;
2516:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-6::::VOIPSERV=1,TERMID=td14:IS;
2517:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-7::::VOIPSERV=1,TERMID=td15:IS;
2518:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-8::::VOIPSERV=1,TERMID=td16:IS;
2519:   
2520:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td5:IS;
2521:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td6:IS;
2522:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td7:IS;
2523:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td8:IS;
2524:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td17:IS;
2525:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td18:IS;
2526:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td19:IS;
2527:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td20:IS;
2528:   
2529:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1::::VOIPSERV=1,TERMID=td9:IS;
2530:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-2::::VOIPSERV=1,TERMID=td10:IS;
2531:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-3::::VOIPSERV=1,TERMID=td11:IS;
2532:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-4::::VOIPSERV=1,TERMID=td12:IS;
2533:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-5::::VOIPSERV=1,TERMID=td21:IS;
2534:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-6::::VOIPSERV=1,TERMID=td22:IS;
2535:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-7::::VOIPSERV=1,TERMID=td23:IS;
2536:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-8::::VOIPSERV=1,TERMID=td24:IS;
2537:   
2538:  # VOIP service state
2539:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2540:   
2541:   
2542:  ";
2543:                      }
2544:                      else
2545:                      {
2546:                          throw new Exception("Unknown familyType") { };
2547:                      }
2548:                  }
2549:                  else
2550:                  {
2551:   
2552:                      sa = @"
2553:  # Delete then create VOIP and associated ONTPOTS: " + nddOnt.Access.Name + @" " + nddOnt.Position;
2554:   
2555:                      sa += @"
2556:  # ONT does not have an associated Access to it.";
2557:   
2558:                      sa += @"
2559:   
2560:  # Delete ONTPOTS
2561:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4:::::OOS;
2562:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4::;
2563:   
2564:  # Delete VOIP
2565:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2566:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2567:   
2568:  # Create VOIP
2569:  ENT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1::::BWPROFUPID=1,BWPROFDNID=1,PQPROFID=1,LABEL=" + nddOnt.Access.Name + @",SVLAN=" /*+ ponGroup.Vlan*/ + @",IPADDRLOC=" + nddOnt.Ip + @",NETMASKLOC=" + nddOnt.MgcSubnetMask + @",DEFROUTER=" + ponGroup.GatewayIp + @",IPADDRMGC=" + nddOnt.MgcIp + @",IPADDRMGCSEC=" + nddOnt.MgcSecondaryIp + @",VOIPMODE=SSH248,CONFIGFILE=" + olt.Odf.Router.Oams.FirstOrDefault().ConfigFile + @":IS;
2570:   
2571:  # Create ONTPOTS
2572:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2573:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2574:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2575:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2576:   
2577:  # VOIP service state
2578:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2579:   
2580:   
2581:  ";
2582:                  }
2583:              }
2584:   
2585:              return sa;
2586:          }
2587:   
2588:          ////////////////////////////////////////////////////////////////////////////
2589:   
2590:          /// <summary>
2591:          ///
2592:          /// </summary>
2593:          public static string CommandsToCreateOntPots(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, Ia.Ngn.Cl.Model.Ont ont, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2594:          {
2595:              string sa, cardPortOnt, voipServiceState;
2596:   
2597:              cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2598:   
2599:              if (edServiceVoipIsOos) voipServiceState = "OOS";
2600:              else voipServiceState = "IS";
2601:   
2602:              sa = @"
2603:  # Create ONTPOTS: " + ont.Access.Name + @" " + ont.Access.Position;
2604:   
2605:              if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
2606:              {
2607:                  sa += @"
2608:   
2609:  # Create ONTPOTS
2610:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2611:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2612:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2613:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2614:   
2615:  # VOIP service state
2616:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2617:   
2618:   
2619:  ";
2620:              }
2621:              else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
2622:              {
2623:                  sa += @"
2624:   
2625:  # Create ONTPOTS
2626:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2627:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2628:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2629:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2630:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td5:IS;
2631:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td6:IS;
2632:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td7:IS;
2633:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td8:IS;
2634:   
2635:  # VOIP service state
2636:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2637:   
2638:   
2639:  ";
2640:              }
2641:              else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
2642:              {
2643:                  sa += @"
2644:   
2645:  # Create ONTPOTS
2646:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1::::VOIPSERV=1,TERMID=td1:IS;
2647:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-2::::VOIPSERV=1,TERMID=td2:IS;
2648:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-3::::VOIPSERV=1,TERMID=td3:IS;
2649:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-4::::VOIPSERV=1,TERMID=td4:IS;
2650:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-5::::VOIPSERV=1,TERMID=td13:IS;
2651:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-6::::VOIPSERV=1,TERMID=td14:IS;
2652:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-7::::VOIPSERV=1,TERMID=td15:IS;
2653:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-8::::VOIPSERV=1,TERMID=td16:IS;
2654:   
2655:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td5:IS;
2656:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td6:IS;
2657:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td7:IS;
2658:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td8:IS;
2659:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td17:IS;
2660:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td18:IS;
2661:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td19:IS;
2662:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td20:IS;
2663:   
2664:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1::::VOIPSERV=1,TERMID=td9:IS;
2665:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-2::::VOIPSERV=1,TERMID=td10:IS;
2666:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-3::::VOIPSERV=1,TERMID=td11:IS;
2667:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-4::::VOIPSERV=1,TERMID=td12:IS;
2668:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-5::::VOIPSERV=1,TERMID=td21:IS;
2669:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-6::::VOIPSERV=1,TERMID=td22:IS;
2670:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-7::::VOIPSERV=1,TERMID=td23:IS;
2671:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-8::::VOIPSERV=1,TERMID=td24:IS;
2672:   
2673:  # VOIP service state
2674:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2675:   
2676:   
2677:  ";
2678:              }
2679:              else
2680:              {
2681:                  sa += @"
2682:   
2683:  # Unknown FamilyType
2684:   
2685:   
2686:  ";
2687:              }
2688:   
2689:              return sa;
2690:          }
2691:   
2692:          ////////////////////////////////////////////////////////////////////////////
2693:   
2694:          /// <summary>
2695:          ///
2696:          /// </summary>
2697:          public static List<string> CommandsToPreprovisionOntWithinOlt(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2698:          {
2699:              string cardPortOnt, voipServiceState;
2700:              List<string> list;
2701:   
2702:              list = new List<string>();
2703:   
2704:              if (edServiceVoipIsOos) voipServiceState = "OOS";
2705:              else voipServiceState = "IS";
2706:   
2707:              cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2708:   
2709:              //list.Add("# Preprovision an empty ONT on the network: " + nddOnt.Access.Name + @" " + nddOnt.Position + " (" + nddOnt.Ip + @");");
2710:              list.Add("ENT-ONT:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONT-1-1-" + cardPortOnt + @"::::SWVERPLND=" + Ia.Ngn.Cl.Model.Data.Nokia.Ams.PlannedSoftware + @",DESC1=" + nddOnt.Access.Name + @",DESC2=""NULL"":OOS;");
2711:   
2712:              //list.Add("# Provision the VOIP service;");
2713:              list.Add("ENT-ONTCARD:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTCARD-1-1-" + cardPortOnt + @"-2:::POTS::IS;");
2714:              list.Add("ENT-ONTCARD:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTCARD-1-1-" + cardPortOnt + @"-1:::10_100BASET::IS;");
2715:              list.Add("ENT-ONTENET:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTENET-1-1-" + cardPortOnt + @"-1-1::::SESSPROFID=1,MAXMACNUM=4:IS;");
2716:              list.Add("ENT-ONTENET:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTENET-1-1-" + cardPortOnt + @"-1-2::::SESSPROFID=1,MAXMACNUM=4:IS;");
2717:              list.Add("ENT-SERVICE-VOIP:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1::::BWPROFUPID=1,BWPROFDNID=1,PQPROFID=1,SVLAN=" /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @",IPADDRLOC=" + nddOnt.Ip + @",NETMASKLOC=" + nddOnt.MgcSubnetMask + @",DEFROUTER=" + nddOnt.Pon.PonGroup.GatewayIp + @",IPADDRMGC=" + nddOnt.MgcIp + @",IPADDRMGCSEC=" + nddOnt.MgcSecondaryIp + @",VOIPMODE=SSH248,CONFIGFILE=kuwait.xml:IS;");
2718:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;");
2719:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;");
2720:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;");
2721:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;");
2722:   
2723:              //list.Add("# VOIP service state");
2724:              list.Add("ED-SERVICE-VOIP:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";");
2725:   
2726:              return list;
2727:          }
2728:   
2729:          ////////////////////////////////////////////////////////////////////////////
2730:   
2731:          /// <summary>
2732:          ///
2733:          /// </summary>
2734:          public static string CommandsToPreprovisionOntWithinOltUsingConfigureCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2735:          {
2736:              string sa, rackSubCardPortOnt;//, voipServiceState;
2737:   
2738:              //if (edServiceVoipIsOos) voipServiceState = "OOS";
2739:              //else voipServiceState = "IS";
2740:   
2741:              rackSubCardPortOnt = nddOnt.Rack + "/" + nddOnt.Sub + "/" + nddOnt.CardSlot + "/" + nddOnt.Port + "/" + nddOnt.InternalNumber;
2742:   
2743:              sa = @"
2744:  configure equipment ont slot " + rackSubCardPortOnt + @"/1 planned-card-type 10_100base plndnumdataports 2 plndnumvoiceports 0
2745:  configure equipment ont slot " + rackSubCardPortOnt + @"/2 planned-card-type pots plndnumdataports 0 plndnumvoiceports 4
2746:  configure qos interface ont:" + rackSubCardPortOnt + @" us-num-queue 8
2747:  configure qos interface " + rackSubCardPortOnt + @"/voip upstream-queue 5 bandwidth-profile name:VOICE bandwidth-sharing ont-sharing 
2748:  configure bridge port " + rackSubCardPortOnt + @"/voip max-unicast-mac 8    
2749:  configure bridge port " + rackSubCardPortOnt + @"/voip vlan-id " /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @"
2750:  configure bridge port " + rackSubCardPortOnt + @"/voip pvid " /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @"
2751:  configure voice ont service " + rackSubCardPortOnt + @"/1 voip-mode softswitch-h248 mgc-ip-addr " + nddOnt.MgcIp + @" sec-mgc-ip-addr " + nddOnt.MgcSecondaryIp + @" conf-file-name " + nddOnt.Pon.PonGroup.Olt.Odf.Router.Oams.First().ConfigFile + @" ip-address " + nddOnt.Ip + @" net-mask 255.255.248.0 default-router " + nddOnt.Pon.PonGroup.GatewayIp + @" vlan " /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @"
2752:   
2753:  ";
2754:   
2755:              return sa;
2756:          }
2757:   
2758:          ////////////////////////////////////////////////////////////////////////////    
2759:          ////////////////////////////////////////////////////////////////////////////    
2760:      }
2761:   
2762:      ////////////////////////////////////////////////////////////////////////////
2763:      ////////////////////////////////////////////////////////////////////////////   
2764:  }