protected void IntegrateQueryDevices(IAndroidLogcatTaskResult resut)
        {
            var deviceIdsResult = ((AndroidLogcatRetrieveDeviceIdsResult)resut);
            var deviceInfos = deviceIdsResult.deviceInfo;

            foreach (var d in m_Devices)
            {
                d.Value.UpdateState(IAndroidLogcatDevice.DeviceState.Disconnected);
            }

            foreach (var info in deviceInfos)
            {
                GetOrCreateDevice(info.id).UpdateState(info.state);
            }

            // If our selected device was removed, deselect it
            if (m_SelectedDevice != null && m_SelectedDevice.State != IAndroidLogcatDevice.DeviceState.Connected)
            {
                m_SelectedDevice = null;
                if (deviceIdsResult.notifyListeners)
                    DeviceSelected?.Invoke(m_SelectedDevice);
            }

            if (m_SelectedDevice != null)
            {
                if (m_SelectedDevice != m_Devices[m_SelectedDevice.Id])
                    throw new Exception("The selected device is not among our list of devices");
            }

            DevicesUpdated?.Invoke();
        }
        internal void SelectDevice(IAndroidLogcatDevice device, bool notifyListeners = true)
        {
            if (m_SelectedDevice == device)
                return;

            if (device != null && device.State != IAndroidLogcatDevice.DeviceState.Connected)
            {
                AndroidLogcatInternalLog.Log("Trying to select device which is not connected: " + device.Id);
                if (m_SelectedDevice == null)
                    return;

                m_SelectedDevice = null;
            }
            else
            {
                m_SelectedDevice = device;
            }

            if (m_SelectedDevice != null && !m_Devices.Keys.Contains(m_SelectedDevice.Id))
                throw new Exception("Selected device is not among our listed devices");

            m_Runtime.UserSettings.LastSelectedDeviceId = m_SelectedDevice != null ? m_SelectedDevice.Id : "";

            if (notifyListeners)
                DeviceSelected?.Invoke(m_SelectedDevice);
        }
Esempio n. 3
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var device = _devices[indexPath.Row];

            DeviceSelected?.Invoke(this, device);
            StopDiscovery();
        }
Esempio n. 4
0
 // Raises the DeviceSelected event
 internal void OnDeviceSelected(DeviceInformation device)
 {
     DeviceSelected?.Invoke(this, new DeviceSelectedEventArgs()
     {
         SelectedDevice = device
     });
 }
Esempio n. 5
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            DeviceEventArgs args = new DeviceEventArgs();

            args.Device = devices [indexPath.Row];

            DeviceSelected?.Invoke(this, args);
        }
Esempio n. 6
0
        /// <summary>
        /// Runs the scan activity.
        /// </summary>
        /// <returns>The result of the activity.</returns>
        public PluginExecutionResult RunScanActivity()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error.");

            try
            {
                var devices     = ExecutionData.Assets.OfType <IDeviceInfo>();
                var assetTokens = devices.Select(n => new AssetLockToken(n, ScanOptions.LockTimeouts));

                //If there is no device to run
                if (assetTokens.Count() == 0)
                {
                    //Skip When there are no device to execute on.
                    return(new PluginExecutionResult(PluginResult.Skipped, "No Asset available to run."));
                }

                RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceInfo.AssetId));

                    // Log the device and server used for this activity
                    ScanLog.DeviceId = deviceInfo.AssetId;
                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(ExecutionData, deviceInfo));
                    if (_serverName != null)
                    {
                        ExecutionServices.DataLogger.Submit(new ActivityExecutionServerUsageLog(ExecutionData, _serverName));
                    }

                    using (IDevice device = CreateAutomationDevice(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(ExecutionData, this.UpdateStatus);
                        result           = retryManager.Run(() => ExecuteScan(device, deviceInfo));
                    }
                }
                                                      );

                RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (AcquireLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable.");
            }
            catch (HoldLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {ScanOptions.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded.");
            }
            LogDebug("Scan activity complete.");
            return(result);
        }
Esempio n. 7
0
 /// <summary>
 /// Called when [device selected].
 /// </summary>
 /// <param name="deviceId">The device identifier.</param>
 protected void OnDeviceSelected(string deviceId)
 {
     DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceId));
 }
        /// <summary>
        /// Runs the scan activity.
        /// </summary>
        /// <returns>The result of the activity.</returns>
        public PluginExecutionResult RunLinkPrintActivity()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error.");

            try
            {
                var devices     = ExecutionData.Assets.OfType <IDeviceInfo>();
                var assetTokens = devices.Select(n => new AssetLockToken(n, _lockTimeoutData));

                RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceInfo.AssetId));

                    if (_linkPrintOptions != null)
                    {
                        AppNameSelected?.Invoke(this, new StatusChangedEventArgs(_linkPrintOptions.AppName));
                    }
                    else
                    {
                        AppNameSelected?.Invoke(this, new StatusChangedEventArgs(LinkJobType));
                    }

                    ConnectorLog.DeviceId = deviceInfo.AssetId;

                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(ExecutionData, deviceInfo));

                    if (_serverName != null)
                    {
                        ExecutionServices.DataLogger.Submit(new ActivityExecutionServerUsageLog(ExecutionData, _serverName));
                    }

                    using (IDevice device = CreateAutomationDevice(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(ExecutionData, this.UpdateStatus);
                        result           = retryManager.Run(() => ExecuteLinkPrint(device, deviceInfo));
                    }
                }
                                                      );

                RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (ArgumentException ex)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error.");
            }
            catch (InvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error.");
            }
            catch (AcquireLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable.");
            }
            catch (HoldLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_lockTimeoutData.HoldTimeout}.", "Automation timeout exceeded.");
            }
            LogDebug($"Print activity complete. Result is {result.Result.ToString()}: {result.Message}");

            return(result);
        }
Esempio n. 9
0
        private void InvokeDeviceSelected(VideoCaptureDeviceInfo device)
        {
            var args = new VideoDeviceSelectedEventArgs(device);

            DeviceSelected?.Invoke(this, args);
        }