public Capture(SIEESettings settings, SIEEFieldlist schema) { InitializeComponent(); this.settings = settings; this.schema = schema; addFields(schema); }
public virtual void ExportBatch(SIEESettings settings, SIEEBatch batch) { if (!isInitialized) { Init(settings); isInitialized = true; } try { foreach (SIEEDocument doc in batch) { try { ExportDocument(settings, doc, getDocumentName(settings, doc), doc.Fieldlist); doc.Succeeded = true; } catch (Exception e) { Trace.WriteError("SIEEExport failed for batch " + doc.BatchId); Trace.WriteError(e.ToString()); doc.Succeeded = false; doc.ErrorMsg = e.ToString(); } } } finally { Term(); } }
public DialogResult MyShowDialog() { SIEESettings settings = control.GetSettings(); Type t = settings.GetType(); return(ShowDialog()); }
public override object Backup() { EECExportDestination clone = base.Backup() as EECExportDestination; SIEESettings s = (SIEESettings)SIEESerializer.Clone(settings.GetEmbeddedSettings()); clone.settings.SetEmbeddedSettings(s); return(clone); }
public virtual void SetSettings(SIEESettings s) { settings = s; SIEEViewModel vmCommon = factory.CreateViewModel(settings); wpfControl.SetDataContext(vmCommon); vmCommon.Initialize(wpfControl); }
public void SetEmbeddedSettings(SIEESettings s) { sieeSettings = s; // maintain a base64 string version for serialization string xmlString = Serializer.SerializeToXmlString(s, System.Text.Encoding.Unicode); SerializedSettings = SIEESerializer.ObjectToString(xmlString); }
public static SIEEFactory GetFromSettings(SIEESettings s) { string key = s.GetType().Name; if (bySettingsType.ContainsKey(key)) { return(bySettingsType[key]); } return(null); }
public void LoadDefaults(SIEESettings settings) { try { SetDefaults(settings.GetType(), this); } catch (Exception ex) { SIEEMessageBox.Show( "Cannot set defaults. Reason:\n" + ex.Message, "Load default values", System.Windows.MessageBoxImage.Error); } }
private void btn_configure_Click(object sender, EventArgs e) { Configure confDlg = new Configure(); Cursor.Current = Cursors.WaitCursor; try { cbox_extensionSelector_SelectedIndexChanged(null, null); confDlg.AddControl(control); control.Size = confDlg.Size; // Simulate serialization by SIEE and by OCC confDlg.Settings = (SIEESettings)SIEESerializer.Clone(settings); string xmlString = Serializer.SerializeToXmlString(settings, System.Text.Encoding.Unicode); if (Properties.Settings.Default.ConfigSize.Width != 0) { confDlg.Size = Properties.Settings.Default.ConfigSize; } if (confDlg.MyShowDialog() == DialogResult.OK) { settings = confDlg.Settings; try { schema = settings.CreateSchema(); schema.MakeFieldnamesOCCCompliant(); verifySchema(schema); lbl_message.Text = "Settings and schema"; lbl_location.Text = description.GetLocation(settings); richTextBox_settings.Text = settings.ToString() + Environment.NewLine + "---------------" + Environment.NewLine + schema.ToString(data: false) + Environment.NewLine + "---------------" + Environment.NewLine + "Location = " + description.GetLocation(settings); btn_export.Enabled = false; btn_capture.Enabled = true; lbl_status.Text = "Configuration ready"; } catch (Exception e1) { MessageBox.Show("Error loading configuration\n" + e1.Message); } Properties.Settings.Default.ConfigSize = confDlg.Size; saveCurrentSettings(); } } finally { Cursor.Current = Cursors.Default; } }
/// Get the document name based on the filename settings public virtual string getDocumentName(SIEESettings settings, SIEEDocument doc) { // Annotation (exportName) has highest priority if (doc.ScriptingName != null) { return(doc.ScriptingName); } // Check input filename option string nameSpec = settings.GetDocumentNameSpec(); if (nameSpec == null) { return(doc.InputFileName); } // Take name from file name specification NameSpecParser nsp = new NameSpecParser(doc.BatchId, doc.DocumentId, doc.Fieldlist.ToKeyValuePairs()); return(nsp.Convert(nameSpec)); }
private void loadExportExtention(SIEEFactory factory) { try { control = new SIEEControl(factory); settings = (SIEESettings)factory.CreateSettings(); export = (SIEEExport)factory.CreateExport(); description = (SIEEDescription)factory.CreateDescription(); } catch (Exception ex) { MessageBox.Show("Factory error.\n" + ex.Message); } if (chbox_reloadConfiguration.Checked && Properties.Settings.Default.SavedConfigurationType == description.TypeName) { try { settings = (SIEESettings)SIEESerializer.StringToObject(Properties.Settings.Default.SavedConfiguration); } catch (Exception e) { MessageBox.Show("Loading saved configuration failed. Rason:\n" + e.Message); } } btn_configure.Enabled = false; btn_capture.Enabled = false; btn_export.Enabled = false; try { SIEESerializer.StringToObject(SIEESerializer.ObjectToString(settings)); } catch (Exception ex) { MessageBox.Show("Serialization for settings object failed:\n" + ex.Message); cbox_extensionSelector.SelectedText = Properties.Settings.Default.CurrentExtension; return; } pict_Icon.Image = description.Image; btn_configure.Enabled = true; Properties.Settings.Default.CurrentExtension = cbox_extensionSelector.Text; lbl_status.Text = "Extension selected"; }
/// Various functions in the SIEE_Adapter need to access the true settings, i.e. the /// embedded settings. If there is no embedded settings yet, it will be recreated from /// the serialized version. If even that does not exist a brand new object is created /// from the factory. public SIEESettings GetEmbeddedSettings() { if (sieeSettings != null) { return(sieeSettings); } if (!string.IsNullOrEmpty(SerializedSettings)) { try { //throw new Exception("Test dummy exception"); string xmlString = (string)SIEESerializer.StringToObject(SerializedSettings); sieeSettings = (SIEESettings)Serializer.DeserializeFromXmlString(xmlString, factory.CreateSettings().GetType(), System.Text.Encoding.Unicode); } catch (Exception e) { System.Windows.Forms.MessageBox.Show( "Error loading export destination. \n" + "Settings for export extension is lost.\n" + "You need to reconfigure the export extension\n\n" + $"Extension type = {SettingsTypename}\n" + e.ToString(), "Load profile", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error ); sieeSettings = factory.CreateSettings(); } } else { sieeSettings = factory.CreateSettings(); } return(sieeSettings); }
public abstract void ExportDocument(SIEESettings settings, SIEEDocument document, string name, SIEEFieldlist fieldlist);
public override void ExportDocument(SIEESettings settings, SIEEDocument document, string name, SIEEFieldlist fieldlist) { ExportFunc(settings, document, name, fieldlist); }
} // not needed public override SIEEViewModel CreateViewModel(SIEESettings settings) { return(null); } // not needed
public abstract SIEEViewModel CreateViewModel(SIEESettings settings);
/* For SIEE use only */ public virtual void ClearLocation(SIEESettings settings) { }
public virtual void Init(SIEESettings settings) { }
public EECWriterSettings() { SerializedSettings = ""; SerializedSchema = ""; sieeSettings = null; }
public virtual string GetLocation(SIEESettings s) { return("unknown"); }
public override XmlDocument transform(XmlDocument data, IParameters parameters) { // The SIEEBatch is created from the schema as defined in the setting object. It contains all // fields regardless of whether they have been mapped to OCC fields. SIEEFieldlist schema = (SIEEFieldlist)SIEESerializer.StringToObject(writerSettings.SerializedSchema); // This class has no initialization by which the factory could be set beforehand. We therefore // load the factory from the SIEE_FactoryManager. (This was the only reason to invent the // SIEE_FactoryManager in the first place. SIEEFactory factory = SIEEFactoryManager.GetFromSettingsTypename(writerSettings.SettingsTypename); writerSettings.SetFactory(factory); // Create the SIEE objects wee need SIEEExport myExport = factory.CreateExport(); SIEEDescription description = factory.CreateDescription(); DataPool pool = new DataPool(data); SIEEBatch batch = new SIEEBatch(); int maxRetryCount = description.NumberOfRetries; string batchId = pool.RootNode.Fields["cc_BatchId"].Value; string profile = pool.RootNode.Fields["cc_ProfileName"].Value; SIEEExport.Trace.WriteInfo("Start exporting batch " + batchId); ExportStateParams exportStateParams = null; Dictionary <SIEEDocument, Document> siee2dataPool = new Dictionary <SIEEDocument, Document>(); Dictionary <SIEEDocument, int> annotationNumber = new Dictionary <SIEEDocument, int>(); for (int i = 0; i < pool.RootNode.Documents.Count; i++) { Document document = pool.RootNode.Documents[i]; SIEEDocument sieeDocument = documentToFieldlist(new SIEEFieldlist(schema), document, batchId, profile); sieeDocument.DocumentId = String.Format("{0:D4}", i); sieeDocument.DocumentClass = document.Name; sieeDocument.SIEEAnnotation = sieeDocument.NewSIEEAnnotation = null; int anNo = findAnnotation(document); annotationNumber[sieeDocument] = anNo; if (anNo != 0) { sieeDocument.SIEEAnnotation = document.Annotations[annotationName(anNo - 1)].Value; } exportStateParams = DataPoolWorkflowStateExtensions.GetExportStateParams(document); // Process only documents with state "ToBeProcessed" (not yet exported documents or documents whose export failed). if (exportStateParams.state == ExportState.ToBeProcessed) { siee2dataPool[sieeDocument] = document; batch.Add(sieeDocument); } } try { SIEESettings settings = writerSettings.GetEmbeddedSettings(); myExport.ExportBatch(settings, batch); } catch (Exception e) { SIEEExport.Trace.WriteError("SIEEWriterExport: Batch " + batchId + " failed", e); throw; } foreach (SIEEDocument doc in batch) { Document occDocument = siee2dataPool[doc]; int anNo = annotationNumber[doc]; if (doc.NewSIEEAnnotation != null) { occDocument.Annotations.Add(new Annotation(pool, annotationName(anNo), doc.NewSIEEAnnotation)); } exportStateParams = DataPoolWorkflowStateExtensions.GetExportStateParams(occDocument); if (doc.Succeeded) { occDocument.Annotations.Add(new Annotation(pool, "TargetDocumentId", doc.TargetDocumentId)); occDocument.Annotations.Add(new Annotation(pool, "TargetType", description.TypeName)); exportStateParams.state = ExportState.Succeeded; } else { exportStateParams.message = "Export failed: " + doc.ErrorMsg; if (doc.NonRecoverableError) { throw new Exception("Fatal export error: " + doc.ErrorMsg); } } // Set delay time for start of retry if (exportStateParams.repetitionCount == 0) { exportStateParams.delaySeconds = description.StartTimeForRetry; } DataPoolWorkflowStateExtensions.HandleExportStateParams(occDocument, maxRetryCount, exportStateParams); } SIEEExport.Trace.WriteInfo("Done exporting batch " + batchId); return(data); }