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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ams

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

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

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