/// <summary>
        /// Determines whether the latest DTM message contains the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns><c>true</c> if the latest DTM message contains the specified text; otherwise, <c>false</c>.</returns>
        public bool Contains(string text)
        {
            bool result = true;

            string message = new DtmMessages().strGetNewestUserMessage;

            if (message == null)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Element 'Dtm messages' is null.");
                result = false;
            }
            else
            {
                message = message.ToLower();
                string textToLower = text.ToLower();

                if (message.Contains(textToLower) == false)
                {
                    result = false;
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The latest Dtm message does not contain '" + text + "'.");
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The latest Dtm message contains '" + text + "'.");
                }
            }

            return(result);
        }
        /// <summary>
        /// Determines whether the latest DTM message contains a critical error message.
        /// </summary>
        /// <returns><c>true</c> if the latest DTM message contains a critical error message; otherwise, <c>false</c>.</returns>
        public bool ContainsCriticalError()
        {
            bool result = true;

            string messageForLog = new DtmMessages().strGetNewestUserMessage;

            if (messageForLog == null)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Element 'Dtm messages' is null.");
                result = false;
            }
            else
            {
                string       message = messageForLog.ToLower();
                const string Text    = "critical error";

                if (message.Contains(Text) == false)
                {
                    result = false;
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The latest Dtm message does not contain a critical error message");
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The latest Dtm message contains the following critical error: " + messageForLog + " .");
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks DTM messages for a critical error
        /// </summary>
        /// <returns>List with critical error message or list with empty string.</returns>
        public List <string> Run()
        {
            List <string> result  = new List <string>();
            string        message = new DtmMessages().strGetNewestUserMessage;

            if (message == null)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Element 'Dtm messages' is null.");
                result.Add(string.Empty);
            }
            else if (new ScanDtmMessages().ContainsCriticalError())
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Critical error found.");
                result.Add(message);
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "There is no critical error present.");
                result.Add(string.Empty);
            }

            return(result);
        }
        /// <summary>
        /// Creates network (scan for device) via menu. Waits for the action to finish and reports the result. Sets the network tag for the device.
        /// </summary>
        /// <param name="timeoutInMilliseconds">
        /// Timeout for the scanning progress in milliseconds.
        /// </param>
        /// <param name="networkTag">
        /// The network Tag for the device.
        /// </param>
        /// <returns>
        /// <c>true</c> if scanning finished successfully, <c>false</c> otherwise.
        /// </returns>
        public bool Run(int timeoutInMilliseconds, string networkTag)
        {
            bool result = true;
            var  watch  = new Stopwatch();

            new Functions.MenuArea.Toolbar.Execution.RunCreateNetwork().ViaIcon();

            Element scanningInProgress = new ScanningElements().ScanningInProgressDialog;
            Element scanningResult     = new ScanningElements().ScanningResultDialog;

            watch.Start();

            // Wait until the scanning in progress dialog is visible
            while (scanningInProgress == null && watch.ElapsedMilliseconds < 10000)
            {
                scanningInProgress = new ScanningElements().ScanningInProgressDialog;
            }

            // Wait until scanning is finished
            while (scanningInProgress != null && watch.ElapsedMilliseconds < timeoutInMilliseconds && scanningResult == null)
            {
                scanningInProgress = new ScanningElements().ScanningInProgressDialog;
                scanningResult     = new ScanningElements().ScanningResultDialog;
            }

            watch.Stop();
            if (watch.ElapsedMilliseconds >= timeoutInMilliseconds)
            {
                // Scanning took too long
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Scanning timed out. It took " + watch.ElapsedMilliseconds + " milliseconds. Timeout after: " + timeoutInMilliseconds + " milliseconds.");
                result = false;
            }
            else if (new ScanningElements().ScanningResultDialog != null)
            {
                // Scanning result dialog is open -> Quality != 1.Take a screen and close dialog via ok button
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Dtm quality level is not '1'. Please check the connected device.");
                Log.Screenshot(new ScanningElements().ScanningResultDialog);
                result = false;
                Button ok = new ScanningElements().OkButton;
                if (ok != null && ok.Enabled)
                {
                    ok.Click();
                }
            }
            else
            {
                // Scanning finished, check whether it was successful or it failed
                if (new Functions.Dialogs.DtmMessages.Validation.ScanDtmMessages().Contains("Finished scanning."))
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Scanning finished.");
                    if (DeviceFunctionLoader.CoDIA.Parameterization.Functions.ApplicationArea.MainView.Validation.ModuleOpeningAndClosing.IsOnlineModuleAlreadyOpened())
                    {
                        Flows.CloseModuleOnline.Run();
                    }

                    SpecificFlows.SetNetworkTag.Run(networkTag);
                }
                else
                {
                    var messages = new DtmMessages().GetAllDtmMessages;
                    foreach (var message in messages)
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), message);
                    }

                    result = false;
                }
            }

            return(result);
        }