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

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-2019 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 Msan
  50:      {
  51:          private static Dictionary<string, int> associateServiceIdAndPortBetweenCreateAndReadDictionary = new Dictionary<string, int>();
  52:   
  53:          private static Ia.Ngn.Cl.Model.Business.Procedure
  54:              createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(72, Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList),
  55:              createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(0, Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList),
  56:              updateEmsOntFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.EmsOntToBeUpdatedFromH248ToSipList),
  57:              createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList);
  58:   
  59:          private static Ia.Ngn.Cl.Model.Client.Huawei.Ems ems = new Ia.Ngn.Cl.Model.Client.Huawei.Ems();
  60:   
  61:          /// <summary/>
  62:          public static string UserName { get { return ConfigurationManager.AppSettings["u2000HuaweiServerUser"].ToString(); } }
  63:          /// <summary/>
  64:          public static string Password { get { return ConfigurationManager.AppSettings["u2000HuaweiServerUserPassword"].ToString(); } }
  65:   
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          public Msan()
  73:          {
  74:          }
  75:   
  76:          ////////////////////////////////////////////////////////////////////////////
  77:   
  78:          /// <summary>
  79:          ///
  80:          /// </summary>
  81:          public static void Connect(out Ia.Cl.Model.Result result)
  82:          {
  83:              if (ems != null && !ems.IsConnected)
  84:              {
  85:                  ems.Connect(out result);
  86:              }
  87:              else
  88:              {
  89:                  result = new Ia.Cl.Model.Result();
  90:   
  91:                  result.AddWarning("Warning: ems is already connected. ");
  92:              }
  93:          }
  94:   
  95:          ////////////////////////////////////////////////////////////////////////////
  96:   
  97:          /// <summary>
  98:          ///
  99:          /// </summary>
 100:          public static void Disconnect(out Ia.Cl.Model.Result result)
 101:          {
 102:              if (ems != null && ems.IsConnected)
 103:              {
 104:                  ems.Disconnect(out result);
 105:              }
 106:              else
 107:              {
 108:                  result = new Ia.Cl.Model.Result();
 109:   
 110:                  result.AddWarning("Warning: ems is already disconnected. ");
 111:              }
 112:          }
 113:   
 114:          ////////////////////////////////////////////////////////////////////////////
 115:   
 116:          /// <summary>
 117:          ///
 118:          /// </summary>
 119:          public static void Login()
 120:          {
 121:              ems.Login();
 122:          }
 123:   
 124:          ////////////////////////////////////////////////////////////////////////////
 125:   
 126:          /// <summary>
 127:          ///
 128:          /// </summary>
 129:          public static void Logout()
 130:          {
 131:              ems.Logout();
 132:          }
 133:   
 134:          ////////////////////////////////////////////////////////////////////////////
 135:   
 136:          /// <summary>
 137:          ///
 138:          /// </summary>
 139:          public static Queue<string> ReceiveQueue
 140:          {
 141:              get
 142:              {
 143:                  return ems.ReceiveQueue;
 144:              }
 145:          }
 146:   
 147:          ////////////////////////////////////////////////////////////////////////////
 148:   
 149:          /// <summary>
 150:          ///
 151:          /// </summary>
 152:          public static Queue<string> SendQueue
 153:          {
 154:              get
 155:              {
 156:                  return ems.SendQueue;
 157:              }
 158:          }
 159:   
 160:          ////////////////////////////////////////////////////////////////////////////
 161:   
 162:          /// <summary>
 163:          ///
 164:          /// </summary>
 165:          public static bool IsConnected
 166:          {
 167:              get
 168:              {
 169:                  return ems.IsConnected;
 170:              }
 171:          }
 172:   
 173:          ////////////////////////////////////////////////////////////////////////////
 174:   
 175:          /// <summary>
 176:          ///
 177:          /// </summary>
 178:          public static bool IsLoggedIn
 179:          {
 180:              get
 181:              {
 182:                  return ems.IsLoggedIn;
 183:              }
 184:          }
 185:   
 186:          ////////////////////////////////////////////////////////////////////////////
 187:   
 188:          /// <summary>
 189:          ///
 190:          /// </summary>
 191:          public static void Dispose()
 192:          {
 193:              ems.Dispose();
 194:          }
 195:   
 196:          ////////////////////////////////////////////////////////////////////////////
 197:   
 198:          /// <summary>
 199:          ///
 200:          /// </summary>
 201:          public static void ProcessReceiveQueue(out Ia.Cl.Model.Result result)
 202:          {
 203:              string rowString, formattedString;
 204:   
 205:              result = new Ia.Cl.Model.Result();
 206:   
 207:              try
 208:              {
 209:                  Debug.WriteLine("--------------------------------------");
 210:                  Debug.WriteLine("ProcessReceiveQueue(): receiveQueue.Count: " + ems.ReceiveQueue.Count);
 211:   
 212:                  while (ems.ReceiveQueue.Count > 0)
 213:                  {
 214:                      rowString = ems.ReceiveQueue.Dequeue();
 215:   
 216:                      formattedString = rowString;
 217:   
 218:                      Debug.WriteLine("ProcessReceiveQueue(): formattedString: " + formattedString);
 219:   
 220:                      ems.Update(formattedString, ref ems, out Ia.Cl.Model.Result r);
 221:   
 222:                      result.AddResult(r);
 223:                      //result.AddWarning("Debugging: Start --------------------------------------");
 224:                      //result.AddWarning(rowString);
 225:                      //result.AddWarning("Debugging: End ----------------------------------------");
 226:                  }
 227:   
 228:                  Debug.WriteLine("--------------------------------------");
 229:              }
 230:              catch (Exception ex)
 231:              {
 232:                  result.AddError("ProcessReceiveQueue(): Exception: " + ex.Message);
 233:              }
 234:          }
 235:   
 236:          ////////////////////////////////////////////////////////////////////////////
 237:   
 238:          /// <summary>
 239:          ///
 240:          /// </summary>
 241:          public static string ProcessSendQueue(out Ia.Cl.Model.Result result)
 242:          {
 243:              bool skipSleep;
 244:              string command;
 245:   
 246:              skipSleep = true;
 247:              command = string.Empty;
 248:              result = new Ia.Cl.Model.Result();
 249:   
 250:              try
 251:              {
 252:                  Debug.WriteLine("--------------------------------------");
 253:                  Debug.WriteLine("ProcessSendQueue(): sendQueue.Count: " + ems.SendQueue.Count);
 254:   
 255:                  if (ems.SendQueue.Count > 0)
 256:                  {
 257:                      command = ems.SendQueue.Dequeue();
 258:   
 259:                      ems.Send(command, skipSleep, out Ia.Cl.Model.Result r);
 260:   
 261:                      if (r.IsSuccessful) result.AddSuccess(r.Message);
 262:                      else result.AddError(r.Message);
 263:                  }
 264:   
 265:                  Debug.WriteLine("--------------------------------------");
 266:              }
 267:              catch (Exception ex)
 268:              {
 269:                  result.AddError("ProcessSendQueue(): Exception: " + ex.Message);
 270:              }
 271:   
 272:              return result.IsSuccessful ? command : string.Empty;
 273:          }
 274:   
 275:          ////////////////////////////////////////////////////////////////////////////
 276:          ////////////////////////////////////////////////////////////////////////////
 277:   
 278:          /// <summary>
 279:          ///
 280:          /// </summary>
 281:          public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, bool ignoreRestrictions, ref Ia.Cl.Model.Result result)
 282:          {
 283:              int pn;
 284:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
 285:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 286:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 287:              Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo emsOntSipInfo;
 288:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 289:   
 290:              if (nddOnt != null)
 291:              {
 292:                  if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt) || ignoreRestrictions)
 293:                  {
 294:                      emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 295:   
 296:                      if (emsOnt != null)
 297:                      {
 298:                          if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 299:                          {
 300:                              if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 301:                              {
 302:                                  pn = port;
 303:   
 304:                                  if (Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary.ContainsKey(nddOnt.Access.Name))
 305:                                  {
 306:                                      mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary[nddOnt.Access.Name];
 307:   
 308:                                      var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mduDev, emsOnt);
 309:   
 310:                                      if (pn != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 311:                                      {
 312:                                          fnSnPn = vacantFnSnPnList.Where(f => f.Pn == pn).SingleOrDefault();
 313:                                      }
 314:                                      else fnSnPn = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mduDev, emsOnt);
 315:   
 316:                                      if (fnSnPn != null)
 317:                                      {
 318:                                          emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 319:   
 320:                                          if (emsVoipPstnUser == null)
 321:                                          {
 322:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, mduDev, nddOnt, service, fnSnPn.Sn, fnSnPn.Pn);
 323:   
 324:                                              if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 325:                                              {
 326:                                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, mduDev, nddOnt, service, fnSnPn.Sn, fnSnPn.Pn);
 327:                                              }
 328:   
 329:                                              associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = fnSnPn.Pn;
 330:                                          }
 331:                                          else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 332:                                      }
 333:                                      else result.AddError("MDU sn and/or tel is invalid or does not exist. ");
 334:                                  }
 335:                                  else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 336:   
 337:                                  /*
 338:                                  tel = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduTelPortForOnt(emsOnt);
 339:  
 340:                                  if (tel != -1)
 341:                                  {
 342:                                      emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 343:  
 344:                                      if (emsVoipPstnUser == null)
 345:                                      {
 346:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, emsOnt.FamilyType, service, tel, nddOnt);
 347:  
 348:                                          if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 349:                                          {
 350:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, emsOnt.FamilyType, service, tel, nddOnt);
 351:                                          }
 352:  
 353:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, tel, nddOnt);
 354:                                      }
 355:                                      else
 356:                                      {
 357:                                          result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 358:                                      }
 359:                                  }
 360:                                  else
 361:                                  {
 362:                                      result.AddError("MDU tel is invalid or does not exist. ");
 363:                                  }
 364:                                  */
 365:                              }
 366:                              else // if not MDU
 367:                              {
 368:                                  var vacantList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantTelForOntList(emsOnt);
 369:   
 370:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 371:                                  {
 372:                                      port = vacantList.Contains(port) ? port : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 373:                                  }
 374:                                  else port = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
 375:   
 376:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 377:                                  {
 378:                                      emsOntSipInfo = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
 379:   
 380:                                      if (emsOntSipInfo == null)
 381:                                      {
 382:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateOntSipInfo(ems, nddOnt, service, port);
 383:   
 384:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 385:   
 386:                                          associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = port;
 387:                                      }
 388:                                      else result.AddError("emsOntSipInfo != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 389:                                  }
 390:                                  else result.AddError("telPort is invalid or does not exist. ");
 391:                              }
 392:                          }
 393:                          else  // if H.248
 394:                          {
 395:                              result.AddError("OLT is not SIP");
 396:                          }
 397:                      }
 398:                      else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name);
 399:                  }
 400:                  else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 401:              }
 402:              else result.AddError("nddOnt is null, does not exist for service: " + service);
 403:          }
 404:   
 405:          ////////////////////////////////////////////////////////////////////////////
 406:   
 407:          /// <summary>
 408:          ///
 409:          /// </summary>
 410:          public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Model.Result result)
 411:          {
 412:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 413:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 414:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 415:   
 416:              if (nddOnt != null)
 417:              {
 418:                  emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 419:   
 420:                  if (emsOnt != null)
 421:                  {
 422:                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 423:                      {
 424:                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary.ContainsKey(nddOnt.Access.Name))
 425:                          {
 426:                              mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary[nddOnt.Access.Name];
 427:   
 428:                              emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 429:   
 430:                              if (emsVoipPstnUser == null)
 431:                              {
 432:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 433:                                  {
 434:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, mduDev.FirstFnSnPn.Sn, port);
 435:                                  }
 436:                                  else if (associateServiceIdAndPortBetweenCreateAndReadDictionary.ContainsKey(service))
 437:                                  {
 438:                                      port = associateServiceIdAndPortBetweenCreateAndReadDictionary[service];
 439:   
 440:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, mduDev.FirstFnSnPn.Sn, port);
 441:                                  }
 442:                                  else
 443:                                  {
 444:                                      foreach (var fsSnPn in mduDev.PossibleFnSnPnList)
 445:                                      {
 446:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev, nddOnt, fsSnPn.Sn, fsSnPn.Pn);
 447:                                      }
 448:                                  }
 449:                              }
 450:                              else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 451:                          }
 452:                          else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 453:   
 454:                          /*
 455:                          possibleNumberOfTd = Ia.Ngn.Cl.Model.Business.Huawei.Ems.PossibleNumberOfTdForOntEquipmentType(emsOnt.EquipmentType);
 456:  
 457:                          for (int tel = 0; tel < possibleNumberOfTd; tel++) // incorrect
 458:                          {
 459:                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, nddOnt, sn, tel);
 460:                          }
 461:                          */
 462:                      }
 463:                      else // if not MDU
 464:                      {
 465:                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 466:                      }
 467:   
 468:                      Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(service);
 469:                  }
 470:                  else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name);
 471:              }
 472:              else result.AddError("nddOnt is null, does not exist for service: " + service);
 473:          }
 474:   
 475:          ////////////////////////////////////////////////////////////////////////////
 476:   
 477:          /// <summary>
 478:          ///
 479:          /// </summary>
 480:          public static void VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, bool ignoreRestrictions, ref Ia.Cl.Model.Result result)
 481:          {
 482:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
 483:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 484:              Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo emsOntSipInfo;
 485:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser;
 486:   
 487:              emsOntSipInfo = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
 488:   
 489:              if (emsOntSipInfo != null)
 490:              {
 491:                  emsOnt = emsOntSipInfo.EmsOnt;
 492:   
 493:                  if (emsOnt.Access != null)
 494:                  {
 495:                      nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Id == emsOnt.Access.Id select o).SingleOrDefault();
 496:   
 497:                      if (nddOnt != null)
 498:                      {
 499:                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt) || ignoreRestrictions)
 500:                          {
 501:                              if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 502:                              {
 503:                                  if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 504:                                  {
 505:                                      result.AddError("ONT family type is MDU");
 506:                                  }
 507:                                  else
 508:                                  {
 509:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
 510:   
 511:                                      //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt);
 512:                                  }
 513:                              }
 514:                              else  // if H.248
 515:                              {
 516:                                  result.AddError("OLT is not SIP");
 517:                              }
 518:                          }
 519:                          else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 520:                      }
 521:                      else result.AddError("nddOnt is null, does not exist for service: " + service);
 522:                  }
 523:                  else result.AddError("emsOnt.Access is null for service: " + service);
 524:              }
 525:              else
 526:              {
 527:                  emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 528:   
 529:                  if (emsVoipPstnUser != null)
 530:                  {
 531:                      emsOnt = emsVoipPstnUser.EmsOnt;
 532:   
 533:                      if (emsOnt.Access != null)
 534:                      {
 535:                          nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Id == emsOnt.Access.Id select o).SingleOrDefault();
 536:   
 537:                          if (nddOnt != null)
 538:                          {
 539:                              if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
 540:                              {
 541:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == true || ignoreRestrictions) // if IsSip == true
 542:                                  {
 543:                                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 544:                                      {
 545:                                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary.ContainsKey(nddOnt.Access.Name))
 546:                                          {
 547:                                              mduDev = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary[nddOnt.Access.Name];
 548:   
 549:                                              emsVoipPstnUser = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 550:   
 551:                                              if (emsVoipPstnUser == null)
 552:                                              {
 553:                                                  if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 554:                                                  {
 555:                                                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
 556:                                                  }
 557:   
 558:                                                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
 559:                                              }
 560:                                              else result.AddError("emsVoipPstnUser != null values must be null before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name);
 561:                                          }
 562:                                          else result.AddError("emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name);
 563:   
 564:                                          /*
 565:                                          if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 566:                                          {
 567:                                              Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, emsOnt.FamilyType, service, emsVoipPstnUser.PN, nddOnt);
 568:                                          }
 569:  
 570:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, emsOnt.FamilyType, service, emsVoipPstnUser.PN, nddOnt);
 571:  
 572:                                          //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, emsVoipPstnUser.PN, nddOnt);
 573:                                          */
 574:                                      }
 575:                                      else
 576:                                      {
 577:                                      }
 578:                                  }
 579:                                  else  // if H.248
 580:                                  {
 581:                                      result.AddError("OLT is not SIP");
 582:                                  }
 583:                              }
 584:                              else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name);
 585:                          }
 586:                          else result.AddError("nddOnt is null, does not exist for service: " + service);
 587:                      }
 588:                      else result.AddError("emsOnt.Access is null for service: " + service);
 589:                  }
 590:                  else result.AddError("emsOntSipInfo is null and emsVoipPstnUser is null for service: " + service);
 591:              }
 592:          }
 593:   
 594:          ////////////////////////////////////////////////////////////////////////////
 595:          ////////////////////////////////////////////////////////////////////////////
 596:   
 597:          /// <summary>
 598:          ///
 599:          /// </summary>
 600:          public static void ManageSynchronizationBetweenGponAndSwitch(out Ia.Cl.Model.Result result)
 601:          {
 602:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 603:   
 604:              result = new Ia.Cl.Model.Result();
 605:   
 606:              process = createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.NextProcess();
 607:   
 608:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 609:              {
 610:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
 611:                  {
 612:                      result.AddSuccess("create: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 613:   
 614:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, false, ref result);
 615:                  }
 616:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 617:                  {
 618:                      result.AddSuccess("read: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 619:   
 620:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 621:                  }
 622:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
 623:                  {
 624:                      result.AddSuccess("delete: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastNHourProcedure.ProgressCounterString);
 625:   
 626:                      VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, false, ref result);
 627:                  }
 628:                  else result.AddSuccess("sync: undefined procedure. ");
 629:              }
 630:              else result.AddSuccess("sync: nothing to create or delete");
 631:          }
 632:   
 633:          ////////////////////////////////////////////////////////////////////////////
 634:   
 635:          /// <summary>
 636:          ///
 637:          /// </summary>
 638:          public static void ManageSynchronizationBetweenGponAndSwitchForOntsWithIssues(out Ia.Cl.Model.Result result)
 639:          {
 640:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 641:   
 642:              result = new Ia.Cl.Model.Result();
 643:   
 644:              process = createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.NextProcess();
 645:   
 646:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 647:              {
 648:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
 649:                  {
 650:                      result.AddSuccess("create: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 651:   
 652:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, false, ref result);
 653:                  }
 654:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 655:                  {
 656:                      result.AddSuccess("read: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 657:   
 658:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 659:                  }
 660:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
 661:                  {
 662:                      result.AddSuccess("delete: " + process.ServiceId + " " + createOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceForOntsWithIssuesProcedure.ProgressCounterString);
 663:   
 664:                      VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, false, ref result);
 665:                  }
 666:                  else result.AddSuccess("sync: undefined procedure. ");
 667:              }
 668:              else result.AddSuccess("sync: nothing to create or delete");
 669:          }
 670:   
 671:          ////////////////////////////////////////////////////////////////////////////
 672:   
 673:          /// <summary>
 674:          ///
 675:          /// </summary>
 676:          public static void ManageUpdateOfOntFromH248ToSip(out Ia.Cl.Model.Result result)
 677:          {
 678:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 679:   
 680:              result = new Ia.Cl.Model.Result();
 681:   
 682:              process = updateEmsOntFromH248ToSipProcedure.NextProcess();
 683:   
 684:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 685:              {
 686:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
 687:                  {
 688:                      result.AddSuccess("update: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 689:   
 690:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendUpdateOntFromH248ToSip(ems, process.Ont);
 691:                  }
 692:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 693:                  {
 694:                      result.AddSuccess("read: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 695:   
 696:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOnt(ems, process.Ont);
 697:                  }
 698:                  else result.AddSuccess("update: undefined procedure. ");
 699:              }
 700:              else result.AddSuccess("update: nothing to update");
 701:          }
 702:   
 703:          ////////////////////////////////////////////////////////////////////////////
 704:   
 705:          /// <summary>
 706:          ///
 707:          /// </summary>
 708:          public static void ManageCreateOntSipInfoOrOntVoipPstnUserForOntUpdatedFromH248ToSip(out Ia.Cl.Model.Result result)
 709:          {
 710:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 711:   
 712:              result = new Ia.Cl.Model.Result();
 713:   
 714:              process = createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.NextProcess();
 715:   
 716:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 717:              {
 718:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
 719:                  {
 720:                      result.AddSuccess("create: " + process.Ont.Access.Name + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 721:   
 722:                      CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, process.Port, true, ref result);
 723:                  }
 724:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 725:                  {
 726:                      result.AddSuccess("read: " + process.Ont.Access.Name + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 727:   
 728:                      ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, process.Port, ref result);
 729:                  }
 730:                  else result.AddSuccess("create: undefined procedure. ");
 731:              }
 732:              else result.AddSuccess("create: nothing to create");
 733:          }
 734:   
 735:          ////////////////////////////////////////////////////////////////////////////
 736:   
 737:          /// <summary>
 738:          ///
 739:          /// </summary>
 740:          public static void ManageSendEnqueue(out Ia.Cl.Model.Result result)
 741:          {
 742:              long queueCount;
 743:              string accessName, command;
 744:              List<string> list;
 745:   
 746:              result = new Ia.Cl.Model.Result();
 747:   
 748:              queueCount = Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.MsanApplication.Count;
 749:   
 750:              if (queueCount > 0)
 751:              {
 752:                  accessName = Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.MsanApplication.Dequeue;
 753:   
 754:                  list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.QueueProperlySelectedEmsCommandsToRetriveOntNetworkElementDataByAccessName(accessName);
 755:   
 756:                  foreach (string s in list)
 757:                  {
 758:                      ems.SendQueue.Enqueue(s);
 759:   
 760:                      result.AddSuccess("Sent: " + s);
 761:                  }
 762:              }
 763:              else
 764:              {
 765:                  command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.QueueProperlySelectedSingleEmsCommandToManageOntNetworkElements;
 766:   
 767:                  ems.SendQueue.Enqueue(command);
 768:   
 769:                  result.AddSuccess("Sent: " + command);
 770:              }
 771:          }
 772:   
 773:          ////////////////////////////////////////////////////////////////////////////
 774:          ////////////////////////////////////////////////////////////////////////////
 775:   
 776:          /// <summary>
 777:          ///
 778:          /// </summary>
 779:          public static void SequentiallyReadDevList(out Ia.Cl.Model.Result result)
 780:          {
 781:              string devType;
 782:              DateTime now;
 783:   
 784:              result = new Ia.Cl.Model.Result();
 785:              now = DateTime.UtcNow.AddHours(3);
 786:   
 787:              var redundantDevList = Ia.Ngn.Cl.Model.Data.Huawei.Dev.RedundantDevList();
 788:   
 789:              if (redundantDevList.Count == 0)
 790:              {
 791:                  /*
 792:                   * List DEVs with DT: MA5600T (OLTs) (LST-DEV::DT=249:{ctag}::;)
 793:                   * List DEVs with DT: MA5603T (OLTs) (LST-DEV::DT=95:{ctag}::;)
 794:                   * List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
 795:                   * 
 796:                   * I can't read MA5878 using LST-DEV::DT, I have to use LST-DEV::DEV
 797:                   * e.g. LST-DEV::DEV=MDU-SAB-1443-001:{ctag}::;
 798:                   */
 799:   
 800:                  switch (now.Day % 3)
 801:                  {
 802:                      case 0: devType = "MA5600T"; break;
 803:                      case 1: devType = "MA5603T"; break;
 804:                      case 2: devType = "MA5616"; break;
 805:                      default: devType = "MA5600T"; break;
 806:                  }
 807:   
 808:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadDevListByDt(ems, devType);
 809:                  result.AddSuccess("Reading Devs with devType : " + devType);
 810:              }
 811:              else
 812:              {
 813:                  throw new Exception("SequentiallyReadDevList(): redundantDevList.Count != 0 there are duplicate names in EmsDev");
 814:              }
 815:          }
 816:   
 817:          ////////////////////////////////////////////////////////////////////////////
 818:   
 819:          /// <summary>
 820:          ///
 821:          /// </summary>
 822:          public static void SequentiallyReadBoardListForDevAndOntListForMduDev(out Ia.Cl.Model.Result result)
 823:          {
 824:              Ia.Ngn.Cl.Model.Huawei.EmsDev dev;
 825:   
 826:              result = new Ia.Cl.Model.Result();
 827:   
 828:              dev = Ia.Ngn.Cl.Model.Business.Huawei.Dev.SequentialEmsDevListItem(out int sequentialProvisioningProcedureQueueCount, out string progressCounterString);
 829:   
 830:              if (dev != null)
 831:              {
 832:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadBoardList(ems, dev.DEV);
 833:   
 834:                  // if dev is MDU we will read ONTs
 835:                  if (dev.DT == "MA5616" || dev.DT == "MA5878") //&List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
 836:                  {
 837:                      Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntList(ems, dev.DID);
 838:                  }
 839:   
 840:                  result.AddSuccess("dev: " + dev.DEV + ", " + progressCounterString);
 841:              }
 842:              else result.AddError("Dev is null or empty. ");
 843:          }
 844:   
 845:          ////////////////////////////////////////////////////////////////////////////
 846:   
 847:          /// <summary>
 848:          ///
 849:          /// </summary>
 850:          public static void SequentiallyReadPortListForBoard(out Ia.Cl.Model.Result result)
 851:          {
 852:              Ia.Ngn.Cl.Model.Huawei.EmsBoard board;
 853:   
 854:              result = new Ia.Cl.Model.Result();
 855:   
 856:              board = Ia.Ngn.Cl.Model.Business.Huawei.Board.SequentialEmsBoardListItem(out int sequentialProvisioningProcedureQueueCount, out string progressCounterString);
 857:   
 858:              if (board != null)
 859:              {
 860:                  Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadPortList(ems, board.EmsDev.DEV, board.FN, board.SN);
 861:   
 862:                  result.AddSuccess("DEV: " + board.EmsDev.DEV + ", SN: " + board.SN + " " + progressCounterString);
 863:              }
 864:              else result.AddError("Board is null or empty. ");
 865:          }
 866:   
 867:          ////////////////////////////////////////////////////////////////////////////
 868:          ////////////////////////////////////////////////////////////////////////////
 869:      }
 870:   
 871:      ////////////////////////////////////////////////////////////////////////////
 872:      ////////////////////////////////////////////////////////////////////////////
 873:  }