/// <summary> /// Converts the specified XML metadata to the new version. /// </summary> /// <param name="xml">The XML metadata.</param> /// <returns>System.Xml.Linq.XElement.</returns> public XElement Convert(XElement xml) { Version v4_10 = new Version("4.10.0.0"); Version v4_12 = new Version("4.12.0.0"); // Get XML root namespace for manual conversion XNamespace rootNS = xml.GetDefaultNamespace(); //Determine what data version we are working with. Version version = ParseVersionFromMetadata(xml); ScanToEmailData resultData = null; if (version < v4_10) { //Convert old metadata to new schema. resultData = new ScanToEmailData() { AddressSource = GetValue(xml, "AddressSource"), AutomationPause = GetTimeSpan(xml, "AutomationPause"), DigitalSendServer = GetValue(xml, "DigitalSendServer"), EmailAddress = GetValue(xml, "EmailAddress"), ImagePreviewOptions = GetInt(xml, "ImagePreviewOptions"), LaunchQuicksetFromApp = GetBool(xml, "LaunchQuicksetFromApp"), QuickSetName = GetValue(xml, "QuickSetName"), UseOcr = GetBool(xml, "UseOcr"), UseQuickset = GetBool(xml, "UseQuickset") }; } else if (version >= v4_10 && version < v4_12) { //Deserialize what is there. It's possible Some ScanOptions were saved. resultData = Serializer.Deserialize <ScanToEmailData>(xml); } else { //No Conversion necessary return(xml); } //Only update these next properties if they are found in the metadata root. if (Exists(xml, "LockTimeouts", true)) { resultData.ScanOptions.LockTimeouts = GetLockTimeoutData(rootNS, xml); } if (Exists(xml, "PageCount", true)) { resultData.ScanOptions.PageCount = GetInt(xml, "PageCount"); } if (Exists(xml, "UseAdf", true)) { resultData.ScanOptions.UseAdf = GetBool(xml, "UseAdf"); } return(Serializer.Serialize(resultData)); }
/// <summary> /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />. /// </summary> /// <param name="configuration">The configuration data.</param> /// <param name="environment">Information about the plugin environment.</param> public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment) { ScanToEmailData activityData = configuration.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); ConfigureControls(activityData); assetSelectionControl.Initialize(configuration.Assets, DeviceAttributes); assetSelectionControl.AdfDocuments = configuration.Documents; lockTimeoutControl.Initialize(activityData.ScanOptions.LockTimeouts); }
public PluginExecutionResult Execute(PluginExecutionData executionData) { ScanToEmailData data = executionData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); var manager = string.IsNullOrWhiteSpace(data.DigitalSendServer) ? new EmailScanManager(executionData) : new EmailScanManager(executionData, data.DigitalSendServer); manager.ActivityStatusChanged += UpdateStatus; manager.DeviceSelected += UpdateDevice; return(manager.RunScanActivity()); }
private void ConfigureControls(ScanToEmailData data) { email_ComboBox.Text = data.EmailAddress; useOcr_CheckBox.Checked = data.UseOcr; pageCount_NumericUpDown.Value = data.ScanOptions.PageCount; assetSelectionControl.AutomationPause = data.AutomationPause; assetSelectionControl.UseAdf = data.ScanOptions.UseAdf; quickSet_TextBox.Text = data.QuickSetName; quickSet_RadioButton.Checked = data.UseQuickset; launchFromApp_RadioButton.Checked = data.LaunchQuicksetFromApp; launchFromHome_RadioButton.Checked = !data.LaunchQuicksetFromApp; OptionalRadioButton.Checked = data.ImagePreviewOptions == 0; GenerateRadioButton.Checked = data.ImagePreviewOptions == 1; RestrictRadioButton.Checked = data.ImagePreviewOptions == 2; email_ComboBox.Items.Clear(); // Populate the list of email addresses foreach (string email in ConfigurationServices.EnvironmentConfiguration.GetOutputMonitorDestinations("OutputEmail")) { email_ComboBox.Items.Add(email); } // Determine whether the DSS server should be filled in if (!string.IsNullOrEmpty(data.DigitalSendServer)) { usesDigitalSendServer_CheckBox.Checked = true; digitalSendServer_TextBox.Text = data.DigitalSendServer; } else { usesDigitalSendServer_CheckBox.Checked = false; } // Check AddressSource addressSource_comboBox.SelectedIndex = string.IsNullOrEmpty(data.AddressSource) ? 0 : addressSource_comboBox.Items.IndexOf(data.AddressSource); _scanOptions = data.ScanOptions; if (data.ApplicationAuthentication) { radioButton_ScanToEmail.Checked = true; } else { radioButton_SignInButton.Checked = true; } comboBox_AuthProvider.SelectedValue = data.AuthProvider; }
/// <summary> /// Validates the given metadata against the ScanToEmail Activity data. /// </summary> /// <param name="configurationData">The configuration data.</param> /// <returns>true if valid</returns> public bool ValidateMetadata(ref PluginConfigurationData configurationData) { bool validData = true; ScanToEmailData activityData = null; try { activityData = configurationData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); } catch { activityData = new ScanToEmailData(); validData = false; } configurationData = new PluginConfigurationData(activityData, ScanToEmailConfigControl.Version); return(validData); }
/// <summary> /// Creates and returns a <see cref="PluginConfigurationData" /> instance containing the /// configuration data from this control. /// </summary> /// <returns>The configuration data.</returns> public PluginConfigurationData GetConfiguration() { ScanToEmailData data = new ScanToEmailData() { EmailAddress = email_ComboBox.Text, AddressSource = addressSource_comboBox.SelectedItem.ToString(), UseOcr = useOcr_CheckBox.Checked, AutomationPause = assetSelectionControl.AutomationPause, QuickSetName = quickSet_TextBox.Text, UseQuickset = quickSet_RadioButton.Checked, LaunchQuicksetFromApp = launchFromApp_RadioButton.Checked, ImagePreviewOptions = OptionalRadioButton.Checked ? 0 : GenerateRadioButton.Checked ? 1 : RestrictRadioButton.Checked ? 2 : 0, ScanOptions = _scanOptions, ApplicationAuthentication = radioButton_ScanToEmail.Checked, AuthProvider = (AuthenticationProvider)comboBox_AuthProvider.SelectedValue }; data.ScanOptions.PageCount = (int)pageCount_NumericUpDown.Value; data.ScanOptions.LockTimeouts = lockTimeoutControl.Value; data.ScanOptions.UseAdf = assetSelectionControl.UseAdf; if (data.UseOcr) { data.ScanOptions.FileType = DeviceAutomation.FileType.SearchablePdfOcr; } data.DigitalSendServer = usesDigitalSendServer_CheckBox.Checked ? digitalSendServer_TextBox.Text : null; return(new PluginConfigurationData(data, Version) { Assets = assetSelectionControl.AssetSelectionData, Documents = assetSelectionControl.AdfDocuments }); }
public EmailScanManager(PluginExecutionData executionData, string serverName) : base(executionData, serverName) { _data = executionData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); ScanOptions = _data.ScanOptions; }