)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Ems (Ia.Ftn.Cl.Models.Client.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) client support class for Huawei's Fixed Telecommunications Network (FTN) EMS client model.

    1: using Dart.Telnet;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.Diagnostics;
    5: using System.Security.Cryptography.X509Certificates;
    6:  
    7: namespace Ia.Ftn.Cl.Models.Client.Huawei
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// Fixed Telecommunications Network's Operations Support System Management Intranet (FTN OSS) client support class for Huawei's Fixed Telecommunications Network (FTN) EMS client model.
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright © 2017-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     /// </remarks> 
   18:     public class Ems
   19:     {
   20:         private string receiveString;
   21:  
   22:         private byte[] buffer = new byte[1024];
   23:         private TelnetModel telnetModel;
   24:         private Dart.Telnet.Telnet telnet;
   25:         private X509CertificateCollection clientCertificates = new X509CertificateCollection();
   26:         private System.ComponentModel.IContainer components;
   27:  
   28:         /// <summary/>
   29:         public static int WaitAfterSendInMillisecond { get { return 4000; } }
   30:  
   31:         public static int WaitAfterSendForCfgCommandInMillisecond { get { return 10000; } }
   32:  
   33:         public string LastSentCommand { get; private set; }
   34:  
   35:         public Queue<string> ReceiveQueue { get; set; }
   36:  
   37:         public Queue<string> SendQueue { get; set; }
   38:  
   39:         public Queue<string> SystemIsBusyResendQueue { get; set; }
   40:  
   41:         public Queue<string> OntLoadingCommandIsBeingExecutedNowResendQueue { get; set; }
   42:  
   43:         public Dictionary<string, DateTime> OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary { get; set; }
   44:  
   45:         public Queue<string> OntSipInfoCommandAgainAfterNSecondsResendQueue { get; set; }
   46:  
   47:         /// <summary/>
   48:         public bool IsLoggedIn { get; set; }
   49:  
   50:         ////////////////////////////////////////////////////////////////////////////
   51:  
   52:         /// <summary>
   53:         /// 
   54:         /// </summary>
   55:         public enum ResultCode : long
   56:         {
   57:             // I'm basically using the almost exact document phrasing of error codes
   58:             /// <summary/>
   59:             Unknown = -1,
   60:  
   61:             /// <summary/>
   62:             Succeeded = 0,
   63:  
   64:             /// <summary/>
   65:             DeviceDoesNotExist1 = 2686058531,
   66:  
   67:             /// <summary/>
   68:             DeviceDoesNotExist2 = 15658136501,
   69:  
   70:             /// <summary/>
   71:             ResourceDoesNotExist = 2686058552,
   72:  
   73:             /// <summary/>
   74:             OntIsNotOnline = 2689012370,
   75:  
   76:             /// <summary/>
   77:             CommunicatingWithDmFailed = 2686058603,
   78:  
   79:             /// <summary/>
   80:             OntIsOffline = 2689014724,
   81:  
   82:             /// <summary/>
   83:             OntLoadingCommandIsBeingExecutedNow = 2689014933,
   84:  
   85:             /// <summary/>
   86:             SystemIsBusy1 = 2686058516,
   87:  
   88:             /// <summary/>
   89:             SystemIsBusy2 = 2689017157,
   90:  
   91:             /// <summary/>
   92:             AttempetingTimeout = 2686058596,
   93:  
   94:             /// <summary/>
   95:             CommandSyntaxError = 2686058497,
   96:  
   97:             /// <summary/>
   98:             UnknownCommand = 2686058499,
   99:  
  100:             /// <summary/>
  101:             TaskTimeout = 2686058508,
  102:  
  103:             /// <summary/>
  104:             ValueOfParameterIsWrong = 2686058500,
  105:  
  106:             /// <summary/>
  107:             DbaProfileDoesNotExist1 = 102690820,
  108:  
  109:             /// <summary/>
  110:             DbaProfileDoesNotExist2 = 2689014791,
  111:  
  112:             /// <summary/>
  113:             NodeParameterSetFailed = 1615069195,
  114:  
  115:             /// <summary/>
  116:             VersionDoesNotMatchOrCommunicationWithDeviceFailed = 1615462437,
  117:  
  118:             /// <summary/>
  119:             FailedToCommunicateWithDevice1 = 1610614842,
  120:  
  121:             /// <summary/>
  122:             FailedToCommunicateWithDevice2 = 1616445483,
  123:  
  124:             /// <summary/>
  125:             FailedToCommunicateWithDevice3 = 1616445484,
  126:  
  127:             /// <summary/>
  128:             FailedToCommunicateWithDevice4 = 1616445485,
  129:  
  130:             /// <summary/>
  131:             LoginAddressIsNotInUserAcl = 76546022,
  132:  
  133:             /// <summary/>
  134:             LoginAddressIsNotInSystemAcl = 76546023,
  135:  
  136:             /// <summary/>
  137:             DeviceOfflineError = 1610612765,
  138:  
  139:             /// <summary/>
  140:             OperationIsNotSupported = 2689008176,
  141:  
  142:             /// <summary/>
  143:             ParametersConflictWithVasProfile = 1615069206,
  144:  
  145:             /// <summary/>
  146:             ProfileAlreadyExists = 2689023090,
  147:  
  148:             /// <summary/>
  149:             TrafficProfileDoesNotExist = 2689020327,
  150:  
  151:             /// <summary/>
  152:             MgParameterIsConflicting = 2688880284,
  153:  
  154:             /// <summary/>
  155:             NoOnuTypeIsSetInGeneralProfile = 1618280538,
  156:  
  157:             /// <summary/>
  158:             OntIsUsedByOthers = 1618214927,
  159:  
  160:             /// <summary/>
  161:             UserDoesNotLogIn = 2686058521,
  162:  
  163:             /// <summary/>
  164:             PortDoesNotExist = 2689015666,
  165:  
  166:             /// <summary/>
  167:             TelephoneNumberAlreadyExists = 2689015764,
  168:  
  169:             /// <summary/>
  170:             ThePasswordHasExpiredOrNeedsToBeChangedOnNextLogin = 1618280766,
  171:  
  172:             /// <summary/>
  173:             TheUserAccountIsLocked = 76546024,
  174:  
  175:             /// <summary/>
  176:             TheOntDoesNotSuppportConfigeringValueAddedServiceWithoutBindingGeneralVasProfile = 1615069214,
  177:  
  178:             /// <summary/>
  179:             NoMatchingPortPleaseCheckTheDataSetting = 2686059269,
  180:  
  181:             /// <summary/>
  182:             AnInstanceUnknownToTheAgentIsDesignated = 2689007637,
  183:  
  184:             /// <summary/>
  185:             ThePortIsNotConfiguredMgUserData = 2689015732,
  186:  
  187:             /// <summary/>
  188:             PortHasBeenConfiguredWithUserData = 2689015744,
  189:  
  190:             /// <summary/>
  191:             TheCpeIsNotExistent = 161503642,
  192:  
  193:             /// <summary/>
  194:             TheVersionIsNotConfigurable = 1615069190,
  195:         }
  196:  
  197:         ////////////////////////////////////////////////////////////////////////////
  198:  
  199:         /// <summary>
  200:         ///
  201:         /// </summary>
  202:         public static string ResultCodeString(long _resultCode)
  203:         {
  204:             // see: ColoredResultCodeString()
  205:             string resultCodeString;
  206:             Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode resultCode;
  207:  
  208:             resultCode = (Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode)_resultCode;
  209:  
  210:             resultCodeString = resultCode.ToString();
  211:             resultCodeString = Ia.Cl.Models.Default.CamelToProperCase(resultCodeString);
  212:             resultCodeString = Ia.Cl.Models.Default.ToTitleCase(resultCodeString);
  213:             resultCodeString = resultCodeString.Replace("Ont", "ONT");
  214:  
  215:             return resultCodeString;
  216:         }
  217:  
  218:         ////////////////////////////////////////////////////////////////////////////
  219:  
  220:         /// <summary>
  221:         ///
  222:         /// </summary>
  223:         public static string ColoredResultCodeString(long _resultCode)
  224:         {
  225:             // see: ResultCodeString()
  226:             string resultCodeString, coloredResultCodeString;
  227:             Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode resultCode;
  228:  
  229:             resultCode = (Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode)_resultCode;
  230:  
  231:             resultCodeString = resultCode.ToString();
  232:             resultCodeString = Ia.Cl.Models.Default.CamelToProperCase(resultCodeString);
  233:             resultCodeString = Ia.Cl.Models.Default.ToTitleCase(resultCodeString);
  234:             resultCodeString = resultCodeString.Replace("Ont", "ONT");
  235:  
  236:             switch (resultCode)
  237:             {
  238:                 case Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.Succeeded: coloredResultCodeString = "<span style=\"color:Green\">" + resultCodeString + "</span>"; break;
  239:                 case Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.SystemIsBusy2: coloredResultCodeString = "<span style=\"color:MediumPurple\">" + resultCodeString + "</span>"; break;
  240:                 case Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.OntIsOffline: coloredResultCodeString = "<span style=\"color:OrangeRed\">" + resultCodeString + "</span>"; break;
  241:                 case Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.DeviceOfflineError: coloredResultCodeString = "<span style=\"color:Red\">" + resultCodeString + "</span>"; break;
  242:                 default: coloredResultCodeString = "<span style=\"color:Blue\">" + resultCodeString + "</span>"; break;
  243:             }
  244:  
  245:             return coloredResultCodeString;
  246:         }
  247:  
  248:         ////////////////////////////////////////////////////////////////////////////
  249:  
  250:         /// <summary>
  251:         ///
  252:         /// </summary>
  253:         public Ems()
  254:         {
  255:             components = new System.ComponentModel.Container();
  256:  
  257:             Dart.Telnet.Option option1 = new Dart.Telnet.Option();
  258:             Dart.Telnet.Option option2 = new Dart.Telnet.Option();
  259:             Dart.Telnet.Option option3 = new Dart.Telnet.Option();
  260:             Dart.Telnet.Option option4 = new Dart.Telnet.Option();
  261:             Dart.Telnet.Option option5 = new Dart.Telnet.Option();
  262:  
  263:             telnet = new Dart.Telnet.Telnet(components);
  264:  
  265:             option1.Code = Dart.Telnet.OptionCode.SuppressGoAheads;
  266:             option2.Code = Dart.Telnet.OptionCode.WindowSize;
  267:             option2.SubOption = new byte[] { 0, 80, 0, 24 };
  268:             option3.Code = Dart.Telnet.OptionCode.TerminalType;
  269:             option3.SubOption = new byte[] { 0, 116, 116, 121 };
  270:             telnet.ClientOptions.AddRange(new Dart.Telnet.Option[] { option1, option2, option3 });
  271:  
  272:             option4.Code = Dart.Telnet.OptionCode.SuppressGoAheads;
  273:             option5.Code = Dart.Telnet.OptionCode.Echo;
  274:             telnet.ServerOptions.AddRange(new Dart.Telnet.Option[] { option4, option5 });
  275:  
  276:             telnet.SocketOption.ReceiveTimeout = 1000;
  277:             telnet.SynchronizingObject = null;
  278:             telnet.ClientOptionChanged += Telnet_ClientOptionChanged;
  279:             telnet.ServerOptionChanged += Telnet_ServerOptionChanged;
  280:             telnet.Data += Telnet_Data;
  281:             telnet.StateChanged += Telnet_StateChanged;
  282:             telnet.Log += Telnet_Log;
  283:             telnet.Error += Telnet_Error;
  284:  
  285:             telnetModel = new TelnetModel();
  286:  
  287:             // set non-serializable Telnet component
  288:             telnetModel.Telnet = telnet;
  289:             telnetModel.ReceiveLoopRequired = true;
  290:  
  291:             // subscribe to certificate events
  292:             telnetModel.CertificateRequested += new EventHandler<LocalCertificateEventArgs>(TelnetModel_CertificateRequested);
  293:             telnetModel.CertificatePresented += new EventHandler<RemoteCertificateEventArgs>(TelnetModel_CertificatePresented);
  294:  
  295:             /*
  296:             this.telnet = new Dart.Telnet.Telnet(); // this.components);
  297: 
  298:             this.telnet.ClientOptions.AddRange(new Dart.Telnet.Option[] {
  299:             new Dart.Telnet.Option(Dart.Telnet.OptionCode.SuppressGoAheads, null, Dart.Telnet.OptionState.RequestOn),
  300:             new Dart.Telnet.Option(Dart.Telnet.OptionCode.WindowSize, new byte[] {((byte)(0)),((byte)(80)),((byte)(0)),((byte)(24))}, Dart.Telnet.OptionState.RequestOn),
  301:             new Dart.Telnet.Option(Dart.Telnet.OptionCode.TerminalType, new byte[] {((byte)(0)),((byte)(120)),((byte)(116)),((byte)(101)),((byte)(114)),((byte)(109))}, Dart.Telnet.OptionState.RequestOn)});
  302: 
  303:             this.telnet.ServerOptions.AddRange(new Dart.Telnet.Option[] {
  304:             new Dart.Telnet.Option(Dart.Telnet.OptionCode.SuppressGoAheads, null, Dart.Telnet.OptionState.RequestOn),
  305:             new Dart.Telnet.Option(Dart.Telnet.OptionCode.Echo, null, Dart.Telnet.OptionState.RequestOn)});
  306:             */
  307:  
  308:             //this.telnet.SynchronizingObject = this;
  309:             //this.telnet.TerminalType = "xterm";
  310:             //this.telnet.WindowSize = new System.Drawing.Size(80, 24);
  311:             ////this.telnet.EndReceive += new Dart.Telnet.SegmentEventHandler(this.Telnet_EndReceive);
  312:             ////this.telnet.ConnectedChangedEx += new Dart.Telnet.EventHandlerEx(this.Telnet_ConnectedChangedEx);
  313:  
  314:             receiveString = string.Empty;
  315:  
  316:             ReceiveQueue = new Queue<string>();
  317:             SendQueue = new Queue<string>();
  318:             SystemIsBusyResendQueue = new Queue<string>();
  319:             OntLoadingCommandIsBeingExecutedNowResendQueue = new Queue<string>();
  320:  
  321:             OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary = new Dictionary<string, DateTime>();
  322:             OntSipInfoCommandAgainAfterNSecondsResendQueue = new Queue<string>();
  323:  
  324:             IsLoggedIn = false;
  325:         }
  326:  
  327:         ////////////////////////////////////////////////////////////////////////////
  328:  
  329:         /// <summary>
  330:         ///
  331:         /// </summary>
  332:         ~Ems()
  333:         {
  334:             Dispose(true);
  335:         }
  336:  
  337:         ////////////////////////////////////////////////////////////////////////////
  338:  
  339:         /// <summary>
  340:         ///
  341:         /// </summary>
  342:         public Ia.Cl.Models.Result Connect()
  343:         {
  344:             var result = new Ia.Cl.Models.Result();
  345:  
  346:             // if a model with a matching server exists, remove it, then add it so that it is first in the list
  347:             telnetModel.Session.RemoteEndPoint = new IPEndPoint(Ia.Ftn.Cl.Models.Business.Huawei.Ems.Host, Ia.Ftn.Cl.Models.Business.Huawei.Ems.Port);
  348:             telnetModel.Credentials.Username = string.Empty; // txtUsername.Text;
  349:             telnetModel.Credentials.Password = string.Empty; // txtPassword.Text;
  350:             telnetModel.Credentials.CommandPrompt = string.Empty; // txtCommandPrompt.Text;
  351:             telnetModel.Credentials.UsernamePrompt = string.Empty; // txtLoginPrompt.Text;
  352:             telnetModel.Credentials.PasswordPrompt = string.Empty; // txtPasswordPrompt.Text;
  353:             telnetModel.SecurityType = SecurityType.None; // (SecurityType)cboSecurity.SelectedIndex;
  354:             telnetModel.SaveSession();
  355:  
  356:             if (telnetModel.Session.RemoteEndPoint.Port == 23)
  357:             {
  358:                 telnetModel.Telnet.ClientOptions.Add(new Option(OptionCode.SuppressGoAheads, null, OptionState.RequestOn));
  359:                 telnetModel.Telnet.ClientOptions.Add(new Option(OptionCode.WindowSize, new System.Byte[] { ((System.Byte)(0)), ((System.Byte)(80)), ((System.Byte)(0)), ((System.Byte)(24)) }, OptionState.RequestOn));
  360:                 telnetModel.Telnet.ClientOptions.Add(new Option(OptionCode.TerminalType, new System.Byte[] { ((System.Byte)(0)), ((System.Byte)(116)), ((System.Byte)(116)), ((System.Byte)(121)) }, OptionState.RequestOn));
  361:  
  362:                 telnetModel.Telnet.ServerOptions.Add(new Option(OptionCode.SuppressGoAheads, null, OptionState.RequestOn));
  363:                 telnetModel.Telnet.ServerOptions.Add(new Option(OptionCode.Echo, null, OptionState.RequestOn));
  364:                 telnetModel.Telnet.ServerOptions.Add(new Option(OptionCode.OutputPageSize, null, OptionState.RequestOn));
  365:             }
  366:             else
  367:             {
  368:                 telnetModel.Telnet.ClientOptions.Clear();
  369:                 telnetModel.Telnet.ServerOptions.Clear();
  370:             }
  371:  
  372:             // connect and receive data on a separate thread
  373:             telnet.Start(telnetModel.Connect, null);
  374:  
  375:             result.AddSuccess("Connected");
  376:  
  377:             /*
  378:             try
  379:             {
  380:                 telnet.ClientOptions.Add(new Dart.Telnet.Option(Dart.Telnet.OptionCode.SuppressGoAheads, null, Dart.Telnet.OptionState.RequestOn));
  381:                 telnet.ClientOptions.Add(new Dart.Telnet.Option(Dart.Telnet.OptionCode.TerminalType, new System.Byte[] { ((System.Byte)(0)), ((System.Byte)(116)), ((System.Byte)(116)), ((System.Byte)(121)) }, Dart.Telnet.OptionState.RequestOn));
  382:                 telnet.ServerOptions.Add(new Dart.Telnet.Option(Dart.Telnet.OptionCode.SuppressGoAheads, null, Dart.Telnet.OptionState.RequestOn));
  383:                 telnet.ServerOptions.Add(new Dart.Telnet.Option(Dart.Telnet.OptionCode.Echo, null, Dart.Telnet.OptionState.RequestOn));
  384:                 telnet.ServerOptions.Add(new Dart.Telnet.Option(Dart.Telnet.OptionCode.OutputPageSize, null, Dart.Telnet.OptionState.RequestOn));
  385: 
  386:                 ////telnet.Connect(Ia.Ftn.Cl.Models.Business.Huawei.Ems.Host, Ia.Ftn.Cl.Models.Business.Huawei.Ems.Port.ToString());
  387: 
  388:                 // receive using asynchronous technique
  389:                 ////telnet.ReceiveTimeout = 0;
  390:                 ////telnet.BeginReceive(buffer);
  391: 
  392:                 result.AddSuccess("Connected");
  393:             }
  394:             catch (Exception ex)
  395:             {
  396:                 result.AddError("Exception: " + ex.Message);
  397: 
  398:                 telnet.Close();
  399:             }
  400:             */
  401:  
  402:             return result;
  403:         }
  404:  
  405:         ////////////////////////////////////////////////////////////////////////////
  406:  
  407:         /// <summary>
  408:         ///
  409:         /// </summary>
  410:         public Ia.Cl.Models.Result Disconnect()
  411:         {
  412:             var result = new Ia.Cl.Models.Result();
  413:  
  414:             try
  415:             {
  416:                 telnetModel.Telnet.Close();
  417:  
  418:                 result.AddSuccess("Disconnected");
  419:             }
  420:             catch (Exception ex)
  421:             {
  422:                 result.AddError(ex.Message);
  423:             }
  424:  
  425:             return result;
  426:         }
  427:  
  428:         ////////////////////////////////////////////////////////////////////////////
  429:  
  430:         /// <summary>
  431:         ///
  432:         /// </summary>
  433:         public bool IsConnected
  434:         {
  435:             get
  436:             {
  437:                 return telnetModel.IsConnected;
  438:             }
  439:         }
  440:  
  441:         ////////////////////////////////////////////////////////////////////////////
  442:  
  443:         /// <summary>
  444:         ///
  445:         /// </summary>
  446:         public /*override*/ void Dispose(bool disposing)
  447:         {
  448:             if (disposing)
  449:             {
  450:                 if (components != null)
  451:                 {
  452:                     components.Dispose();
  453:                 }
  454:             }
  455:  
  456:             //base.Dispose(disposing);
  457:         }
  458:  
  459:         ////////////////////////////////////////////////////////////////////////////
  460:  
  461:         /// <summary>
  462:         ///
  463:         /// </summary>
  464:         public void Login()
  465:         {
  466:             // sendQueue.Enqueue(Ia.Ftn.Cl.Model.Business.Huawei.Ems.Semicolon); did not make any different
  467:  
  468:             // below: I need this because NCE somehow needs to be triggered before I send login information
  469:             SendQueue.Enqueue(Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsKeepAliveCommand);
  470:             SendQueue.Enqueue(Ia.Ftn.Cl.Models.Business.Huawei.Ems.EmsKeepAliveCommand);
  471:  
  472:             SendQueue.Enqueue(Ia.Ftn.Cl.Models.Business.Huawei.Ems.LoginUser);
  473:         }
  474:  
  475:         ////////////////////////////////////////////////////////////////////////////
  476:  
  477:         /// <summary>
  478:         ///
  479:         /// </summary>
  480:         public void Logout()
  481:         {
  482:             SendQueue.Enqueue(Ia.Ftn.Cl.Models.Business.Huawei.Ems.LogoutUser);
  483:         }
  484:  
  485:         ////////////////////////////////////////////////////////////////////////////
  486:  
  487:         /// <summary>
  488:         ///
  489:         /// </summary>
  490:         public Ia.Cl.Models.Result Send(string text, bool skipSleep)
  491:         {
  492:             var result = new Ia.Cl.Models.Result();
  493:  
  494:             try
  495:             {
  496:                 if (telnetModel.IsConnected)
  497:                 {
  498:                     if (!string.IsNullOrEmpty(text))
  499:                     {
  500:                         LastSentCommand = text;
  501:  
  502:                         //this.textBox.AppendText("\r\n/* Sending: " + text + " */\r\n");
  503:  
  504:                         telnetModel.WriteData(text + "\r\n"); // I added "\r\n", not sure if it will work with read server
  505:  
  506:                         result.AddSuccess("Sent: [" + text + "]");
  507:                     }
  508:                     else
  509:                     {
  510:                         result.AddError("No text to send.");
  511:                     }
  512:                 }
  513:                 else
  514:                 {
  515:                     result.AddError("No established telnet connection.");
  516:                     //if(processRunning) waitToConnectionCounter = waitToConnectionCounterSeconds;
  517:                 }
  518:             }
  519:             catch (Exception ex)
  520:             {
  521:                 //if(processRunning) waitToConnectionCounter = waitToConnectionCounterSeconds;
  522:  
  523:                 result.AddError(ex.Message);
  524:             }
  525:  
  526:             if (!skipSleep)
  527:             {
  528:                 // this is meant to give the Telnet_EndReceive() time to receive and process data from session
  529:                 // we will wait according to the type of commands send
  530:  
  531:                 if (Ia.Ftn.Cl.Models.Business.Huawei.Ems.IsACfgCommand(LastSentCommand))
  532:                 {
  533:                     System.Threading.Thread.Sleep(Ia.Ftn.Cl.Models.Client.Huawei.Ems.WaitAfterSendForCfgCommandInMillisecond);
  534:                 }
  535:                 else
  536:                 {
  537:                     System.Threading.Thread.Sleep(Ia.Ftn.Cl.Models.Client.Huawei.Ems.WaitAfterSendInMillisecond);
  538:                 }
  539:             }
  540:  
  541:             return result;
  542:         }
  543:  
  544:         ////////////////////////////////////////////////////////////////////////////
  545:  
  546:         /// <summary>
  547:         ///
  548:         /// </summary>
  549:         private void Telnet_Data(object sender, DataEventArgs e)
  550:         {
  551:             string message, entry;
  552:             string[] receiveStringSplit;
  553:  
  554:             Debug.WriteLine(" ");
  555:             Debug.WriteLine("============================================");
  556:  
  557:             receiveString += e.Data.ToString();
  558:  
  559:             Debug.WriteLine("Telnet_EndReceive(): e.Segment: [" + e.Data.ToString() + "], receiveString: [" + receiveString + "]");
  560:  
  561:             if (!string.IsNullOrEmpty(receiveString))
  562:             {
  563:                 receiveStringSplit = receiveString.Split(new string[] { "\r\n;" }, StringSplitOptions.None);
  564:  
  565:                 if (receiveStringSplit.Length > 0)
  566:                 {
  567:                     for (int i = 0; i < receiveStringSplit.Length; i++)
  568:                     {
  569:                         entry = receiveStringSplit[i];
  570:  
  571:                         if (!string.IsNullOrEmpty(entry) && !string.IsNullOrWhiteSpace(entry))
  572:                         {
  573:                             // will not enqueue an empty entry
  574:  
  575:                             if (i == receiveStringSplit.Length - 1)
  576:                             {
  577:                                 // if there is a non empty last entry that means its incomplete and we will assign it to receiveString
  578:  
  579:                                 receiveString = entry;
  580:                             }
  581:                             else
  582:                             {
  583:                                 message = entry + "\r\n;"; // important
  584:  
  585:                                 if (!ReceiveQueue.Contains(message))
  586:                                 {
  587:                                     // will not enqueue duplicate
  588:  
  589:                                     ReceiveQueue.Enqueue(message);
  590:  
  591:                                     Debug.WriteLine("Telnet_EndReceive(): ReceiveQueue.Enqueue(message): [" + message + "]");
  592:                                 }
  593:  
  594:                                 receiveString = string.Empty;
  595:                             }
  596:                         }
  597:                     }
  598:                 }
  599:  
  600:                 Debug.WriteLine("Telnet_EndReceive(): receiveString: [" + receiveString + "]");
  601:             }
  602:             else
  603:             {
  604:  
  605:             }
  606:  
  607:             ////if (telnet.Connected) telnet.BeginReceive(buffer);
  608:  
  609:             Debug.WriteLine("============================================");
  610:             Debug.WriteLine(" ");
  611:         }
  612:  
  613:         ////////////////////////////////////////////////////////////////////////////
  614:  
  615:         /// <summary>
  616:         ///
  617:         /// </summary>
  618:         private void Telnet_StateChanged(object sender, EventArgs e)
  619:         {
  620:             // always raised when connection is established or closed (state property changes)
  621:             switch (telnetModel.Telnet.State)
  622:             {
  623:                 case ConnectionState.Connected:
  624:                 case ConnectionState.ConnectedAndSecure: break;
  625:                 case ConnectionState.Closed: break;
  626:             }
  627:         }
  628:  
  629:         ////////////////////////////////////////////////////////////////////////////
  630:  
  631:         /// <summary>
  632:         ///
  633:         /// </summary>
  634:         private void Telnet_ClientOptionChanged(object sender, OptionEventArgs e)
  635:         {
  636:         }
  637:  
  638:         ////////////////////////////////////////////////////////////////////////////
  639:  
  640:         /// <summary>
  641:         ///
  642:         /// </summary>
  643:         private void Telnet_ServerOptionChanged(object sender, OptionEventArgs e)
  644:         {
  645:         }
  646:  
  647:         ////////////////////////////////////////////////////////////////////////////
  648:  
  649:         /// <summary>
  650:         ///
  651:         /// </summary>
  652:         private void Telnet_Error(object sender, Dart.Telnet.ErrorEventArgs e)
  653:         {
  654:         }
  655:  
  656:         ////////////////////////////////////////////////////////////////////////////
  657:  
  658:         /// <summary>
  659:         ///
  660:         /// </summary>
  661:         private void Telnet_Log(object sender, DataEventArgs e)
  662:         {
  663:             // e.Data;
  664:         }
  665:  
  666:         ////////////////////////////////////////////////////////////////////////////
  667:  
  668:         /// <summary>
  669:         ///
  670:         /// </summary>
  671:         void TelnetModel_CertificateRequested(object sender, LocalCertificateEventArgs e)
  672:         {
  673:         }
  674:  
  675:         ////////////////////////////////////////////////////////////////////////////
  676:  
  677:         /// <summary>
  678:         ///
  679:         /// </summary>
  680:         void TelnetModel_CertificatePresented(object sender, RemoteCertificateEventArgs e)
  681:         {
  682:         }
  683:  
  684:         ////////////////////////////////////////////////////////////////////////////
  685:  
  686:         /// <summary>
  687:         ///
  688:         /// </summary>
  689:         public Ia.Cl.Models.Result Update(string rowData, ref Ia.Ftn.Cl.Models.Client.Huawei.Ems ems, out string systemIsBusyResponseCommand, out string ontLoadingCommandIsBeingExecutedNowResponseCommand)
  690:         {
  691:             return Ia.Ftn.Cl.Models.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput(rowData, ref ems, out systemIsBusyResponseCommand, out ontLoadingCommandIsBeingExecutedNowResponseCommand);
  692:         }
  693:  
  694:         ////////////////////////////////////////////////////////////////////////////
  695:         ////////////////////////////////////////////////////////////////////////////
  696:     }
  697:  
  698:     ////////////////////////////////////////////////////////////////////////////
  699:     ////////////////////////////////////////////////////////////////////////////
  700: }