Пример #1
0
        public override object Execute(Workflow workflow)
        {
            RetrieveEndpointData();
            if (State == null)
            {
                return(null);
            }

            if (State.Schema == null)
            {
                var msg = "Provided schema is empty.";
                OnExecuteFailed(msg, Severity.INFO);
                return(null);
            }

            if (!Path.GetExtension(State.DataFilePath).ToLower().Contains("xml"))
            {
                var msg = $"Provided data file at {State.DataFilePath} is not an XML file.";
                OnExecuteFailed(msg, Severity.INFO);
                return(null);
            }
            else if (!File.Exists(State.DataFilePath))
            {
                var msg = "Could not find XML data file at path " + State.DataFilePath;
                OnExecuteFailed(msg, Severity.ERROR);
                return(null);
            }

            var dataFile = XDocument.Load(State.DataFilePath);

            if (State.InputIsSchema || IsSchemaFile(dataFile))
            {
                var msg = $"Provided file at {State.DataFilePath} is not an XML data file.";
                OnExecuteFailed(msg, Severity.INFO);
                return(null);
            }

            try
            {
                var window = MainWindow.Instance;
                window.Load(workflow, Guid, State.Schema, dataFile);
                window.ShowDialog();
                RequestStateUpdate?.Invoke(window.Workflow);
            }
            catch (Exception e)
            {
                string msg = $"Critical failure in Designer: {e.Message}";
                OnExecuteFailed(msg, Severity.ERROR);
            }

            return(null);
        }
Пример #2
0
        public override object Execute(Workflow workflow)
        {
            if (this.OutputNode.State == null)
            {
                this.OutputNode.State = new ModuleState();
            }

            var element = workflow.GetAppState(ModuleName, Guid);

            if (element != null)
            {
                //ReadProgramCSV(element.Element("Root"));
            }


            ShowWindow();


            RequestStateUpdate?.Invoke(workflow);
            return(null);
        }
Пример #3
0
        public override object Execute(Workflow workflow)
        {
            logger.Trace("Executing xmlinput module");

            Logger.Log(Severity.DEBUG, LogCategory.MODULE, "Test");
            if (this.OutputNode.State == null)
            {
                this.OutputNode.State = new ModuleState();
            }

            var  msg    = "";
            bool failed = false;

            try
            {
                Program.Main(this.OutputNode.State);
            }
            catch (Exception e)
            {
                msg = $"Critical failure in XML Converter: {e.Message}";
            }

            if (Program.form == null)
            {
                return(null);
            }

            if (Program.form.isCancel)
            {
                return(null);
            }

            if (msg.Length > 0)
            {
                failed = true;
            }
            else if (this.OutputNode.State.Schema == null || this.OutputNode.State.DataFilePath == null)
            {
                msg += "Procedure not completed.";
                if (this.OutputNode.State.Schema == null)
                {
                    msg += " Schema not available. Please generate a schema before closing the window.";
                }
                if (this.OutputNode.State.DataFilePath == null)
                {
                    msg += " Input path not available. Input file was not added before closing the window.";
                }
                failed = true;
            }
            else
            {
                if (!File.Exists(this.OutputNode.State.DataFilePath))
                {
                    msg   += string.Format("Input file does not exist at path: {0}.", this.OutputNode.State.DataFilePath);
                    failed = true;
                }
            }

            if (failed)
            {
                if (OutputNode.IsConnected())
                {
                    msg = "Disconnecting module: " + msg;
                    OutputNode.Disconnect();
                }
                Logger.Log(Severity.WARN, LogCategory.MODULE, msg);
                System.Windows.Forms.MessageBox.Show(msg);
                this.OutputNode.State.DataFilePath = "";
                return(null);
            }

            logger.Info("Calling   RequestStateUpdate?.Invoke(workflow)");
            RequestStateUpdate?.Invoke(workflow);
            return(null);
        }
        public override object Execute(Workflow workflow)
        {
            logger.Info("Entered Command:{0}", workflow.Command);

            if (!ValidateInputSchema())
            {
                return(null);
            }

            string msg    = "";
            bool   failed = false;

            this.WorkFlow = workflow;

            if (workflow.Command == (int)JdSuite.Common.Module.Commands.DoubleClick)
            {
                ShowParameterWindow();
            }


            var element = workflow.GetAppState(ModuleName, Guid);

            if (element != null)
            {
                //ReadProgramCSV(element.Element("Root"));
            }



            if (this.OutputNode.State.Schema == null)
            {
                msg   += "Process is incomplete as Output Schema is not set.";
                failed = true;
            }

            if (this.OutputNode.State.DataFilePath == null)
            {
                msg   += " Output node data file path is not set. ";
                failed = true;
            }



            if (failed)
            {
                logger.Error(msg);
                MessageService.ShowError("Output node validation error", msg);
            }

            if (failed)
            {
                if (OutputNode.IsConnected())
                {
                    msg = "Disconnecting module due to errors: " + msg;
                    OutputNode.Disconnect();
                }

                logger.Warn(msg);

                this.OutputNode.State.DataFilePath = "";
                return(null);
            }


            logger.Info("Calling   RequestStateUpdate?.Invoke(workflow)");
            RequestStateUpdate?.Invoke(workflow);

            return(null);
        }