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

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