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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ams

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

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

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