protected void Initialize(SIEEFactory f)
 {
     factory = f;
     SIEEFactoryManager.Add(factory);
     settings = new EECWriterSettings();
     settings.SetFactory(factory);
     description = f.CreateDescription();
 }
Example #2
0
        public static void Add(SIEEFactory f)
        {
            string key = f.CreateSettings().GetType().Name;

            if (!bySettingsType.ContainsKey(key))
            {
                bySettingsType.Add(key, f);
                key = f.CreateSettings().GetType().ToString();
                byTypeName.Add(key, f);
            }
        }
Example #3
0
        public SIEEControl(SIEEFactory factory)
        {
            InitializeComponent();
            // During OCC's profile delete the Appartmenttype is not STA, for whatever reason.
            // So don't do anything
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                return;
            }

            this.factory = factory;
            wpfControl   = factory.CreateWpfControl();
            SIEEUtilsWPF.EmbedWPFControl(this, wpfControl);
            wpfControl.SieeControl = this; // connect controls -> setDefaults needs the control
        }
Example #4
0
        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";
        }
 public SIEEWriterControl(SIEEFactory f)
 {
     embeddedControl = new SIEEControl(f);
     InitializeComponent();
 }
Example #6
0
 public void SetFactory(SIEEFactory f)
 {
     factory = f;
     this.SettingsTypename = factory.CreateSettings().GetType().ToString();
 }
        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);
        }