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);
        }
Пример #2
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);
        }
Пример #3
0
        private bool CanRun(WorkInfo workInfo)
        {
            if (InputNode.IsConnected() == false)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"{this.DisplayName} input node is not connected with any other module");
                return(false);
            }



            if (this.InputNode.State == null)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as InputNode.State is null");
                return(false);
            }

            this.InputNode.State.DataFilePath = ((OutputNode)this.InputNode.Connector).State.DataFilePath;
            this.InputNode.State.DataFile     = ((OutputNode)this.InputNode.Connector).State.DataFile;
            this.InputNode.State.Schema       = ((OutputNode)this.InputNode.Connector).State.Schema;

            if (this.InputNode.State.DataFilePath == null)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as InputNode.State.DataFilePath is null");
                return(false);
            }
            if (this.InputNode.State.DataFile == null)
            {
                this.InputNode.State.DataFile = WorkflowFileFactory.LoadFromXmlFile(this.InputNode.State.DataFilePath);
                //workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as InputNode.State.DataFile is null");
                //return false;
            }

            if (!File.Exists(this.InputNode.State.DataFilePath))
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as {InputNode.State.DataFilePath} does not exist ");
                return(false);
            }

            string prevModuleName = workInfo.NextModuleRTL(this).DisplayName;

            if (InputNode.State.Schema == null)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as Previous Module {prevModuleName} dis not pass Schema");
                return(false);
            }

            if (OutputNode.IsConnected() == false)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as OutputNode is not connected");
                return(false);
            }

            if (OutputNode.State == null)
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as OutputNode.State is null");
                return(false);
            }

            if (string.IsNullOrEmpty(OutputNode.State.DataFilePath))
            {
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Halting execution as OutputNode.DataFilePath is not set");
                return(false);
            }
            this.OutputNode.State.Schema   = this.InputNode.State.Schema;
            this.OutputNode.State.DataFile = this.InputNode.State.DataFile;

            string msg = "";

            if (SortingFields.Count <= 0)
            {
                msg = string.Format("Halting execution as as sorting fields are not provided");
                logger.Warn(msg);

                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, msg);
                return(false);
            }


            return(true);
        }