Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether [is catalog update dialog shown].
        /// </summary>
        /// <returns><c>true</c> if [is catalog update dialog shown]; otherwise, <c>false</c>.</returns>
        public bool IsCatalogUpdateDialogShown()
        {
            var  updateCatalog = new UpdateDtmCatalogueElements().UpdateCatalogue;
            bool result        = updateCatalog != null;

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether [is confirm deleted devices dialog shown].
        /// </summary>
        /// <returns><c>true</c> if [is confirm deleted devices dialog shown]; otherwise, <c>false</c>.</returns>
        public bool IsConfirmDeletedDevicesDialogShown()
        {
            var  confirmDeleteDevicesMessage = new UpdateDtmCatalogueElements().RemovedDevicesDialog;
            bool result = confirmDeleteDevicesMessage != null;

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines whether catalog update is running
        /// </summary>
        /// <returns><c>true</c> if this instance is updating; otherwise, <c>false</c>.</returns>
        private bool IsUpdating()
        {
            var  updateInProgress = new UpdateDtmCatalogueElements().InProgressDialog;
            bool result           = updateInProgress != null;

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Waits until moving finished.
        /// </summary>
        /// <param name="timeoutInMilliseconds">
        /// The timeout in milliseconds.
        /// </param>
        /// <returns>
        /// <c>true</c> if updating finished, <c>false</c> otherwise.
        /// </returns>
        public bool WaitUntilMovingFinished(int timeoutInMilliseconds)
        {
            bool   result = true;
            var    watch  = new Stopwatch();
            Button move   = new UpdateDtmCatalogueElements().Move;

            if (move == null)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Move button is null.");
                result = false;
            }
            else
            {
                watch.Start();
                while (move.Enabled)
                {
                    if (watch.ElapsedMilliseconds >= timeoutInMilliseconds)
                    {
                        result = false;
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Time out reached.Moving took longer than: " + timeoutInMilliseconds + " milliseconds.");
                        break;
                    }
                }

                watch.Stop();
            }

            return(result);
        }
        /// <summary>
        /// Determines whether changed devices are available or not.
        /// </summary>
        /// <returns><c>true</c> if changed devices are available, <c>false</c> otherwise.</returns>
        public bool AreChangedDevicesAvailable()
        {
            bool        result = false;
            int         changedDevicesFound  = 0;
            IList <Row> changedDeviceRowList = new UpdateDtmCatalogueElements().DevicesOnRight;

            if (changedDeviceRowList == null)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "List with devices on right side is null or empty.");
            }
            else if (changedDeviceRowList.Count == 0)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No changed devices found, list is empty.");
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Listing all changed devices:");
                var foundDevices = new StringBuilder();
                foreach (Row myCell in changedDeviceRowList)
                {
                    IList <Unknown> cellChildren = myCell.Children;
                    if (cellChildren.Count > 1)
                    {
                        Cell statusCell    = cellChildren[0].Element;
                        Cell deviceTypCell = cellChildren[1].Element;
                        if (statusCell != null && deviceTypCell != null)
                        {
                            if (statusCell.Text != null)
                            {
                                if (statusCell.Text.Contains("Changed"))
                                {
                                    foundDevices.Append(deviceTypCell.Text);
                                    changedDevicesFound++;
                                    result = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Cell children from changedDeviceRowList not existing.");
                    }
                }

                if (changedDevicesFound > 0)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), foundDevices.ToString());
                }
            }

            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Found " + changedDevicesFound + " changed devices.");
            return(result);
        }
        private bool IsUpdating()
        {
            var updateInProgress       = new UpdateDtmCatalogueElements().InProgressDialog;
            var updateButton           = new UpdateDtmCatalogueElements().Update;
            var okButton               = new UpdateDtmCatalogueElements().Ok;
            var removedDevicesOkButton = new UpdateDtmCatalogueElements().RemovedDevicesDialogOkButton;

            // ReSharper disable ReplaceWithSingleAssignment.True
            bool result = true;

            if ((updateInProgress == null && updateButton.Enabled && okButton.Enabled) || removedDevicesOkButton != null)
            {
                result = false;
            }
            // ReSharper restore ReplaceWithSingleAssignment.True
            return(result);
        }
Ejemplo n.º 7
0
        public bool Run(int timeToWaitForUpdateMessage, int timeoutForUpdateProgress, bool shouldFindNewOrChangedDevice, int maxMinutesSinceDtmWasInstalled, int timeToWaitForMoving)
        {
            bool result           = true;
            bool dtmsChangedOrNew = false;

            // Open the catalog via menu
            if (Execution.OpenUpdateDtmCatalogue.ViaMenu() == false)
            {
                result = false;
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to open Update Catalog dialog.");
            }
            else
            {
                // Wait for the Update Catalog dialog to show up. Wait for a specified time
                if (Validation.ValidationMethods.WaitForCatalogUpdateDialog(timeToWaitForUpdateMessage) == false)
                {
                    result = false;
                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Update Catalog dialog did not show up within: " + timeToWaitForUpdateMessage + " milliseconds.");
                }
                else
                {
                    // Update dialog is shown, start the update
                    if (HostApplicationLoader.FDT.FieldCare.Functions.Dialogs.UpdateDTMCatalogue.Execution.UpdateDtmCatalogue.Update() == false)
                    {
                        result = false;
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Starting Update Catalog failed");
                    }
                    else
                    {
                        // Wait for the update to finish
                        if (Validation.ValidationMethods.WaitUntilUpdatingFinished(timeoutForUpdateProgress) == false)
                        {
                            result = false;
                            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Update progress did not finish within: ");
                        }
                        else
                        {
                            // Update finished, check whether the Confirm removed devices dialog shows up. Confirm if needed.
                            if (Validation.ValidationMethods.WaitForConfirmRemovedDevicesDialog(10000))
                            {
                                Button ok = new UpdateDtmCatalogueElements().RemovedDevicesDialogOkButton;
                                if (ok != null)
                                {
                                    ok.Click();
                                }
                            }

                            // Check for new devices
                            if (Validation.ValidationMethods.AreNewDevicesAvailable())
                            {
                                dtmsChangedOrNew = true;

                                // Select new devices
                                if (HostApplicationLoader.FDT.FieldCare.Functions.Dialogs.UpdateDTMCatalogue.Execution.UpdateDtmCatalogue.SelectNewOnLeft(true, maxMinutesSinceDtmWasInstalled) == false)
                                {
                                    result = false;
                                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Selecting new devices failed. ");
                                }
                                else
                                {
                                    // Move new devices
                                    if (HostApplicationLoader.FDT.FieldCare.Functions.Dialogs.UpdateDTMCatalogue.Execution.UpdateDtmCatalogue.Move() == false)
                                    {
                                        result = false;
                                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Moving new devices failed. ");
                                    }
                                    else
                                    {
                                        // Wait for moving to finish if update is huge
                                        if (Validation.ValidationMethods.WaitUntilMovingFinished(timeToWaitForMoving) == false)
                                        {
                                            result = false;
                                            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Moving new devices took too long. ");
                                        }
                                    }
                                }
                            }

                            // Check for changed devices
                            if (Validation.ValidationMethods.AreChangedDevicesAvailable())
                            {
                                dtmsChangedOrNew = true;
                            }

                            // Confirm update with ok button
                            if (HostApplicationLoader.FDT.FieldCare.Functions.Dialogs.UpdateDTMCatalogue.Execution.UpdateDtmCatalogue.Confirm() == false)
                            {
                                result = false;
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Update failed. ");
                            }
                        }
                    }
                }

                if (shouldFindNewOrChangedDevice)
                {
                    if (dtmsChangedOrNew == false)
                    {
                        result = false;
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "There were no updates to the dtm catalog. No new or changed devices found.");
                    }
                }

                if (result)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Update successful.");
                }
            }

            return(result);
        }