)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » U2000

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

Optical Fiber Network Management Intranet Portal (OFN) support class for Huawei's Next Generation Network (NGN) business model

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Configuration;
   4:  using System.Diagnostics;
   5:  using System.Linq;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Business.Huawei
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Optical Fiber Network Management Intranet Portal (OFN) support class for Huawei's Next Generation Network (NGN) business model
  13:      /// </summary>
  14:      /// 
  15:      /// <value>
  16:      /// - Add Service Reference to ims.api.huawei
  17:      /// - Make sure web.config or app.config as:
  18:      ///   <system.serviceModel>
  19:      ///     <bindings>
  20:      ///        <basicHttpBinding>
  21:      ///           <binding name="ATSV100R003C01SPC100Binding" />
  22:      ///        </basicHttpBinding>
  23:      ///      </bindings>
  24:      ///      <client>
  25:      ///        <endpoint address="http://*.*.*.*:8080/spg" binding="basicHttpBinding" bindingConfiguration="ATSV100R003C01SPC100Binding" contract="ims.api.huawei.ATSV100R003C01SPC100" name="ATSV100R003C01SPC100Port" />
  26:      ///      </client>
  27:      ///   </system.serviceModel>
  28:      ///                        
  29:      /// - Add:
  30:      ///  <appSettings>
  31:      ///     <add key="u2000HuaweiServerUser" value="*" />
  32:      ///     <add key="u2000HuaweiServerUserPassword" value="*" />
  33:      ///   </appSettings>
  34:      /// </value>
  35:      /// 
  36:      /// <remarks> 
  37:      /// Copyright © 2014-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  38:      ///
  39:      /// 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
  40:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  41:      ///
  42:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  43:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  44:      /// 
  45:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  46:      /// 
  47:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  48:      /// </remarks> 
  49:      public class U2000
  50:      {
  51:          private static readonly Dictionary<string, int> associateServiceIdAndPortBetweenCreateAndReadDictionary = new Dictionary<string, int>();
  52:          private static readonly Procedure createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(72, Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
  53:          private static readonly Procedure createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(0, Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
  54:          private static readonly Procedure updateEmsOntFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.EmsOntToBeUpdatedFromH248ToSipList);
  55:          private static readonly Procedure createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList);
  56:          private static Ia.Ngn.Cl.Model.Client.Huawei.Ems ems = new Ia.Ngn.Cl.Model.Client.Huawei.Ems();
  57:   
  58:          /// <summary/>
  59:          public static string UserName { get { return ConfigurationManager.AppSettings["u2000HuaweiServerUser"].ToString(); } }
  60:   
  61:          /// <summary/>
  62:          public static string Password { get { return ConfigurationManager.AppSettings["u2000HuaweiServerUserPassword"].ToString(); } }
  63:   
  64:   
  65:          ////////////////////////////////////////////////////////////////////////////
  66:   
  67:          /// <summary>
  68:          ///
  69:          /// </summary>
  70:          public U2000()
  71:          {
  72:          }
  73:   
  74:          ////////////////////////////////////////////////////////////////////////////
  75:   
  76:          /// <summary>
  77:          ///
  78:          /// </summary>
  79:          public static void Connect(out Ia.Cl.Model.Result result)
  80:          {
  81:              if (ems != null && !ems.IsConnected)
  82:              {
  83:                  ems.Connect(out result);
  84:              }
  85:              else
  86:              {
  87:                  result = new Ia.Cl.Model.Result();
  88:   
  89:                  result.AddWarning("Warning: ems is already connected. ");
  90:              }
  91:          }
  92:   
  93:          ////////////////////////////////////////////////////////////////////////////
  94:   
  95:          /// <summary>
  96:          ///
  97:          /// </summary>
  98:          public static void Disconnect(out Ia.Cl.Model.Result result)
  99:          {
 100:              if (ems != null && ems.IsConnected)
 101:              {
 102:                  ems.Disconnect(out result);
 103:              }
 104:              else
 105:              {
 106:                  result = new Ia.Cl.Model.Result();
 107:   
 108:                  result.AddWarning("Warning: ems is already disconnected. ");
 109:              }
 110:          }
 111:   
 112:          ////////////////////////////////////////////////////////////////////////////
 113:   
 114:          /// <summary>
 115:          ///
 116:          /// </summary>
 117:          public static void Login()
 118:          {
 119:              ems.Login();
 120:          }
 121:   
 122:          ////////////////////////////////////////////////////////////////////////////
 123:   
 124:          /// <summary>
 125:          ///
 126:          /// </summary>
 127:          public static void Logout()
 128:          {
 129:              ems.Logout();
 130:          }
 131:   
 132:          ////////////////////////////////////////////////////////////////////////////
 133:   
 134:          /// <summary>
 135:          ///
 136:          /// </summary>
 137:          public static Queue<string> ReceiveQueue
 138:          {
 139:              get
 140:              {
 141:                  return ems.ReceiveQueue;
 142:              }
 143:          }
 144:   
 145:          ////////////////////////////////////////////////////////////////////////////
 146:   
 147:          /// <summary>
 148:          ///
 149:          /// </summary>
 150:          public static Queue<string> SendQueue
 151:          {
 152:              get
 153:              {
 154:                  return ems.SendQueue;
 155:              }
 156:          }
 157:   
 158:          ////////////////////////////////////////////////////////////////////////////
 159:   
 160:          /// <summary>
 161:          ///
 162:          /// </summary>
 163:          public static bool IsConnected
 164:          {
 165:              get
 166:              {
 167:                  return ems.IsConnected;
 168:              }
 169:          }
 170:   
 171:          ////////////////////////////////////////////////////////////////////////////
 172:   
 173:          /// <summary>
 174:          ///
 175:          /// </summary>
 176:          public static bool IsLoggedIn
 177:          {
 178:              get
 179:              {
 180:                  return ems.IsLoggedIn;
 181:              }
 182:          }
 183:   
 184:          ////////////////////////////////////////////////////////////////////////////
 185:   
 186:          /// <summary>
 187:          ///
 188:          /// </summary>
 189:          public static void Dispose()
 190:          {
 191:              ems.Dispose();
 192:          }
 193:   
 194:          ////////////////////////////////////////////////////////////////////////////
 195:   
 196:          /// <summary>
 197:          ///
 198:          /// </summary>
 199:          public static void ProcessReceiveQueue(out Ia.Cl.Model.Result result)
 200:          {
 201:              string rowString, formattedString;
 202:   
 203:              result = new Ia.Cl.Model.Result();
 204:   
 205:              try
 206:              {
 207:                  Debug.WriteLine("--------------------------------------");
 208:                  Debug.WriteLine("ProcessReceiveQueue(): receiveQueue.Count: " + ems.ReceiveQueue.Count);
 209:   
 210:                  while (ems.ReceiveQueue.Count > 0)
 211:                  {
 212:                      rowString = ems.ReceiveQueue.Dequeue();
 213:   
 214:                      formattedString = rowString;
 215:   
 216:                      Debug.WriteLine("ProcessReceiveQueue(): formattedString: " + formattedString);
 217:   
 218:                      ems.Update(formattedString, ref ems, out Ia.Cl.Model.Result r);
 219:   
 220:                      result.AddResult(r);
 221:                      //result.AddWarning("Debugging: Start --------------------------------------");
 222:                      //result.AddWarning(rowString);
 223:                      //result.AddWarning("Debugging: End ----------------------------------------");
 224:                  }
 225:   
 226:                  Debug.WriteLine("--------------------------------------");
 227:              }
 228:              catch (Exception ex)
 229:              {
 230:                  result.AddError("ProcessReceiveQueue(): Exception: " + ex.Message);
 231:              }
 232:          }
 233:   
 234:          ////////////////////////////////////////////////////////////////////////////
 235:   
 236:          /// <summary>
 237:          ///
 238:          /// </summary>
 239:          public static string ProcessSendQueue(out Ia.Cl.Model.Result result)
 240:          {
 241:              bool skipSleep;
 242:              string command;
 243:   
 244:              skipSleep = true;
 245:              command = string.Empty;
 246:              result = new Ia.Cl.Model.Result();
 247:   
 248:              try
 249:              {
 250:                  Debug.WriteLine("--------------------------------------");
 251:                  Debug.WriteLine("ProcessSendQueue(): sendQueue.Count: " + ems.SendQueue.Count);
 252:   
 253:                  if (ems.SendQueue.Count > 0)
 254:                  {
 255:                      command = ems.SendQueue.Dequeue();
 256:   
 257:                      ems.Send(command, skipSleep, out Ia.Cl.Model.Result r);
 258:   
 259:                      if (r.IsSuccessful) result.AddSuccess(r.Message);
 260:                      else result.AddError(r.Message);
 261:                  }
 262:   
 263:                  Debug.WriteLine("--------------------------------------");
 264:              }
 265:              catch (Exception ex)
 266:              {
 267:                  result.AddError("ProcessSendQueue(): Exception: " + ex.Message);
 268:              }
 269:   
 270:              return result.IsSuccessful ? command : string.Empty;
 271:          }
 272:   
 273:          ////////////////////////////////////////////////////////////////////////////
 274:          ////////////////////////////////////////////////////////////////////////////
 275:   
 276:          /// <summary>
 277:          ///
 278:          /// </summary>
 279:          public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, string portString, bool ignoreRestrictions, out Ia.Cl.Model.Result result)
 280:          {
 281:              int serviceType, port;
 282:              string serviceId;
 283:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 284:   
 285:              result = new Ia.Cl.Model.Result();
 286:   
 287:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService;
 288:   
 289:              try
 290:              {
 291:                  if (!string.IsNullOrEmpty(service))
 292:                  {
 293:                      serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 294:   
 295:                      if (!string.IsNullOrEmpty(accessName))
 296:                      {
 297:                          port = int.TryParse(portString, out int i) ? i : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 298:   
 299:                          nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
 300:   
 301:                          if (nddOnt != null)
 302:                          {
 303:                              if (Service.NumberIsWithinAllowedDomainList(service))
 304:                              {
 305:                                  Ia.Ngn.Cl.Model.Business.Huawei.U2000.CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, nddOnt, port, ignoreRestrictions, ref result);
 306:                              }
 307:                              else result.AddError("Service number does not belong to allowed domain lists");
 308:                          }
 309:                          else result.AddError("NDD ONT is null for access name: " + accessName);
 310:                      }
 311:                      else
 312:                      {
 313:                          result.AddError("AccessName null or empty");
 314:                      }
 315:                  }
 316:                  else
 317:                  {
 318:                      result.AddError("Service null or empty");
 319:                  }
 320:              }
 321:              catch (Exception ex)
 322:              {
 323:                  result.AddError("Exception: " + ex.ToString());
 324:              }
 325:          }
 326:   
 327:          ////////////////////////////////////////////////////////////////////////////
 328:   
 329:          /// <summary>
 330:          ///
 331:          /// </summary>
 332:          public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, bool ignoreRestrictions, ref Ia.Cl.Model.Result result)
 333:          {
 334:              int pn;
 335:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
 336:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 337:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 338:              Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo emsOntSipInfo;
 339:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 340:   
 341:              if (nddOnt != null)
 342:              {
 343:                  if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt) || ignoreRestrictions)
 344:                  {
 345:                      emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 346:   
 347:                      if (emsOnt != null)
 348:                      {
 349:                          if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 350:                          {
 351:                              if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 352:                              {
 353:                                  pn = port;
 354:   
 355:                                  if (Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
 356:                                  {
 357:                                      mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary[nddOnt.Access.Name];
 358:   
 359:                                      var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mduDev, emsOnt);
 360:   
 361:                                      if (pn != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 362:                                      {
 363:                                          fnSnPn = vacantFnSnPnList.Where(f => f.Pn == pn).SingleOrDefault();
 364:                                      }
 365:                                      else fnSnPn = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mduDev, emsOnt);
 366:   
 367:                                      if (fnSnPn != null)
 368:                                      {
 369:                                          emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 370:   
 371:                                          if (emsVoipPstnUser == null)
 372:                                          {
 373:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, mduDev, nddOnt, service, fnSnPn.Sn, fnSnPn.Pn);
 374:   
 375:                                              if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 376:                                              {
 377:                                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, mduDev, nddOnt, service, fnSnPn.Sn, fnSnPn.Pn);
 378:                                              }
 379:   
 380:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
 381:   
 382:                                              associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = fnSnPn.Pn;
 383:                                          }
 384:                                          else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 385:                                      }
 386:                                      else result.AddError("MDU sn and/or tel is invalid or does not exist. ");
 387:                                  }
 388:                                  else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 389:   
 390:                                  /*
 391:                                  tel = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduTelPortForOnt(emsOnt);
 392:  
 393:                                  if (tel != -1)
 394:                                  {
 395:                                      emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 396:  
 397:                                      if (emsVoipPstnUser == null)
 398:                                      {
 399:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, emsOnt.FamilyType, service, tel, nddOnt);
 400:  
 401:                                          if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 402:                                          {
 403:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, emsOnt.FamilyType, service, tel, nddOnt);
 404:                                          }
 405:  
 406:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, tel, nddOnt);
 407:                                      }
 408:                                      else
 409:                                      {
 410:                                          result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 411:                                      }
 412:                                  }
 413:                                  else
 414:                                  {
 415:                                      result.AddError("MDU tel is invalid or does not exist. ");
 416:                                  }
 417:                                  */
 418:                              }
 419:                              else // if not MDU
 420:                              {
 421:                                  var vacantList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantTelForOntList(emsOnt);
 422:   
 423:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 424:                                  {
 425:                                      port = vacantList.Contains(port) ? port : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 426:                                  }
 427:                                  else port = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
 428:   
 429:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 430:                                  {
 431:                                      emsOntSipInfo = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
 432:   
 433:                                      if (emsOntSipInfo == null)
 434:                                      {
 435:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateOntSipInfo(ems, nddOnt, service, port);
 436:   
 437:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 438:   
 439:                                          associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = port;
 440:                                      }
 441:                                      else result.AddError("emsOntSipInfo != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 442:                                  }
 443:                                  else result.AddError("telPort is invalid or does not exist. ");
 444:                              }
 445:                          }
 446:                          else  // if H.248
 447:                          {
 448:                              result.AddError("OLT is not SIP");
 449:                          }
 450:                      }
 451:                      else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name);
 452:                  }
 453:                  else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 454:              }
 455:              else result.AddError("nddOnt is null, does not exist for service: " + service);
 456:          }
 457:   
 458:          ////////////////////////////////////////////////////////////////////////////
 459:   
 460:          /// <summary>
 461:          ///
 462:          /// </summary>
 463:          public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, string portString, out Ia.Cl.Model.Result result)
 464:          {
 465:              int port, serviceType;
 466:              string serviceId;
 467:   
 468:              result = new Ia.Cl.Model.Result();
 469:   
 470:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService;
 471:   
 472:              try
 473:              {
 474:                  if (!string.IsNullOrEmpty(service))
 475:                  {
 476:                      serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 477:   
 478:                      if (!string.IsNullOrEmpty(accessName))
 479:                      {
 480:                          port = int.TryParse(portString, out int i) ? i : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 481:   
 482:                          var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
 483:   
 484:                          if (nddOnt != null)
 485:                          {
 486:                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(service))
 487:                              {
 488:                                  Ia.Ngn.Cl.Model.Business.Huawei.U2000.ReadOntSipInfoOrVoipPstnUser(service, nddOnt, port, ref result);
 489:                              }
 490:                              else result.AddError("Service number does not belong to allowed domain lists");
 491:                          }
 492:                          else result.AddError("NDD ONT is null for access name: " + accessName);
 493:                      }
 494:                      else
 495:                      {
 496:                          result.AddError("AccessName null or empty");
 497:                      }
 498:                  }
 499:                  else
 500:                  {
 501:                      result.AddError("Service null or empty");
 502:                  }
 503:              }
 504:              catch (Exception ex)
 505:              {
 506:                  result.AddError("Exception: " + ex.ToString());
 507:              }
 508:          }
 509:   
 510:          ////////////////////////////////////////////////////////////////////////////
 511:   
 512:          /// <summary>
 513:          ///
 514:          /// </summary>
 515:          public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Model.Result result)
 516:          {
 517:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 518:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 519:              //Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 520:   
 521:              if (nddOnt != null)
 522:              {
 523:                  emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 524:   
 525:                  if (emsOnt != null)
 526:                  {
 527:                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 528:                      {
 529:                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
 530:                          {
 531:                              mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary[nddOnt.Access.Name];
 532:   
 533:                              //emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 534:   
 535:                              //if (emsVoipPstnUser == null)
 536:                              //{
 537:                              if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 538:                              {
 539:                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, mduDev.FirstFnSnPn.Sn, port);
 540:                              }
 541:                              else if (associateServiceIdAndPortBetweenCreateAndReadDictionary.ContainsKey(service))
 542:                              {
 543:                                  port = associateServiceIdAndPortBetweenCreateAndReadDictionary[service];
 544:   
 545:                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, mduDev.FirstFnSnPn.Sn, port);
 546:                              }
 547:                              else
 548:                              {
 549:                                  foreach (var fsSnPn in mduDev.PossibleFnSnPnList)
 550:                                  {
 551:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, fsSnPn.Sn, fsSnPn.Pn);
 552:                                  }
 553:                              }
 554:                              //}
 555:                              //else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 556:                          }
 557:                          else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 558:   
 559:                          /*
 560:                          possibleNumberOfTd = Ia.Ngn.Cl.Model.Business.Huawei.Ems.PossibleNumberOfTdForOntEquipmentType(emsOnt.EquipmentType);
 561:  
 562:                          for (int tel = 0; tel < possibleNumberOfTd; tel++) // incorrect
 563:                          {
 564:                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, nddOnt, sn, tel);
 565:                          }
 566:                          */
 567:                      }
 568:                      else // if not MDU
 569:                      {
 570:                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 571:                      }
 572:   
 573:                      //Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(service); causes number to keep on appearing in service-request if the ONT is offline
 574:                  }
 575:                  else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name);
 576:              }
 577:              else result.AddError("nddOnt is null, does not exist for service: " + service);
 578:          }
 579:   
 580:          ////////////////////////////////////////////////////////////////////////////
 581:   
 582:          /// <summary>
 583:          ///
 584:          /// </summary>
 585:          public static void DeleteOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, string portString, bool ignoreRestrictions, out Ia.Cl.Model.Result result)
 586:          {
 587:              int port, serviceType;
 588:              string serviceId;
 589:   
 590:              result = new Ia.Cl.Model.Result();
 591:   
 592:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService;
 593:   
 594:              try
 595:              {
 596:                  if (!string.IsNullOrEmpty(service))
 597:                  {
 598:                      serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 599:   
 600:                      if (!string.IsNullOrEmpty(accessName))
 601:                      {
 602:                          port = int.TryParse(portString, out int i) ? i : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 603:   
 604:                          var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
 605:   
 606:                          if (nddOnt != null)
 607:                          {
 608:                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(service))
 609:                              {
 610:                                  Ia.Ngn.Cl.Model.Business.Huawei.U2000.VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(service, nddOnt, ignoreRestrictions, ref result);
 611:                              }
 612:                              else result.AddError("Service number does not belong to allowed domain lists");
 613:                          }
 614:                          else result.AddError("NDD ONT is null for access name: " + accessName);
 615:                      }
 616:                      else
 617:                      {
 618:                          result.AddError("AccessName null or empty");
 619:                      }
 620:                  }
 621:                  else
 622:                  {
 623:                      result.AddError("Service null or empty");
 624:                  }
 625:              }
 626:              catch (Exception ex)
 627:              {
 628:                  result.AddError("Exception: " + ex.ToString());
 629:              }
 630:          }
 631:   
 632:          ////////////////////////////////////////////////////////////////////////////
 633:   
 634:          /// <summary>
 635:          ///
 636:          /// </summary>
 637:          public static void VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool ignoreRestrictions, ref Ia.Cl.Model.Result result)
 638:          {
 639:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 640:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 641:              Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo emsOntSipInfo;
 642:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 643:   
 644:              emsOntSipInfo = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
 645:   
 646:              if (emsOntSipInfo != null)
 647:              {
 648:                  emsOnt = emsOntSipInfo.EmsOnt;
 649:   
 650:                  if (emsOnt.Access != null)
 651:                  {
 652:                      nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Id == emsOnt.Access.Id select o).SingleOrDefault();
 653:   
 654:                      if (nddOnt != null)
 655:                      {
 656:                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt) || ignoreRestrictions)
 657:                          {
 658:                              if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 659:                              {
 660:                                  if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 661:                                  {
 662:                                      result.AddError("ONT family type is MDU");
 663:                                  }
 664:                                  else
 665:                                  {
 666:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
 667:   
 668:                                      //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 669:                                  }
 670:                              }
 671:                              else  // if H.248
 672:                              {
 673:                                  result.AddError("OLT is not SIP");
 674:                              }
 675:                          }
 676:                          else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 677:                      }
 678:                      else result.AddError("nddOnt is null, does not exist for service: " + service);
 679:                  }
 680:                  else result.AddError("emsOnt.Access is null for service: " + service);
 681:              }
 682:              else
 683:              {
 684:                  emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 685:   
 686:                  if (emsVoipPstnUser != null)
 687:                  {
 688:                      emsOnt = emsVoipPstnUser.EmsOnt;
 689:   
 690:                      if (emsOnt.Access != null)
 691:                      {
 692:                          nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Id == emsOnt.Access.Id select o).SingleOrDefault();
 693:   
 694:                          if (nddOnt != null)
 695:                          {
 696:                              if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
 697:                              {
 698:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 699:                                  {
 700:                                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 701:                                      {
 702:                                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
 703:                                          {
 704:                                              mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary[nddOnt.Access.Name];
 705:   
 706:                                              //emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 707:   
 708:                                              //if (emsVoipPstnUser == null)
 709:                                              //{
 710:                                              if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 711:                                              {
 712:                                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
 713:                                              }
 714:   
 715:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
 716:   
 717:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
 718:                                              //}
 719:                                              //else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 720:                                          }
 721:                                          else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 722:   
 723:                                          /*
 724:                                          if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 725:                                          {
 726:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, emsOnt.FamilyType, service, emsVoipPstnUser.PN, nddOnt);
 727:                                          }
 728:  
 729:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, emsOnt.FamilyType, service, emsVoipPstnUser.PN, nddOnt);
 730:  
 731:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, emsVoipPstnUser.PN, nddOnt);
 732:                                          */
 733:                                      }
 734:                                      else
 735:                                      {
 736:                                      }
 737:                                  }
 738:                                  else  // if H.248
 739:                                  {
 740:                                      result.AddError("OLT is not SIP");
 741:                                  }
 742:                              }
 743:                              else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 744:                          }
 745:                          else result.AddError("nddOnt is null, does not exist for service: " + service);
 746:                      }
 747:                      else result.AddError("emsOnt.Access is null for service: " + service);
 748:                  }
 749:                  else result.AddError("emsOntSipInfo is null and emsVoipPstnUser is null for service: " + service);
 750:              }
 751:          }
 752:   
 753:          ////////////////////////////////////////////////////////////////////////////
 754:          ////////////////////////////////////////////////////////////////////////////
 755:   
 756:          /// <summary>
 757:          ///
 758:          /// </summary>
 759:          public static void ManageSynchronizationBetweenGponAndSwitch(out Ia.Cl.Model.Result result)
 760:          {
 761:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 762:   
 763:              result = new Ia.Cl.Model.Result();
 764:   
 765:              process = createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.NextProcess();
 766:   
 767:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 768:              {
 769:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
 770:                  {
 771:                      result.AddSuccess("create: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 772:   
 773:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, false, ref result);
 774:                  }
 775:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 776:                  {
 777:                      result.AddSuccess("read: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 778:   
 779:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 780:                  }
 781:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
 782:                  {
 783:                      result.AddSuccess("delete: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 784:   
 785:                      VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, false, ref result);
 786:                  }
 787:                  else result.AddSuccess("sync: undefined procedure. ");
 788:              }
 789:              else result.AddSuccess("sync: nothing to create or delete");
 790:          }
 791:   
 792:          ////////////////////////////////////////////////////////////////////////////
 793:   
 794:          /// <summary>
 795:          ///
 796:          /// </summary>
 797:          public static void ManageSynchronizationBetweenGponAndSwitchForOntsWithIssues(out Ia.Cl.Model.Result result)
 798:          {
 799:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 800:   
 801:              result = new Ia.Cl.Model.Result();
 802:   
 803:              process = createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.NextProcess();
 804:   
 805:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 806:              {
 807:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
 808:                  {
 809:                      result.AddSuccess("create: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 810:   
 811:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, false, ref result);
 812:                  }
 813:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 814:                  {
 815:                      result.AddSuccess("read: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 816:   
 817:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 818:                  }
 819:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
 820:                  {
 821:                      result.AddSuccess("delete: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 822:   
 823:                      VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, false, ref result);
 824:                  }
 825:                  else result.AddSuccess("sync: undefined procedure. ");
 826:              }
 827:              else result.AddSuccess("sync: nothing to create or delete");
 828:          }
 829:   
 830:          ////////////////////////////////////////////////////////////////////////////
 831:   
 832:          /// <summary>
 833:          ///
 834:          /// </summary>
 835:          public static void ManageUpdateOfOntFromH248ToSip(out Ia.Cl.Model.Result result)
 836:          {
 837:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 838:   
 839:              result = new Ia.Cl.Model.Result();
 840:   
 841:              process = updateEmsOntFromH248ToSipProcedure.NextProcess();
 842:   
 843:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 844:              {
 845:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
 846:                  {
 847:                      result.AddSuccess("update: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 848:   
 849:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendUpdateOntFromH248ToSip(ems, process.Ont);
 850:                  }
 851:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 852:                  {
 853:                      result.AddSuccess("read: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 854:   
 855:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOnt(ems, process.Ont);
 856:                  }
 857:                  else result.AddSuccess("update: undefined procedure. ");
 858:              }
 859:              else result.AddSuccess("update: nothing to update");
 860:          }
 861:   
 862:          ////////////////////////////////////////////////////////////////////////////
 863:   
 864:          /// <summary>
 865:          ///
 866:          /// </summary>
 867:          public static void ManageCreateOntSipInfoOrOntVoipPstnUserForOntUpdatedFromH248ToSip(out Ia.Cl.Model.Result result)
 868:          {
 869:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 870:   
 871:              result = new Ia.Cl.Model.Result();
 872:   
 873:              process = createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.NextProcess();
 874:   
 875:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 876:              {
 877:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
 878:                  {
 879:                      result.AddSuccess("create: " + process.Ont.Access.Name + " " + process.Service + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 880:   
 881:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, process.Port, true, ref result);
 882:                  }
 883:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 884:                  {
 885:                      result.AddSuccess("read: " + process.Ont.Access.Name + " " + process.Service + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 886:   
 887:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, process.Port, ref result);
 888:                  }
 889:                  else result.AddSuccess("create: undefined procedure. ");
 890:              }
 891:              else result.AddSuccess("create: nothing to create");
 892:          }
 893:   
 894:          ////////////////////////////////////////////////////////////////////////////
 895:   
 896:          /// <summary>
 897:          ///
 898:          /// </summary>
 899:          public static void ManageQueue(out Ia.Cl.Model.Result result)
 900:          {
 901:              long queueCount;
 902:              string accessName;
 903:              List<string> list; //, accessNames;
 904:   
 905:              result = new Ia.Cl.Model.Result();
 906:   
 907:              queueCount = Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.U2000Application.Count;
 908:   
 909:              if (queueCount > 0)
 910:              {
 911:                  //accessNames = new List<string>();
 912:   
 913:                  //for (int i = 0; i < queueCount; i++)
 914:                  //{
 915:                  accessName = Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.U2000Application.Dequeue;
 916:   
 917:                  list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.QueueProperlySelectedEmsCommandsToRetriveOntNetworkElementDataByAccessName(accessName);
 918:   
 919:                  foreach (string s in list) ems.SendQueue.Enqueue(s);
 920:   
 921:                  //accessNames.Add(accessName);
 922:                  //}
 923:   
 924:                  //result.AddSuccess(string.Join(",", accessNames));
 925:                  result.AddSuccess(accessName);
 926:              }
 927:          }
 928:   
 929:          ////////////////////////////////////////////////////////////////////////////
 930:   
 931:          /// <summary>
 932:          ///
 933:          /// </summary>
 934:          public static void Manage(out Ia.Cl.Model.Result result)
 935:          {
 936:              string command;
 937:   
 938:              result = new Ia.Cl.Model.Result();
 939:   
 940:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.QueueProperlySelectedSingleEmsCommandToManageOntNetworkElements;
 941:   
 942:              ems.SendQueue.Enqueue(command);
 943:   
 944:              result.AddSuccess(command);
 945:          }
 946:   
 947:          ////////////////////////////////////////////////////////////////////////////
 948:          ////////////////////////////////////////////////////////////////////////////
 949:   
 950:          /// <summary>
 951:          ///
 952:          /// </summary>
 953:          public static void SequentiallyReadDevList(out Ia.Cl.Model.Result result)
 954:          {
 955:              string devType;
 956:              DateTime now;
 957:   
 958:              result = new Ia.Cl.Model.Result();
 959:              now = DateTime.UtcNow.AddHours(3);
 960:   
 961:              var redundantDevList = Ia.Ngn.Cl.Model.Data.Huawei.Dev.RedundantDevList();
 962:   
 963:              if (redundantDevList.Count == 0)
 964:              {
 965:                  /*
 966:                   * List DEVs with DT: MA5600T (OLTs) (LST-DEV::DT=249:{ctag}::;)
 967:                   * List DEVs with DT: MA5603T (OLTs) (LST-DEV::DT=95:{ctag}::;)
 968:                   * List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
 969:                   * 
 970:                   * I can't read MA5878 using LST-DEV::DT, I have to use LST-DEV::DEV
 971:                   * e.g. LST-DEV::DEV=MDU-SAB-1443-001:{ctag}::;
 972:                   */
 973:   
 974:                  switch (now.Day % 3)
 975:                  {
 976:                      case 0: devType = "MA5600T"; break;
 977:                      case 1: devType = "MA5603T"; break;
 978:                      case 2: devType = "MA5616"; break;
 979:                      default: devType = "MA5600T"; break;
 980:                  }
 981:   
 982:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadDevListByDt(ems, devType);
 983:                  result.AddSuccess("Reading Devs with devType : " + devType);
 984:              }
 985:              else
 986:              {
 987:                  throw new Exception("SequentiallyReadDevList(): redundantDevList.Count != 0 there are duplicate names in EmsDev");
 988:              }
 989:          }
 990:   
 991:          ////////////////////////////////////////////////////////////////////////////
 992:   
 993:          /// <summary>
 994:          ///
 995:          /// </summary>
 996:          public static void SequentiallyReadBoardListForDevAndOntListForMduDev(out Ia.Cl.Model.Result result)
 997:          {
 998:              Ia.Ngn.Cl.Model.Huawei.EmsDev dev;
 999:   
1000:              result = new Ia.Cl.Model.Result();
1001:              dev = Ia.Ngn.Cl.Model.Business.Huawei.Dev.SequentialEmsDevListItem(out _, out string progressCounterString);
1002:   
1003:              if (dev != null)
1004:              {
1005:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadBoardList(ems, dev.DEV);
1006:   
1007:                  // if dev is MDU we will read ONTs
1008:                  if (dev.DT == "MA5616" || dev.DT == "MA5878") //&List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
1009:                  {
1010:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntList(ems, dev.DID);
1011:                  }
1012:   
1013:                  result.AddSuccess("dev: " + dev.DEV + ", " + progressCounterString);
1014:              }
1015:              else result.AddError("Dev is null or empty. ");
1016:          }
1017:   
1018:          ////////////////////////////////////////////////////////////////////////////
1019:   
1020:          /// <summary>
1021:          ///
1022:          /// </summary>
1023:          public static void SequentiallyReadPortListForBoard(out Ia.Cl.Model.Result result)
1024:          {
1025:              Ia.Ngn.Cl.Model.Huawei.EmsBoard board;
1026:   
1027:              result = new Ia.Cl.Model.Result();
1028:              board = Ia.Ngn.Cl.Model.Business.Huawei.Board.SequentialEmsBoardListItem(out _, out string progressCounterString);
1029:   
1030:              if (board != null)
1031:              {
1032:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadPortList(ems, board.EmsDev.DEV, board.FN, board.SN);
1033:   
1034:                  result.AddSuccess("DEV: " + board.EmsDev.DEV + ", SN: " + board.SN + " " + progressCounterString);
1035:              }
1036:              else result.AddError("Board is null or empty. ");
1037:          }
1038:   
1039:          ////////////////////////////////////////////////////////////////////////////
1040:          ////////////////////////////////////////////////////////////////////////////
1041:      }
1042:   
1043:      ////////////////////////////////////////////////////////////////////////////
1044:      ////////////////////////////////////////////////////////////////////////////
1045:  }