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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ems

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

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

   1:  using System;
   2:  using System.Configuration;
   3:  using System.Text.RegularExpressions;
   4:  using System.Data;
   5:  using System.Collections.Generic;
   6:  using System.Linq;
   7:  using System.Collections;
   8:   
   9:  namespace Ia.Ngn.Cl.Model.Business.Huawei
  10:  {
  11:      ////////////////////////////////////////////////////////////////////////////
  12:   
  13:      /// <summary publish="true">
  14:      /// Access Management System (AMS) support class for Huawei's Next Generation Network (NGN) business model.
  15:      /// </summary>
  16:   
  17:      /// <remarks> 
  18:      /// Copyright © 2016-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  19:      ///
  20:      /// 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
  21:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  22:      ///
  23:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  24:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  25:      /// 
  26:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  27:      /// 
  28:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  29:      /// </remarks> 
  30:      public partial class Ems
  31:      {
  32:          private static Queue<string> emsCommandQueue = new Queue<string>();
  33:          private static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
  34:   
  35:          /// <summary/>
  36:          public enum EmsOpcode
  37:          {
  38:              LstDev, LstBoard, LstPort, LstOnt, ModOntAlias, ModOntAliasAnnul, LstOntSipInfo, CfgOntVainDiv, CfgOntVainDivVacant, AddVoipPstnUser, LstVoipPstnUser, DelVoipPstnUser, CfgVoipPstnAccount, CfgVoipPstnAccountVacant
  39:          }
  40:   
  41:          /// <summary/>
  42:          public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
  43:   
  44:          /// <summary/>
  45:          public static string Host { get { return ConfigurationManager.AppSettings["u2000ServerHost"].ToString(); } }
  46:          /// <summary/>
  47:          public static int Port { get { return int.Parse(ConfigurationManager.AppSettings["u2000ServerPort"].ToString()); } }
  48:   
  49:          /// <summary/>
  50:          public static string LoginUser { get { return PrepareCtaggedCommand(ConfigurationManager.AppSettings["u2000ServerLoginUser"].ToString()); } }
  51:   
  52:          /// <summary/>
  53:          public static string LogoutUser { get { return PrepareCtaggedCommand(ConfigurationManager.AppSettings["u2000ServerLogoutUser"].ToString()); } }
  54:   
  55:          ////////////////////////////////////////////////////////////////////////////
  56:   
  57:          /// <summary>
  58:          /// Response class of U2000 TL1 NBI following the "10.3 Response Format Description standard" in iManager U2000 Unified Network Management System Guide.
  59:          /// </summary>
  60:          public class Response
  61:          {
  62:              /// <summary/>
  63:              public enum CompletionCodeType { DENY, COMPLD };
  64:              /// <summary/>
  65:              public enum CommandType { Operation, Query };
  66:              /// <summary/>
  67:              public bool OperationCommand { get { return !QueryCommand; } }
  68:              /// <summary/>
  69:              public bool QueryCommand { get; set; }
  70:   
  71:              /// <summary/>
  72:              public int BlockTag { get; set; }
  73:              /// <summary/>
  74:              public int CurrentBlockCount { get; set; }
  75:              /// <summary/>
  76:              public int TotalCount { get; set; }
  77:   
  78:              /// <summary/>
  79:              public string Ctag { get; set; }
  80:              /// <summary/>
  81:              public string CompletionCode { get; set; }
  82:   
  83:              /// <summary/>
  84:              public string Title { get; set; }
  85:              /// <summary/>
  86:              public string Endesc { get; set; }
  87:   
  88:              /// <summary/>
  89:              public string CommandFromCorrelationTagDictionaryByCtag
  90:              {
  91:                  get
  92:                  {
  93:                      string opcode;
  94:   
  95:                      if (Ia.Ngn.Cl.Model.Data.Huawei.Ems.CorrelationTagDictionary.ContainsKey(Ctag)) opcode = Ia.Ngn.Cl.Model.Data.Huawei.Ems.CorrelationTagDictionary[Ctag];
  96:                      else opcode = string.Empty;
  97:   
  98:                      return opcode;
  99:                  }
 100:              }
 101:   
 102:              /// <summary/>
 103:              public DataTable QueryDataTable { get; set; }
 104:   
 105:              /// <summary/>
 106:              public Response() { }
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          ///
 113:          /// </summary>
 114:          public Ems() { }
 115:   
 116:          ////////////////////////////////////////////////////////////////////////////
 117:          ////////////////////////////////////////////////////////////////////////////
 118:   
 119:          /// <summary>
 120:          ///
 121:          /// </summary>
 122:          private static List<string> PrepareCtaggedCommand(List<string> commandList)
 123:          {
 124:              List<string> ctaggedCommandList;
 125:   
 126:              if (commandList.Count > 0)
 127:              {
 128:                  ctaggedCommandList = new List<string>(commandList.Count);
 129:   
 130:                  foreach (string command in commandList)
 131:                  {
 132:                      ctaggedCommandList.Add(PrepareCtaggedCommand(command));
 133:                  }
 134:              }
 135:              else ctaggedCommandList = new List<string>();
 136:   
 137:              return ctaggedCommandList;
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:   
 142:          /// <summary>
 143:          ///
 144:          /// </summary>
 145:          public static string PrepareCtaggedCommand(string command)
 146:          {
 147:              string ctaggedCommand, ctag;
 148:   
 149:              if (command.Contains("{ctag}"))
 150:              {
 151:                  ctag = Ia.Cl.Model.Default.RandomNumber(12);
 152:   
 153:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.CorrelationTagDictionary[ctag] = command;
 154:   
 155:                  ctaggedCommand = command.Replace("{ctag}", ctag);
 156:              }
 157:              else
 158:              {
 159:                  ctaggedCommand = string.Empty;
 160:              }
 161:   
 162:              return ctaggedCommand;
 163:          }
 164:   
 165:          ////////////////////////////////////////////////////////////////////////////
 166:          ////////////////////////////////////////////////////////////////////////////
 167:   
 168:          /// <summary>
 169:          ///
 170:          /// </summary>
 171:          public static string RemoveMduNameInHuaweiOntActivationReportSpecificNameFormat(string line)
 172:          {
 173:              // typos I think
 174:              line = line.Replace("MGF-4-", "MGF-");
 175:              line = line.Replace("SAB-01-", "SAB-");
 176:   
 177:              line = line.Replace("ONT-", "");
 178:              line = line.Replace("MDU-", "");
 179:              line = line.Replace("MDI-", "");
 180:              line = line.Replace("B4-", "");
 181:   
 182:              return line;
 183:          }
 184:   
 185:          ////////////////////////////////////////////////////////////////////////////
 186:   
 187:          /// <summary>
 188:          ///
 189:          /// </summary>
 190:          public static string Semicolon
 191:          {
 192:              get
 193:              {
 194:                  return ";";
 195:              }
 196:          }
 197:   
 198:          ////////////////////////////////////////////////////////////////////////////
 199:   
 200:          /// <summary>
 201:          ///
 202:          /// </summary>
 203:          public static string EmsKeepAliveCommand
 204:          {
 205:              get
 206:              {
 207:                  return PrepareCtaggedCommand("SHAKEHAND:::{ctag}::;");
 208:              }
 209:          }
 210:          ////////////////////////////////////////////////////////////////////////////
 211:   
 212:          /// <summary>
 213:          ///
 214:          /// </summary>
 215:          public static string QueueProperlySelectedSingleEmsCommandToManageOntNetworkElements
 216:          {
 217:              get
 218:              {
 219:                  int randomPercent, count;
 220:                  string command;
 221:                  List<string> list;
 222:   
 223:                  command = EmsKeepAliveCommand;
 224:   
 225:                  /*
 226:                  if (priorityEmsCommandQueue.Count > 0)
 227:                  {
 228:                      command = priorityEmsCommandQueue.Dequeue();
 229:                  }
 230:                  else
 231:                  {
 232:                      randomPercent = Ia.Cl.Model.Default.RandomPercent();
 233:  
 234:                      if(randomPercent < 5)
 235:                      {
 236:                          if (amsUpdatePotsCommandQueue.Count == 0)
 237:                          {
 238:                              list = EmsCommandsToUpdateOntOntPotsCustomerWithItsConnectedServiceNumberList();
 239:  
 240:                              amsUpdatePotsCommandQueue = new Queue<string>(list);
 241:                          }
 242:  
 243:                          if (amsUpdatePotsCommandQueue.Count > 0) command = amsUpdatePotsCommandQueue.Dequeue();
 244:                      }
 245:  
 246:                      if(command == null && randomPercent < 20)
 247:                      {
 248:                          if (amsUpdateCommandQueue.Count == 0)
 249:                          {
 250:                              list = EmsCommandsToUpdateAndDisplayOntDescriptionWithItsAccessNameList();
 251:  
 252:                              amsUpdateCommandQueue = new Queue<string>(list);
 253:                          }
 254:  
 255:                          if (amsUpdateCommandQueue.Count > 0) command = amsUpdateCommandQueue.Dequeue();
 256:                      }
 257:  
 258:                      if (command == null && randomPercent < 60)
 259:                      {
 260:                          if (amsCreateOntCommandQueue.Count == 0)
 261:                          {
 262:                              if (oltId != 0) amsCommandOltId = oltId;
 263:                              else amsCommandOltId = (from q in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where q.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select q.Id).ToList().PickRandom();
 264:  
 265:                              list = EmsCommandsToPreprovisionOntThatAreNotProvisionedAsDefinedInNddDocumentWithinAnOltList(amsCommandOltId, true, false, out count);
 266:  
 267:                              amsCreateOntCommandQueue = new Queue<string>(list);
 268:                          }
 269:  
 270:                          if (amsCreateOntCommandQueue.Count > 0) command = amsCreateOntCommandQueue.Dequeue();
 271:                      }
 272:  
 273:                      if (command == null && randomPercent < 80)
 274:                      {
 275:                      */
 276:   
 277:                  if (emsCommandQueue.Count == 0)
 278:                  {
 279:                      olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiOltList.NextOf(olt);
 280:   
 281:                      list = EmsCommandsToRetrieveOntAndOntSipInfoWithDefinedFamilyType_EmsCommandsToRetrieveOntForOntsDefinedInNddDocument_EmsCommandsToUpdateAndRetrieveOntAliasWithItsAccessNameList(olt);
 282:   
 283:                      emsCommandQueue = new Queue<string>(list);
 284:                  }
 285:   
 286:                  if (emsCommandQueue.Count > 0) command = emsCommandQueue.Dequeue();
 287:                  /*
 288:              }
 289:  
 290:              if(command == null) command = EmsCommandOfARandomEmsKeepAlive();
 291:          }
 292:          */
 293:   
 294:                  return command;
 295:              }
 296:          }
 297:   
 298:          ////////////////////////////////////////////////////////////////////////////
 299:   
 300:          /// <summary>
 301:          ///
 302:          /// </summary>
 303:          public static List<string> QueueProperlySelectedEmsCommandsToRetriveOntNetworkElementDataByAccessName(string input)
 304:          {
 305:              string accessName;
 306:              Ia.Cl.Model.Result result;
 307:              List<string> list;
 308:   
 309:              result = new Ia.Cl.Model.Result();
 310:              list = new List<string>(5);
 311:   
 312:              if (!string.IsNullOrEmpty(input))
 313:              {
 314:                  if (input.Length > 0)
 315:                  {
 316:                      input = input.Trim();
 317:                      input = input.ToUpper();
 318:   
 319:                      if (Regex.IsMatch(input, @"^[a-zA-Z]{3}\s+\d{1,4}\s+\d{1,3}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\.\d{1,4}\.\d{1,3}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\/\d{1,4}\/\d{1,3}$"))
 320:                      {
 321:                          if (Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(input, out accessName))
 322:                          {
 323:                              list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsCommandsToRetrieveOntAndOntSipInfoAndVoipPstnUserForASingleOntWithDefinedFamilyTypeAndForItIfThisSingleOntDefinedInNddDocumentList(accessName);
 324:                          }
 325:                          else
 326:                          {
 327:                              result.AddError("ReadOnt(): Error: accessName is not within allowed ONT list. ");
 328:                          }
 329:                      }
 330:                      else
 331:                      {
 332:                          result.AddError("ReadOnt(): Error: accessName is not valid. ");
 333:                      }
 334:                  }
 335:                  else
 336:                  {
 337:                      result.AddError("ReadOnt(): Error: accessName is empty. ");
 338:                  }
 339:              }
 340:              else
 341:              {
 342:                  result.AddError("ReadOnt(): Error: accessName is null or empty. ");
 343:              }
 344:   
 345:              if (list.Count == 0) list.Add(EmsKeepAliveCommand);
 346:   
 347:              return list;
 348:          }
 349:   
 350:          ////////////////////////////////////////////////////////////////////////////
 351:          ////////////////////////////////////////////////////////////////////////////
 352:   
 353:          /// <summary>
 354:          ///
 355:          /// </summary>
 356:          public static string ReadDevListCommand(string devType)
 357:          {
 358:              string command;
 359:   
 360:              command = FormatEmsDevLstCommand(EmsOpcode.LstDev, devType);
 361:   
 362:              return command;
 363:          }
 364:   
 365:          ////////////////////////////////////////////////////////////////////////////
 366:          ////////////////////////////////////////////////////////////////////////////
 367:   
 368:          /// <summary>
 369:          ///
 370:          /// </summary>
 371:          public static string ReadBoardListCommand(string dev)
 372:          {
 373:              string command;
 374:   
 375:              command = FormatEmsBoardLstCommand(EmsOpcode.LstBoard, dev, 0);
 376:   
 377:              return command;
 378:          }
 379:   
 380:          ////////////////////////////////////////////////////////////////////////////
 381:          ////////////////////////////////////////////////////////////////////////////
 382:   
 383:          /// <summary>
 384:          ///
 385:          /// </summary>
 386:          public static string ReadOntListCommand(int did)
 387:          {
 388:              string command;
 389:   
 390:              command = FormatEmsLstCommand(EmsOpcode.LstOnt, did);
 391:   
 392:              return command;
 393:          }
 394:   
 395:          ////////////////////////////////////////////////////////////////////////////
 396:          ////////////////////////////////////////////////////////////////////////////
 397:   
 398:          /// <summary>
 399:          ///
 400:          /// </summary>
 401:          public static string ReadPortListCommand(string dev, int fn, int sn)
 402:          {
 403:              string command;
 404:   
 405:              command = FormatEmsPortLstCommand(EmsOpcode.LstPort, dev, fn, sn);
 406:   
 407:              return command;
 408:          }
 409:   
 410:          ////////////////////////////////////////////////////////////////////////////
 411:          ////////////////////////////////////////////////////////////////////////////
 412:   
 413:          /// <summary>
 414:          ///
 415:          /// </summary>
 416:          public static string CreateOrModifyOntSipInfoCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 417:          {
 418:              string command;
 419:   
 420:              command = FormatEmsCfgOntVainDivCommand(EmsOpcode.CfgOntVainDiv, nddOnt, service, telPort);
 421:   
 422:              return command;
 423:          }
 424:   
 425:          ////////////////////////////////////////////////////////////////////////////
 426:   
 427:          /// <summary>
 428:          ///
 429:          /// </summary>
 430:          public static string ReadOntSipInfoCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 431:          {
 432:              string command;
 433:   
 434:              command = FormatEmsLstCommand(EmsOpcode.LstOntSipInfo, nddOnt);
 435:   
 436:              return command;
 437:          }
 438:   
 439:          ////////////////////////////////////////////////////////////////////////////
 440:   
 441:          /// <summary>
 442:          ///
 443:          /// </summary>
 444:          public static string VacateOntSipInfoCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 445:          {
 446:              string command;
 447:   
 448:              command = FormatEmsCfgOntVainDivCommand(EmsOpcode.CfgOntVainDivVacant, nddOnt, service, telPort);
 449:   
 450:              return command;
 451:          }
 452:   
 453:          ////////////////////////////////////////////////////////////////////////////
 454:   
 455:          /// <summary>
 456:          ///
 457:          /// </summary>
 458:          public static string CreateOrModifyVoipPstnUserCommand(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 459:          {
 460:              string command;
 461:   
 462:              command = FormatEmsVoipPstnUserCommand(EmsOpcode.AddVoipPstnUser, mduDev, nddOnt, service, sn, telPort);
 463:   
 464:              return command;
 465:          }
 466:   
 467:          ////////////////////////////////////////////////////////////////////////////
 468:   
 469:          /// <summary>
 470:          ///
 471:          /// </summary>
 472:          public static string ReadVoipPstnUserCommand(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int sn, int telPort)
 473:          {
 474:              string command;
 475:   
 476:              command = FormatEmsLstVoipPstnUserCommand(EmsOpcode.LstVoipPstnUser, mduDev, nddOnt, sn, telPort);
 477:   
 478:              return command;
 479:          }
 480:   
 481:          ////////////////////////////////////////////////////////////////////////////
 482:   
 483:          /// <summary>
 484:          ///
 485:          /// </summary>
 486:          public static string DeleteVoipPstnUserCommand(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 487:          {
 488:              string command;
 489:   
 490:              command = FormatEmsVoipPstnUserCommand(EmsOpcode.DelVoipPstnUser, mduDev, nddOnt, service, sn, telPort);
 491:   
 492:              return command;
 493:          }
 494:   
 495:          ////////////////////////////////////////////////////////////////////////////
 496:   
 497:          /// <summary>
 498:          ///
 499:          /// </summary>
 500:          public static string CreateOrModifyVoipPstnAccountCommand(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 501:          {
 502:              string command;
 503:   
 504:              command = FormatEmsCfgVoipPstnAccountCommand(EmsOpcode.CfgVoipPstnAccount, mduDev, nddOnt, service, sn, telPort);
 505:   
 506:              return command;
 507:          }
 508:   
 509:          ////////////////////////////////////////////////////////////////////////////
 510:   
 511:          /// <summary>
 512:          ///
 513:          /// </summary>
 514:          public static string ReadVoipPstnAccountCommand(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 515:          {
 516:              string command;
 517:   
 518:              command = null; // FormatEmsLstCommand(EmsOpcode.LstOntSipInfo, nddOnt);
 519:   
 520:              return command;
 521:          }
 522:   
 523:          ////////////////////////////////////////////////////////////////////////////
 524:   
 525:          /// <summary>
 526:          ///
 527:          /// </summary>
 528:          public static string VacateVoipPstnAccountCommand(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 529:          {
 530:              string command;
 531:   
 532:              command = FormatEmsCfgVoipPstnAccountCommand(EmsOpcode.CfgVoipPstnAccountVacant, mduDev, nddOnt, service, sn, telPort);
 533:   
 534:              return command;
 535:          }
 536:   
 537:          ////////////////////////////////////////////////////////////////////////////
 538:          ////////////////////////////////////////////////////////////////////////////
 539:   
 540:          /// <summary>
 541:          ///
 542:          /// </summary>
 543:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode)
 544:          {
 545:              return FormatEmsLstCommand(amsOpcode, 0, 0, null, null, null);
 546:          }
 547:   
 548:          ////////////////////////////////////////////////////////////////////////////
 549:   
 550:          /// <summary>
 551:          ///
 552:          /// </summary>
 553:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, int did)
 554:          {
 555:              return FormatEmsLstCommand(amsOpcode, 0, did, null, null, null);
 556:          }
 557:   
 558:          ////////////////////////////////////////////////////////////////////////////
 559:   
 560:          /// <summary>
 561:          ///
 562:          /// </summary>
 563:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 564:          {
 565:              return FormatEmsLstCommand(amsOpcode, 0, 0, null, null, null);
 566:          }
 567:   
 568:          ////////////////////////////////////////////////////////////////////////////
 569:   
 570:          /// <summary>
 571:          ///
 572:          /// </summary>
 573:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon)
 574:          {
 575:              return FormatEmsLstCommand(amsOpcode, 0, 0, null, pon, null);
 576:          }
 577:   
 578:          ////////////////////////////////////////////////////////////////////////////
 579:   
 580:          /// <summary>
 581:          ///
 582:          /// </summary>
 583:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 584:          {
 585:              return FormatEmsLstCommand(amsOpcode, 0, 0, null, null, ont);
 586:          }
 587:   
 588:          ////////////////////////////////////////////////////////////////////////////
 589:   
 590:          /// <summary>
 591:          ///
 592:          /// </summary>
 593:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, int telPort)
 594:          {
 595:              return FormatEmsLstCommand(amsOpcode, telPort, 0, null, null, ont);
 596:          }
 597:   
 598:          ////////////////////////////////////////////////////////////////////////////
 599:   
 600:          /// <summary>
 601:          ///
 602:          /// </summary>
 603:          private static string FormatEmsLstCommand(EmsOpcode amsOpcode, int telPort, int did, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 604:          {
 605:              int sn, pn, ontId;
 606:              string command;
 607:   
 608:              if (amsOpcode == EmsOpcode.LstOnt)
 609:              {
 610:                  if (ont != null)
 611:                  {
 612:                      sn = ont.CardSlot;
 613:                      pn = ont.Port;
 614:                      ontId = ont.InternalNumber;
 615:   
 616:                      //command = "LST-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::;";
 617:                      command = "LST-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::SHOWOPTION=SERIALNUM;";
 618:                      //command = "LST-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::SHOWOPTION=SERIALNUM PWD LOID CHECKCODE ALMPROF DEV VLAN PRI IP MASK GATE ROUTEIP ROUTEMASK NEXTHOP SNMPPROF OPTALMPROF VAPROF MACLEARN SRVLEVELPROF HARDWAREVERSION LSTUPTIME LSTDOWNTIME DEVCURRENTTIME VASPROFILESET;";
 619:                  }
 620:                  else if (pon != null)
 621:                  {
 622:                      sn = pon.CardSlot;
 623:                      pn = pon.Port;
 624:   
 625:                      command = "LST-ONT::DEV=" + pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ":{ctag}::;";
 626:                  }
 627:                  else if (olt != null)
 628:                  {
 629:                      command = "LST-ONT::DID=" + olt.Did + ":{ctag}::;";
 630:                  }
 631:                  else if (did > 0)
 632:                  {
 633:                      command = "LST-ONT::DID=" + did + ":{ctag}::;";
 634:                  }
 635:                  else
 636:                  {
 637:                      command = string.Empty;
 638:                  }
 639:              }
 640:              else if (amsOpcode == EmsOpcode.LstOntSipInfo)
 641:              {
 642:                  if (ont != null)
 643:                  {
 644:                      sn = ont.CardSlot;
 645:                      pn = ont.Port;
 646:                      ontId = ont.InternalNumber;
 647:   
 648:                      command = "LST-ONTSIPINFO::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::;";
 649:                  }
 650:                  else if (pon != null)
 651:                  {
 652:                      sn = pon.CardSlot;
 653:                      pn = pon.Port;
 654:   
 655:                      command = "LST-ONTSIPINFO::DEV=" + pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ":{ctag}::;";
 656:                  }
 657:                  else
 658:                  {
 659:                      command = string.Empty;
 660:                  }
 661:              }
 662:              else
 663:              {
 664:                  command = string.Empty;
 665:              }
 666:   
 667:              return PrepareCtaggedCommand(command);
 668:          }
 669:   
 670:          ////////////////////////////////////////////////////////////////////////////
 671:   
 672:          /// <summary>
 673:          ///
 674:          /// </summary>
 675:          private static string FormatEmsLstVoipPstnUserCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, int sn, int telPort)
 676:          {
 677:              string command;
 678:   
 679:              if (amsOpcode == EmsOpcode.LstVoipPstnUser)
 680:              {
 681:                  if (ont != null) // && telPort != 0) telPort can be 0
 682:                  {
 683:                      //sn = ont.CardSlot; you can not use ont.CardSlot for SN in Huawei MDUs
 684:   
 685:                      // LST-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::;
 686:                      command = "LST-VOIPPSTNUSER::DEV=" + mduDev.Dev + ",FN=0,SN=" + sn + ",PN=" + telPort + ":{ctag}::;";
 687:                  }
 688:                  else
 689:                  {
 690:                      command = string.Empty;
 691:                  }
 692:              }
 693:              else
 694:              {
 695:                  command = string.Empty;
 696:              }
 697:   
 698:              return PrepareCtaggedCommand(command);
 699:          }
 700:   
 701:          ////////////////////////////////////////////////////////////////////////////
 702:   
 703:          /// <summary>
 704:          ///
 705:          /// </summary>
 706:          private static string FormatEmsDevLstCommand(EmsOpcode amsOpcode, string devType)
 707:          {
 708:              int devTypeId;
 709:              string command;
 710:   
 711:              if (amsOpcode == EmsOpcode.LstDev)
 712:              {
 713:                  devTypeId = Ia.Ngn.Cl.Model.Data.Huawei.Dev.DevTypeToDevTypeIdDictionary[devType];
 714:   
 715:                  if (devTypeId != 0)
 716:                  {
 717:                      command = "LST-DEV::DT=" + devTypeId + ":{ctag}::;";
 718:                  }
 719:                  else
 720:                  {
 721:                      command = string.Empty;
 722:                  }
 723:              }
 724:              else
 725:              {
 726:                  command = string.Empty;
 727:              }
 728:   
 729:              return PrepareCtaggedCommand(command);
 730:          }
 731:   
 732:          ////////////////////////////////////////////////////////////////////////////
 733:   
 734:          /// <summary>
 735:          ///
 736:          /// </summary>
 737:          private static string FormatEmsBoardLstCommand(EmsOpcode amsOpcode, string dev, int fn)
 738:          {
 739:              string command;
 740:   
 741:              if (amsOpcode == EmsOpcode.LstBoard)
 742:              {
 743:                  if (!string.IsNullOrWhiteSpace(dev))
 744:                  {
 745:                      command = "LST-BOARD::DEV=" + dev + ",FN=" + fn + ":{ctag}::;";
 746:                  }
 747:                  else
 748:                  {
 749:                      command = string.Empty;
 750:                  }
 751:              }
 752:              else
 753:              {
 754:                  command = string.Empty;
 755:              }
 756:   
 757:              return PrepareCtaggedCommand(command);
 758:          }
 759:   
 760:          ////////////////////////////////////////////////////////////////////////////
 761:   
 762:          /// <summary>
 763:          ///
 764:          /// </summary>
 765:          private static string FormatEmsPortLstCommand(EmsOpcode amsOpcode, string dev, int fn, int sn)
 766:          {
 767:              string command;
 768:   
 769:              if (amsOpcode == EmsOpcode.LstPort)
 770:              {
 771:                  if (!string.IsNullOrWhiteSpace(dev))
 772:                  {
 773:                      command = "LST-PORT::DEV=" + dev + ",FN=" + fn + ",SN=" + sn + ":{ctag}::;";
 774:                  }
 775:                  else
 776:                  {
 777:                      command = string.Empty;
 778:                  }
 779:              }
 780:              else
 781:              {
 782:                  command = string.Empty;
 783:              }
 784:   
 785:              return PrepareCtaggedCommand(command);
 786:          }
 787:   
 788:          ////////////////////////////////////////////////////////////////////////////
 789:   
 790:          /// <summary>
 791:          ///
 792:          /// </summary>
 793:          private static string FormatEmsModCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 794:          {
 795:              int sn, pn, ontId;
 796:              string command;
 797:   
 798:              if (ont != null)
 799:              {
 800:                  if (amsOpcode == EmsOpcode.ModOntAlias)
 801:                  {
 802:                      // MOD-ONT::DEV=OLT-JHB-SAA-01,FN=0,SN=1,PN=1,ONTID=20:{ctag}::ALIAS=SAA.502.20;
 803:                      sn = ont.CardSlot;
 804:                      pn = ont.Port;
 805:                      ontId = ont.InternalNumber;
 806:   
 807:                      command = "MOD-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::ALIAS=" + ont.Access.Name + ";";
 808:                  }
 809:                  else if (amsOpcode == EmsOpcode.ModOntAliasAnnul)
 810:                  {
 811:                      // MOD-ONT::DEV=OLT-JHB-SAA-01,FN=0,SN=1,PN=1,ONTID=20:{ctag}::ALIAS=;
 812:                      sn = ont.CardSlot;
 813:                      pn = ont.Port;
 814:                      ontId = ont.InternalNumber;
 815:   
 816:                      command = "MOD-ONT::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=0,SN=" + sn + ",PN=" + pn + ",ONTID=" + ontId + ":{ctag}::ALIAS=;";
 817:                  }
 818:                  else
 819:                  {
 820:                      command = string.Empty;
 821:                  }
 822:              }
 823:              else
 824:              {
 825:                  command = string.Empty;
 826:              }
 827:   
 828:              return command;
 829:          }
 830:   
 831:          ////////////////////////////////////////////////////////////////////////////
 832:   
 833:          /// <summary>
 834:          ///
 835:          /// </summary>
 836:          private static string FormatEmsCfgOntVainDivCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service, int telPort)
 837:          {
 838:              string command, aid, impiOrPrividUser, sipSubscriberRegistrationPassword, emsEmpty;
 839:   
 840:              /*
 841:  CFG-ONTVAINDIV::DEV=OLT_01,FN=0,SN=1,PN=0,ONTID=2,SIPUSERNAME_2=+96524674071,SIPUSERPWD_2=admin,SIPNAME_2=+96524674071@ims.moc.kw:{ctag}::;
 842:  
 843:     7340032 2017-12-20 17:26:33
 844:  M  {ctag} COMPLD
 845:     EN=0   ENDESC=Succeeded.
 846:  ;
 847:  CFG-ONTVAINDIV::DEV=OLT-QRN-FUN-01,FN=0,SN=1,PN=1,ONTID=20,SIPUSERNAME_2=+96524674071,SIPUSERPWD_2=admin,SIPNAME_2=+96524674071@ims.moc.kw:{ctag}::;
 848:  CFG-ONTVAINDIV::DEV=OLT-QRN-FUN-01,FN=0,SN=1,PN=1,ONTID=20,SIPUSERNAME_2=a2,SIPUSERPWD_2=admin,SIPNAME_2=a2@ims.moc.kw:{ctag}::;
 849:  CFG-ONTVAINDIV::DEV=OLT-QRN-FUN-01,FN=0,SN=1,PN=1,ONTID=20,SIPUSERNAME_3=a3,SIPUSERPWD_3=admin,SIPNAME_3=a2@ims.moc.kw:{ctag}::;
 850:  CFG-ONTVAINDIV::DEV=OLT-QRN-FUN-01,FN=0,SN=1,PN=1,ONTID=20,SIPUSERNAME_4=a4,SIPUSERPWD_4=admin,SIPNAME_4=a2@ims.moc.kw:{ctag}::;
 851:  
 852:  CFG-ONTVAINDIV::DEV=OLT-JHB-JBA-01,FN=0,SN=1,PN=0,ONTID=2,SIPUSERNAME_1=--,SIPUSERPWD_1=--,SIPNAME_1=--:{ctag}::;
 853:  CFG-ONTVAINDIV::DEV=OLT-JHB-JBA-01,FN=0,SN=1,PN=0,ONTID=2,SIPUSERNAME_2=--,SIPUSERPWD_2=--,SIPNAME_2=--:{ctag}::;
 854:  CFG-ONTVAINDIV::DEV=OLT-JHB-JBA-01,FN=0,SN=1,PN=0,ONTID=2,SIPUSERNAME_3=--,SIPUSERPWD_3=--,SIPNAME_3=--:{ctag}::;
 855:  CFG-ONTVAINDIV::DEV=OLT-JHB-JBA-01,FN=0,SN=1,PN=0,ONTID=2,SIPUSERNAME_4=--,SIPUSERPWD_4=--,SIPNAME_4=--:{ctag}::;
 856:  */
 857:   
 858:              aid = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuAid(service); //"+965" + service
 859:   
 860:              // send priv_96525212254 for Nokia switch and +96524602283@ims.moc.kw for Huawei switch
 861:              if (ont.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 862:              {
 863:                  impiOrPrividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Impi(service);
 864:                  sipSubscriberRegistrationPassword = Ia.Ngn.Cl.Model.Business.Huawei.Ims.SipSubscriberRegistrationPassword;
 865:              }
 866:              else //if(ont.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 867:              {
 868:                  impiOrPrividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(service);
 869:                  sipSubscriberRegistrationPassword = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SipSubscriberRegistrationPassword;
 870:              }
 871:   
 872:              if (ont != null)
 873:              {
 874:                  if (amsOpcode == EmsOpcode.CfgOntVainDiv)
 875:                  {
 876:                      command = @"CFG-ONTVAINDIV::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=" + ont.Rack + ",SN=" + ont.CardSlot + ",PN=" + ont.Port + ",ONTID=" + ont.InternalNumber + ",SIPUSERNAME_" + telPort + "=" + aid + ",SIPUSERPWD_" + telPort + "=" + sipSubscriberRegistrationPassword + ",SIPNAME_" + telPort + "=" + impiOrPrividUser + ":{ctag}::;";
 877:                  }
 878:                  else if (amsOpcode == EmsOpcode.CfgOntVainDivVacant)
 879:                  {
 880:                      emsEmpty = "--"; // this means vacant
 881:                      // also SIPUSERPWD_n is "--"
 882:                      command = @"CFG-ONTVAINDIV::DEV=" + ont.Pon.PonGroup.Olt.EmsName + ",FN=" + ont.Rack + ",SN=" + ont.CardSlot + ",PN=" + ont.Port + ",ONTID=" + ont.InternalNumber + ",SIPUSERNAME_" + telPort + "=" + emsEmpty + ",SIPUSERPWD_" + telPort + "=" + emsEmpty + ",SIPNAME_" + telPort + "=" + emsEmpty + ":{ctag}::;";
 883:                  }
 884:                  else
 885:                  {
 886:                      command = string.Empty;
 887:                  }
 888:              }
 889:              else
 890:              {
 891:                  command = string.Empty;
 892:              }
 893:   
 894:              return PrepareCtaggedCommand(command);
 895:          }
 896:   
 897:          ////////////////////////////////////////////////////////////////////////////
 898:   
 899:          /// <summary>
 900:          ///
 901:          /// </summary>
 902:          private static string FormatEmsCfgVoipPstnAccountCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service, int sn, int telPort)
 903:          {
 904:              string command, aid, impiOrPrividUser, sipSubscriberRegistrationPassword, emsEmpty;
 905:   
 906:              /*
 907:  CFG-VOIPPSTNACCOUNT::DEV= MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::BINDINDEX=0,UserName=priv_96524602285,Password=1234;
 908:  CFG-VOIPPSTNACCOUNT::DEV= MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::BINDINDEX=0,UserName=--,Password=--;
 909:  */
 910:   
 911:              aid = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuAid(service); //"+965" + service
 912:   
 913:              // send priv_96525212254 for Nokia switch and +96524602283@ims.moc.kw for Huawei switch
 914:              if (ont.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 915:              {
 916:                  impiOrPrividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Impi(service);
 917:                  sipSubscriberRegistrationPassword = Ia.Ngn.Cl.Model.Business.Huawei.Ims.SipSubscriberRegistrationPassword;
 918:              }
 919:              else //if(ont.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 920:              {
 921:                  impiOrPrividUser = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(service);
 922:                  sipSubscriberRegistrationPassword = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SipSubscriberRegistrationPassword;
 923:              }
 924:   
 925:              if (ont != null)
 926:              {
 927:                  if (amsOpcode == EmsOpcode.CfgVoipPstnAccount)
 928:                  {
 929:                      // CFG-VOIPPSTNACCOUNT::DEV= MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::BINDINDEX=0,UserName= priv_96524602285,Password=1234;
 930:                      command = @"CFG-VOIPPSTNACCOUNT::DEV=" + mduDev.Dev + ",FN=" + ont.Rack + ",SN=" + sn + ",PN=" + telPort + ":{ctag}::BINDINDEX=0,UserName=" + impiOrPrividUser + ",Password=" + sipSubscriberRegistrationPassword + ";";
 931:                  }
 932:                  else //if (amsOpcode == EmsOpcode.CfgVoipPstnAccountVacant)
 933:                  {
 934:                      emsEmpty = "--"; // this means vacant
 935:                                       // also UserName is "--"
 936:                      command = @"CFG-VOIPPSTNACCOUNT::DEV=" + mduDev.Dev + ",FN=" + ont.Rack + ",SN=" + sn + ",PN=" + telPort + ":{ctag}::BINDINDEX=0,UserName=" + emsEmpty + ",Password=" + emsEmpty + ";";
 937:                  }
 938:              }
 939:              else
 940:              {
 941:                  command = string.Empty;
 942:              }
 943:   
 944:              return PrepareCtaggedCommand(command);
 945:          }
 946:   
 947:          ////////////////////////////////////////////////////////////////////////////
 948:   
 949:          /// <summary>
 950:          ///
 951:          /// </summary>
 952:          private static string FormatEmsVoipPstnUserCommand(EmsOpcode amsOpcode, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service, int sn, int telPort)
 953:          {
 954:              string command, serviceWithCountryCode;
 955:   
 956:              /*
 957:              Add new SIP number on MDU:
 958:              ADD-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::MGID=0,DN=96524602285;
 959:  
 960:              Delete SIP number from MDU:
 961:              DEL-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:7::;
 962:              */
 963:   
 964:              serviceWithCountryCode = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode(service);
 965:   
 966:              if (ont != null)
 967:              {
 968:                  if (amsOpcode == EmsOpcode.AddVoipPstnUser)
 969:                  {
 970:                      // ADD-VOIPPSTNUSER::DEV=MDU-MA5616-TEST-S,FN=0,SN=4,PN=1:{ctag}::MGID=0,DN=96524674072;
 971:                      // ADD-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::MGID=0,DN=96524602285;
 972:                      // PN IS TELPORT for MDU
 973:                      command = @"ADD-VOIPPSTNUSER::DEV=" + mduDev.Dev + ",FN=" + ont.Rack + ",SN=" + sn + ",PN=" + telPort + ":{ctag}::MGID=0,DN=" + serviceWithCountryCode + ";";
 974:                  }
 975:                  else if (amsOpcode == EmsOpcode.DelVoipPstnUser)
 976:                  {
 977:                      // DEL-VOIPPSTNUSER::DEV=MDU-MA5616-TEST-S,FN=0,SN=4,PN=1:7::;
 978:                      // PN IS TELPORT for MDU
 979:                      command = @"DEL-VOIPPSTNUSER::DEV=" + mduDev.Dev + ",FN=" + ont.Rack + ",SN=" + sn + ",PN=" + telPort + ":{ctag}::;";
 980:                  }
 981:                  else
 982:                  {
 983:                      command = string.Empty;
 984:                  }
 985:              }
 986:              else
 987:              {
 988:                  command = string.Empty;
 989:              }
 990:   
 991:              return PrepareCtaggedCommand(command);
 992:          }
 993:   
 994:          ////////////////////////////////////////////////////////////////////////////
 995:   
 996:          /// <summary>
 997:          /// Return a bool indicator as to weather the command is a CFG "slow" command
 998:          /// </summary>
 999:          public static bool IsACfgCommand(string command)
1000:          {
1001:              bool b;
1002:              string s;
1003:   
1004:              if (!string.IsNullOrEmpty(command))
1005:              {
1006:                  s = command.ToLower();
1007:                  b = s.Contains("cfg-ontvaindiv") || s.Contains("cfg-voippstnaccount");
1008:              }
1009:              else b = false;
1010:   
1011:              return b;
1012:          }
1013:   
1014:          ////////////////////////////////////////////////////////////////////////////
1015:   
1016:          /// <summary>
1017:          ///
1018:          /// </summary>
1019:          private static void EmsNameAndCardPortOntSquenceFromOntPosition(string ontPosition, out string amsName, out string pon)
1020:          {
1021:              Match match;
1022:   
1023:              if (!string.IsNullOrEmpty(ontPosition))
1024:              {
1025:                  // SUR-1-1-1-1-1;
1026:                  match = Regex.Match(ontPosition, @"([a-zA-Z]{3}\-\d{1,2}\-\d{1,2})\-(\d{1,2}\-\d{1,2}\-\d{1,2})");
1027:   
1028:                  amsName = match.Groups[1].Value;
1029:                  pon = match.Groups[2].Value;
1030:              }
1031:              else
1032:              {
1033:                  amsName = string.Empty;
1034:                  pon = string.Empty;
1035:              }
1036:          }
1037:   
1038:          ////////////////////////////////////////////////////////////////////////////
1039:   
1040:          /// <summary>
1041:          ///
1042:          /// </summary>
1043:          public static List<string> EmsCommandsToRetrieveOntAndOntSipInfoAndVoipPstnUserForASingleOntWithDefinedFamilyTypeAndForItIfThisSingleOntDefinedInNddDocumentList(string accessName)
1044:          {
1045:              List<string> l1, l2;
1046:              HashSet<string> list;
1047:   
1048:              l1 = EmsCommandToRetrieveSingleOntDefinedInNddDocumentList(accessName);
1049:   
1050:              l2 = EmsCommandsToRetrieveOntAndOntSipInfoAndVoipPstnUserForSingleOntsWithDefinedFamilyTypeOrDefinedMduDevList(accessName);
1051:   
1052:              list = new HashSet<string>();
1053:   
1054:              foreach (var i in l1) list.Add(i);
1055:              foreach (var i in l2) list.Add(i);
1056:   
1057:              return list.ToList();
1058:          }
1059:   
1060:          ////////////////////////////////////////////////////////////////////////////
1061:   
1062:          /// <summary>
1063:          ///
1064:          /// </summary>
1065:          public static List<string> EmsCommandsToRetrieveOntAndOntSipInfoWithDefinedFamilyType_EmsCommandsToRetrieveOntForOntsDefinedInNddDocument_EmsCommandsToUpdateAndRetrieveOntAliasWithItsAccessNameList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1066:          {
1067:              HashSet<string> hashSet1, hashSet2, hashSet3, hashSet;
1068:   
1069:              hashSet1 = new HashSet<string>(); //EmsCommandsToRetrieveOntForOntsDefinedInNddDocumentList(olt));
1070:   
1071:              hashSet2 = new HashSet<string>(EmsCommandsToRetrieveOntAndOntSipInfoWithDefinedFamilyTypeList(olt));
1072:   
1073:              hashSet3 = new HashSet<string>(); // EmsCommandsToUpdateAndRetrieveOntAliasWithItsAccessNameList(olt);
1074:   
1075:              hashSet = new HashSet<string>(hashSet1);
1076:              hashSet.UnionWith(hashSet2);
1077:              hashSet.UnionWith(hashSet3);
1078:   
1079:              return hashSet.Shuffle().ToList();
1080:          }
1081:   
1082:          ////////////////////////////////////////////////////////////////////////////
1083:   
1084:          /// <summary>
1085:          ///
1086:          /// </summary>
1087:          public static List<string> EmsCommandsToUpdateAndRetrieveOntAliasWithItsAccessNameList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1088:          {
1089:              string accessName, ontId, ontAlias;
1090:              List<string> list;
1091:              Dictionary<string, string> ontAccessIdToOntAccessNameDictionary;
1092:              Hashtable ontIdWithNullAccessHashtable;
1093:              //Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
1094:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1095:              //List<Ia.Ngn.Cl.Model.Ont> ontList;
1096:              Dictionary<string, string> ontIdToAliasForNonNullAccessDictionary;
1097:              Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontIdToOntDictionary;
1098:              list = null;
1099:   
1100:              ontAccessIdToOntAccessNameDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
1101:   
1102:              ontIdToAliasForNonNullAccessDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Ont.IdToAliasForNonNullAccessDictionary;
1103:   
1104:              ontIdWithNullAccessHashtable = Ia.Ngn.Cl.Model.Data.Huawei.Ont.IdWithNullAccessHashtable;
1105:   
1106:              ontIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntDictionary;
1107:   
1108:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1109:              {
1110:                  list = new List<string>();
1111:   
1112:                  //ontList = (from o in db.Onts where o.Access != null select o).ToList();
1113:   
1114:                  // insert descriptions for missing entries
1115:                  if (ontIdToAliasForNonNullAccessDictionary.Count > 0)
1116:                  {
1117:                      foreach (KeyValuePair<string, string> kvp in ontIdToAliasForNonNullAccessDictionary) //Ia.Ngn.Cl.Model.Ont ont in ontList)
1118:                      {
1119:                          ontId = kvp.Key;
1120:                          ontAlias = kvp.Value;
1121:   
1122:                          if (ontAccessIdToOntAccessNameDictionary.ContainsKey(ontId))
1123:                          {
1124:                              accessName = ontAccessIdToOntAccessNameDictionary[ontId];
1125:   
1126:                              if (ontAlias != accessName)
1127:                              {
1128:                                  // below: too slow needs to be changed
1129:                                  nddOnt = ontIdToOntDictionary[ontId]; // (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where nddo.Id == ont.Id select nddo).SingleOrDefault();
1130:   
1131:                                  if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
1132:                                  {
1133:                                      //familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId;
1134:   
1135:                                      list.Add(Ia.Ngn.Cl.Model.Business.Huawei.Ems.FormatEmsModCommand(EmsOpcode.ModOntAlias, nddOnt));
1136:                                  }
1137:                              }
1138:                              else
1139:                              {
1140:                              }
1141:                          }
1142:                      }
1143:                  }
1144:   
1145:                  // delete descriptions ONTs with missing access info
1146:                  if (ontIdWithNullAccessHashtable.Count > 0)
1147:                  {
1148:                      foreach (string _ontId in ontIdWithNullAccessHashtable.Keys)
1149:                      {
1150:                          if (ontIdToOntDictionary.ContainsKey(_ontId))
1151:                          {
1152:                              nddOnt = ontIdToOntDictionary[_ontId];
1153:   
1154:                              if (nddOnt.Pon.PonGroup.Olt.Id == olt.Id)
1155:                              {
1156:                                  list.Add(Ia.Ngn.Cl.Model.Business.Huawei.Ems.FormatEmsModCommand(EmsOpcode.ModOntAliasAnnul, nddOnt));
1157:                              }
1158:                          }
1159:                      }
1160:                  }
1161:              }
1162:   
1163:              return list.ToList();
1164:          }
1165:   
1166:          ////////////////////////////////////////////////////////////////////////////
1167:   
1168:          /// <summary>
1169:          ///
1170:          /// </summary>
1171:          private static List<string> EmsCommandToRetrieveSingleOntDefinedInNddDocumentList(string accessName)
1172:          {
1173:              List<string> list;
1174:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1175:   
1176:              list = new List<string>();
1177:   
1178:              if (!string.IsNullOrEmpty(accessName))
1179:              {
1180:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
1181:   
1182:                  if (nddOnt != null)
1183:                  {
1184:                      list.Add(FormatEmsLstCommand(EmsOpcode.LstOnt, nddOnt));
1185:                  }
1186:              }
1187:   
1188:              return list;
1189:          }
1190:   
1191:          ////////////////////////////////////////////////////////////////////////////
1192:   
1193:          /// <summary>
1194:          ///
1195:          /// </summary>
1196:          private static List<string> EmsCommandsToRetrieveOntForOntsDefinedInNddDocumentList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1197:          {
1198:              List<string> list;
1199:   
1200:              list = new List<string>();
1201:   
1202:              if (olt != null)
1203:              {
1204:                  foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
1205:                  {
1206:                      foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon in ponGroup.PonList)
1207:                      {
1208:                          foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in pon.OntList)
1209:                          {
1210:                              list.Add(FormatEmsLstCommand(EmsOpcode.LstOnt, ont));
1211:                          }
1212:                      }
1213:                  }
1214:              }
1215:   
1216:              return list;
1217:          }
1218:   
1219:          ////////////////////////////////////////////////////////////////////////////
1220:   
1221:          /// <summary>
1222:          ///
1223:          /// </summary>
1224:          private static List<string> EmsCommandsToRetrieveOntAndOntSipInfoAndVoipPstnUserForSingleOntsWithDefinedFamilyTypeOrDefinedMduDevList(string accessName)
1225:          {
1226:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
1227:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1228:              Ia.Ngn.Cl.Model.Huawei.EmsOnt ont;
1229:              List<string> list;
1230:   
1231:              list = new List<string>();
1232:   
1233:              if (!string.IsNullOrEmpty(accessName))
1234:              {
1235:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
1236:   
1237:                  if (nddOnt != null)
1238:                  {
1239:                      if (Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary.ContainsKey(nddOnt.Access.Name))
1240:                      {
1241:                          mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary[nddOnt.Access.Name];
1242:   
1243:                          list.Add(FormatEmsLstCommand(EmsOpcode.LstOnt, mduDev.Did));
1244:   
1245:                          list.Add(FormatEmsBoardLstCommand(EmsOpcode.LstBoard, mduDev.Dev, 0));
1246:   
1247:                          foreach (var fsSnPn in mduDev.PossibleFnSnPnList)
1248:                          {
1249:                              list.Add(FormatEmsLstVoipPstnUserCommand(EmsOpcode.LstVoipPstnUser, mduDev, nddOnt, fsSnPn.Sn, fsSnPn.Pn));
1250:                          }
1251:                      }
1252:                      else
1253:                      {
1254:                          ont = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
1255:   
1256:                          if (ont != null)
1257:                          {
1258:                              if (ont.FamilyType == Ont.FamilyType.Mdu)
1259:                              {
1260:                                  //list.Add(FormatEmsBoardLstCommand(EmsOpcode.LstBoard, ont.Dev, 0));
1261:                              }
1262:                              else
1263:                              {
1264:                                  list.Add(FormatEmsLstCommand(EmsOpcode.LstOnt, nddOnt));
1265:   
1266:                                  list.Add(FormatEmsLstCommand(EmsOpcode.LstOntSipInfo, nddOnt));
1267:                              }
1268:                          }
1269:                      }
1270:                  }
1271:              }
1272:   
1273:              return list;
1274:          }
1275:   
1276:          ////////////////////////////////////////////////////////////////////////////
1277:   
1278:          /// <summary>
1279:          ///
1280:          /// </summary>
1281:          private static List<string> EmsCommandsToRetrieveOntAndOntSipInfoWithDefinedFamilyTypeList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1282:          {
1283:              int did;
1284:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType;
1285:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1286:              List<string> list;
1287:              List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList;
1288:              List<Ia.Ngn.Cl.Model.Huawei.EmsOnt> ontList;
1289:   
1290:              list = new List<string>();
1291:   
1292:              if (olt != null)
1293:              {
1294:                  did = olt.Did;
1295:   
1296:                  if (did != 0)
1297:                  {
1298:                      ontList = Ia.Ngn.Cl.Model.Data.Huawei.Ont.ListByDid(did);
1299:                      nddOntList = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt == olt select o).ToList();
1300:   
1301:                      if (ontList != null && ontList.Count > 0 && nddOntList != null && nddOntList.Count > 0)
1302:                      {
1303:                          list = new List<string>(ontList.Count);
1304:   
1305:                          foreach (Ia.Ngn.Cl.Model.Huawei.EmsOnt ont in ontList)
1306:                          {
1307:                              equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentTypeFromString(ont.EQUIPMENTID);
1308:   
1309:                              if (ont.Access != null)
1310:                              {
1311:                                  nddOnt = (from o in nddOntList where o.Id == ont.Id select o).SingleOrDefault();
1312:   
1313:                                  if (nddOnt != null)
1314:                                  {
1315:                                      list.Add(FormatEmsLstCommand(EmsOpcode.LstOnt, nddOnt));
1316:   
1317:                                      list.Add(FormatEmsLstCommand(EmsOpcode.LstOntSipInfo, nddOnt));
1318:                                  }
1319:                                  else
1320:                                  {
1321:   
1322:                                  }
1323:                              }
1324:                          }
1325:                      }
1326:                      else
1327:                      {
1328:   
1329:                      }
1330:                  }
1331:                  else
1332:                  {
1333:   
1334:                  }
1335:              }
1336:              else
1337:              {
1338:   
1339:              }
1340:   
1341:              return list;
1342:          }
1343:   
1344:          ////////////////////////////////////////////////////////////////////////////
1345:   
1346:          /// <summary>
1347:          /// 
1348:          /// </summary>
1349:          public static int PossibleNumberOfTdForOntEquipmentType(int equipmentTypeId)
1350:          {
1351:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType;
1352:   
1353:              equipmentType = (Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType)equipmentTypeId;
1354:   
1355:              return PossibleNumberOfTdForOntEquipmentType(equipmentType);
1356:          }
1357:   
1358:          ////////////////////////////////////////////////////////////////////////////
1359:   
1360:          /// <summary>
1361:          /// 
1362:          /// </summary>
1363:          public static List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> PossibleFnSnPnForMduDevList(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mdu)
1364:          {
1365:              int count;
1366:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> list;
1367:   
1368:              list = new List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn>();
1369:   
1370:              if (mdu != null)
1371:              {
1372:                  foreach (var mduDevBoard in mdu.MduDevBoardList)
1373:                  {
1374:                      count = PossibleNumberOfTdForOntEquipmentType(mduDevBoard.EquipmentType);
1375:   
1376:                      for (int pn = 0; pn < count; pn++)
1377:                      {
1378:                          list.Add(new Default.FnSnPn { Fn = mduDevBoard.Fn, Sn = mduDevBoard.Sn, Pn = pn });
1379:                      }
1380:                  }
1381:              }
1382:   
1383:              return list;
1384:          }
1385:   
1386:          ////////////////////////////////////////////////////////////////////////////
1387:   
1388:          /// <summary>
1389:          /// 
1390:          /// </summary>
1391:          public static int PossibleNumberOfTdForOntEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
1392:          {
1393:              int number;
1394:   
1395:              switch (equipmentType)
1396:              {
1397:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: number = 2; break;
1398:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: number = 4; break;
1399:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: number = 32; break;
1400:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: number = 48; break;
1401:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: number = 64; break;
1402:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: number = 96; break;
1403:   
1404:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16: number = 16; break;
1405:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32: number = 32; break;
1406:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48: number = 48; break;
1407:   
1408:                  default: number = 0; break;
1409:              }
1410:   
1411:              return number;
1412:          }
1413:   
1414:          ////////////////////////////////////////////////////////////////////////////
1415:   
1416:          /// <summary>
1417:          /// 
1418:          /// </summary>
1419:          public static int PossibleNumberOfHsiServiceForOntEquipmentType(int equipmentTypeId)
1420:          {
1421:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType;
1422:   
1423:              equipmentType = (Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType)equipmentTypeId;
1424:   
1425:              return PossibleNumberOfHsiServiceForOntEquipmentType(equipmentType);
1426:          }
1427:   
1428:          ////////////////////////////////////////////////////////////////////////////
1429:   
1430:          /// <summary>
1431:          /// 
1432:          /// </summary>
1433:          public static int PossibleNumberOfHsiServiceForOntEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
1434:          {
1435:              int number;
1436:   
1437:              switch (equipmentType)
1438:              {
1439:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: number = 4; break;
1440:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: number = 4; break;
1441:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: number = 8; break;
1442:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: number = 8; break;
1443:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: number = 8; break;
1444:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: number = 8; break;
1445:   
1446:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16: number = 8; break;
1447:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32: number = 8; break;
1448:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48: number = 8; break;
1449:   
1450:                  default: number = 0; break;
1451:              }
1452:   
1453:              return number;
1454:          }
1455:   
1456:          /*
1457:          ////////////////////////////////////////////////////////////////////////////
1458:  
1459:          /// <summary>
1460:          /// Return the ONT family type from the software version
1461:          /// </summary>
1462:          public static Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType FamilyType(string activeSoftware, string plannedSoftware)
1463:          {
1464:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType;
1465:  
1466:              if (activeSoftware != null)
1467:              {
1468:                  if (activeSoftware == plannedSoftware)
1469:                  {
1470:                      if (activeSoftware.Contains("3FE508")) familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu;
1471:                      else if (activeSoftware.Contains("3FE511")) familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Soho;
1472:                      else if (activeSoftware.Contains("3FE514")) familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu;
1473:                      else familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Undefined;
1474:                  }
1475:                  else familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Undefined;
1476:              }
1477:              else familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Undefined;
1478:  
1479:              return familyType;
1480:          }
1481:          */
1482:   
1483:          ////////////////////////////////////////////////////////////////////////////
1484:   
1485:          /// <summary>
1486:          ///
1487:          /// </summary>
1488:          public static bool UpdateDatabaseWithEmsCommandOutput(string rowData, ref Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, out Ia.Cl.Model.Result result)
1489:          {
1490:              bool b;
1491:              Ia.Ngn.Cl.Model.Business.Huawei.Ems.Response response;
1492:   
1493:              b = false;
1494:              result = new Ia.Cl.Model.Result();
1495:   
1496:              // below: remove all '\' characters from rowData and reset NULL comments to ""
1497:              rowData = rowData.Replace(@"\", "");
1498:              rowData = rowData.Replace(@"NULL", "");
1499:   
1500:              response = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ParseResponse(rowData); // Ia.Cl.Model.Default.GenerateDataTableFromTabDelimitedText(rowData, out result);
1501:   
1502:              // don't use if (response.QueryCommand) because if resource did not exist it will set Query command to false
1503:   
1504:              if (response.CompletionCode == "COMPLD")
1505:              {
1506:                  if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-DEV:"))
1507:                  {
1508:                      if (response.QueryDataTable != null)
1509:                      {
1510:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Dev.Update(response, out result);
1511:                      }
1512:                      else result.AddWarning(response.Endesc);
1513:                  }
1514:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-BOARD:"))
1515:                  {
1516:                      if (response.QueryDataTable != null)
1517:                      {
1518:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Board.Update(response, out result);
1519:                      }
1520:                      else result.AddWarning(response.Endesc);
1521:                  }
1522:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-PORT:"))
1523:                  {
1524:                      if (response.QueryDataTable != null)
1525:                      {
1526:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Port.Update(response, out result);
1527:                      }
1528:                      else result.AddWarning(response.Endesc);
1529:                  }
1530:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-ONT:"))
1531:                  {
1532:                      if (Regex.IsMatch(response.CommandFromCorrelationTagDictionaryByCtag, @"LST-ONT::DEV=(.+?),FN=(\d+),SN=(\d+),PN=(\d+),ONTID=(\d+):"))
1533:                      {
1534:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Update(response, out result);
1535:                      }
1536:                      else if (Regex.IsMatch(response.CommandFromCorrelationTagDictionaryByCtag, @"LST-ONT::DEV=(.+?),FN=(\d+),SN=(\d+),PN=(\d+):"))
1537:                      {
1538:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Ont.UpdateList(response, out result);
1539:                      }
1540:                      else if (Regex.IsMatch(response.CommandFromCorrelationTagDictionaryByCtag, @"LST-ONT::DID=(\d+):"))
1541:                      {
1542:                          b = Ia.Ngn.Cl.Model.Data.Huawei.Ont.UpdateListWithDid(response, out result);
1543:                      }
1544:                      else
1545:                      {
1546:                          b = false;
1547:                      }
1548:                  }
1549:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-ONTSIPINFO:"))
1550:                  {
1551:                      if (response.QueryDataTable != null)
1552:                      {
1553:                          b = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.Update(response, out result);
1554:                      }
1555:                      else result.AddWarning(response.Endesc);
1556:                  }
1557:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("CFG-ONTVAINDIV:"))
1558:                  {
1559:                      result.AddSuccess(response.Endesc);
1560:                  }
1561:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LST-VOIPPSTNUSER:"))
1562:                  {
1563:                      if (response.QueryDataTable != null)
1564:                      {
1565:                          b = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.Update(response, out result);
1566:                      }
1567:                      else result.AddWarning(response.Endesc);
1568:                  }
1569:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("ADD-VOIPPSTNUSER:"))
1570:                  {
1571:                      result.AddSuccess(response.Endesc);
1572:                  }
1573:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("CFG-VOIPPSTNACCOUNT:"))
1574:                  {
1575:                      result.AddSuccess(response.Endesc);
1576:                  }
1577:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("SHAKEHAND:"))
1578:                  {
1579:                      result.AddSuccess(response.Endesc);
1580:                  }
1581:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LOGIN:"))
1582:                  {
1583:                      ems.IsLoggedIn = true;
1584:   
1585:                      result.AddSuccess(response.Endesc);
1586:                  }
1587:                  else if (response.CommandFromCorrelationTagDictionaryByCtag.Contains("LOGOUT:"))
1588:                  {
1589:                      ems.IsLoggedIn = false;
1590:   
1591:                      result.AddSuccess(response.Endesc);
1592:                  }
1593:                  else
1594:                  {
1595:                      result.AddWarning("No designated opcode to process");
1596:   
1597:                      b = false;
1598:                  }
1599:              }
1600:              else
1601:              {
1602:                  result.AddWarning(response.Endesc);
1603:   
1604:                  b = false;
1605:              }
1606:   
1607:              return b;
1608:          }
1609:   
1610:          ////////////////////////////////////////////////////////////////////////////
1611:   
1612:          /// <summary>
1613:          /// Parse the U2000 TL1 NBI response by approximatly following the "10.3 Response Format Description standard" in iManager U2000 Unified Network Management System Guide.
1614:          /// </summary>
1615:          public static Response ParseResponse(string rowData)
1616:          {
1617:              bool attributeFirstGroupFlag;
1618:              int blockTag, currentBlockCount, totalCount;
1619:              string header, responseIdentification, textBlock, Endesc, terminator, quotedLine, result, title, attributeValueStringList, ctag, completionCode;
1620:              DataTable dataTable;
1621:              MatchCollection matchCollection;
1622:              Ia.Ngn.Cl.Model.Business.Huawei.Ems.Response response;
1623:              List<string> attributeList;
1624:              List<List<string>> valueListList;
1625:              Dictionary<string, string> attributeValueDictionary;
1626:   
1627:              blockTag = currentBlockCount = totalCount = 0;
1628:   
1629:              title = string.Empty;
1630:              Endesc = string.Empty;
1631:              ctag = string.Empty;
1632:              completionCode = string.Empty;
1633:   
1634:              response = new Response();
1635:   
1636:              attributeList = new List<string>(100);
1637:              valueListList = new List<List<string>>(100);
1638:              attributeValueDictionary = new Dictionary<string, string>(100);
1639:   
1640:              matchCollection = Regex.Matches(rowData, @"(\r\n\n   \d+? \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)(\r\nM  [\w\d]+? [\w\d]+?)(\r\n   EN=.+?   ENDESC=.+?)(\r\n[;>])", RegexOptions.Singleline);
1641:              //                                         header                                           response identification   text block                  terminator
1642:   
1643:              foreach (Match match in matchCollection)
1644:              {
1645:                  header = match.Groups[1].Value;
1646:                  responseIdentification = match.Groups[2].Value;
1647:                  textBlock = match.Groups[3].Value;
1648:                  terminator = match.Groups[4].Value;
1649:   
1650:                  if (!string.IsNullOrEmpty(responseIdentification))
1651:                  {
1652:                      matchCollection = Regex.Matches(responseIdentification, @"^\r\nM  ([\w\d]+?) ([\w\d]+?)$", RegexOptions.Singleline);
1653:   
1654:                      foreach (Match match9 in matchCollection)
1655:                      {
1656:                          ctag = match9.Groups[1].Value;
1657:                          completionCode = match9.Groups[2].Value;
1658:   
1659:                          if (!string.IsNullOrEmpty(textBlock))
1660:                          {
1661:                              matchCollection = Regex.Matches(textBlock, @"^\r\n   EN=.+?   ENDESC=(.+?)\r\n   (.+?\r\n)$", RegexOptions.Singleline); // if you do (.+?)$ you will not match the last \n
1662:   
1663:                              if (matchCollection.Count > 0)
1664:                              {
1665:                                  foreach (Match match2 in matchCollection)
1666:                                  {
1667:                                      Endesc = match2.Groups[1].Value;
1668:                                      quotedLine = match2.Groups[2].Value;
1669:   
1670:                                      if (!string.IsNullOrEmpty(quotedLine))
1671:                                      {
1672:                                          response.QueryCommand = true;
1673:   
1674:                                          matchCollection = Regex.Matches(quotedLine, @"^blktag=(.+?)\r\n   blkcount=(.+?)\r\n   blktotal=(.+?)\r\n(.+?\r\n)$", RegexOptions.Singleline); // if you do (.+?)$ you will not match the last \n
1675:   
1676:                                          foreach (Match match3 in matchCollection)
1677:                                          {
1678:                                              blockTag = int.Parse(match3.Groups[1].Value);
1679:                                              currentBlockCount = int.Parse(match3.Groups[2].Value);
1680:                                              totalCount = int.Parse(match3.Groups[3].Value);
1681:   
1682:                                              result = match3.Groups[4].Value;
1683:   
1684:                                              if (!string.IsNullOrEmpty(result))
1685:                                              {
1686:                                                  matchCollection = Regex.Matches(result, @"^\r\n(.+?)\r\n-*\r\n(.+?\r\n)-*\r\n\r\n$", RegexOptions.Singleline);
1687:   
1688:                                                  foreach (Match match4 in matchCollection)
1689:                                                  {
1690:                                                      title = match4.Groups[1].Value;
1691:   
1692:                                                      attributeValueStringList = match4.Groups[2].Value;
1693:   
1694:                                                      if (!string.IsNullOrEmpty(attributeValueStringList))
1695:                                                      {
1696:                                                          matchCollection = Regex.Matches(attributeValueStringList, @"(.+?)\r\n", RegexOptions.Singleline);
1697:   
1698:                                                          attributeFirstGroupFlag = true;
1699:   
1700:                                                          foreach (Match match5 in matchCollection)
1701:                                                          {
1702:                                                              if (attributeFirstGroupFlag)
1703:                                                              {
1704:                                                                  attributeList = new List<string>(Regex.Split(match5.Groups[1].Value, @"\t"));
1705:   
1706:                                                                  attributeFirstGroupFlag = false;
1707:                                                              }
1708:                                                              else valueListList.Add(new List<string>(Regex.Split(match5.Groups[1].Value, @"\t")));
1709:                                                          }
1710:                                                      }
1711:                                                  }
1712:                                              }
1713:                                          }
1714:                                      }
1715:                                      else
1716:                                      {
1717:                                          response.QueryCommand = false;
1718:                                      }
1719:                                  }
1720:                              }
1721:                              else
1722:                              {
1723:                                  matchCollection = Regex.Matches(textBlock, @"^\r\n   EN=.+?   ENDESC=(.+?)$", RegexOptions.Singleline); // if you do (.+?)$ you will not match the last \n
1724:   
1725:                                  foreach (Match match6 in matchCollection)
1726:                                  {
1727:                                      Endesc = match6.Groups[1].Value;
1728:                                  }
1729:                              }
1730:                          }
1731:                      }
1732:                  }
1733:              }
1734:   
1735:              // build datatable
1736:   
1737:              dataTable = new DataTable();
1738:              dataTable.Clear();
1739:   
1740:              if (attributeList.Count > 0)
1741:              {
1742:                  foreach (string attribute in attributeList) dataTable.Columns.Add(attribute);
1743:   
1744:                  if (valueListList.Count > 0)
1745:                  {
1746:                      if (attributeList.Count == valueListList[0].Count)
1747:                      {
1748:                          foreach (List<string> valuelist in valueListList)
1749:                          {
1750:                              dataTable.Rows.Add(valuelist.ToArray());
1751:                          }
1752:                      }
1753:                      else
1754:                      {
1755:                          throw new Exception("ParseResponse(): attributeList.Count != valueListList[0].Count");
1756:                      }
1757:                  }
1758:              }
1759:              else dataTable = null;
1760:   
1761:              response.BlockTag = blockTag;
1762:              response.CurrentBlockCount = currentBlockCount;
1763:              response.TotalCount = totalCount;
1764:   
1765:              response.Title = title;
1766:              response.Endesc = Endesc;
1767:              response.Ctag = ctag;
1768:              response.CompletionCode = completionCode;
1769:              response.QueryDataTable = dataTable;
1770:   
1771:              return response;
1772:          }
1773:   
1774:          ////////////////////////////////////////////////////////////////////////////    
1775:          ////////////////////////////////////////////////////////////////////////////    
1776:      }
1777:   
1778:      ////////////////////////////////////////////////////////////////////////////
1779:      ////////////////////////////////////////////////////////////////////////////   
1780:  }