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

Integrated Applications Programming Company

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.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Configuration;
   5:  using System.Data;
   6:  using System.Linq;
   7:  using System.Text.RegularExpressions;
   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-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated 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, RtrvServiceVoip, RtrvOntPots, 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 ProperlySelectedSingleAmsCommandToManageOntVoipPotsNetworkElements
 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.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr).PickRandom();
 232:   
 233:                          list = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyType_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.RtrvServiceVoip)
 282:                  {
 283:                      command = "RTRV-SERVICE-VOIP:" + amsName + ":VOIP-1-1-" + pon + "-1;";
 284:                      list.Add(command);
 285:                  }
 286:                  else if (amsOpcode == AmsOpcode.RtrvOntPots)
 287:                  {
 288:                      foreach (string ontPotsCardPort in Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(familyType))
 289:                      {
 290:                          command = "RTRV-ONTPOTS:" + amsName + ":ONTPOTS-1-1-" + pon + "-" + ontPotsCardPort + ";";
 291:                          list.Add(command);
 292:                      }
 293:                  }
 294:              }
 295:   
 296:              return list;
 297:          }
 298:   
 299:          ////////////////////////////////////////////////////////////////////////////
 300:   
 301:          /// <summary>
 302:          ///
 303:          /// </summary>
 304:          private static string FormatAmsOntCommand(AmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 305:          {
 306:              string command, amsName, pon;
 307:   
 308:              command = string.Empty;
 309:   
 310:              if (!string.IsNullOrEmpty(ont.Position))
 311:              {
 312:                  AmsNameAndCardPortOntSquenceFromOntPosition(ont.Position, out amsName, out pon);
 313:   
 314:                  if (amsOpcode == AmsOpcode.EdOntDesc1)
 315:                  {
 316:                      command = "ED-ONT:" + amsName + @":ONT-1-1-" + pon + "::::DESC1=" + ont.Access.Name + @":;";
 317:                      // ED-ONT:ESH-1-1:ONT-1-1-2-2-26::::DESC1=ESH.4.26:;
 318:                  }
 319:                  else if (amsOpcode == AmsOpcode.EdOntDesc1Annul)
 320:                  {
 321:                      //command = "ED-ONT:" + amsName + @":ONT-1-1-" + pon + "::::DESC1=:;"; // this has no effect on ONT DESC1
 322:                      // ED-ONT:ESH-1-1:ONT-1-1-2-2-26::::DESC1=:;
 323:   
 324:                      command = "ED-ONT:" + amsName + @":ONT-1-1-" + pon + "::::DESC1=NULL:;"; // you must send NULL to change ONT DESC1
 325:                      // ED-ONT:ESH-1-1:ONT-1-1-2-2-26::::DESC1=NULL:;
 326:                  }
 327:                  else if (amsOpcode == AmsOpcode.InitSys)
 328:                  {
 329:                      command = "INIT-SYS:" + amsName + @":ONT-1-1-" + pon + ":::6;";
 330:                      // INIT-SYS:SHD-SUR-LAG17:ONT-1-1-1-1-1:::6;
 331:                  }
 332:              }
 333:   
 334:              return command;
 335:          }
 336:   
 337:          ////////////////////////////////////////////////////////////////////////////
 338:   
 339:          /// <summary>
 340:          ///
 341:          /// </summary>
 342:          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 customerInformation)
 343:          {
 344:              string command;
 345:              List<string> list;
 346:   
 347:              command = null;
 348:   
 349:              list = new List<string>(10);
 350:   
 351:              if (!string.IsNullOrEmpty(ont.Position))
 352:              {
 353:                  AmsNameAndCardPortOntSquenceFromOntPosition(ont.Position, out string amsName, out string pon);
 354:   
 355:                  termination = termination.Replace("td", "");
 356:   
 357:                  if (int.TryParse(termination, out int td))
 358:                  {
 359:                      ReturnOntPotsCardAndPortFromFamilyTypeAndTd(familyType, td, out int card, out int port);
 360:   
 361:                      if (amsOpcode == AmsOpcode.EdOntPotsCustinfo)
 362:                      {
 363:                          if (!string.IsNullOrEmpty(customerInformation))
 364:                          {
 365:                              command = "ED-ONTPOTS:" + amsName + @":ONTPOTS-1-1-" + pon + "-" + card + "-" + port + "::::CUSTINFO=" + customerInformation + @":;";
 366:                              // ED-ONTPOTS:ESH-1-1:ONTPOTS-1-1-1-1-1-2-1::::CUSTINFO=23632222:;\n";
 367:                          }
 368:                          else
 369:                          {
 370:                              command = "ED-ONTPOTS:" + amsName + @":ONTPOTS-1-1-" + pon + "-" + card + "-" + port + "::::CUSTINFO=NULL:;";
 371:                              // ED-ONTPOTS:ESH-1-1:ONTPOTS-1-1-1-1-1-2-1::::CUSTINFO=NULL:;\n";
 372:                          }
 373:   
 374:                          list.Add(command);
 375:                      }
 376:                  }
 377:              }
 378:   
 379:              return list;
 380:          }
 381:   
 382:          ////////////////////////////////////////////////////////////////////////////
 383:   
 384:          /// <summary>
 385:          ///
 386:          /// </summary>
 387:          private static string FormatAmsCommand(AmsOpcode amsOpcode, string amsName)
 388:          {
 389:              string command;
 390:   
 391:              if (amsOpcode == AmsOpcode.RtrvAlmPon)
 392:              {
 393:                  command = "RTRV-ALM-PON:" + amsName + ":ALL:::MN,,NSA;";
 394:   
 395:              }
 396:              else if (amsOpcode == AmsOpcode.RtrvHdr)
 397:              {
 398:                  command = "RTRV-HDR:" + amsName + ":;";
 399:              }
 400:              else command = null;
 401:   
 402:              return command;
 403:          }
 404:   
 405:          ////////////////////////////////////////////////////////////////////////////
 406:   
 407:          /// <summary>
 408:          ///
 409:          /// </summary>
 410:          private static void AmsNameAndCardPortOntSquenceFromOntServiceHsiPosition(string ontPosition, out string amsName, out string cardPortOntCardPortServiceSequence)
 411:          {
 412:              Match match;
 413:   
 414:              // SUR-1-1-1-1-1-1-1-1;
 415:              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})");
 416:   
 417:              amsName = match.Groups[1].Value;
 418:              cardPortOntCardPortServiceSequence = match.Groups[2].Value;
 419:          }
 420:   
 421:          ////////////////////////////////////////////////////////////////////////////
 422:   
 423:          /// <summary>
 424:          ///
 425:          /// </summary>
 426:          private static void AmsNameAndCardPortOntSquenceFromOntPosition(string ontPosition, out string amsName, out string pon)
 427:          {
 428:              Match match;
 429:   
 430:              if (!string.IsNullOrEmpty(ontPosition))
 431:              {
 432:                  // SBN-ARD-Lag1-1-1-1;
 433:                  match = Regex.Match(ontPosition, @"^([\w\d\-]+)\-(\d{1,2}\-\d{1,2}\-\d{1,2})$");
 434:   
 435:                  if (match.Success)
 436:                  {
 437:                      amsName = match.Groups[1].Value;
 438:                      pon = match.Groups[2].Value;
 439:                  }
 440:                  else
 441:                  {
 442:                      amsName = string.Empty;
 443:                      pon = string.Empty;
 444:                  }
 445:              }
 446:              else
 447:              {
 448:                  amsName = string.Empty;
 449:                  pon = string.Empty;
 450:              }
 451:          }
 452:   
 453:          ////////////////////////////////////////////////////////////////////////////
 454:   
 455:          /// <summary>
 456:          /// Extract OLT Id, Card, Port, and ONT from ONT Position
 457:          /// </summary>
 458:          [Obsolete]
 459:          public static void OltIdCardPortOntFromOntPosition(string ontPosition, out int oltId, out int card, out int port, out int ont)
 460:          {
 461:              string amsName;
 462:              Match match;
 463:   
 464:              if (!string.IsNullOrEmpty(ontPosition))
 465:              {
 466:                  // SBN-ARD-Lag1-1-1-1;
 467:                  match = Regex.Match(ontPosition, @"^([\w\d\-]+)\-(\d{1,2})\-(\d{1,2})\-(\d{1,2})$");
 468:   
 469:                  if (match.Success)
 470:                  {
 471:                      amsName = match.Groups[1].Value;
 472:                      card = int.Parse(match.Groups[2].Value);
 473:                      port = int.Parse(match.Groups[3].Value);
 474:                      ont = int.Parse(match.Groups[4].Value);
 475:   
 476:                      oltId = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.AmsName == amsName select o.Id).FirstOrDefault();
 477:                  }
 478:                  else
 479:                  {
 480:                      amsName = string.Empty;
 481:                      card = port = ont = 0;
 482:   
 483:                      oltId = 0;
 484:                  }
 485:              }
 486:              else
 487:              {
 488:                  amsName = string.Empty;
 489:                  card = port = ont = 0;
 490:   
 491:                  oltId = 0;
 492:              }
 493:          }
 494:   
 495:          ////////////////////////////////////////////////////////////////////////////
 496:   
 497:          /// <summary>
 498:          ///
 499:          /// </summary>
 500:          public static string OntPositionFromAmsNameAndCardPortOntSquence(string amsName, string cardPortOnt)
 501:          {
 502:              string ontPosition;
 503:   
 504:              ontPosition = amsName + "-" + cardPortOnt;
 505:   
 506:              return ontPosition;
 507:          }
 508:   
 509:          ////////////////////////////////////////////////////////////////////////////
 510:   
 511:          /// <summary>
 512:          ///
 513:          /// </summary>
 514:          public static List<string> AmsCommandsToUpdateOntDescriptionWithItsAccessNameList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 515:          {
 516:              string accessName, ontId, ontDescription1;
 517:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 518:              List<string> list;
 519:   
 520:              var ontIdToOntAccessNameDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntAccessNameDictionary;
 521:   
 522:              var ontIdToDescription1ForNonNullAccessDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdToDescription1ForNonNullAccessDictionary;
 523:   
 524:              var ontIdToDescription1ForNullAccessDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdToDescription1ForNullAccessDictionary;
 525:   
 526:              //var ontIdWithNullAccessHashtable = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdWithNullAccessHashtable;
 527:   
 528:              var ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 529:   
 530:              list = new List<string>();
 531:   
 532:              // insert descriptions for missing entries
 533:              if (ontIdToDescription1ForNonNullAccessDictionary.Count > 0)
 534:              {
 535:                  foreach (KeyValuePair<string, string> kvp in ontIdToDescription1ForNonNullAccessDictionary) //Ia.Ngn.Cl.Model.Ont ont in ontList)
 536:                  {
 537:                      ontId = kvp.Key;
 538:                      ontDescription1 = kvp.Value;
 539:   
 540:                      if (ontIdToOntAccessNameDictionary.ContainsKey(ontId))
 541:                      {
 542:                          accessName = ontIdToOntAccessNameDictionary[ontId];
 543:   
 544:                          if (ontDescription1 != accessName)
 545:                          {
 546:                              nddOnt = ontIdToOntDictionary[ontId];
 547:   
 548:                              if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 549:                              {
 550:                                  list.Add(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntCommand(AmsOpcode.EdOntDesc1, nddOnt));
 551:                              }
 552:                          }
 553:                          else
 554:                          {
 555:                          }
 556:                      }
 557:                  }
 558:              }
 559:   
 560:              // delete descriptions ONTs with missing access info
 561:              if (ontIdToDescription1ForNullAccessDictionary.Count > 0)
 562:              {
 563:                  foreach (KeyValuePair<string, string> kvp in ontIdToDescription1ForNullAccessDictionary)
 564:                  {
 565:                      ontId = kvp.Key;
 566:                      ontDescription1 = kvp.Value;
 567:   
 568:                      if (!string.IsNullOrEmpty(ontDescription1))
 569:                      {
 570:                          if (ontIdToOntDictionary.ContainsKey(ontId))
 571:                          {
 572:                              nddOnt = ontIdToOntDictionary[ontId];
 573:   
 574:                              if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 575:                              {
 576:                                  list.Add(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntCommand(AmsOpcode.EdOntDesc1Annul, nddOnt));
 577:                              }
 578:                          }
 579:                      }
 580:                  }
 581:              }
 582:   
 583:              return list.ToList();
 584:          }
 585:   
 586:          ////////////////////////////////////////////////////////////////////////////
 587:   
 588:          /// <summary>
 589:          ///
 590:          /// </summary>
 591:          public static List<string> AmsCommandsToUpdateCustInfoWithServiceNumberInOntOntPotsList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 592:          {
 593:              List<string> list;
 594:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 595:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 596:   
 597:              var ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 598:   
 599:              //var ontIdWithNullAccessHashtable = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdWithNullAccessHashtable;
 600:   
 601:              var ontOntPotsServiceList = Ia.Ngn.Cl.Model.Data.Nokia.Ams.OntOntPotsServiceList();
 602:   
 603:              list = new List<string>(ontOntPotsServiceList.Count);
 604:   
 605:              // insert descriptions for missing entries
 606:              if (ontOntPotsServiceList.Count > 0)
 607:              {
 608:                  foreach (var ontOntPotsService in ontOntPotsServiceList)
 609:                  {
 610:                      if (ontIdToOntDictionary.ContainsKey(ontOntPotsService.OntId))
 611:                      {
 612:                          nddOnt = ontIdToOntDictionary[ontOntPotsService.OntId];
 613:   
 614:                          if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 615:                          {
 616:                              familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ontOntPotsService.OntFamilyTypeId;
 617:   
 618:                              list.AddRange(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntOntPotsCommandList(AmsOpcode.EdOntPotsCustinfo, nddOnt, familyType, ontOntPotsService.Termination, ontOntPotsService.Service));
 619:                          }
 620:                      }
 621:                  }
 622:              }
 623:   
 624:              /*
 625:              // delete descriptions non existant entries
 626:              if (ontIdWithNullAccessHashtable.Count > 0)
 627:              {
 628:                  foreach (string _ontId in ontIdWithNullAccessHashtable.Keys)
 629:                  {
 630:                      if (ontIdToOntDictionary.ContainsKey(_ontId))
 631:                      {
 632:                          nddOnt = ontIdToOntDictionary[_ontId];
 633:  
 634:                          if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
 635:                          {
 636:                              list.Add(Ia.Ngn.Cl.Model.Business.Nokia.Ams.FormatAmsOntCommand(AmsOpcode.EdOntDesc1Annul, nddOnt));
 637:                          }
 638:                      }
 639:                  }
 640:              }
 641:              */
 642:   
 643:              return list;
 644:          }
 645:   
 646:          ////////////////////////////////////////////////////////////////////////////
 647:   
 648:          /// <summary>
 649:          ///
 650:          /// </summary>
 651:          public static List<string> AmsCommandsToPreprovisionAllOntsAsDefinedInNddDocumentWithinOltList(int oltId, bool edServiceVoipIsOos, out int count)
 652:          {
 653:              List<string> l, list;
 654:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 655:   
 656:              count = 0;
 657:              list = null;
 658:   
 659:              nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId select o).ToList();
 660:   
 661:              if (nddOntList != null && nddOntList.Count > 0)
 662:              {
 663:                  list = new List<string>(nddOntList.Count);
 664:   
 665:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 666:                  {
 667:                      l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOlt(nddOnt, edServiceVoipIsOos);
 668:   
 669:                      list.AddRange(l);
 670:                      count++;
 671:                  }
 672:              }
 673:              else
 674:              {
 675:              }
 676:   
 677:              return list;
 678:          }
 679:   
 680:          ////////////////////////////////////////////////////////////////////////////
 681:   
 682:          /// <summary>
 683:          ///
 684:          /// </summary>
 685:          public static List<string> AmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, bool includeDisplayCommand, bool edServiceVoipIsOos, out int count)
 686:          {
 687:              List<string> l, list;
 688:              List<string> ontIdList;
 689:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
 690:   
 691:              count = 0;
 692:              list = null;
 693:   
 694:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 695:              {
 696:                  nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 697:   
 698:                  ontIdList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.IdList(olt.Id); //.ReadListByOltId(olt.Id);
 699:   
 700:                  if (nddOntList != null && nddOntList.Count > 0)
 701:                  {
 702:                      list = new List<string>(nddOntList.Count);
 703:   
 704:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt in nddOntList)
 705:                      {
 706:                          if (!ontIdList.Contains(nddOnt.Id))
 707:                          {
 708:                              l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.CommandsToPreprovisionOntWithinOlt(nddOnt, edServiceVoipIsOos);
 709:                              list.AddRange(l);
 710:   
 711:                              if (includeDisplayCommand)
 712:                              {
 713:                                  l = Ia.Ngn.Cl.Model.Business.Nokia.Ams.AmsCommandsToRetrieveOntVoipPotsForSingleOntsWithDefinedFamilyTypeList(nddOnt.Access.Name);
 714:                                  list.AddRange(l);
 715:                              }
 716:   
 717:                              count++;
 718:                          }
 719:                      }
 720:                  }
 721:              }
 722:   
 723:              return list;
 724:          }
 725:   
 726:          ////////////////////////////////////////////////////////////////////////////
 727:   
 728:          /// <summary>
 729:          ///
 730:          /// </summary>
 731:          public static List<string> AmsCommandsToRetrieveOntVoipPotsForASingleOntWithDefinedFamilyTypeAndForItIfThisSingleOntDefinedInNddDocumentList(string accessName)
 732:          {
 733:              Random r;
 734:              List<string> l1, l2, list;
 735:   
 736:              r = new Random();
 737:   
 738:              l1 = AmsCommandToRetrieveSingleOntDefinedInNddDocumentList(accessName);
 739:   
 740:              l2 = AmsCommandsToRetrieveOntVoipPotsForSingleOntsWithDefinedFamilyTypeList(accessName);
 741:   
 742:              list = new List<string>(l1.Count + l2.Count);
 743:   
 744:              foreach (var item in l1) list.Add(item);
 745:              foreach (var item in l2) list.Add(item);
 746:   
 747:              return list.Distinct().ToList();
 748:          }
 749:   
 750:          ////////////////////////////////////////////////////////////////////////////
 751:   
 752:          /// <summary>
 753:          ///
 754:          /// </summary>
 755:          public static List<string> AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyTypeAndForOtherOntsDefinedInNddDocumentList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 756:          {
 757:              List<string> l1, l2, list;
 758:   
 759:              l1 = AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyTypeList(olt);
 760:   
 761:              l2 = AmsCommandsToRetrieveOntsDefinedInNddDocumentList(olt);
 762:   
 763:              list = new List<string>(l1.Count + l2.Count);
 764:   
 765:              foreach (var item in l1) list.Add(item);
 766:              foreach (var item in l2) list.Add(item);
 767:   
 768:              return list.Distinct().Shuffle().ToList();
 769:          }
 770:   
 771:          ////////////////////////////////////////////////////////////////////////////
 772:   
 773:          /// <summary>
 774:          ///
 775:          /// </summary>
 776:          public static List<string> AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyType_AmsCommandsToRetrieveOntsDefinedInNddDocument_AmsCommandsToUpdateAndDisplayOntDescriptionWithItsAccessName_AmsCommandsToUpdateOntOntPotsCustomerWithItsConnectedServiceNumberList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 777:          {
 778:              HashSet<string> hashSet1, hashSet2, hashSet3, hashSet4, hashSet;
 779:   
 780:              hashSet1 = new HashSet<string>(AmsCommandsToUpdateOntDescriptionWithItsAccessNameList(olt));
 781:   
 782:              hashSet2 = new HashSet<string>(AmsCommandsToUpdateCustInfoWithServiceNumberInOntOntPotsList(olt));
 783:   
 784:              hashSet3 = new HashSet<string>(AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyTypeList(olt));
 785:   
 786:              hashSet4 = new HashSet<string>(AmsCommandsToRetrieveOntsDefinedInNddDocumentList(olt));
 787:   
 788:              hashSet = new HashSet<string>(hashSet1);
 789:              hashSet.UnionWith(hashSet2);
 790:              hashSet.UnionWith(hashSet3);
 791:              hashSet.UnionWith(hashSet4);
 792:   
 793:              return hashSet.ToList(); //.Shuffle().ToList();
 794:          }
 795:   
 796:          ////////////////////////////////////////////////////////////////////////////
 797:   
 798:          /// <summary>
 799:          ///
 800:          /// </summary>
 801:          private static List<string> AmsCommandToRetrieveSingleOntDefinedInNddDocumentList(string accessName)
 802:          {
 803:              List<string> list;
 804:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 805:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 806:   
 807:              list = new List<string>(5); // 5 is max number of commands from this function
 808:   
 809:              if (!string.IsNullOrEmpty(accessName))
 810:              {
 811:                  //nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
 812:                  nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary.ContainsKey(accessName) ? Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary[accessName] : null;
 813:   
 814:                  if (nddOnt != null)
 815:                  {
 816:                      familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 817:   
 818:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
 819:                  }
 820:              }
 821:   
 822:              return list;
 823:          }
 824:   
 825:          ////////////////////////////////////////////////////////////////////////////
 826:   
 827:          /// <summary>
 828:          ///
 829:          /// </summary>
 830:          private static List<string> AmsCommandsToRetrieveOntsDefinedInNddDocumentList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 831:          {
 832:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 833:              List<string> list;
 834:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList;
 835:   
 836:              ontList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id select o).ToList();
 837:   
 838:              familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
 839:   
 840:              list = new List<string>(ontList.Count);
 841:   
 842:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in ontList)
 843:              {
 844:                  list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, ont.Position));
 845:              }
 846:   
 847:              return list;
 848:          }
 849:   
 850:          ////////////////////////////////////////////////////////////////////////////
 851:   
 852:          /// <summary>
 853:          ///
 854:          /// </summary>
 855:          private static List<string> AmsCommandsToRetrieveOntVoipPotsForSingleOntsWithDefinedFamilyTypeList(string accessName)
 856:          {
 857:              List<string> list;
 858:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 859:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 860:              Ia.Ngn.Cl.Model.Ont ont;
 861:   
 862:              list = new List<string>(5); // 5 is max number of commands from this function
 863:   
 864:              if (!string.IsNullOrEmpty(accessName))
 865:              {
 866:                  //nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
 867:                  nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary.ContainsKey(accessName) ? Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessNameToOntDictionary[accessName] : null;
 868:   
 869:                  if (nddOnt != null)
 870:                  {
 871:                      ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 872:   
 873:                      if (ont != null)
 874:                      {
 875:                          familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 876:   
 877:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
 878:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceVoip, familyType, nddOnt.Position));
 879:                          list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOntPots, familyType, nddOnt.Position));
 880:                      }
 881:                  }
 882:              }
 883:   
 884:              return list;
 885:          }
 886:   
 887:          ////////////////////////////////////////////////////////////////////////////
 888:   
 889:          /// <summary>
 890:          ///
 891:          /// </summary>
 892:          private static List<string> AmsCommandsToRetrieveOntVoipPotsForOntsWithDefinedFamilyTypeList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 893:          {
 894:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 895:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 896:              List<string> list;
 897:              Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontIdToOntDictionary;
 898:              List<Ia.Ngn.Cl.Model.Ont> ontList;
 899:   
 900:              ontList = Ia.Ngn.Cl.Model.Data.Nokia.Ont.NonNullAccessList(olt.Id);
 901:   
 902:              ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
 903:   
 904:              list = new List<string>(ontList.Count);
 905:   
 906:              foreach (Ia.Ngn.Cl.Model.Ont ont in ontList)
 907:              {
 908:                  familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
 909:   
 910:                  if (ontIdToOntDictionary.ContainsKey(ont.Id))
 911:                  {
 912:                      nddOnt = ontIdToOntDictionary[ont.Id];
 913:   
 914:                      //if (ont.Access != null) access is already non null
 915:                      //{
 916:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOnt, familyType, nddOnt.Position));
 917:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvServiceVoip, familyType, nddOnt.Position));
 918:                      list.AddRange(FormatAmsRtrvCommand(AmsOpcode.RtrvOntPots, familyType, nddOnt.Position));
 919:                      //}
 920:                  }
 921:              }
 922:   
 923:              return list;
 924:          }
 925:   
 926:          ////////////////////////////////////////////////////////////////////////////
 927:   
 928:          /// <summary>
 929:          ///
 930:          /// </summary>
 931:          public static ArrayList AmsCommandsToRetrieveNewOntAlarmsForOltArrayList()
 932:          {
 933:              ArrayList amsCommandArrayList;
 934:   
 935:              amsCommandArrayList = new ArrayList(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
 936:   
 937:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
 938:              {
 939:                  amsCommandArrayList.Add(FormatAmsCommand(AmsOpcode.RtrvAlmPon, olt.AmsName));
 940:              }
 941:   
 942:              return amsCommandArrayList;
 943:          }
 944:   
 945:          ////////////////////////////////////////////////////////////////////////////
 946:   
 947:          /// <summary>
 948:          ///
 949:          /// </summary>
 950:          public static ArrayList AmsCommandsToUpdateOntServiceDescriptionWithItsIspNameArrayList()
 951:          {
 952:              ArrayList amsCommandArrayList;
 953:   
 954:              amsCommandArrayList = new ArrayList(100);
 955:   
 956:              return amsCommandArrayList;
 957:          }
 958:   
 959:          ////////////////////////////////////////////////////////////////////////////
 960:   
 961:          /// <summary>
 962:          /// 
 963:          /// </summary>
 964:          public static int PossibleNumberOfTdForOntFamilyType(int familyTypeId)
 965:          {
 966:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
 967:   
 968:              familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyTypeId;
 969:   
 970:              return PossibleNumberOfTdForOntFamilyType(familyType);
 971:          }
 972:   
 973:          ////////////////////////////////////////////////////////////////////////////
 974:   
 975:          /// <summary>
 976:          /// 
 977:          /// </summary>
 978:          public static int PossibleNumberOfTdForOntFamilyType(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
 979:          {
 980:              int number;
 981:   
 982:              switch (familyType)
 983:              {
 984:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu: number = 4; break;
 985:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho: number = 8; break;
 986:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu: number = 24; break;
 987:                  default: number = 0; break;
 988:              }
 989:   
 990:              return number;
 991:          }
 992:   
 993:          ////////////////////////////////////////////////////////////////////////////
 994:   
 995:          /// <summary>
 996:          /// Get the number of card-port for a parameter of familyType and td
 997:          /// </summary>
 998:          public static void ReturnOntPotsCardAndPortFromFamilyTypeAndTd(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, int td, out int card, out int port)
 999:          {
1000:              card = port = 0;
1001:   
1002:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
1003:              {
1004:                  if (td >= 1 && td <= 4)
1005:                  {
1006:                      card = 2; port = td;
1007:                  }
1008:              }
1009:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1010:              {
1011:                  if (td >= 1 && td <= 8)
1012:                  {
1013:                      card = 2; port = td;
1014:                  }
1015:              }
1016:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1017:              {
1018:                  if (td >= 1 && td <= 24)
1019:                  {
1020:                      if (td >= 1 && td <= 4 || td >= 13 && td <= 16)
1021:                      {
1022:                          card = 1;
1023:                          if (td <= 4) port = td;
1024:                          else port = td - 8;
1025:                      }
1026:                      else if (td >= 5 && td <= 8 || td >= 17 && td <= 20)
1027:                      {
1028:                          card = 2;
1029:                          if (td <= 8) port = td - 4;
1030:                          else port = td - 12;
1031:                      }
1032:                      else if (td >= 9 && td <= 12 || td >= 21 && td <= 24)
1033:                      {
1034:                          card = 3;
1035:                          if (td <= 12) port = td - 8;
1036:                          else port = td - 16;
1037:                      }
1038:                  }
1039:              }
1040:          }
1041:   
1042:          ////////////////////////////////////////////////////////////////////////////
1043:   
1044:          /// <summary>
1045:          /// 
1046:          /// </summary>
1047:          public static ArrayList PossiblePotsCardPortConfigurationForOntFamilyTypeArrayList(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1048:          {
1049:              ArrayList al;
1050:   
1051:              al = new ArrayList(100);
1052:   
1053:              // 1-1
1054:   
1055:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
1056:              {
1057:                  al.Add("2-1");
1058:                  al.Add("2-2");
1059:                  al.Add("2-3");
1060:                  al.Add("2-4");
1061:              }
1062:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1063:              {
1064:                  al.Add("2-1");
1065:                  al.Add("2-2");
1066:                  al.Add("2-3");
1067:                  al.Add("2-4");
1068:                  al.Add("2-5");
1069:                  al.Add("2-6");
1070:                  al.Add("2-7");
1071:                  al.Add("2-8");
1072:              }
1073:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1074:              {
1075:                  al.Add("1-1");
1076:                  al.Add("1-2");
1077:                  al.Add("1-3");
1078:                  al.Add("1-4");
1079:                  al.Add("1-5");
1080:                  al.Add("1-6");
1081:                  al.Add("1-7");
1082:                  al.Add("1-8");
1083:   
1084:                  al.Add("2-1");
1085:                  al.Add("2-2");
1086:                  al.Add("2-3");
1087:                  al.Add("2-4");
1088:                  al.Add("2-5");
1089:                  al.Add("2-6");
1090:                  al.Add("2-7");
1091:                  al.Add("2-8");
1092:   
1093:                  al.Add("3-1");
1094:                  al.Add("3-2");
1095:                  al.Add("3-3");
1096:                  al.Add("3-4");
1097:                  al.Add("3-5");
1098:                  al.Add("3-6");
1099:                  al.Add("3-7");
1100:                  al.Add("3-8");
1101:              }
1102:   
1103:              return al;
1104:          }
1105:   
1106:          ////////////////////////////////////////////////////////////////////////////
1107:   
1108:          /// <summary>
1109:          /// 
1110:          /// </summary>
1111:          public static List<string> PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1112:          {
1113:              List<string> list;
1114:   
1115:              list = new List<string>(100);
1116:   
1117:              // 1-1-1
1118:   
1119:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu || familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1120:              {
1121:                  list.Add("1-1-1");
1122:                  list.Add("1-2-1");
1123:              }
1124:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1125:              {
1126:                  // ???
1127:                  list.Add("1-1-1");
1128:                  list.Add("1-2-1");
1129:                  list.Add("1-3-1");
1130:                  list.Add("1-4-1");
1131:                  list.Add("1-5-1");
1132:                  list.Add("1-6-1");
1133:                  list.Add("1-7-1");
1134:                  list.Add("1-8-1");
1135:                  list.Add("1-9-1");
1136:                  list.Add("1-10-1");
1137:                  list.Add("1-11-1");
1138:                  list.Add("1-12-1");
1139:              }
1140:   
1141:              return list;
1142:          }
1143:   
1144:          ////////////////////////////////////////////////////////////////////////////
1145:   
1146:          /// <summary>
1147:          /// 
1148:          /// </summary>
1149:          public static int PossibleNumberOfHsiCardPortServiceConfigurationForOntFamilyType(int familyType)
1150:          {
1151:              List<string> list;
1152:   
1153:              list = PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList((Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyType);
1154:   
1155:              return list.Count;
1156:          }
1157:   
1158:          ////////////////////////////////////////////////////////////////////////////
1159:   
1160:          /// <summary>
1161:          /// 
1162:          /// </summary>
1163:          public static int PositionOfHsiServiceForCardAndPortAndOntFamilyType(int card, int port, Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType)
1164:          {
1165:              int position;
1166:   
1167:              if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu || familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
1168:              {
1169:                  position = port;
1170:              }
1171:              else if (familyType == Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
1172:              {
1173:                  position = (card - 1) * 4 + port;
1174:              }
1175:              else position = 0;
1176:   
1177:              return position;
1178:          }
1179:   
1180:          ////////////////////////////////////////////////////////////////////////////
1181:   
1182:          /// <summary>
1183:          /// Return the ONT family type from the software version
1184:          /// </summary>
1185:          private static Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType FamilyType(string activeSoftware, string plannedSoftware)
1186:          {
1187:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
1188:   
1189:              if (activeSoftware != null)
1190:              {
1191:                  if (activeSoftware == plannedSoftware || plannedSoftware == "auto" || plannedSoftware == "AUTO")
1192:                  {
1193:                      if (activeSoftware.StartsWith("3FE508")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu;
1194:                      else if (activeSoftware.StartsWith("3FE511")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho;
1195:                      else if (activeSoftware.StartsWith("3FE514")) familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu;
1196:                      else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1197:                  }
1198:                  else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1199:              }
1200:              else familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined;
1201:   
1202:              return familyType;
1203:          }
1204:   
1205:          ////////////////////////////////////////////////////////////////////////////
1206:   
1207:          /// <summary>
1208:          ///
1209:          /// </summary>
1210:          public static bool UpdateDatabaseWithAmsCommandOutput(string rowData, out Ia.Cl.Model.Result result)
1211:          {
1212:              bool b;
1213:              string accessId, ontId, ontPosition;
1214:              string line, amsName, cardPortOnt;
1215:              DateTime eventTime;
1216:              Match match;
1217:              MatchCollection matchCollection;
1218:              Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState state;
1219:   
1220:              //ponNameToPonIdHashtable = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonNameToPonIdHashtable;
1221:   
1222:              b = false;
1223:              result = new Ia.Cl.Model.Result();
1224:              //result.Content = rowData;
1225:   
1226:              // below: remove all '\' characters from rowData and reset NULL comments to ""
1227:              rowData = rowData.Replace(@"\", "");
1228:              rowData = rowData.Replace(@"NULL", "");
1229:   
1230:              if (rowData.Contains("RTRV-ONT:"))
1231:              {
1232:                  #region RTRV-ONT
1233:                  Ia.Ngn.Cl.Model.Ont ont, dataOnt;
1234:   
1235:                  /*
1236:         SUR-1-1 08-07-10 09:35:07
1237:      M  0 COMPLD
1238:         / * 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 * /
1239:         / * -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- * /
1240:         / * 1-1-8&ONT-1-1-1-1-9 * /
1241:         "ONT-1-1-1-1-1::BTRYBKUP=NO,BERINT=8000,DESC1="SLA.1.1",
1242:         DESC2="all is well",PROVVERSION="*",SERNUM=ALCLA0A1A5F8,
1243:         SUBSLOCID="WILDCARD",SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,
1244:         SCHEDPROFID=1,SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,
1245:         POWERSHEDPROFNM="NULL",ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,
1246:         SWVERACT=3FE50853AFMA07,SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,
1247:         EQUIPID=BVM3G00CRAO420EB    ,NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:
1248:         IS-NR"
1249:         "ONT-1-1-1-1-10::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1250:         PROVVERSION="*",SERNUM=ALCLA0A1A479,SUBSLOCID="WILDCARD",
1251:         SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1252:         SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1253:         ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1254:         SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1255:         NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1256:         "ONT-1-1-1-1-2::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1257:         PROVVERSION="*",SERNUM=ALCLA0A261BB,SUBSLOCID="WILDCARD",
1258:         SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1259:         SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1260:         ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1261:         SWVERPSV=3FE50853AAAA22,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1262:         NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1263:                   */
1264:   
1265:                  // below: information from the definition of "RTRV-ONT" in "AMS TL1 Commands Reference"
1266:   
1267:                  /*
1268:  IP 0
1269:  <
1270:   
1271:     SUR-1-1 08-07-10 09:35:07
1272:  M  0 COMPLD
1273:     / * 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 * /
1274:     / * -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- * /
1275:     / * 1-1-8&ONT-1-1-1-1-9 * /
1276:     "ONT-1-1-1-1-1::BTRYBKUP=NO,BERINT=8000,DESC1="SLA.1.1",
1277:     DESC2="all is well",PROVVERSION="*",SERNUM=ALCLA0A1A5F8,
1278:     SUBSLOCID="WILDCARD",SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,
1279:     SCHEDPROFID=1,SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,
1280:     POWERSHEDPROFNM="NULL",ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,
1281:     SWVERACT=3FE50853AFMA07,SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,
1282:     EQUIPID=BVM3G00CRAO420EB    ,NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:
1283:     IS-NR"
1284:     "ONT-1-1-1-1-10::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1285:     PROVVERSION="*",SERNUM=ALCLA0A1A479,SUBSLOCID="WILDCARD",
1286:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1287:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1288:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1289:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1290:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1291:     "ONT-1-1-1-1-2::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1292:     PROVVERSION="*",SERNUM=ALCLA0A261BB,SUBSLOCID="WILDCARD",
1293:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1294:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1295:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1296:     SWVERPSV=3FE50853AAAA22,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1297:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1298:   
1299:     / * More Output Follows * /
1300:  >
1301:   
1302:     SUR-1-1 08-07-10 09:35:07
1303:  M  0 COMPLD
1304:     / * 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 * /
1305:     "ONT-1-1-1-1-3::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1306:     PROVVERSION="*",SERNUM=ALCLA0A1C9BC,SUBSLOCID="WILDCARD",
1307:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1308:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1309:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1310:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1311:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1312:     "ONT-1-1-1-1-4::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1313:     PROVVERSION="*",SERNUM=ALCLA0A1A47A,SUBSLOCID="WILDCARD",
1314:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1315:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1316:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1317:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1318:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1319:     "ONT-1-1-1-1-5::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1320:     PROVVERSION="*",SERNUM=ALCLA0A1AE44,SUBSLOCID="WILDCARD",
1321:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1322:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1323:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1324:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1325:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1326:   
1327:     / * More Output Follows * /
1328:  >
1329:   
1330:     SUR-1-1 08-07-10 09:35:08
1331:  M  0 COMPLD
1332:     / * 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 * /
1333:     "ONT-1-1-1-1-6::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1334:     PROVVERSION="*",SERNUM=ALCLA0A1BE26,SUBSLOCID="WILDCARD",
1335:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1336:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1337:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1338:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1339:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1340:     "ONT-1-1-1-1-7::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1341:     PROVVERSION="*",SERNUM=ALCLA0A1C94B,SUBSLOCID="WILDCARD",
1342:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1343:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1344:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAB01,SWVERACT=3FE50853AFMA07,
1345:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1346:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1347:     "ONT-1-1-1-1-8::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1348:     PROVVERSION="*",SERNUM=ALCLA0A1A484,SUBSLOCID="WILDCARD",
1349:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1350:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1351:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1352:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1353:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1354:   
1355:     / * More Output Follows * /
1356:  >
1357:   
1358:     SUR-1-1 08-07-10 09:35:08
1359:  M  0 COMPLD
1360:     / * 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 * /
1361:     "ONT-1-1-1-1-9::BTRYBKUP=NO,BERINT=8000,DESC1="NULL",DESC2="NULL",
1362:     PROVVERSION="*",SERNUM=ALCLA0A1A43E,SUBSLOCID="WILDCARD",
1363:     SWVERPLND="3FE50853AFMA07",FECUP=DISABLE,SCHEDPROFID=1,
1364:     SCHEDPROFNM="defSubSchedProf",POWERSHEDPROFID=0,POWERSHEDPROFNM="NULL",
1365:     ONTENABLE=AUTO,EQPTVERNUM=3FE50683ADAA01,SWVERACT=3FE50853AFMA07,
1366:     SWVERPSV=3FE50853AFKA03,VENDORID=ALCL,EQUIPID=BVM3G00CRAO420EB    ,
1367:     NUMSLOTS=2,NUMTCONT=22,NUMTRFSCH=22,NUMPQ=22:IS-NR"
1368:  ;
1369:                  */
1370:   
1371:                  // below: read OntPosition
1372:                  match = Regex.Match(rowData, @"RTRV-ONT:([\w\d\-]+)", RegexOptions.Singleline);
1373:   
1374:                  amsName = match.Groups[1].Value;
1375:   
1376:                  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);
1377:   
1378:                  if (match.Success)
1379:                  {
1380:                      cardPortOnt = match.Groups[1].Value;
1381:   
1382:                      line = match.Groups[2].Value;
1383:   
1384:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1385:   
1386:                      if (!string.IsNullOrEmpty(ontId))
1387:                      {
1388:                          dataOnt = new Ia.Ngn.Cl.Model.Ont();
1389:   
1390:                          dataOnt.Id = ontId;
1391:                          dataOnt.BatteryBackupAvailable = (Ia.Cl.Model.Default.Match(line, @"BTRYBKUP=(\w+)") == "YES") ? true : false;
1392:                          dataOnt.Description1 = Ia.Cl.Model.Default.Match(line, @"DESC1=""([^""]{1,64})""");
1393:                          dataOnt.Description2 = Ia.Cl.Model.Default.Match(line, @"DESC2=""([^""]{1,64})""");
1394:                          dataOnt.Serial = Ia.Cl.Model.Default.Match(line, @"SERNUM=(\w{12})");
1395:                          dataOnt.PlannedSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERPLND=""(auto|AUTO|\w{14})""");
1396:                          dataOnt.ActiveSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERACT=(\w{14})");
1397:                          dataOnt.PassiveSoftware = Ia.Cl.Model.Default.Match(line, @"SWVERPSV=(\w{14})");
1398:                          dataOnt.FamilyTypeId = (int)FamilyType(dataOnt.ActiveSoftware, dataOnt.PlannedSoftware);
1399:                          dataOnt.VendorId = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.VendorIdFromName(Ia.Cl.Model.Default.Match(line, @"VENDORID=(\w+)"));
1400:                          dataOnt.EquipmentId = Ia.Cl.Model.Default.Match(line, @"EQUIPID=(\w{16})");
1401:   
1402:                          switch (match.Groups[3].Value)
1403:                          {
1404:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1405:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1406:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1407:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1408:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1409:                          }
1410:   
1411:                          dataOnt.StateId = (int)state;
1412:   
1413:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1414:                          {
1415:                              accessId = Ia.Ngn.Cl.Model.Business.Access.AccessId(ontId);
1416:   
1417:                              if (accessId != null) dataOnt.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
1418:   
1419:                              ont = (from o in db.Onts where o.Id == dataOnt.Id select o).SingleOrDefault();
1420:   
1421:                              if (ont == null)
1422:                              {
1423:                                  dataOnt.Created = dataOnt.Updated = DateTime.UtcNow.AddHours(3);
1424:   
1425:                                  db.Onts.Add(dataOnt);
1426:                              }
1427:                              else
1428:                              {
1429:                                  // below: copy values from dataOnt to ont
1430:   
1431:                                  if (ont.Update(dataOnt))
1432:                                  {
1433:                                      db.Onts.Attach(ont);
1434:                                      db.Entry(ont).State = System.Data.Entity.EntityState.Modified;
1435:                                  }
1436:                              }
1437:   
1438:                              db.SaveChanges();
1439:   
1440:                              b = true;
1441:                          }
1442:                      }
1443:                      else
1444:                      {
1445:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1446:                      }
1447:                  }
1448:                  else
1449:                  {
1450:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1451:                  }
1452:                  #endregion
1453:              }
1454:              else if (rowData.Contains("ED-ONT:"))
1455:              {
1456:                  #region ED-ONT
1457:                  Ia.Ngn.Cl.Model.Ont ont, dataOnt;
1458:   
1459:                  /*
1460:     SUR-5-2 14-11-23 05:22:08
1461:  M  0 COMPLD
1462:     / * ED-ONT:SUR-5-2:ONT-1-1-1-2-6::::DESC1=ZAH.2.6: * /
1463:   
1464:  M  0 COMPLD
1465:     / * ED-ONT:QRW-SLB-LAG2:ONT-1-1-3-2-10:98499:::DESC1=QRW.33.10: * /
1466:  ;
1467:                  */
1468:   
1469:                  // below: read OntPosition
1470:                  match = Regex.Match(rowData, @"ED-ONT:([\w\d\-]+)", RegexOptions.Singleline);
1471:   
1472:                  amsName = match.Groups[1].Value;
1473:   
1474:                  match = Regex.Match(rowData, @"ONT-1-1-(\d{1,2}-\d{1,2}-\d{1,2}):\d{0,6}:::(.+?):", RegexOptions.Singleline);
1475:   
1476:                  if (match.Success)
1477:                  {
1478:                      cardPortOnt = match.Groups[1].Value;
1479:   
1480:                      line = match.Groups[2].Value;
1481:   
1482:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1483:   
1484:                      if (!string.IsNullOrEmpty(ontId))
1485:                      {
1486:                          dataOnt = new Ia.Ngn.Cl.Model.Ont();
1487:   
1488:                          dataOnt.Id = ontId;
1489:                          dataOnt.Description1 = Ia.Cl.Model.Default.Match(line, @"DESC1=(.{1,64})");
1490:                          dataOnt.Description2 = Ia.Cl.Model.Default.Match(line, @"DESC2=(.{1,64})");
1491:   
1492:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1493:                          {
1494:                              ont = (from o in db.Onts where o.Id == dataOnt.Id select o).SingleOrDefault();
1495:   
1496:                              if (ont == null)
1497:                              {
1498:                                  // below: Don't create a new ONT in this ED-ONT function
1499:                                  //dataOnt.Created = dataOnt.Updated = DateTime.UtcNow.AddHours(3);
1500:   
1501:                                  //db.Onts.Add(dataOnt);
1502:                              }
1503:                              else
1504:                              {
1505:                                  // below: copy values from dataOnt to ont
1506:   
1507:                                  if (ont.Update(dataOnt))
1508:                                  {
1509:                                      db.Onts.Attach(ont);
1510:                                      db.Entry(ont).State = System.Data.Entity.EntityState.Modified;
1511:                                  }
1512:                              }
1513:   
1514:                              db.SaveChanges();
1515:   
1516:                              b = true;
1517:                          }
1518:                      }
1519:                      else
1520:                      {
1521:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1522:                      }
1523:                  }
1524:                  else
1525:                  {
1526:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1527:                  }
1528:                  #endregion
1529:              }
1530:              else if (rowData.Contains("RTRV-SERVICE-VOIP:"))
1531:              {
1532:                  #region RTRV-SERVICE-VOIP
1533:   
1534:                  string ontServiceVoipId;
1535:                  int card;
1536:                  Ia.Ngn.Cl.Model.OntServiceVoip ontServiceVoip, dataOntServiceVoip;
1537:   
1538:                  // below: information from the definition of "RTRV-SERVICE-VOIP" in "AMS TL1 Commands Reference"
1539:   
1540:                  /*
1541:   
1542:     SUR-1-1 08-07-09 09:43:13
1543:  M  0 COMPLD
1544:     / * RTRV-SERVICE-VOIP:SUR-1-1:VOIP-1-1-1-1-1-1&VOIP-1-1-1-1-10-1&VOIP-1-1 * /
1545:     / * -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- * /
1546:     / * 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 * /
1547:     "VOIP-1-1-1-1-1-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1548:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1549:     IPADDRLOC=10.3.144.1,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1550:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1551:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1552:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1553:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1554:     SRCVLANID=0:IS-NR"
1555:     "VOIP-1-1-1-1-10-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1556:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1557:     IPADDRLOC=10.3.144.10,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1558:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1559:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1560:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1561:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1562:     SRCVLANID=0:IS-NR"
1563:     "VOIP-1-1-1-1-2-1::BWPROFUPID=1,BWPROFUPNM=VOIP,BWPROFDNID=1,
1564:     BWPROFDNNM=VOIP,PQPROFID=1,PQPROFNM=VOIPPQ,AESENABLE=DISABLE,SVLAN=10,
1565:     IPADDRLOC=10.3.144.2,NETMASKLOC=255.255.248.0,DEFROUTER=10.3.151.254,
1566:     IPADDRMGC=10.255.251.5,IPADDRFTP=0.0.0.0,DHCP=DISABLE,PORTMGC=2944,
1567:     VOIPDSCP=24,VOIPMODE=SSH248,CONFIGFILE=kuwait.xml,CLIENTID="",
1568:     CUSTOMERID="",SECRETID=,SECRETK=,IPSECENABLE=DISABLED,CONFMETH=FTPSERVER,
1569:     SPGPROFID=0,SPGPROFNM="",SPGUNAME="",SPGPWD="",SPGREALM="",
1570:     SRCVLANID=0:IS-NR"
1571:   
1572:     / * More Output Follows * /
1573:  >
1574:                  */
1575:   
1576:                  // below: read OntPosition
1577:                  match = Regex.Match(rowData, @"RTRV-SERVICE-VOIP:([\w\d\-]+)", RegexOptions.Singleline);
1578:   
1579:                  amsName = match.Groups[1].Value;
1580:   
1581:                  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);
1582:   
1583:                  if (match.Success)
1584:                  {
1585:                      cardPortOnt = match.Groups[1].Value;
1586:                      card = int.Parse(match.Groups[2].Value);
1587:   
1588:                      line = match.Groups[3].Value;
1589:   
1590:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1591:   
1592:                      if (!string.IsNullOrEmpty(ontId))
1593:                      {
1594:                          ontServiceVoipId = Ia.Ngn.Cl.Model.Business.Nokia.OntServiceVoip.OntServiceVoipId(ontId, card);
1595:   
1596:                          dataOntServiceVoip = new Ia.Ngn.Cl.Model.OntServiceVoip();
1597:   
1598:                          dataOntServiceVoip.Id = ontServiceVoipId;
1599:   
1600:                          dataOntServiceVoip.ConfiguratinFile = Ia.Cl.Model.Default.Match(line, @"CONFIGFILE=(\w{1,}\.xml)");
1601:                          dataOntServiceVoip.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTOMERID=""([^""]{1,62})""");
1602:                          dataOntServiceVoip.FtpIp = Ia.Cl.Model.Default.Match(line, @"IPADDRFTP=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1603:                          dataOntServiceVoip.Ip = Ia.Cl.Model.Default.Match(line, @"IPADDRLOC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1604:                          dataOntServiceVoip.Label = Ia.Cl.Model.Default.Match(line, @"LABEL=""([^""]{1,80})""");
1605:                          dataOntServiceVoip.MgcIp = Ia.Cl.Model.Default.Match(line, @"IPADDRMGC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1606:                          dataOntServiceVoip.MgcSecondaryIp = Ia.Cl.Model.Default.Match(line, @"IPADDRMGCSEC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1607:   
1608:                          switch (match.Groups[4].Value)
1609:                          {
1610:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1611:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1612:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1613:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1614:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1615:                          }
1616:   
1617:                          dataOntServiceVoip.StateId = (int)state;
1618:   
1619:                          dataOntServiceVoip.Svlan = int.Parse(Ia.Cl.Model.Default.Match(line, @"SVLAN=(\d{1,3})"));
1620:   
1621:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1622:                          {
1623:                              dataOntServiceVoip.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1624:   
1625:                              ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == dataOntServiceVoip.Id select osv).SingleOrDefault();
1626:   
1627:                              if (ontServiceVoip == null)
1628:                              {
1629:                                  dataOntServiceVoip.Created = dataOntServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
1630:   
1631:                                  db.OntServiceVoips.Add(dataOntServiceVoip);
1632:                              }
1633:                              else
1634:                              {
1635:                                  // below: copy values from dataOnt to ont
1636:   
1637:                                  if (ontServiceVoip.Update(dataOntServiceVoip))
1638:                                  {
1639:                                      db.OntServiceVoips.Attach(ontServiceVoip);
1640:                                      db.Entry(ontServiceVoip).State = System.Data.Entity.EntityState.Modified;
1641:                                  }
1642:                              }
1643:   
1644:                              db.SaveChanges();
1645:   
1646:                              b = true;
1647:                          }
1648:                      }
1649:                      else
1650:                      {
1651:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1652:                      }
1653:                  }
1654:                  else
1655:                  {
1656:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1657:                  }
1658:                  #endregion
1659:              }
1660:              else if (rowData.Contains("RTRV-ONTPOTS:"))
1661:              {
1662:                  #region RTRV-ONTPOTS
1663:   
1664:                  string ontOntPotsId;
1665:                  int card, port, svlan;
1666:                  Ia.Ngn.Cl.Model.OntOntPots ontOntPots, dataOntOntPots;
1667:   
1668:                  // below: information from the definition of "RTRV-ONTPOTS" in "AMS TL1 Commands Reference"
1669:   
1670:                  /*
1671:                   * ;RTRV-ONTPOTS:SUR-1-1:ONTPOTS-1-1-1-1-1-2-1;
1672:   
1673:     SUR-1-1 14-03-13 08:15:46
1674:  M  0 COMPLD
1675:     /* RTRV-ONTPOTS:SUR-1-1:ONTPOTS-1-1-1-1-1-2-1 * /
1676:     "ONTPOTS-1-1-1-1-1-2-1::VOIPSERV=1,TERMID=td1,POTSDSCP=46,POTSPWR=0,
1677:     CALLHIST=DISABLED,PWROVERRIDE=FALSE,SIPMSGTOTH=0,BRRPKTLOSSTH=0,XJTTRTH=0,
1678:     RXGAIN=0,TXGAIN=0:IS-NR"
1679:  ;
1680:  */
1681:   
1682:                  // below: read OntPosition
1683:                  match = Regex.Match(rowData, @"RTRV-ONTPOTS:([\w\d\-]+)", RegexOptions.Singleline);
1684:   
1685:                  amsName = match.Groups[1].Value;
1686:   
1687:                  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);
1688:   
1689:                  if (match.Success)
1690:                  {
1691:                      cardPortOnt = match.Groups[1].Value;
1692:                      card = int.Parse(match.Groups[2].Value);
1693:                      port = int.Parse(match.Groups[3].Value);
1694:   
1695:                      line = match.Groups[4].Value;
1696:   
1697:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1698:   
1699:                      if (!string.IsNullOrEmpty(ontId))
1700:                      {
1701:                          ontOntPotsId = Ia.Ngn.Cl.Model.Business.Nokia.OntOntPots.OntOntPotsId(ontId, card, port);
1702:   
1703:                          dataOntOntPots = new Ia.Ngn.Cl.Model.OntOntPots();
1704:   
1705:                          dataOntOntPots.Id = ontOntPotsId;
1706:   
1707:                          dataOntOntPots.Card = card;
1708:                          dataOntOntPots.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTINFO=(\w{1,80})");
1709:                          dataOntOntPots.Port = port;
1710:   
1711:                          switch (match.Groups[5].Value)
1712:                          {
1713:                              case "IS-NR": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr; break;
1714:                              case "OOS-AU": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu; break;
1715:                              case "OOS-MA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa; break;
1716:                              case "OOS-AUMA": state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma; break;
1717:                              default: state = Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined; break;
1718:                          }
1719:   
1720:                          dataOntOntPots.StateId = (int)state;
1721:   
1722:                          if (int.TryParse(Ia.Cl.Model.Default.Match(line, @"SVLAN=(\d{1,3})"), out svlan)) dataOntOntPots.Svlan = svlan;
1723:   
1724:                          dataOntOntPots.Termination = Ia.Cl.Model.Default.Match(line, @"TERMID=(\w{1,20})");
1725:                          dataOntOntPots.Tn = Ia.Cl.Model.Default.Match(line, @"TN=(\w{1,16})");
1726:                          dataOntOntPots.VoipClientIp = Ia.Cl.Model.Default.Match(line, @"VOIPCLIENTADDR=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})");
1727:   
1728:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1729:                          {
1730:                              dataOntOntPots.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1731:   
1732:                              ontOntPots = (from oop in db.OntOntPotses where oop.Id == dataOntOntPots.Id select oop).SingleOrDefault();
1733:   
1734:                              if (ontOntPots == null)
1735:                              {
1736:                                  dataOntOntPots.Created = dataOntOntPots.Updated = DateTime.UtcNow.AddHours(3);
1737:   
1738:                                  db.OntOntPotses.Add(dataOntOntPots);
1739:                              }
1740:                              else
1741:                              {
1742:                                  // below: copy values from dataOnt to ont
1743:   
1744:                                  if (ontOntPots.Update(dataOntOntPots))
1745:                                  {
1746:                                      db.OntOntPotses.Attach(ontOntPots);
1747:                                      db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
1748:                                  }
1749:                              }
1750:   
1751:                              db.SaveChanges();
1752:   
1753:                              b = true;
1754:                          }
1755:                      }
1756:                      else
1757:                      {
1758:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1759:                      }
1760:                  }
1761:                  else
1762:                  {
1763:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1764:                  }
1765:   
1766:                  #endregion
1767:              }
1768:              else if (rowData.Contains("ED-ONTPOTS:"))
1769:              {
1770:                  #region ED-ONTPOTS
1771:   
1772:                  string ontOntPotsId;
1773:                  int card, port;
1774:                  Ia.Ngn.Cl.Model.OntOntPots ontOntPots, dataOntOntPots;
1775:   
1776:                  /* ED-ONTPOTS:SUL-1-1:ONTPOTS-1-1-9-1-1-2-1:14614:::CUSTINFO=24977777: */
1777:   
1778:                  // below: read OntPosition
1779:                  match = Regex.Match(rowData, @"ED-ONTPOTS:([\w\d\-]+)", RegexOptions.Singleline);
1780:   
1781:                  amsName = match.Groups[1].Value;
1782:   
1783:                  match = Regex.Match(rowData, @"ONTPOTS-1-1-(\d{1,2}-\d{1,2}-\d{1,2})-(\d{1,2})-(\d{1,2}):(.+?):", RegexOptions.Singleline);
1784:   
1785:                  if (match.Success)
1786:                  {
1787:                      cardPortOnt = match.Groups[1].Value;
1788:                      card = int.Parse(match.Groups[2].Value);
1789:                      port = int.Parse(match.Groups[3].Value);
1790:   
1791:                      line = match.Groups[4].Value;
1792:   
1793:                      ontId = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(amsName, cardPortOnt);
1794:   
1795:                      if (!string.IsNullOrEmpty(ontId))
1796:                      {
1797:                          ontOntPotsId = Ia.Ngn.Cl.Model.Business.Nokia.OntOntPots.OntOntPotsId(ontId, card, port);
1798:   
1799:                          dataOntOntPots = new Ia.Ngn.Cl.Model.OntOntPots();
1800:   
1801:                          dataOntOntPots.Id = ontOntPotsId;
1802:   
1803:                          dataOntOntPots.Card = card;
1804:                          dataOntOntPots.Customer = Ia.Cl.Model.Default.Match(line, @"CUSTINFO=(\w{1,80})");
1805:                          dataOntOntPots.Port = port;
1806:   
1807:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
1808:                          {
1809:                              dataOntOntPots.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1810:   
1811:                              ontOntPots = (from oop in db.OntOntPotses where oop.Id == dataOntOntPots.Id select oop).SingleOrDefault();
1812:   
1813:                              if (ontOntPots == null)
1814:                              {
1815:                                  dataOntOntPots.Created = dataOntOntPots.Updated = DateTime.UtcNow.AddHours(3);
1816:   
1817:                                  db.OntOntPotses.Add(dataOntOntPots);
1818:                              }
1819:                              else
1820:                              {
1821:                                  if (ontOntPots.Update(dataOntOntPots))
1822:                                  {
1823:                                      db.OntOntPotses.Attach(ontOntPots);
1824:                                      db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
1825:                                  }
1826:                              }
1827:   
1828:                              db.SaveChanges();
1829:   
1830:                              b = true;
1831:                          }
1832:                      }
1833:                      else
1834:                      {
1835:                          result.AddError("Error in UpdateDatabaseWithAmsCommandOutput(): ontId was null or empty for amsName: [" + amsName + "] and pon: [" + cardPortOnt + "].");
1836:                      }
1837:                  }
1838:                  else
1839:                  {
1840:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1841:                  }
1842:   
1843:                  #endregion
1844:              }
1845:              else if (rowData.Contains("RTRV-ALM-PON:"))
1846:              {
1847:                  #region RTRV-ALM-PON
1848:   
1849:                  Ia.Ngn.Cl.Model.Event @event;
1850:   
1851:                  // below: important, remove all ''' char from string
1852:                  rowData = rowData.Replace(@"'", "");
1853:   
1854:                  // below: read eventTime and amsName
1855:                  // QRW-1-1 14-03-31 06:15:20
1856:                  match = Regex.Match(rowData, @"([\w\d\-]+) ((\d{2})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))", RegexOptions.Singleline);
1857:   
1858:                  amsName = match.Groups[1].Value;
1859:                  eventTime = DateTime.ParseExact(match.Groups[2].Captures[0].Value, "yy-MM-dd HH:mm:ss", null);
1860:   
1861:                  // "PON-1-1-9-2,PON:MN,NEWONT,NSA,,,,: \"SERNUM =ALCLA0A2D17A, SLID =DEFAULT,\""
1862:                  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);
1863:   
1864:                  if (matchCollection.Count > 0)
1865:                  {
1866:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
1867:                      {
1868:                          foreach (Match m in matchCollection)
1869:                          {
1870:                              if (m.Success)
1871:                              {
1872:                                  @event = new Ia.Ngn.Cl.Model.Event();
1873:   
1874:                                  @event.Aid = m.Groups[1].Value;
1875:                                  @event.Cause = "NEWONT";
1876:                                  @event.Class = "ONT";
1877:                                  @event.Detail = m.Groups[2].Value;
1878:                                  @event.EventTime = eventTime;
1879:                                  @event.NodeTime = null;
1880:                                  @event.Number = 0;
1881:                                  @event.SeverityEffect = "NSA";
1882:                                  @event.Severity = "MN";
1883:                                  @event.System = amsName;
1884:                                  @event.TypeId = 0;
1885:   
1886:                                  @event.Created = @event.Updated = DateTime.UtcNow.AddHours(3);
1887:                                  db.Events.Add(@event);
1888:   
1889:                                  b = true;
1890:                              }
1891:                          }
1892:   
1893:                          db.SaveChanges();
1894:                      }
1895:                  }
1896:                  else
1897:                  {
1898:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1899:                  }
1900:   
1901:                  #endregion
1902:              }
1903:              else if (rowData.Contains("REPT ALM"))
1904:              {
1905:                  #region REPT ALM
1906:   
1907:                  string _class, aid;
1908:                  Ia.Ngn.Cl.Model.Event @event;
1909:   
1910:                  // below: important, remove all ''' char from string
1911:                  rowData = rowData.Replace(@"'", "");
1912:   
1913:                  // 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\"" ;
1914:   
1915:                  /*
1916:     SLA-SUR-LAG16 18-06-24 18:21:01
1917:  A  37211 REPT ALM ONT
1918:     "ONT-1-1-5-9-20:CL,DG,SA,6-24,18-21-1:
1919:     "Received Dying Gasp indication from ONT","
1920:  ;                 */
1921:                  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]*""(.+?)""[,]{0,1}""\r\n;", RegexOptions.Singleline);
1922:   
1923:                  if (match.Success)
1924:                  {
1925:                      amsName = match.Groups[1].Value;
1926:   
1927:                      _class = match.Groups[12].Captures[0].Value;
1928:                      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;
1929:   
1930:                      ontPosition = CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(amsName, _class, aid);
1931:                      ontId = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdFromPosition(ontPosition);
1932:   
1933:                      @event = new Ia.Ngn.Cl.Model.Event();
1934:   
1935:                      @event.Aid = aid;
1936:                      @event.Cause = match.Groups[18].Captures[0].Value;
1937:                      @event.Class = _class;
1938:                      @event.Detail = match.Groups[27].Captures[0].Value.Replace(@"""", "");
1939:                      @event.EventTime = DateTime.ParseExact(match.Groups[2].Captures[0].Value, "yy-MM-dd HH:mm:ss", null);
1940:                      @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);
1941:                      @event.Number = int.Parse(match.Groups[10].Captures[0].Value);
1942:                      @event.SeverityEffect = match.Groups[19].Captures[0].Value;
1943:                      @event.Severity = match.Groups[17].Captures[0].Value;
1944:                      @event.System = amsName;
1945:                      @event.TypeId = 0;
1946:   
1947:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
1948:                      {
1949:                          if (ontId != null) @event.Ont = (from o in db.Onts where o.Id == ontId select o).SingleOrDefault();
1950:   
1951:                          @event.Created = @event.Updated = DateTime.UtcNow.AddHours(3);
1952:                          db.Events.Add(@event);
1953:                          db.SaveChanges();
1954:   
1955:                          b = true;
1956:                      }
1957:                  }
1958:                  else
1959:                  {
1960:                      result.AddWarning("Warning in UpdateDatabaseWithAmsCommandOutput(): Row data: [" + rowData + "] was not matched.");
1961:                  }
1962:   
1963:                  #endregion
1964:              }
1965:   
1966:              return b;
1967:          }
1968:   
1969:          ////////////////////////////////////////////////////////////////////////////
1970:   
1971:          /// <summary>
1972:          /// 
1973:          /// </summary>
1974:          private static string CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(string amsName, string _class, string aid)
1975:          {
1976:              /*
1977:  --BRGPORT    BRGPORT-1-1-11-2-6-1-1
1978:  --PON    PON-1-1-13-1
1979:  --EQPT    LT-1-1-14
1980:  --ONTPOTS    ONTPOTS-1-1-8-1-17-2-2
1981:  --ONTVOIP    VOIP-1-1-13-2-22-1
1982:  --ONT    ONT-1-1-13-1-10
1983:  --ONTENET    ONTENET-1-1-2-1-20-1-1
1984:  --ONTCARD    ONTCARD-1-1-9-2-8-1
1985:  --ONTHSI    HSI-1-1-2-1-8-1-2-2
1986:              */
1987:   
1988:              string ontPosition;
1989:              Match match;
1990:   
1991:              ontPosition = string.Empty;
1992:   
1993:              if (!string.IsNullOrEmpty(aid) && !string.IsNullOrEmpty(_class))
1994:              {
1995:                  if (_class == "BRGPORT")
1996:                  {
1997:                      // BRGPORT    BRGPORT-1-1-11-2-6-1-1
1998:                      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);
1999:   
2000:                      if (match.Success)
2001:                      {
2002:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2003:                      }
2004:                      else
2005:                      {
2006:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2007:                      }
2008:                  }
2009:                  else if (_class == "PON")
2010:                  {
2011:                      // PON    PON-1-1-13-1
2012:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2013:   
2014:                      if (match.Success)
2015:                      {
2016:                          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
2017:                      }
2018:                      else
2019:                      {
2020:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2021:                      }
2022:                  }
2023:                  else if (_class == "EQPT")
2024:                  {
2025:                      // EQPT    LT-1-1-14
2026:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2027:   
2028:                      if (match.Success)
2029:                      {
2030:                          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
2031:                      }
2032:                      else
2033:                      {
2034:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2035:                      }
2036:                  }
2037:                  else if (_class == "ONTPOTS")
2038:                  {
2039:                      // ONTPOTS    ONTPOTS-1-1-8-1-17-2-2
2040:                      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);
2041:   
2042:                      if (match.Success)
2043:                      {
2044:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2045:                      }
2046:                      else
2047:                      {
2048:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2049:                      }
2050:                  }
2051:                  else if (_class == "ONTVOIP")
2052:                  {
2053:                      // ONTVOIP    VOIP-1-1-13-2-22-1
2054:                      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);
2055:   
2056:                      if (match.Success)
2057:                      {
2058:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2059:                      }
2060:                      else
2061:                      {
2062:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2063:                      }
2064:                  }
2065:                  else if (_class == "ONT")
2066:                  {
2067:                      // ONT    ONT-1-1-13-1-10
2068:                      match = Regex.Match(aid, @"^(\w+)-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})-(\d{1,2})$", RegexOptions.Singleline);
2069:   
2070:                      if (match.Success)
2071:                      {
2072:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2073:                      }
2074:                      else
2075:                      {
2076:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2077:                      }
2078:                  }
2079:                  else if (_class == "ONTENET")
2080:                  {
2081:                      // ONTENET    ONTENET-1-1-2-1-20-1-1
2082:                      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);
2083:   
2084:                      if (match.Success)
2085:                      {
2086:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2087:                      }
2088:                      else
2089:                      {
2090:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2091:                      }
2092:                  }
2093:                  else if (_class == "ONTCARD")
2094:                  {
2095:                      // ONTCARD    ONTCARD-1-1-9-2-8-1
2096:                      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);
2097:   
2098:                      if (match.Success)
2099:                      {
2100:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2101:                      }
2102:                      else
2103:                      {
2104:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2105:                      }
2106:                  }
2107:                  else if (_class == "ONTHSI")
2108:                  {
2109:                      // ONTHSI    HSI-1-1-2-1-8-1-2-2
2110:                      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);
2111:   
2112:                      if (match.Success)
2113:                      {
2114:                          ontPosition = amsName + "-" + int.Parse(match.Groups[4].Value) + "-" + int.Parse(match.Groups[5].Value) + "-" + int.Parse(match.Groups[6].Value);
2115:                      }
2116:                      else
2117:                      {
2118:                          throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): class: " + _class + ", aid: " + aid + " unmatched. ") { };
2119:                      }
2120:                  }
2121:                  else
2122:                  {
2123:                      throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): Unknown class. ") { };
2124:                  }
2125:              }
2126:              else
2127:              {
2128:                  throw new Exception("CalculateRelaventOntPositionAccordingToAmsNameAndClassAndAid(): aid and/or class are null. ") { };
2129:              }
2130:   
2131:              return ontPosition;
2132:          }
2133:   
2134:          ////////////////////////////////////////////////////////////////////////////
2135:   
2136:          /// <summary>
2137:          ///
2138:          /// </summary>
2139:          public bool AddPot(string td)
2140:          {
2141:              bool b;
2142:   
2143:              b = true;
2144:   
2145:   
2146:              return b;
2147:          }
2148:   
2149:          ////////////////////////////////////////////////////////////////////////////
2150:   
2151:          /// <summary>
2152:          ///
2153:          /// </summary>
2154:          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)
2155:          {
2156:              string sa, cardPortOnt, voipServiceState;
2157:   
2158:              sa = string.Empty;
2159:   
2160:              foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
2161:              {
2162:                  cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2163:   
2164:                  if (edServiceVoipIsOos) voipServiceState = "OOS";
2165:                  else voipServiceState = "IS";
2166:   
2167:                  sa = @"
2168:  # Delete then create VOIP and associated ONTPOTS: " + nddOnt.Access.Name + @" " + nddOnt.Position;
2169:   
2170:                  if (ont != null)
2171:                  {
2172:                      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)
2173:                      {
2174:                          sa += @"
2175:   
2176:  # Delete ONTPOTS
2177:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4:::::OOS;
2178:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4::;
2179:   
2180:  # Delete VOIP
2181:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2182:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2183:   
2184:  # Create VOIP
2185:  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;
2186:   
2187:  # Create ONTPOTS
2188:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2189:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2190:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2191:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2192:   
2193:  # VOIP service state
2194:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2195:   
2196:   
2197:  ";
2198:                      }
2199:                      else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
2200:                      {
2201:                          sa += @"
2202:   
2203:  # Delete ONTPOTS
2204:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8:::::OOS;
2205:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8::;
2206:   
2207:  # Delete VOIP
2208:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2209:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2210:   
2211:  # Create VOIP
2212:  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;
2213:   
2214:  # Create ONTPOTS
2215:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2216:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2217:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2218:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2219:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td5:IS;
2220:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td6:IS;
2221:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td7:IS;
2222:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td8:IS;
2223:   
2224:  # VOIP service state
2225:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2226:   
2227:   
2228:  ";
2229:                      }
2230:                      else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
2231:                      {
2232:                          sa += @"
2233:   
2234:  # Delete ONTPOTS
2235:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1&&-8:::::OOS;
2236:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8:::::OOS;
2237:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1&&-8:::::OOS;
2238:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1&&-8::;
2239:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-8::;
2240:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1&&-8::;
2241:   
2242:  # Delete VOIP
2243:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2244:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2245:   
2246:  # Create VOIP
2247:  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;
2248:   
2249:  # Create ONTPOTS
2250:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1::::VOIPSERV=1,TERMID=td1:IS;
2251:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-2::::VOIPSERV=1,TERMID=td2:IS;
2252:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-3::::VOIPSERV=1,TERMID=td3:IS;
2253:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-4::::VOIPSERV=1,TERMID=td4:IS;
2254:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-5::::VOIPSERV=1,TERMID=td13:IS;
2255:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-6::::VOIPSERV=1,TERMID=td14:IS;
2256:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-7::::VOIPSERV=1,TERMID=td15:IS;
2257:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-8::::VOIPSERV=1,TERMID=td16:IS;
2258:   
2259:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td5:IS;
2260:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td6:IS;
2261:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td7:IS;
2262:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td8:IS;
2263:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td17:IS;
2264:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td18:IS;
2265:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td19:IS;
2266:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td20:IS;
2267:   
2268:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1::::VOIPSERV=1,TERMID=td9:IS;
2269:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-2::::VOIPSERV=1,TERMID=td10:IS;
2270:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-3::::VOIPSERV=1,TERMID=td11:IS;
2271:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-4::::VOIPSERV=1,TERMID=td12:IS;
2272:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-5::::VOIPSERV=1,TERMID=td21:IS;
2273:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-6::::VOIPSERV=1,TERMID=td22:IS;
2274:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-7::::VOIPSERV=1,TERMID=td23:IS;
2275:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-8::::VOIPSERV=1,TERMID=td24:IS;
2276:   
2277:  # VOIP service state
2278:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2279:   
2280:   
2281:  ";
2282:                      }
2283:                      else
2284:                      {
2285:                          throw new Exception("Unknown familyType") { };
2286:                      }
2287:                  }
2288:                  else
2289:                  {
2290:   
2291:                      sa = @"
2292:  # Delete then create VOIP and associated ONTPOTS: " + nddOnt.Access.Name + @" " + nddOnt.Position;
2293:   
2294:                      sa += @"
2295:  # ONT does not have an associated Access to it.";
2296:   
2297:                      sa += @"
2298:   
2299:  # Delete ONTPOTS
2300:  ED-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4:::::OOS;
2301:  DLT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1&&-4::;
2302:   
2303:  # Delete VOIP
2304:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::OOS;
2305:  DLT-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1;
2306:   
2307:  # Create VOIP
2308:  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;
2309:   
2310:  # Create ONTPOTS
2311:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2312:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2313:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2314:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2315:   
2316:  # VOIP service state
2317:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2318:   
2319:   
2320:  ";
2321:                  }
2322:              }
2323:   
2324:              return sa;
2325:          }
2326:   
2327:          ////////////////////////////////////////////////////////////////////////////
2328:   
2329:          /// <summary>
2330:          ///
2331:          /// </summary>
2332:          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)
2333:          {
2334:              string sa, cardPortOnt, voipServiceState;
2335:   
2336:              cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2337:   
2338:              if (edServiceVoipIsOos) voipServiceState = "OOS";
2339:              else voipServiceState = "IS";
2340:   
2341:              sa = @"
2342:  # Create ONTPOTS: " + ont.Access.Name + @" " + ont.Access.Position;
2343:   
2344:              if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu)
2345:              {
2346:                  sa += @"
2347:   
2348:  # Create ONTPOTS
2349:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2350:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2351:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2352:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2353:   
2354:  # VOIP service state
2355:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2356:   
2357:   
2358:  ";
2359:              }
2360:              else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho)
2361:              {
2362:                  sa += @"
2363:   
2364:  # Create ONTPOTS
2365:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;
2366:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;
2367:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;
2368:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;
2369:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td5:IS;
2370:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td6:IS;
2371:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td7:IS;
2372:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td8:IS;
2373:   
2374:  # VOIP service state
2375:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2376:   
2377:   
2378:  ";
2379:              }
2380:              else if (ont.FamilyTypeId == (int)Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu)
2381:              {
2382:                  sa += @"
2383:   
2384:  # Create ONTPOTS
2385:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-1::::VOIPSERV=1,TERMID=td1:IS;
2386:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-2::::VOIPSERV=1,TERMID=td2:IS;
2387:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-3::::VOIPSERV=1,TERMID=td3:IS;
2388:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-4::::VOIPSERV=1,TERMID=td4:IS;
2389:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-5::::VOIPSERV=1,TERMID=td13:IS;
2390:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-6::::VOIPSERV=1,TERMID=td14:IS;
2391:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-7::::VOIPSERV=1,TERMID=td15:IS;
2392:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-1-8::::VOIPSERV=1,TERMID=td16:IS;
2393:   
2394:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td5:IS;
2395:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td6:IS;
2396:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td7:IS;
2397:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td8:IS;
2398:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-5::::VOIPSERV=1,TERMID=td17:IS;
2399:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-6::::VOIPSERV=1,TERMID=td18:IS;
2400:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-7::::VOIPSERV=1,TERMID=td19:IS;
2401:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-8::::VOIPSERV=1,TERMID=td20:IS;
2402:   
2403:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-1::::VOIPSERV=1,TERMID=td9:IS;
2404:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-2::::VOIPSERV=1,TERMID=td10:IS;
2405:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-3::::VOIPSERV=1,TERMID=td11:IS;
2406:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-4::::VOIPSERV=1,TERMID=td12:IS;
2407:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-5::::VOIPSERV=1,TERMID=td21:IS;
2408:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-6::::VOIPSERV=1,TERMID=td22:IS;
2409:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-7::::VOIPSERV=1,TERMID=td23:IS;
2410:  ENT-ONTPOTS:" + olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-3-8::::VOIPSERV=1,TERMID=td24:IS;
2411:   
2412:  # VOIP service state
2413:  ED-SERVICE-VOIP:" + olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";
2414:   
2415:   
2416:  ";
2417:              }
2418:              else
2419:              {
2420:                  sa += @"
2421:   
2422:  # Unknown FamilyType
2423:   
2424:   
2425:  ";
2426:              }
2427:   
2428:              return sa;
2429:          }
2430:   
2431:          ////////////////////////////////////////////////////////////////////////////
2432:   
2433:          /// <summary>
2434:          ///
2435:          /// </summary>
2436:          public static List<string> CommandsToPreprovisionOntWithinOlt(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2437:          {
2438:              string cardPortOnt, voipServiceState;
2439:              List<string> list;
2440:   
2441:              list = new List<string>();
2442:   
2443:              if (edServiceVoipIsOos) voipServiceState = "OOS";
2444:              else voipServiceState = "IS";
2445:   
2446:              cardPortOnt = nddOnt.CardSlot + "-" + nddOnt.Port + "-" + nddOnt.InternalNumber;
2447:   
2448:              //list.Add("# Preprovision an empty ONT on the network: " + nddOnt.Access.Name + @" " + nddOnt.Position + " (" + nddOnt.Ip + @");");
2449:              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;");
2450:   
2451:              //list.Add("# Provision the VOIP service;");
2452:              list.Add("ENT-ONTCARD:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTCARD-1-1-" + cardPortOnt + @"-2:::POTS::IS;");
2453:              list.Add("ENT-ONTCARD:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTCARD-1-1-" + cardPortOnt + @"-1:::10_100BASET::IS;");
2454:              list.Add("ENT-ONTENET:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTENET-1-1-" + cardPortOnt + @"-1-1::::SESSPROFID=1,MAXMACNUM=4:IS;");
2455:              list.Add("ENT-ONTENET:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTENET-1-1-" + cardPortOnt + @"-1-2::::SESSPROFID=1,MAXMACNUM=4:IS;");
2456:              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;");
2457:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-1::::VOIPSERV=1,TERMID=td1:IS;");
2458:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-2::::VOIPSERV=1,TERMID=td2:IS;");
2459:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-3::::VOIPSERV=1,TERMID=td3:IS;");
2460:              list.Add("ENT-ONTPOTS:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":ONTPOTS-1-1-" + cardPortOnt + @"-2-4::::VOIPSERV=1,TERMID=td4:IS;");
2461:   
2462:              //list.Add("# VOIP service state");
2463:              list.Add("ED-SERVICE-VOIP:" + nddOnt.Pon.PonGroup.Olt.AmsName + @":VOIP-1-1-" + cardPortOnt + @"-1:::::" + voipServiceState + @";");
2464:   
2465:              return list;
2466:          }
2467:   
2468:          ////////////////////////////////////////////////////////////////////////////
2469:   
2470:          /// <summary>
2471:          ///
2472:          /// </summary>
2473:          public static string CommandsToPreprovisionOntWithinOltUsingConfigureCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool edServiceVoipIsOos)
2474:          {
2475:              string sa, rackSubCardPortOnt;//, voipServiceState;
2476:   
2477:              //if (edServiceVoipIsOos) voipServiceState = "OOS";
2478:              //else voipServiceState = "IS";
2479:   
2480:              rackSubCardPortOnt = nddOnt.Rack + "/" + nddOnt.Sub + "/" + nddOnt.CardSlot + "/" + nddOnt.Port + "/" + nddOnt.InternalNumber;
2481:   
2482:              sa = @"
2483:  configure equipment ont slot " + rackSubCardPortOnt + @"/1 planned-card-type 10_100base plndnumdataports 2 plndnumvoiceports 0
2484:  configure equipment ont slot " + rackSubCardPortOnt + @"/2 planned-card-type pots plndnumdataports 0 plndnumvoiceports 4
2485:  configure qos interface ont:" + rackSubCardPortOnt + @" us-num-queue 8
2486:  configure qos interface " + rackSubCardPortOnt + @"/voip upstream-queue 5 bandwidth-profile name:VOICE bandwidth-sharing ont-sharing 
2487:  configure bridge port " + rackSubCardPortOnt + @"/voip max-unicast-mac 8    
2488:  configure bridge port " + rackSubCardPortOnt + @"/voip vlan-id " /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @"
2489:  configure bridge port " + rackSubCardPortOnt + @"/voip pvid " /*+ nddOnt.Pon.PonGroup.Olt.Vlan*/ + @"
2490:  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*/ + @"
2491:   
2492:  ";
2493:   
2494:              return sa;
2495:          }
2496:   
2497:          ////////////////////////////////////////////////////////////////////////////    
2498:          ////////////////////////////////////////////////////////////////////////////    
2499:      }
2500:   
2501:      ////////////////////////////////////////////////////////////////////////////
2502:      ////////////////////////////////////////////////////////////////////////////   
2503:  }