-
Notifications
You must be signed in to change notification settings - Fork 1
Plugins
The scan plugin allows the creation of custom plugins. The settings and form adaptations are similar to the Review Plugin that is approached in the next section Review Plugin.

The review plugin allows personalize review station to configure specific fields for each client, the next example contains three combo box with options from the database, three text fields with results from the SmartDocumentor API and a grid, where its shown the documents tabular text by line.

It is possible to configure the Review Plugin based on the generic plugin or template. You can set the Review plugin as is shown below.
The example is for a review based on Generic plugin. The Review Plugin must inherit from BaseReviewPlugin, it's common afterward to customize the messages to the users.
Note that the LearningActive is set to false on Debug, this will prevent the application from sending test files to the SmartDocumentor API.
33. public partial class ReviewPlugin : BaseReviewPlugin
34. {
35. #region Properties
36.
37. protected override string ConfigFileName {get {return "SmartDocumentor.Client.Fields.xml";}}
38. protected override string PluginId {get {return "Invoice";}}
39. protected override bool ShowVendorFinder {get{return false;}}
40. protected override bool ShowVendorHeader {get{return false;}}
41. #if DEBUG
42. protected override bool LearningActive {get{return false;}}
43. #else
44. protected override bool LearningActive {get{return true;}}
45. #endif
46. protected override bool ShowReviewErrorMessageToUser {get{ return true;}}
47. protected override string ReviewErrorMessage {get{return "Valide os campos em erro!";}}
48. protected override string MandatoryFieldErrorMessage {get { return "Campo '{0}' é obrigatório";}}
49. protected override string PluginLoadErrorMessage {get{ return "Erro no plugin. Por favor contacte o departamento de informática";}}
50. protected override bool RunInvoiceValidations {get{return false;}}
51. protected override bool ShowDeleteConfirmationMessage {get{ return true;}}
52. protected override string DeleteConfirmationMessage {get{return "Tem a certeza que deseja eliminar?";}}
53.
54. #endregion
55. …
The next example shows the reading from settings on the configuration to the class.
1. public ReviewPlugin(){
2. }
3. public override void SetCustomProperties(Dictionary<string, object> customProperties)
4. {
5. base.SetCustomProperties(customProperties);
6. if (!customProperties.ContainsKey(Constants.Settings.ConnectionString))
7. {
8. throw new ArgumentNullException(Constants.Settings.ConnectionString);
9. }
10. if (!customProperties.ContainsKey(Constants.Settings.LocationId))
11. {
12. throw new ArgumentNullException(Constants.Settings.LocationId);
13. }
14. var connectingString = customProperties[Constants.Settings.ConnectionString].ToString();
15. var locationId = customProperties[Constants.Settings.LocationId].ToString();
16. }
Next is possible to see how the sequence workflow when opening the review station and processing each file.
The next diagram is a simplified version of the sequence diagram, showing the methods call in a more intuitive maner.

A template based in a template will be like the generic plugin, but will include in the workspace config a reference to the template under the PropertyList:
28. <PropertyList>
29. <Property ID="ReviewActions" Value="Integrate Document|GesDoc|Send to GesDoc|1;Retry|Retry|Retry|7;Delete Document|Delete|Delete Document|2;" />
30. <Property ID="ReviewTemplates" Value="Template1; Template2" />
31. </PropertyList>
Also, the Review Plugin must inherit from BaseTemplateReviewPlugin.
1. public partial class ReviewPlugin2 : BaseTemplateReviewPlugin
2. {}
The implementation will similar to the generic plugin described next.
Review plugin allows adding new fields and logic to the documents processing.
Adding a new field to the document SmartDocumentor.Client.Fields.xml:
- OrderId = "1" - Ordering index on the form.
- Id = "1" - Internal id up to 100 is reserved for native SD fields.
- Type = "Textbox" - Accepts 3 types: Textbox, Combobox or Checkbox.
- Label = "Supplier TIN" - Description that appears on the form.
- Name = "VendorVAT" - Internal name, in the custom fields follows the standard name of the project name.
- Required = "false" - Whether "True" or "False" if mandatory.
- Visible = "true" - Whether "True" or "False" if visible.
- Enable = "true" - Whether "True" or "False" if editable.
- Pattern = "[0-9]" -- Regex expression to validate.
1. <?xml version="1.0" encoding="utf-8" ?>
2. <Plugins>
3. <Plugin Id="Invoice">
4. <Fields>
5. <Field OrderId="1" Id="1" Type="Textbox" Label="Nif Fornecedor" Name="VendorVAT" Required="true" Visible="true" Enable="true" />
6. <Field OrderId="2" Id="100" Type="Textbox" Label="Nif Empresa" Name="ClientVAT" Required="true" Visible="true" Enable="true" NoNormalization="true"/>
7. <Field OrderId="3" Id="4" Type="Textbox" Label="Nº Documento" Name="DocNumber" Required="true" Visible="true" Enable="true" NoNormalization="true"/>
8. <Field OrderId="4" Id="5" Type="Textbox" Label="Data de Emissão" Name="DocDate" Required="true" Visible="true" Enable="true" />
9. <Field OrderId="2000" Id="1001" Type="CustomSingleColumnGrid" Label="Guias de remessa" Name="PONumbers" Required="true" Visible="true" Enable="true" />
10. </Fields>
11. </Plugin>
12. </Plugins>
Create a Custom field is simples as defining a new field in the SmartDocumentor.Client.Fields.xml.
Constants are defined in a class, most common is Constants.cs In the case of adding a new field, the constant must contain the value that was placed in the Field Name in the SmartDocumentor.Client.Fields.xml file.
Validations are defined in the InvoiceReviewPlugin.cs file.
- public override bool IsFieldValid(ICaptureFieldEditor field, out string errorMessage)
The method is iterated through all fields on the form and allows us to define validation for each field. The results are processed in the ExportDocumentWorker.cs file.
- item.GetPropertyValue - returns the value of the field that is stored in the task.
The new fields must be defined in the CreateRequest object, like the existing ones.
Adress: R. de Passos Manuel 223 3°, 4000-385 Porto, Portugal
Email: support@devscope.net
Phone: +315 22 375 1350
Working Days/Hours: Mon-Fri/9:00AM-19:00PM
Copyright © DevScope