/// <summary> /// Retrieves <see cref="AssetInfo" /> for all assets in the inventory. /// </summary> /// <returns><see cref="AssetInfo" /> for all assets in the inventory.</returns> public AssetInfoCollection GetAssets() { List <AssetInfo> assets = new List <AssetInfo>(); DatabaseQuery(Resources.SelectPrinters, record => { PrintDeviceInfoInternal deviceInfo = new PrintDeviceInfoInternal ( (string)record["AssetId"], (AssetAttributes)record["Attributes"], record["PrinterType"] as string, record["Address"] as string, record["Address2"] as string, record["Password"] as string, record["Product"] as string, (int)record["PortNumber"], (bool)record["SnmpEnabled"] ); deviceInfo.Description = $"{deviceInfo.ProductName} ({(string)record["Model"]}) at {deviceInfo.Address}"; deviceInfo.ModelName = record["ModelName"] as string; deviceInfo.ModelNumber = record["ModelNumber"] as string; deviceInfo.SerialNumber = record["SerialNumber"] as string; assets.Add(deviceInfo); }); DatabaseQuery(Resources.SelectSimulators, record => { DeviceSimulatorInfo deviceSimulatorInfo = new DeviceSimulatorInfo ( (string)record["AssetId"], (AssetAttributes)record["Attributes"], "DeviceSimulator", record["Address"] as string, record["Password"] as string, record["Product"] as string, record["SimulatorType"] as string ); deviceSimulatorInfo.Description = $"{deviceSimulatorInfo.SimulatorType} device simulator at {deviceSimulatorInfo.Address}"; assets.Add(deviceSimulatorInfo); }); DatabaseQuery(Resources.SelectVirtualPrinters, record => { VirtualPrinterInfo virtualPrinterInfo = new VirtualPrinterInfo ( (string)record["AssetId"], (AssetAttributes)record["Attributes"], "VirtualPrinter", record["Address"] as string, 9100, false ); virtualPrinterInfo.Description = $"Virtual printer at {virtualPrinterInfo.Address}"; assets.Add(virtualPrinterInfo); }); DatabaseQuery(Resources.SelectMobileDevices, record => { MobileDeviceInfo mobileDeviceInfo = new MobileDeviceInfo ( (string)record["AssetId"], (AssetAttributes)record["Attributes"], "MobileDevice", record["MobileEquipmentId"] as string, EnumUtil.Parse <MobileDeviceType>(record["MobileDeviceType"] as string, true) ); mobileDeviceInfo.Description = record["Description"] as string; assets.Add(mobileDeviceInfo); }); return(new AssetInfoCollection(assets)); }
/// <summary> /// Run Mobile print activity /// </summary> /// <returns><see cref="PluginExecutionResult"/> for mobile print job</returns> public virtual PluginExecutionResult RunMobilePrintActivity() { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error."); UpdateStatus("Starting Mobile Print Activity"); DeviceSimulatorInfo device = ExecutionData.Assets.GetRandom <DeviceSimulatorInfo>(); DeviceIdentifier = device.Address; UpdateStatus($"Target Mobile Device : {DeviceIdentifier}"); try { SetupJob(); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.AppButtonPress); UpdateStatus("Launching App"); App.LaunchApp(); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.AppShown); UpdateStatus("Select Object to print"); App.SelectTargetToPrint(Target); UpdateStatus("Select Printer"); App.SelectPrinter(PrinterId); UpdateStatus("Set Options"); App.SetOptions(Option); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.PrintJobBegin); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.ProcessingJobBegin); UpdateStatus("Click Print button"); App.Print(); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.ProcessingJobEnd); UpdateStatus("Wait until print job is done"); App.WaitUntilPrintDone(TimeSpan.FromMinutes(3)); WorkflowLogger.RecordEvent(DeviceWorkflowMarker.PrintJobEnd); if (App.CheckPrintStatusOnMobile()) { UpdateStatus("Print Job Success"); result = new PluginExecutionResult(PluginResult.Passed); } else { UpdateStatus("Print Job Fail"); result = new PluginExecutionResult(PluginResult.Failed, "Fail to upload job"); } App.CloseApp(); } catch (MobileWorkflowException ex) { UpdateStatus($"Exception : {ex.Message}"); result = new PluginExecutionResult(PluginResult.Failed, ex, "Mobile Workflow Error"); } catch (NotSupportedException ex) { UpdateStatus($"Exception : {ex.Message}"); result = new PluginExecutionResult(PluginResult.Error, ex, "Plugin code error"); } catch (Exception ex) { UpdateStatus($"Exception : {ex.Message}"); result = new PluginExecutionResult(PluginResult.Error, ex, "Unknown error"); } return(result); }