Пример #1
0
        public ActionLogConfigPage(ActionLogConfig actionLogConfig)
        {
            InitializeComponent();

            ActionLogTextBox.BindControl(actionLogConfig, nameof(ActionLogConfig.ActionLogText));
            LogInputVariablesCheckBox.BindControl(actionLogConfig, nameof(ActionLogConfig.LogInputVariables));
            LogOuputVariablesCheckBox.BindControl(actionLogConfig, nameof(ActionLogConfig.LogOutputVariables));
            LogRunStatusCheckBox.BindControl(actionLogConfig, nameof(ActionLogConfig.LogRunStatus));
            LogErrorCheckBox.BindControl(actionLogConfig, nameof(ActionLogConfig.LogError));
            LogElapsedTimeCheckBox.BindControl(actionLogConfig, nameof(ActionLogConfig.LogElapsedTime));
        }
Пример #2
0
        public void LogAction(IAct logAction)
        {
            if (!logAction.EnableActionLogConfig)
            {
                return;
            }

            StringBuilder   strBuilder      = new StringBuilder();
            ActionLogConfig actionLogConfig = logAction.ActionLogConfig;
            FormatTextTable formatTextTable = new FormatTextTable();

            // log timestamp
            strBuilder.AppendLine(GetCurrentTimeStampHeader());

            // create a new log file if not exists and append the contents
            strBuilder.AppendLine("[Action] " + logAction.ActionDescription);
            strBuilder.AppendLine("[Text] " + actionLogConfig.ActionLogText);

            // log all the input values
            if (actionLogConfig.LogInputVariables)
            {
                strBuilder.AppendLine("[Input Values]");
                formatTextTable = new FormatTextTable();

                List <string> colHeaders = new List <string>();
                colHeaders.Add("Parameter");
                colHeaders.Add("Value");
                formatTextTable.AddRowHeader(colHeaders);

                foreach (ActInputValue actInputValue in logAction.InputValues)
                {
                    List <string> colValues = new List <string>();
                    colValues.Add(actInputValue.ItemName);
                    colValues.Add(actInputValue.Value);
                    formatTextTable.AddRowValues(colValues);
                }
                strBuilder.AppendLine(formatTextTable.FormatLogTable());
            }

            // log all the output variables
            if (actionLogConfig.LogOutputVariables)
            {
                strBuilder.AppendLine("[Return Values]");
                formatTextTable = new FormatTextTable();

                List <string> colHeaders = new List <string>();
                colHeaders.Add("Parameter");
                colHeaders.Add("Expected");
                colHeaders.Add("Actual");
                formatTextTable.AddRowHeader(colHeaders);

                foreach (ActReturnValue actReturnValue in logAction.ReturnValues)
                {
                    List <string> colValues = new List <string>();
                    colValues.Add(actReturnValue.ItemName);
                    colValues.Add(actReturnValue.Expected);
                    colValues.Add(actReturnValue.Actual);
                    formatTextTable.AddRowValues(colValues);
                }
                strBuilder.AppendLine(formatTextTable.FormatLogTable());
            }

            // action status
            if (actionLogConfig.LogRunStatus)
            {
                strBuilder.AppendLine("[Run Status] " + logAction.Status);
            }

            // action elapsed time
            if (actionLogConfig.LogElapsedTime)
            {
                strBuilder.AppendLine("[Elapsed Time (In Secs)] " + logAction.ElapsedSecs);
            }

            // action error
            if (actionLogConfig.LogError)
            {
                strBuilder.AppendLine("[Error] " + logAction.Error);
            }

            // flush value expression
            // flush flow control

            // flush to log file
            FlushToLogFile(strBuilder.ToString());
        }