)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Nce (Ia.Ftn.Cl.Models.Business.Huawei)

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

Fixed Telecommunications Network's Operations Support System Management Intranet (FTN OSS) support class for Huawei's Fixed Telecommunications Network (FTN) business model

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Configuration;
    4: using System.Diagnostics;
    5: using System.Linq;
    6: using System.Threading.Tasks;
    7:  
    8: namespace Ia.Ftn.Cl.Models.Business.Huawei
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Fixed Telecommunications Network's Operations Support System Management Intranet (FTN OSS) support class for Huawei's Fixed Telecommunications Network (FTN) business model
   14:     /// </summary>
   15:     /// 
   16:     /// <value>
   17:     ///"AppSettings": {
   18:     ///   "ApplicationName": "Ia.Ftn.Nce.Wfa",
   19:     ///    "NceHuaweiServerHost": "*.*.*.*",
   20:     ///    "NceHuaweiServerPort": "*",
   21:     ///    "NceHuaweiServerLoginUser": "LOGIN:::{ctag}::UN=*,PWD=*;",
   22:     ///    "NceHuaweiServerLogoutUser": "LOGOUT:::{ctag}::;"
   23:     ///}
   24:     /// </value>
   25:     /// 
   26:     /// <remarks> 
   27:     /// Copyright © 2014-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   28:     /// </remarks> 
   29:     public class Nce
   30:     {
   31:         private static int minute = 0;
   32:         private static readonly Dictionary<string, int> associateServiceIdAndPortBetweenCreateAndReadDictionary = new Dictionary<string, int>();
   33:         private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastHourProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(1, Ia.Ftn.Cl.Models.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
   34:         private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(24, Ia.Ftn.Cl.Models.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
   35:         private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(0, Ia.Ftn.Cl.Models.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
   36:         private static readonly Procedure updateEmsOntFromH248ToSipProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(Ia.Ftn.Cl.Models.Business.Provision.EmsOntToBeUpdatedFromH248ToSipList);
   37:         private static readonly Procedure createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(Ia.Ftn.Cl.Models.Business.Provision.OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList);
   38:  
   39:         private static readonly Procedure msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure = new Ia.Ftn.Cl.Models.Business.Procedure(Ia.Ftn.Cl.Models.Business.Provision.MsanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceList);
   40:  
   41:         private static Ia.Ftn.Cl.Models.Client.Huawei.Ems ems = new Ia.Ftn.Cl.Models.Client.Huawei.Ems();
   42:  
   43:         private static List<string> priorityServiceList = new List<string>();
   44:  
   45:         /// <summary/>
   46:         public static string UserName { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:NceHuaweiServerUser"); } }
   47:  
   48:         /// <summary/>
   49:         public static string Password { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:NceHuaweiServerUserPassword"); } }
   50:  
   51:         /// <summary/>
   52:         public static int SendReadOntSipInfoCommandAgainAfterNSeconds = 30;
   53:  
   54:         ////////////////////////////////////////////////////////////////////////////
   55:  
   56:         /// <summary>
   57:         ///
   58:         /// </summary>
   59:         public Nce()
   60:         {
   61:         }
   62:  
   63:         ////////////////////////////////////////////////////////////////////////////
   64:  
   65:         /// <summary>
   66:         ///
   67:         /// </summary>
   68:         public static void Connect(out Ia.Cl.Models.Result result)
   69:         {
   70:             if (ems != null && !ems.IsConnected)
   71:             {
   72:                 result = ems.Connect();
   73:             }
   74:             else
   75:             {
   76:                 result = new Ia.Cl.Models.Result();
   77:  
   78:                 result.AddWarning("Warning: ems is already connected.");
   79:             }
   80:         }
   81:  
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         ///
   86:         /// </summary>
   87:         public static void Disconnect(out Ia.Cl.Models.Result result)
   88:         {
   89:             if (ems != null && ems.IsConnected)
   90:             {
   91:                 result = ems.Disconnect();
   92:             }
   93:             else
   94:             {
   95:                 result = new Ia.Cl.Models.Result();
   96:  
   97:                 result.AddWarning("Warning: ems is already disconnected.");
   98:             }
   99:         }
  100:  
  101:         ////////////////////////////////////////////////////////////////////////////
  102:  
  103:         /// <summary>
  104:         ///
  105:         /// </summary>
  106:         public static void Login()
  107:         {
  108:             ems.Login();
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public static void Logout()
  117:         {
  118:             ems.Logout();
  119:         }
  120:  
  121:         ////////////////////////////////////////////////////////////////////////////
  122:  
  123:         /// <summary>
  124:         ///
  125:         /// </summary>
  126:         public static Queue<string> ReceiveQueue
  127:         {
  128:             get
  129:             {
  130:                 return ems.ReceiveQueue;
  131:             }
  132:         }
  133:  
  134:         ////////////////////////////////////////////////////////////////////////////
  135:  
  136:         /// <summary>
  137:         ///
  138:         /// </summary>
  139:         public static Queue<string> SendQueue
  140:         {
  141:             get
  142:             {
  143:                 return ems.SendQueue;
  144:             }
  145:         }
  146:  
  147:         ////////////////////////////////////////////////////////////////////////////
  148:  
  149:         /// <summary>
  150:         ///
  151:         /// </summary>
  152:         public static bool IsConnected
  153:         {
  154:             get
  155:             {
  156:                 return ems != null && ems.IsConnected;
  157:             }
  158:         }
  159:  
  160:         ////////////////////////////////////////////////////////////////////////////
  161:  
  162:         /// <summary>
  163:         ///
  164:         /// </summary>
  165:         public static bool IsLoggedIn
  166:         {
  167:             get
  168:             {
  169:                 return ems.IsLoggedIn;
  170:             }
  171:         }
  172:  
  173:         ////////////////////////////////////////////////////////////////////////////
  174:  
  175:         /// <summary>
  176:         ///
  177:         /// </summary>
  178:         public static void Dispose()
  179:         {
  180:             ems.Dispose(true);
  181:         }
  182:  
  183:         ////////////////////////////////////////////////////////////////////////////
  184:         ////////////////////////////////////////////////////////////////////////////
  185:  
  186:         /// <summary>
  187:         ///
  188:         /// </summary>
  189:         public static void ProcessReceiveQueue(out Ia.Cl.Models.Result result)
  190:         {
  191:             string rowString, formattedString;
  192:  
  193:             result = new Ia.Cl.Models.Result();
  194:  
  195:             formattedString = string.Empty;
  196:  
  197:             try
  198:             {
  199:                 Debug.WriteLine("--------------------------------------");
  200:                 Debug.WriteLine("ProcessReceiveQueue(): ReceiveQueue.Count: " + ems.ReceiveQueue.Count);
  201:  
  202:                 while (ems.ReceiveQueue.Count > 0)
  203:                 {
  204:                     rowString = ems.ReceiveQueue.Dequeue();
  205:  
  206:                     formattedString = rowString;
  207:  
  208:                     Debug.WriteLine("ProcessReceiveQueue(): formattedString: " + formattedString);
  209:  
  210:                     var r = ems.Update(formattedString, ref ems, out string systemIsBusyResponseCommand, out string ontLoadingCommandIsBeingExecutedNowResponseCommand);
  211:  
  212:                     if (!string.IsNullOrEmpty(systemIsBusyResponseCommand))
  213:                     {
  214:                         ems.SystemIsBusyResendQueue.Enqueue(systemIsBusyResponseCommand);
  215:                     }
  216:  
  217:                     if (!string.IsNullOrEmpty(ontLoadingCommandIsBeingExecutedNowResponseCommand))
  218:                     {
  219:                         ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Enqueue(ontLoadingCommandIsBeingExecutedNowResponseCommand);
  220:                     }
  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.ToString() + "================= formattedString: [" + formattedString + "]"); //.Message);
  233:             }
  234:         }
  235:  
  236:         ////////////////////////////////////////////////////////////////////////////
  237:  
  238:         /// <summary>
  239:         ///
  240:         /// </summary>
  241:         public static string ProcessSendQueue(out Ia.Cl.Models.Result result)
  242:         {
  243:             string command;
  244:  
  245:             var skipSleep = true;
  246:             result = new Ia.Cl.Models.Result();
  247:  
  248:             try
  249:             {
  250:                 Debug.WriteLine("--------------------------------------");
  251:  
  252:                 if (ems.SystemIsBusyResendQueue.Count > 0) command = ems.SystemIsBusyResendQueue.Dequeue();
  253:                 else if (ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Count > 0) command = ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Dequeue();
  254:                 else if (ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Count > 0) command = ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Dequeue();
  255:                 else if (ems.SendQueue.Count > 0) command = ems.SendQueue.Dequeue();
  256:                 else command = string.Empty;
  257:  
  258:                 if (!string.IsNullOrEmpty(command))
  259:                 {
  260:                     var r = ems.Send(command, skipSleep);
  261:  
  262:                     if (r.IsSuccessful) result.AddSuccess(r.Message);
  263:                     else result.AddError(r.Message);
  264:                 }
  265:  
  266:                 EvaluateSendReadOntSipInfoCommandAgainAfterNSecondsResendQueue();
  267:  
  268:                 Debug.WriteLine("--------------------------------------");
  269:             }
  270:             catch (Exception ex)
  271:             {
  272:                 command = string.Empty;
  273:  
  274:                 result.AddError("ProcessSendQueue(): Exception: " + ex.Message);
  275:             }
  276:  
  277:             return result.IsSuccessful ? command : string.Empty;
  278:         }
  279:  
  280:         ////////////////////////////////////////////////////////////////////////////
  281:  
  282:         /// <summary>
  283:         ///
  284:         /// </summary>
  285:         private static bool Minute()
  286:         {
  287:             bool b;
  288:  
  289:             var now = DateTime.UtcNow.AddHours(3);
  290:  
  291:             if (minute != now.Minute)
  292:             {
  293:                 minute = now.Minute;
  294:  
  295:                 b = true;
  296:             }
  297:             else b = false;
  298:  
  299:             return b;
  300:         }
  301:  
  302:         ////////////////////////////////////////////////////////////////////////////
  303:         ////////////////////////////////////////////////////////////////////////////
  304:  
  305:         /// <summary>
  306:         ///
  307:         /// </summary>
  308:         public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Models.Result result)
  309:         {
  310:             int serviceType;
  311:             string serviceId;
  312:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt;
  313:  
  314:             result = new Ia.Cl.Models.Result();
  315:  
  316:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  317:  
  318:             try
  319:             {
  320:                 if (!string.IsNullOrEmpty(service))
  321:                 {
  322:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  323:                     {
  324:                         serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  325:  
  326:                         if (!string.IsNullOrEmpty(accessName))
  327:                         {
  328:                             nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
  329:  
  330:                             if (nddOnt != null)
  331:                             {
  332:                                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, nddOnt, port, ref result);
  333:                             }
  334:                             else result.AddError("NDD ONT is null for access name: " + accessName + ".");
  335:                         }
  336:                         else result.AddError("AccessName null or empty.");
  337:                     }
  338:                     else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  339:                 }
  340:                 else result.AddError("Service null or empty.");
  341:             }
  342:             catch (Exception ex)
  343:             {
  344:                 result.AddError("Exception: " + ex.ToString() + ".");
  345:             }
  346:         }
  347:  
  348:         ////////////////////////////////////////////////////////////////////////////
  349:  
  350:         /// <summary>
  351:         ///
  352:         /// </summary>
  353:         public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Models.Result result)
  354:         {
  355:             Ia.Ftn.Cl.Models.Business.Huawei.Default.FnSnPnPort fnSnPnPort;
  356:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MduDev mduDev;
  357:             Ia.Ftn.Cl.Models.Huawei.EmsOnt emsOnt;
  358:  
  359:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  360:             {
  361:                 if (nddOnt != null)
  362:                 {
  363:                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  364:                     {
  365:                         emsOnt = Ia.Ftn.Cl.Models.Data.Huawei.Ont.ReadIncludeAccess(nddOnt.Id);
  366:  
  367:                         if (emsOnt != null)
  368:                         {
  369:                             if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  370:                             {
  371:                                 if (emsOnt.FamilyType == Ia.Ftn.Cl.Models.Business.Huawei.Ont.FamilyType.Mdu)
  372:                                 {
  373:                                     var accessNameToMduDevDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionary;
  374:  
  375:                                     if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  376:                                     {
  377:                                         mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
  378:  
  379:                                         var vacantFnSnPnList = Ia.Ftn.Cl.Models.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mduDev, emsOnt);
  380:  
  381:                                         if (vacantFnSnPnList.Count > 0)
  382:                                         {
  383:                                             if (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  384:                                             {
  385:                                                 fnSnPnPort = vacantFnSnPnList.Where(f => f.Port == port).SingleOrDefault();
  386:                                             }
  387:                                             else fnSnPnPort = Ia.Ftn.Cl.Models.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mduDev, emsOnt);
  388:  
  389:                                             if (fnSnPnPort != null)
  390:                                             {
  391:                                                 var emsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByService(service);
  392:  
  393:                                                 if (emsVoipPstnUserList.Count == 0)
  394:                                                 {
  395:                                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, mduDev, nddOnt, service, fnSnPnPort.Sn, fnSnPnPort.Pn);
  396:  
  397:                                                     if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  398:                                                     {
  399:                                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, mduDev, nddOnt, service, fnSnPnPort.Sn, fnSnPnPort.Pn);
  400:                                                     }
  401:  
  402:                                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
  403:  
  404:                                                     associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = fnSnPnPort.Port;
  405:  
  406:                                                     result.AddSuccess("command(s) sent...");
  407:                                                 }
  408:                                                 else result.AddError("emsVoipPstnUserList count != 0. Value must be zero before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
  409:                                             }
  410:                                             else result.AddError("MDU sn and/or tel is invalid or does not exist.");
  411:                                         }
  412:                                         else result.AddError("vacantFnSnPnList.Count is 0. There are no vacant ports in MDU.");
  413:                                     }
  414:                                     else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
  415:                                 }
  416:                                 else // SFU
  417:                                 {
  418:                                     var vacantList = Ia.Ftn.Cl.Models.Data.Huawei.Ems.VacantTelForOntList(emsOnt);
  419:  
  420:                                     if (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  421:                                     {
  422:                                         port = vacantList.Contains(port) ? port : Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
  423:                                     }
  424:                                     else port = Ia.Ftn.Cl.Models.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
  425:  
  426:                                     if (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  427:                                     {
  428:                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendCreateOntSipInfo(ems, nddOnt, service, port);
  429:  
  430:                                         // Don't use SAVE-DEV here
  431:                                         //Ia.Ftn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, emsOnt.EmsPort.EmsBoard.EmsDev);
  432:  
  433:                                         associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = port;
  434:  
  435:                                         result.AddSuccess("command(s) sent...");
  436:                                     }
  437:                                     else result.AddError("port is invalid or does not exist.");
  438:                                 }
  439:                             }
  440:                             else result.AddError("OLT is not SIP, its H.248.");
  441:                         }
  442:                         else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name + ".");
  443:                     }
  444:                     else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name + ".");
  445:                 }
  446:                 else result.AddError("nddOnt is null, does not exist for service: " + service + ".");
  447:             }
  448:             else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  449:         }
  450:  
  451:         ////////////////////////////////////////////////////////////////////////////
  452:  
  453:         /// <summary>
  454:         ///
  455:         /// </summary>
  456:         public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, out Ia.Cl.Models.Result result)
  457:         {
  458:             ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, string.Empty, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, out result);
  459:         }
  460:  
  461:         ////////////////////////////////////////////////////////////////////////////
  462:  
  463:         /// <summary>
  464:         ///
  465:         /// </summary>
  466:         public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Models.Result result)
  467:         {
  468:             // see Ia.Ftn.Cl.Model.Business.Huawei.Nce.SendCommandAgainAfterNSeconds;
  469:  
  470:             ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, false, out result);
  471:         }
  472:  
  473:         ////////////////////////////////////////////////////////////////////////////
  474:  
  475:         /// <summary>
  476:         ///
  477:         /// </summary>
  478:         public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, bool sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Models.Result result)
  479:         {
  480:             int serviceType;
  481:             string serviceId;
  482:  
  483:             result = new Ia.Cl.Models.Result();
  484:  
  485:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  486:  
  487:             try
  488:             {
  489:                 if (!string.IsNullOrEmpty(service))
  490:                 {
  491:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  492:                     {
  493:                         serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  494:  
  495:                         if (!string.IsNullOrEmpty(accessName))
  496:                         {
  497:                             var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
  498:  
  499:                             if (nddOnt != null)
  500:                             {
  501:                                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUser(service, nddOnt, port, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
  502:                             }
  503:                             else result.AddError("NDD ONT is null for access name: " + accessName + ".");
  504:                         }
  505:                         else
  506:                         {
  507:                             Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUser(service, null, port, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
  508:                         }
  509:                     }
  510:                     else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  511:                 }
  512:                 else result.AddError("Service null or empty.");
  513:             }
  514:             catch (Exception ex)
  515:             {
  516:                 result.AddError("Exception: " + ex.ToString() + ".");
  517:             }
  518:         }
  519:  
  520:         ////////////////////////////////////////////////////////////////////////////
  521:  
  522:         /// <summary>
  523:         ///
  524:         /// </summary>
  525:         public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Models.Result result)
  526:         {
  527:             // see Ia.Ftn.Cl.Model.Business.Huawei.Nce.SendCommandAgainAfterNSeconds;
  528:  
  529:             ReadOntSipInfoOrVoipPstnUser(service, nddOnt, port, false, ref result);
  530:         }
  531:  
  532:         ////////////////////////////////////////////////////////////////////////////
  533:  
  534:         /// <summary>
  535:         ///
  536:         /// </summary>
  537:         public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, int port, bool sendReadOntSipInfoCommandAgainAfterNSeconds, ref Ia.Cl.Models.Result result)
  538:         {
  539:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MduDev mduDev;
  540:             Ia.Ftn.Cl.Models.Huawei.EmsOnt emsOnt;
  541:  
  542:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  543:             {
  544:                 if (nddOnt != null)
  545:                 {
  546:                     emsOnt = Ia.Ftn.Cl.Models.Data.Huawei.Ont.Read(nddOnt.Id);
  547:  
  548:                     if (emsOnt != null)
  549:                     {
  550:                         if (emsOnt.FamilyType == Ia.Ftn.Cl.Models.Business.Huawei.Ont.FamilyType.Mdu)
  551:                         {
  552:                             var accessNameToMduDevDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionary;
  553:  
  554:                             if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  555:                             {
  556:                                 mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
  557:  
  558:                                 if (port != Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  559:                                 {
  560:                                     var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
  561:  
  562:                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
  563:                                 }
  564:                                 else if (associateServiceIdAndPortBetweenCreateAndReadDictionary.ContainsKey(service))
  565:                                 {
  566:                                     port = associateServiceIdAndPortBetweenCreateAndReadDictionary[service];
  567:  
  568:                                     var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
  569:  
  570:                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
  571:                                 }
  572:                                 else
  573:                                 {
  574:                                     foreach (var fnSnPnPort in mduDev.PossibleFnSnPnPortList)
  575:                                     {
  576:                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
  577:                                     }
  578:                                 }
  579:  
  580:                                 result.AddSuccess("command(s) sent...");
  581:                             }
  582:                             else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
  583:                         }
  584:                         else // SFU
  585:                         {
  586:                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt, sendReadOntSipInfoCommandAgainAfterNSeconds);
  587:  
  588:                             result.AddSuccess("command(s) sent...");
  589:                         }
  590:                     }
  591:                     else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name + ".");
  592:                 }
  593:                 else
  594:                 {
  595:                     var emsOntSipInfoList = Ia.Ftn.Cl.Models.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
  596:  
  597:                     if (emsOntSipInfoList.Count > 0)
  598:                     {
  599:                         // SFU
  600:  
  601:                         foreach (var emsOntSipInfo in emsOntSipInfoList)
  602:                         {
  603:                             emsOnt = emsOntSipInfo.EmsOnt;
  604:  
  605:                             if (emsOnt.Access != null)
  606:                             {
  607:                                 nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
  608:  
  609:                                 if (nddOnt != null)
  610:                                 {
  611:                                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  612:                                     {
  613:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  614:                                         {
  615:                                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt, sendReadOntSipInfoCommandAgainAfterNSeconds);
  616:  
  617:                                             result.AddSuccess("command(s) sent...");
  618:                                         }
  619:                                         else result.AddError("OLT is not SIP, its H.248.");
  620:                                     }
  621:                                     else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
  622:                                 }
  623:                                 else result.AddError("nddOnt is null, does not exist for service " + service + ".");
  624:                             }
  625:                             else result.AddError("emsOnt.Access is null for service " + service + ".");
  626:                         }
  627:                     }
  628:  
  629:  
  630:                     var emsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByService(service);
  631:  
  632:                     if (emsVoipPstnUserList.Count > 0)
  633:                     {
  634:                         // MDU
  635:  
  636:                         foreach (var emsVoipPstnUser in emsVoipPstnUserList)
  637:                         {
  638:                             emsOnt = emsVoipPstnUser.EmsOnt;
  639:  
  640:                             if (emsOnt.Access != null)
  641:                             {
  642:                                 nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
  643:  
  644:                                 if (nddOnt != null)
  645:                                 {
  646:                                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  647:                                     {
  648:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  649:                                         {
  650:                                             if (emsOnt.FamilyType == Ia.Ftn.Cl.Models.Business.Huawei.Ont.FamilyType.Mdu)
  651:                                             {
  652:                                                 var accessNameToMduDevDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionary;
  653:  
  654:                                                 if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  655:                                                 {
  656:                                                     mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
  657:  
  658:                                                     foreach (var fnSnPnPort in mduDev.PossibleFnSnPnPortList)
  659:                                                     {
  660:                                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
  661:  
  662:                                                         result.AddSuccess("command(s) sent...");
  663:                                                     }
  664:                                                 }
  665:                                                 else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
  666:                                             }
  667:                                             else result.AddError("ONT family type is not MDU.");
  668:                                         }
  669:                                         else result.AddError("OLT is not SIP, its H.248.");
  670:                                     }
  671:                                     else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
  672:                                 }
  673:                                 else result.AddError("nddOnt is null, does not exist for service " + service + ".");
  674:                             }
  675:                             else result.AddError("emsOnt.Access is null for service " + service + ".");
  676:                         }
  677:  
  678:  
  679:                         var msanEmsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
  680:  
  681:                         if (msanEmsVoipPstnUserList.Count > 0)
  682:                         {
  683:                             // MSAN
  684:  
  685:                             foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
  686:                             {
  687:                                 ReadVoipPstnUser(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  688:                             }
  689:  
  690:                             result.AddSuccess("command(s) sent...");
  691:                         }
  692:                     }
  693:                 }
  694:             }
  695:             else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  696:         }
  697:  
  698:         ////////////////////////////////////////////////////////////////////////////
  699:  
  700:         /// <summary>
  701:         ///
  702:         /// </summary>
  703:         public static string DeleteOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Models.Result result)
  704:         {
  705:             int serviceType;
  706:             string serviceId, vacatedAccessName;
  707:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont vacatedNddOnt;
  708:  
  709:             result = new Ia.Cl.Models.Result();
  710:  
  711:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  712:  
  713:             vacatedAccessName = string.Empty;
  714:  
  715:             try
  716:             {
  717:                 if (!string.IsNullOrEmpty(service))
  718:                 {
  719:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  720:                     {
  721:                         serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  722:  
  723:                         if (!string.IsNullOrEmpty(accessName))
  724:                         {
  725:                             var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
  726:  
  727:                             if (nddOnt != null)
  728:                             {
  729:                                 vacatedNddOnt = Ia.Ftn.Cl.Models.Business.Huawei.Nce.VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(service, nddOnt, port, ref result);
  730:  
  731:                                 vacatedAccessName = (vacatedNddOnt != null) ? vacatedNddOnt.Access.Name : string.Empty;
  732:                             }
  733:                             else result.AddError("NDD ONT is null for access name: " + accessName + ".");
  734:                         }
  735:                         else if (port == Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  736:                         {
  737:                             vacatedNddOnt = Ia.Ftn.Cl.Models.Business.Huawei.Nce.VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(service, null, port, ref result);
  738:  
  739:                             vacatedAccessName = (vacatedNddOnt != null) ? vacatedNddOnt.Access.Name : string.Empty;
  740:                         }
  741:                         else result.AddError("accessName is empty or null and port is not PortUndefinedOrInvalidOrUnknown. NCE does not know how to handle vacation where nddOnt is null and port is defined.");
  742:                     }
  743:                     else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  744:                 }
  745:                 else result.AddError("Service null or empty.");
  746:             }
  747:             catch (Exception ex)
  748:             {
  749:                 result.AddError("Exception: " + ex.ToString() + ".");
  750:             }
  751:  
  752:             return vacatedAccessName;
  753:         }
  754:  
  755:         ////////////////////////////////////////////////////////////////////////////
  756:  
  757:         /// <summary>
  758:         ///
  759:         /// </summary>
  760:         public static Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(string service, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Models.Result result)
  761:         {
  762:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont vacatedNddOnt;
  763:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MduDev mduDev;
  764:             Ia.Ftn.Cl.Models.Huawei.EmsOnt emsOnt;
  765:  
  766:             vacatedNddOnt = nddOnt;
  767:  
  768:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  769:             {
  770:                 if (nddOnt != null)
  771:                 {
  772:                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  773:                     {
  774:                         if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  775:                         {
  776:                             emsOnt = Ia.Ftn.Cl.Models.Data.Huawei.Ont.ReadIncludeAccess(nddOnt.Id);
  777:  
  778:                             if (emsOnt.FamilyType == Ia.Ftn.Cl.Models.Business.Huawei.Ont.FamilyType.Mdu)
  779:                             {
  780:                                 var accessNameToMduDevDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionary;
  781:  
  782:                                 if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  783:                                 {
  784:                                     mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
  785:  
  786:                                     if (port == Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  787:                                     {
  788:                                         var emsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByService(service);
  789:  
  790:                                         foreach (var emsVoipPstnUser in emsVoipPstnUserList)
  791:                                         {
  792:                                             if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  793:                                             {
  794:                                                 Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  795:                                             }
  796:  
  797:                                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  798:  
  799:                                             result.AddSuccess("command(s) sent...");
  800:                                         }
  801:                                     }
  802:                                     else
  803:                                     {
  804:                                         var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
  805:  
  806:                                         if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  807:                                         {
  808:                                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, mduDev.FirstFnSnPnPort.Sn, fnSnPnPort.Pn);
  809:                                         }
  810:  
  811:                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, mduDev.FirstFnSnPnPort.Sn, fnSnPnPort.Pn);
  812:  
  813:                                         result.AddSuccess("command(s) sent...");
  814:                                     }
  815:  
  816:                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
  817:                                 }
  818:                                 else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service " + service + " and access " + nddOnt.Access.Name + ".");
  819:                             }
  820:                             else // SFU
  821:                             {
  822:                                 if (port == Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown)
  823:                                 {
  824:                                     var emsOntSipInfoList = Ia.Ftn.Cl.Models.Data.Huawei.OntSipInfo.ReadByService(service);
  825:  
  826:                                     foreach (var emsOntSipInfo in emsOntSipInfoList)
  827:                                     {
  828:                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
  829:                                     }
  830:  
  831:                                     result.AddSuccess("command(s) sent...");
  832:                                 }
  833:                                 else
  834:                                 {
  835:                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, port);
  836:  
  837:                                     result.AddSuccess("command(s) sent...");
  838:                                 }
  839:                             }
  840:                         }
  841:                         else result.AddError("OLT is not SIP, its H.248.");
  842:                     }
  843:                     else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
  844:                 }
  845:                 else
  846:                 {
  847:                     var emsOntSipInfoList = Ia.Ftn.Cl.Models.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
  848:  
  849:                     if (emsOntSipInfoList.Count > 0)
  850:                     {
  851:                         // SFU
  852:  
  853:                         foreach (var emsOntSipInfo in emsOntSipInfoList)
  854:                         {
  855:                             emsOnt = emsOntSipInfo.EmsOnt;
  856:  
  857:                             if (emsOnt.Access != null)
  858:                             {
  859:                                 nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
  860:  
  861:                                 if (nddOnt != null)
  862:                                 {
  863:                                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  864:                                     {
  865:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  866:                                         {
  867:                                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
  868:  
  869:                                             result.AddSuccess("command(s) sent...");
  870:                                         }
  871:                                         else result.AddError("OLT is not SIP, its H.248.");
  872:                                     }
  873:                                     else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
  874:                                 }
  875:                                 else result.AddError("nddOnt is null, does not exist for service " + service + ".");
  876:  
  877:                                 vacatedNddOnt = nddOnt;
  878:                             }
  879:                             else result.AddError("emsOnt.Access is null for service " + service + ".");
  880:                         }
  881:                     }
  882:  
  883:  
  884:                     var emsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByService(service);
  885:  
  886:                     if (emsVoipPstnUserList.Count > 0)
  887:                     {
  888:                         // MDU
  889:  
  890:                         foreach (var emsVoipPstnUser in emsVoipPstnUserList)
  891:                         {
  892:                             emsOnt = emsVoipPstnUser.EmsOnt;
  893:  
  894:                             if (emsOnt.Access != null)
  895:                             {
  896:                                 nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
  897:  
  898:                                 if (nddOnt != null)
  899:                                 {
  900:                                     if (Ia.Ftn.Cl.Models.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
  901:                                     {
  902:                                         if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
  903:                                         {
  904:                                             if (emsOnt.FamilyType == Ia.Ftn.Cl.Models.Business.Huawei.Ont.FamilyType.Mdu)
  905:                                             {
  906:                                                 var accessNameToMduDevDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionary;
  907:  
  908:                                                 if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
  909:                                                 {
  910:                                                     mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
  911:  
  912:                                                     if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  913:                                                     {
  914:                                                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  915:                                                     }
  916:  
  917:                                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  918:  
  919:                                                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
  920:  
  921:                                                     result.AddSuccess("command(s) sent...");
  922:                                                 }
  923:                                                 else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
  924:                                             }
  925:                                             else result.AddError("ONT family type is not MDU.");
  926:                                         }
  927:                                         else result.AddError("OLT is not SIP, its H.248.");
  928:                                     }
  929:                                     else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
  930:                                 }
  931:                                 else result.AddError("nddOnt is null, does not exist for service " + service + ".");
  932:  
  933:                                 vacatedNddOnt = nddOnt;
  934:                             }
  935:                             else result.AddError("emsOnt.Access is null for service " + service + ".");
  936:                         }
  937:                     }
  938:                     else
  939:                     {
  940:                         var msanEmsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
  941:  
  942:                         if (msanEmsVoipPstnUserList.Count > 0)
  943:                         {
  944:                             // MSAN
  945:  
  946:                             foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
  947:                             {
  948:                                 DeleteVoipPstnUserAndOrVacateVoipPstnAccount(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  949:                             }
  950:  
  951:                             result.AddSuccess("command(s) sent...");
  952:                         }
  953:                         else result.AddWarning("Could not find service " + service + ".");
  954:                     }
  955:                 }
  956:             }
  957:             else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  958:  
  959:             return vacatedNddOnt;
  960:         }
  961:  
  962:         ////////////////////////////////////////////////////////////////////////////
  963:  
  964:         /// <summary>
  965:         ///
  966:         /// </summary>
  967:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> DeleteMsanVoipPstnUser2(string service, out Ia.Cl.Models.Result result)
  968:         {
  969:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic lic;
  970:  
  971:             result = new Ia.Cl.Models.Result();
  972:  
  973:             var licList = new List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic>();
  974:  
  975:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  976:             {
  977:                 var msanEmsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
  978:  
  979:                 if (msanEmsVoipPstnUserList.Count > 0)
  980:                 {
  981:                     // MSAN
  982:  
  983:                     foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
  984:                     {
  985:                         DeleteVoipPstnUserAndOrVacateVoipPstnAccount(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
  986:  
  987:                         lic = Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevLicByEmsVoipPstnUserId(emsVoipPstnUser.Id);
  988:  
  989:                         licList.Add(lic);
  990:                     }
  991:  
  992:                     result.AddSuccess("command(s) sent...");
  993:                 }
  994:                 else result.AddWarning("Could not find service " + service + ".");
  995:             }
  996:             else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
  997:  
  998:             return licList;
  999:         }
 1000:  
 1001:         ////////////////////////////////////////////////////////////////////////////
 1002:  
 1003:         /// <summary>
 1004:         ///
 1005:         /// </summary>
 1006:         public static void DeleteVoipPstnUserAndOrVacateVoipPstnAccount(string dev, int fn, int sn, int pn)
 1007:         {
 1008:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, dev, fn, sn, pn);
 1009:  
 1010:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
 1011:  
 1012:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, dev);
 1013:         }
 1014:  
 1015:         ////////////////////////////////////////////////////////////////////////////
 1016:  
 1017:         /// <summary>
 1018:         ///
 1019:         /// </summary>
 1020:         private static void DeleteVoipPstnUserAndOrVacateVoipPstnAccount(int did, int fn, int sn, int pn)
 1021:         {
 1022:             var dev = Ia.Ftn.Cl.Models.Data.Huawei.Dev.DidToDevDictionary[did];
 1023:  
 1024:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, dev, fn, sn, pn);
 1025:  
 1026:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
 1027:  
 1028:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, dev);
 1029:         }
 1030:  
 1031:         ////////////////////////////////////////////////////////////////////////////
 1032:         ////////////////////////////////////////////////////////////////////////////
 1033:  
 1034:         /// <summary>
 1035:         ///
 1036:         /// </summary>
 1037:         public static Ia.Cl.Models.Result CreateMsanVoipPstnUser(string msanDevId, int fn, int sn, int pn, string service)
 1038:         {
 1039:             Ia.Ftn.Cl.Models.Business.Huawei.Default.FnSnPnPort fnSnPn;
 1040:  
 1041:             var result = new Ia.Cl.Models.Result();
 1042:  
 1043:             if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
 1044:             {
 1045:                 var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList where m.Id == msanDevId select m).Single();
 1046:  
 1047:                 var vacantFnSnPnList = Ia.Ftn.Cl.Models.Data.Huawei.Ems.VacantMsanFnSnPnListForMsanDev(msanDev);
 1048:  
 1049:                 if (vacantFnSnPnList.Count > 0)
 1050:                 {
 1051:                     fnSnPn = vacantFnSnPnList.Where(f => f.Fn == fn && f.Sn == sn && f.Pn == pn).SingleOrDefault();
 1052:  
 1053:                     if (fnSnPn == null) fnSnPn = Ia.Ftn.Cl.Models.Data.Huawei.Ems.NextVacantMsanFnSnPnForMsanDev(msanDev);
 1054:  
 1055:                     if (fnSnPn != null)
 1056:                     {
 1057:                         var emsVoipPstnUserList = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.ReadByService(service);
 1058:  
 1059:                         if (emsVoipPstnUserList.Count == 0)
 1060:                         {
 1061:                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendCreateMsanVoipPstnUser(ems, msanDev, fnSnPn.Fn, fnSnPn.Sn, fnSnPn.Pn, service);
 1062:  
 1063:                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, msanDev);
 1064:  
 1065:                             result.AddSuccess("command(s) sent...");
 1066:                         }
 1067:                         else result.AddError("emsVoipPstnUserList count != 0. Value must be zero before the operation is executed for service: " + service + ".");
 1068:                     }
 1069:                     else result.AddError("MDU sn and/or tel is invalid or does not exist.");
 1070:                 }
 1071:                 else result.AddError("vacantFnSnPnList.Count is 0. There are no vacant ports in MSAN.");
 1072:             }
 1073:             else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
 1074:  
 1075:             return result;
 1076:         }
 1077:  
 1078:         ////////////////////////////////////////////////////////////////////////////
 1079:  
 1080:         /// <summary>
 1081:         ///
 1082:         /// </summary>
 1083:         public static void ReadVoipPstnUser(string dev, int fn, int sn, int pn)
 1084:         {
 1085:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, dev, sn, pn);
 1086:         }
 1087:  
 1088:         ////////////////////////////////////////////////////////////////////////////
 1089:  
 1090:         /// <summary>
 1091:         ///
 1092:         /// </summary>
 1093:         public static void ReadMsanVoipPstnUser(Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic lic)
 1094:         {
 1095:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, lic.MsanDevDev, lic.Sn, lic.Pn);
 1096:         }
 1097:  
 1098:         ////////////////////////////////////////////////////////////////////////////
 1099:  
 1100:         /// <summary>
 1101:         ///
 1102:         /// </summary>
 1103:         public static void ReadVoipPstnUser(string service)
 1104:         {
 1105:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, service);
 1106:         }
 1107:  
 1108:         ////////////////////////////////////////////////////////////////////////////
 1109:  
 1110:         /// <summary>
 1111:         ///
 1112:         /// </summary>
 1113:         private static void ReadVoipPstnUser(int did, int fn, int sn, int pn)
 1114:         {
 1115:             var dev = Ia.Ftn.Cl.Models.Data.Huawei.Dev.DidToDevDictionary[did];
 1116:  
 1117:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, dev, sn, pn);
 1118:         }
 1119:  
 1120:         ////////////////////////////////////////////////////////////////////////////
 1121:  
 1122:         /// <summary>
 1123:         ///
 1124:         /// </summary>
 1125:         public static void DeleteVoipPstnUser(string dev, int fn, int sn, int pn)
 1126:         {
 1127:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
 1128:  
 1129:             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendSaveDev(ems, dev);
 1130:         }
 1131:  
 1132:         ////////////////////////////////////////////////////////////////////////////
 1133:  
 1134:         /// <summary>
 1135:         ///
 1136:         /// </summary>
 1137:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> DeleteMsanVoipPstnUser(string service, out Ia.Cl.Models.Result result)
 1138:         {
 1139:             var licList = new List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic>();
 1140:  
 1141:             result = new Ia.Cl.Models.Result();
 1142:  
 1143:             try
 1144:             {
 1145:                 if (!string.IsNullOrEmpty(service))
 1146:                 {
 1147:                     if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
 1148:                     {
 1149:                         licList = Ia.Ftn.Cl.Models.Business.Huawei.Nce.DeleteMsanVoipPstnUser2(service, out result);
 1150:                     }
 1151:                     else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
 1152:                 }
 1153:                 else result.AddError("Service null or empty.");
 1154:             }
 1155:             catch (Exception ex)
 1156:             {
 1157:                 result.AddError("Exception: " + ex.ToString() + ".");
 1158:             }
 1159:  
 1160:             return licList;
 1161:         }
 1162:  
 1163:         ////////////////////////////////////////////////////////////////////////////
 1164:         ////////////////////////////////////////////////////////////////////////////
 1165:  
 1166:         /// <summary>
 1167:         ///
 1168:         /// </summary>
 1169:         public static Ia.Cl.Models.Result ResetOnt(string accessName)
 1170:         {
 1171:             var result = new Ia.Cl.Models.Result();
 1172:  
 1173:             try
 1174:             {
 1175:                 if (!string.IsNullOrEmpty(accessName))
 1176:                 {
 1177:                     var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
 1178:  
 1179:                     if (nddOnt != null)
 1180:                     {
 1181:                         Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendResetOnt(ems, nddOnt);
 1182:                     }
 1183:                     else result.AddError("NDD ONT is null for access name: " + accessName);
 1184:                 }
 1185:                 else
 1186:                 {
 1187:                     result.AddError("AccessName null or empty");
 1188:                 }
 1189:             }
 1190:             catch (Exception ex)
 1191:             {
 1192:                 result.AddError("Exception: " + ex.ToString());
 1193:             }
 1194:  
 1195:             return result;
 1196:         }
 1197:  
 1198:         ////////////////////////////////////////////////////////////////////////////
 1199:         ////////////////////////////////////////////////////////////////////////////
 1200:  
 1201:         /// <summary>
 1202:         ///
 1203:         /// </summary>
 1204:         public static Ia.Cl.Models.Result ManageSynchronizationBetweenAccessAndSwitchPastHour()
 1205:         {
 1206:             // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
 1207:  
 1208:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1209:  
 1210:             var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
 1211:             var result = new Ia.Cl.Models.Result();
 1212:  
 1213:             // problem: I have put empty new List<string>() here because there is an exception: System.Exception: Undefined function
 1214:             process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastHourProcedure.NextProcess(new List<string>());
 1215:  
 1216:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1217:             {
 1218:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Create)
 1219:                 {
 1220:                     result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1221:  
 1222:                     CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1223:                 }
 1224:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1225:                 {
 1226:                     result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1227:  
 1228:                     ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
 1229:                 }
 1230:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Delete)
 1231:                 {
 1232:                     result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1233:  
 1234:                     _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1235:                 }
 1236:                 else result.AddError("sync: undefined procedure.");
 1237:  
 1238:                 // Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Updated() is in Ia.Ftn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
 1239:             }
 1240:             else result.AddWarning("sync: nothing to create or delete");
 1241:  
 1242:             return result;
 1243:         }
 1244:  
 1245:         ////////////////////////////////////////////////////////////////////////////
 1246:  
 1247:         /// <summary>
 1248:         ///
 1249:         /// </summary>
 1250:         public static Ia.Cl.Models.Result ManageSynchronizationBetweenAccessAndSwitchPast24Hours()
 1251:         {
 1252:             // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
 1253:  
 1254:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1255:  
 1256:             var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
 1257:             var result = new Ia.Cl.Models.Result();
 1258:  
 1259:             process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.NextProcess(priorityServiceList);
 1260:  
 1261:             if (priorityServiceList.Count > 50) priorityServiceList.Clear();
 1262:  
 1263:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1264:             {
 1265:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Create)
 1266:                 {
 1267:                     result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1268:  
 1269:                     CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1270:                 }
 1271:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1272:                 {
 1273:                     result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1274:  
 1275:                     ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
 1276:                 }
 1277:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Delete)
 1278:                 {
 1279:                     result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
 1280:  
 1281:                     _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1282:                 }
 1283:                 else result.AddError("sync: undefined procedure.");
 1284:  
 1285:                 // Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Updated() is in Ia.Ftn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
 1286:             }
 1287:             else result.AddWarning("sync: nothing to create or delete");
 1288:  
 1289:             return result;
 1290:         }
 1291:  
 1292:         ////////////////////////////////////////////////////////////////////////////
 1293:  
 1294:         /// <summary>
 1295:         ///
 1296:         /// </summary>
 1297:         public static Ia.Cl.Models.Result ManageSynchronizationBetweenAccessAndSwitch()
 1298:         {
 1299:             // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
 1300:  
 1301:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1302:  
 1303:             var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
 1304:             var result = new Ia.Cl.Models.Result();
 1305:  
 1306:             // problem: I have put empty new List<string>() here because there is an exception: System.Exception: Undefined function
 1307:             process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.NextProcess(new List<string>());
 1308:  
 1309:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1310:             {
 1311:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Create)
 1312:                 {
 1313:                     result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
 1314:  
 1315:                     CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1316:                 }
 1317:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1318:                 {
 1319:                     result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
 1320:  
 1321:                     ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
 1322:                 }
 1323:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Delete)
 1324:                 {
 1325:                     result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
 1326:  
 1327:                     _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
 1328:                 }
 1329:                 else result.AddError("sync: undefined procedure.");
 1330:  
 1331:                 // Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Updated() is in Ia.Ftn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
 1332:             }
 1333:             else result.AddWarning("sync: nothing to create or delete");
 1334:  
 1335:             return result;
 1336:         }
 1337:  
 1338:         ////////////////////////////////////////////////////////////////////////////
 1339:         ////////////////////////////////////////////////////////////////////////////
 1340:  
 1341:         /// <summary>
 1342:         ///
 1343:         /// </summary>
 1344:         public static Ia.Cl.Models.Result ManageDeleteMsanOfProvisionedImsServiceOrWithNoEquivalentInService()
 1345:         {
 1346:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1347:  
 1348:             var result = new Ia.Cl.Models.Result();
 1349:  
 1350:             process = msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.NextProcess();
 1351:  
 1352:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1353:             {
 1354:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Delete)
 1355:                 {
 1356:                     result.AddSuccess("delete: " + process.Service + " " + process.EmsVoipPstnUserDidFnSnPnDn.ToSimpleDidFnSnPnDnTextString() + " " + msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.ProgressCounterString);
 1357:  
 1358:                     DeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.EmsVoipPstnUserDidFnSnPnDn.Did, process.EmsVoipPstnUserDidFnSnPnDn.Fn, process.EmsVoipPstnUserDidFnSnPnDn.Sn, process.EmsVoipPstnUserDidFnSnPnDn.Pn);
 1359:                 }
 1360:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1361:                 {
 1362:                     result.AddSuccess("read: " + process.Service + " " + process.EmsVoipPstnUserDidFnSnPnDn.ToSimpleDidFnSnPnDnTextString() + " " + msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.ProgressCounterString);
 1363:  
 1364:                     ReadVoipPstnUser(process.EmsVoipPstnUserDidFnSnPnDn.Did, process.EmsVoipPstnUserDidFnSnPnDn.Fn, process.EmsVoipPstnUserDidFnSnPnDn.Sn, process.EmsVoipPstnUserDidFnSnPnDn.Pn);
 1365:                 }
 1366:                 else result.AddError("sync: undefined procedure.");
 1367:  
 1368:                 // Ia.Ftn.Cl.Model.Data.MessageQueue.SecretaryApplication.Updated() is in Ia.Ftn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
 1369:             }
 1370:             else result.AddWarning("sync: nothing to delete");
 1371:  
 1372:             return result;
 1373:         }
 1374:  
 1375:         ////////////////////////////////////////////////////////////////////////////
 1376:         ////////////////////////////////////////////////////////////////////////////
 1377:  
 1378:         /// <summary>
 1379:         ///
 1380:         /// </summary>
 1381:         public static void ManageUpdateOfOntFromH248ToSip(out Ia.Cl.Models.Result result)
 1382:         {
 1383:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1384:  
 1385:             result = new Ia.Cl.Models.Result();
 1386:  
 1387:             process = updateEmsOntFromH248ToSipProcedure.NextProcess();
 1388:  
 1389:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1390:             {
 1391:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Update)
 1392:                 {
 1393:                     result.AddSuccess("update: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 1394:  
 1395:                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendUpdateOntFromH248ToSip(ems, process.Ont);
 1396:                 }
 1397:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1398:                 {
 1399:                     result.AddSuccess("read: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
 1400:  
 1401:                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadOnt(ems, process.Ont);
 1402:                 }
 1403:                 else result.AddSuccess("update: undefined procedure.");
 1404:             }
 1405:             else result.AddSuccess("update: nothing to update");
 1406:         }
 1407:  
 1408:         ////////////////////////////////////////////////////////////////////////////
 1409:  
 1410:         /// <summary>
 1411:         ///
 1412:         /// </summary>
 1413:         public static void ManageCreateOntSipInfoOrOntVoipPstnUserForOntUpdatedFromH248ToSip(out Ia.Cl.Models.Result result)
 1414:         {
 1415:             Ia.Ftn.Cl.Models.Business.Procedure.Process process;
 1416:  
 1417:             result = new Ia.Cl.Models.Result();
 1418:  
 1419:             process = createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.NextProcess();
 1420:  
 1421:             if (process.Type != Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.None)
 1422:             {
 1423:                 if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Update)
 1424:                 {
 1425:                     result.AddSuccess("create: " + process.Ont.Access.Name + " " + process.Service + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 1426:  
 1427:                     CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, process.Port, ref result);
 1428:                 }
 1429:                 else if (process.Type == Ia.Ftn.Cl.Models.Business.Procedure.ProcessType.Read)
 1430:                 {
 1431:                     result.AddSuccess("read: " + process.Ont.Access.Name + " " + process.Service + "Ia.Ftn.Cl.Model.Data.MessageQueue." + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
 1432:  
 1433:                     ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, process.Port, ref result);
 1434:                 }
 1435:                 else result.AddSuccess("create: undefined procedure.");
 1436:             }
 1437:             else result.AddSuccess("create: nothing to create");
 1438:         }
 1439:  
 1440:         ////////////////////////////////////////////////////////////////////////////
 1441:  
 1442:         /// <summary>
 1443:         ///
 1444:         /// </summary>
 1445:         public static async Task<Ia.Cl.Models.Result> ManageMessageQueue()
 1446:         {
 1447:             List<string> list;
 1448:  
 1449:             var result = new Ia.Cl.Models.Result();
 1450:  
 1451:             var count = await Ia.Ftn.Cl.Models.Data.MessageQueue.NceApplication.CountAsync;
 1452:  
 1453:             if (count > 0)
 1454:             {
 1455:                 var message = await Ia.Ftn.Cl.Models.Data.MessageQueue.NceApplication.DequeueAsync;
 1456:  
 1457:                 if (message != null)
 1458:                 {
 1459:                     if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadService)
 1460:                     {
 1461:                         var service = message.Service;
 1462:  
 1463:                         list = Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByService(service);
 1464:  
 1465:                         foreach (string s in list) ems.SendQueue.Enqueue(s);
 1466:  
 1467:                         if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
 1468:                     }
 1469:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ReadAccess)
 1470:                     {
 1471:                         list = Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByAccessName(message.AccessName);
 1472:  
 1473:                         foreach (string s in list) ems.SendQueue.Enqueue(s);
 1474:                     }
 1475:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ResetAccess)
 1476:                     {
 1477:                         var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(message.AccessName);
 1478:  
 1479:                         if (nddOnt != null)
 1480:                         {
 1481:                             Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendResetOnt(ems, nddOnt);
 1482:                         }
 1483:                         else result.AddError("NDD ONT is null for access name: " + message.AccessName);
 1484:                     }
 1485:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadServiceAccessPort || message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceOrAmsServiceAccessPort)
 1486:                     {
 1487:                         var service = message.Service;
 1488:                         var accessName = message.AccessName;
 1489:                         var port = (message.Port > 0) ? message.Port : Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
 1490:  
 1491:                         var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
 1492:  
 1493:                         var sendReadOntSipInfoCommandAgainAfterNSeconds = true;
 1494:  
 1495:                         if (nddOnt != null)
 1496:                         {
 1497:                             if (nddOnt.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei)
 1498:                             {
 1499:                                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, out Ia.Cl.Models.Result createResult);
 1500:  
 1501:                                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Models.Result readResult);
 1502:  
 1503:                                 result.AddSuccess("Create/Read: " + service + "|" + accessName + "|" + port + ": " + createResult.Message + "," + readResult.Message);
 1504:  
 1505:                                 if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
 1506:                             }
 1507:                             else result.AddError("Access vendor is not Huawei. Access name: " + accessName + ".");
 1508:                         }
 1509:                         else result.AddError("NDD ONT is null for access name: " + accessName + ".");
 1510:                     }
 1511:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadServiceAccess || message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceOrAmsServiceAccessPort)
 1512:                     {
 1513:                         var service = message.Service;
 1514:                         var accessName = message.AccessName;
 1515:                         var port = (message.Port > 0) ? message.Port : Ia.Ftn.Cl.Models.Business.Default.PortUndefinedOrInvalidOrUnknown;
 1516:  
 1517:                         var nddOnt = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntByAccessName(accessName);
 1518:  
 1519:                         var sendReadOntSipInfoCommandAgainAfterNSeconds = true;
 1520:  
 1521:                         if (nddOnt != null)
 1522:                         {
 1523:                             if (nddOnt.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Huawei)
 1524:                             {
 1525:                                 var vacatedAccessName = Ia.Ftn.Cl.Models.Business.Huawei.Nce.DeleteOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, out Ia.Cl.Models.Result deleteResult);
 1526:  
 1527:                                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, vacatedAccessName, port, sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Models.Result readResult);
 1528:  
 1529:                                 result.AddSuccess("Delete/Read: " + service + "|" + accessName + "|" + port + ": " + deleteResult.Message + "," + readResult.Message);
 1530:  
 1531:                                 if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
 1532:                             }
 1533:                             else result.AddError("Access vendor is not Huawei. Access name: " + accessName + ".");
 1534:                         }
 1535:                         else result.AddError("NDD ONT is null for access name: " + accessName + ".");
 1536:                     }
 1537:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.CreateReadNceMsanServiceMsanCabinetFrameFnSnPn)
 1538:                     {
 1539:                         var msanDevId = message.MsanDevId;
 1540:                         var fn = message.Fn;
 1541:                         var sn = message.Sn;
 1542:                         var pn = message.Pn;
 1543:                         var service = message.Service;
 1544:  
 1545:                         var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList where m.Id == msanDevId select m).Single();
 1546:  
 1547:                         result = Ia.Ftn.Cl.Models.Business.Huawei.Nce.CreateMsanVoipPstnUser(msanDevId, fn, sn, pn, service);
 1548:  
 1549:                         Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadVoipPstnUser(service);
 1550:  
 1551:                         result.AddSuccess("Create/Read: " + msanDev.Dev + "-" + fn + "-" + sn + "-" + pn + "|" + service + ": " + result.Message);
 1552:  
 1553:                         if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
 1554:                     }
 1555:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.DeleteReadNceMsanService)
 1556:                     {
 1557:                         var service = message.Service;
 1558:  
 1559:                         var readResult = new Ia.Cl.Models.Result();
 1560:  
 1561:                         var vacatedLicList = Ia.Ftn.Cl.Models.Business.Huawei.Nce.DeleteMsanVoipPstnUser(service, out result);
 1562:  
 1563:                         foreach (var vacatedLic in vacatedLicList)
 1564:                         {
 1565:                             Ia.Ftn.Cl.Models.Business.Huawei.Nce.ReadMsanVoipPstnUser(vacatedLic);
 1566:                         }
 1567:  
 1568:                         result.AddSuccess("Delete/Read: " + service + ": " + result.Message + "," + readResult.Message);
 1569:  
 1570:                         if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
 1571:                     }
 1572:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.AccessCreated)
 1573:                     {
 1574:                         Ia.Ftn.Cl.Models.Data.Huawei.Default.AccessNameToMduDevDictionaryReset();
 1575:  
 1576:                         result.AddSuccess("Access created: AccessNameToMduDevDictionary reset.");
 1577:                     }
 1578:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.Synchronize)
 1579:                     {
 1580:                         var r = Ia.Ftn.Cl.Models.Business.Huawei.Nce.ManageSynchronizationBetweenAccessAndSwitchPast24Hours();
 1581:                         result.AddResult("Manage: Synchronization: Access with Switch", r);
 1582:  
 1583:                         var r2 = Ia.Ftn.Cl.Models.Business.Huawei.Nce.ManageDeleteMsanOfProvisionedImsServiceOrWithNoEquivalentInService();
 1584:                         result.AddResult("Manage: Synchronization: Delete MSAN of provisioned IMS service", r2);
 1585:                     }
 1586:                     else if (message.Process == Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ActiveApplicationRunningPermissionState)
 1587:                     {
 1588:                         Ia.Ftn.Cl.Models.Business.Default.PermitActiveApplicationsToRun = message.State;
 1589:  
 1590:                         result.AddSuccess("PermitActiveApplicationsToRun: " + message.State);
 1591:                     }
 1592:                     else
 1593:                     {
 1594:                         throw new ArgumentOutOfRangeException("MessageQueue process " + message.Process.ToString() + " is undefined");
 1595:                     }
 1596:  
 1597:                     result.AddSuccess(message.AccessName + ":" + message.Service);
 1598:                 }
 1599:                 else
 1600:                 {
 1601:  
 1602:                 }
 1603:             }
 1604:  
 1605:             return result;
 1606:         }
 1607:  
 1608:         ////////////////////////////////////////////////////////////////////////////
 1609:  
 1610:         /// <summary>
 1611:         ///
 1612:         /// </summary>
 1613:         public static void ManageProperly(out Ia.Cl.Models.Result result)
 1614:         {
 1615:             string command;
 1616:  
 1617:             result = new Ia.Cl.Models.Result();
 1618:  
 1619:             command = Ia.Ftn.Cl.Models.Business.Huawei.Ems.ProperlySelectedSingleEmsCommandToManageOntNetworkElements;
 1620:  
 1621:             ems.SendQueue.Enqueue(command);
 1622:  
 1623:             result.AddSuccess(command);
 1624:         }
 1625:  
 1626:         ////////////////////////////////////////////////////////////////////////////
 1627:         ////////////////////////////////////////////////////////////////////////////
 1628:  
 1629:         /// <summary>
 1630:         ///
 1631:         /// </summary>
 1632:         public static void ReadDevList(out Ia.Cl.Models.Result result)
 1633:         {
 1634:             string command;
 1635:  
 1636:             result = new Ia.Cl.Models.Result();
 1637:  
 1638:             var redundantDevList = Ia.Ftn.Cl.Models.Data.Huawei.Dev.RedundantDevList();
 1639:  
 1640:             if (redundantDevList.Count == 0)
 1641:             {
 1642:                 /*
 1643:                  * List DEVs with DT: MA5600T (OLTs) (LST-DEV::DT=249:{ctag}::;)
 1644:                  * List DEVs with DT: MA5603T (OLTs) (LST-DEV::DT=95:{ctag}::;)
 1645:                  * List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
 1646:                  * 
 1647:                  * I can't read MA5878 using LST-DEV::DT, I have to use LST-DEV::DEV
 1648:                  * e.g. LST-DEV::DEV=MDU-SAB-1443-001:{ctag}::;
 1649:                  */
 1650:  
 1651:                 switch (Ia.Cl.Models.Default.Random(99) % 3)
 1652:                 {
 1653:                     case 0: command = Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5600T"); break;
 1654:                     case 1: command = Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5603T"); break;
 1655:                     case 2: command = Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5616"); ; break;
 1656:                     default: command = string.Empty; break;
 1657:                 }
 1658:  
 1659:                 // delay to prevent mixing of next command output with this long LST-DEV command
 1660:                 Ia.Ftn.Cl.Models.Business.Huawei.Nce.DelaySendQueue(10);
 1661:  
 1662:                 result.AddSuccess("Reading Devs with devTypes: " + command);
 1663:             }
 1664:             else
 1665:             {
 1666:                 throw new Exception("ReadDevList(): redundantDevList.Count != 0 there are duplicate names in EmsDev");
 1667:             }
 1668:         }
 1669:  
 1670:         ////////////////////////////////////////////////////////////////////////////
 1671:  
 1672:         /// <summary>
 1673:         ///
 1674:         /// </summary>
 1675:         public static void SequentiallyReadBoardListForDevAndOntListForMduDev(out Ia.Cl.Models.Result result)
 1676:         {
 1677:             result = new Ia.Cl.Models.Result();
 1678:  
 1679:             var dev = Ia.Ftn.Cl.Models.Business.Huawei.Dev.SequentialEmsDevListItem(out _, out string progressCounterString);
 1680:  
 1681:             if (dev != null)
 1682:             {
 1683:                 Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadBoardList(ems, dev.DEV);
 1684:  
 1685:                 if (dev.Type == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu) //&List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
 1686:                 {
 1687:                     Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadOntList(ems, dev.DID);
 1688:                 }
 1689:  
 1690:                 result.AddSuccess("dev: " + dev.DEV + ", " + progressCounterString);
 1691:             }
 1692:             else result.AddError("Dev is null.");
 1693:         }
 1694:  
 1695:         ////////////////////////////////////////////////////////////////////////////
 1696:  
 1697:         /// <summary>
 1698:         ///
 1699:         /// </summary>
 1700:         public static void SequentiallyReadPortListForBoard(out Ia.Cl.Models.Result result)
 1701:         {
 1702:             result = new Ia.Cl.Models.Result();
 1703:  
 1704:             var board = Ia.Ftn.Cl.Models.Business.Huawei.Board.SequentialEmsBoardListItem(out _, out string progressCounterString);
 1705:  
 1706:             if (board != null)
 1707:             {
 1708:                 Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadPortList(ems, board.EmsDev.DEV, board.FN, board.SN);
 1709:  
 1710:                 result.AddSuccess("DEV: " + board.EmsDev.DEV + ", SN: " + board.SN + " " + progressCounterString);
 1711:             }
 1712:             else result.AddError("Board is null.");
 1713:         }
 1714:  
 1715:         ////////////////////////////////////////////////////////////////////////////
 1716:  
 1717:         /// <summary>
 1718:         ///
 1719:         /// </summary>
 1720:         public static void SequentiallyReadPortForMsan(out Ia.Cl.Models.Result result)
 1721:         {
 1722:             result = new Ia.Cl.Models.Result();
 1723:  
 1724:             var port = Ia.Ftn.Cl.Models.Business.Huawei.Dev.SequentialEmsMsanDevPortListItem(out _, out string progressCounterString);
 1725:  
 1726:             if (port != null)
 1727:             {
 1728:                 Ia.Ftn.Cl.Models.Data.Huawei.Ems.SendReadVoipPstnUser(ems, port.EmsBoard.EmsDev.DEV, port.SN, port.PN);
 1729:  
 1730:                 result.AddSuccess("DEV: " + port.EmsBoard.EmsDev.DEV + ", SN: " + port.SN + " " + progressCounterString);
 1731:             }
 1732:             else result.AddError("port is null.");
 1733:         }
 1734:  
 1735:         ////////////////////////////////////////////////////////////////////////////
 1736:  
 1737:         /// <summary>
 1738:         ///
 1739:         /// </summary>
 1740:         public static void DelaySendQueue(int count)
 1741:         {
 1742:             if (count > 0)
 1743:             {
 1744:                 for (var i = 0; i < count; i++)
 1745:                 {
 1746:                     ems.SendQueue.Enqueue(string.Empty);
 1747:                 }
 1748:             }
 1749:         }
 1750:  
 1751:         ////////////////////////////////////////////////////////////////////////////
 1752:  
 1753:         /// <summary>
 1754:         ///
 1755:         /// </summary>
 1756:         public static void DelaySystemIsBusyResendQueue(int count)
 1757:         {
 1758:             if (count > 0)
 1759:             {
 1760:                 for (var i = 0; i < count; i++)
 1761:                 {
 1762:                     ems.SystemIsBusyResendQueue.Enqueue(string.Empty);
 1763:                 }
 1764:             }
 1765:         }
 1766:  
 1767:         ////////////////////////////////////////////////////////////////////////////
 1768:  
 1769:         /// <summary>
 1770:         ///
 1771:         /// </summary>
 1772:         public static void DelaySystemIsBusyResendQueueByEmsKeepAlive(int count)
 1773:         {
 1774:             if (count > 0)
 1775:             {
 1776:                 for (var i = 0; i < count; i++)
 1777:                 {
 1778:                     ems.SystemIsBusyResendQueue.Enqueue(Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsKeepAliveCommand);
 1779:                 }
 1780:             }
 1781:         }
 1782:  
 1783:         ////////////////////////////////////////////////////////////////////////////
 1784:  
 1785:         /// <summary>
 1786:         ///
 1787:         /// </summary>
 1788:         private static void EvaluateSendReadOntSipInfoCommandAgainAfterNSecondsResendQueue()
 1789:         {
 1790:             var nowDataTime = DateTime.UtcNow.AddHours(3);
 1791:             var commandsToRemoveList = new List<string>();
 1792:  
 1793:             foreach (var kvp in ems.OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary)
 1794:             {
 1795:                 var dateTime = kvp.Value.AddSeconds(Ia.Ftn.Cl.Models.Business.Huawei.Nce.SendReadOntSipInfoCommandAgainAfterNSeconds);
 1796:  
 1797:                 if (dateTime < nowDataTime)
 1798:                 {
 1799:                     var command = kvp.Key;
 1800:  
 1801:                     ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Enqueue(command);
 1802:  
 1803:                     commandsToRemoveList.Add(command);
 1804:                 }
 1805:             }
 1806:  
 1807:             foreach (var command in commandsToRemoveList)
 1808:             {
 1809:                 ems.OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary.Remove(command);
 1810:             }
 1811:         }
 1812:  
 1813:         ////////////////////////////////////////////////////////////////////////////
 1814:  
 1815:         /// <summary>
 1816:         ///
 1817:         /// </summary>
 1818:         public static void TestService(string service)
 1819:         {
 1820:             var list = Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByService(service);
 1821:  
 1822:             foreach (string s in list) ems.SendQueue.Enqueue(s);
 1823:         }
 1824:  
 1825:         ////////////////////////////////////////////////////////////////////////////
 1826:  
 1827:         /// <summary>
 1828:         ///
 1829:         /// </summary>
 1830:         public static void TestAccess(string accessName)
 1831:         {
 1832:             var list = Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByAccessName(accessName);
 1833:  
 1834:             foreach (string s in list) ems.SendQueue.Enqueue(s);
 1835:         }
 1836:  
 1837:         ////////////////////////////////////////////////////////////////////////////
 1838:         ////////////////////////////////////////////////////////////////////////////
 1839:     }
 1840:  
 1841:     ////////////////////////////////////////////////////////////////////////////
 1842:     ////////////////////////////////////////////////////////////////////////////
 1843: }