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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ams

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

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

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