/// <summary>
        /// Processes the results of the command - PostProcess is necessary
        /// </summary>
        /// <param name="results"></param>
        public void ProcessCommandResults(CommandProcessorResults results)
        {
            if (results != null)
            {
                PostProcess(results);
                // 12/09/2008 Don't show  gridtable in output window.
                if (!results.Actions.Contains(Action.GridTable) && !results.Actions.Contains(Action.Update))
                {
                    //ROUTEOUT & CLOSEOUT commands do not have HTML output. They update the Output file.
                    if (results.Actions.Contains(Action.OutputFileName))
                    {
                        if ((results.HtmlOutput.Equals(string.Empty)))
                        {
                            outputWindow.SetOutputFile(results.FileNameOutput);
                        }
                    }

                    outputWindow.SendToOutput(results);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Displays the output in the DataGrid
        /// </summary>
        /// <param name="results">Command Processor Results</param>
        /// <param name="actionId">Action GridTable or Update</param>
        public void SendToOutput(CommandProcessorResults results, Action actionId)
        {
            if (results != null && results.DsOutput != null)
            {   // DEFECT: 200 renamed xmlDataSet to dsResults to reflect use.
                DataSet dsResults = results.DsOutput;
                //xmlDataSet.ReadXml(new StringReader(results.XmlOutput.OuterXml));
                dataGridView1.DataSource = dsResults;
                dataGridView1.DataMember = dsResults.Tables[0].TableName;
                dataGridView1.ReadOnly   = (actionId == Action.GridTable);
                if (dataGridView1.Columns.Contains(ColumnNames.REC_STATUS))
                {
                    dataGridView1.Columns[ColumnNames.REC_STATUS].ReadOnly = true;
                }
                if (dataGridView1.Columns.Contains(ColumnNames.REC_STATUS))
                {
                    dataGridView1.Columns[ColumnNames.UNIQUE_KEY].ReadOnly = true;
                }
                this.dataGridView1.Refresh();
                this.Text = ((actionId == Action.Update) ? SharedStrings.UPDATE_TITLE :
                             SharedStrings.GRIDTABLE_TITLE);

                this.Show(this.Parent);
            }
        }
示例#3
0
        /// <summary>
        /// peforms the Define rule uses the MemoryRegion and this.Context.DataSet to hold variable definitions
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            try
            {
                IVariable var = null;

                #region Preconditions
                //zack check reserved word /11/16/09
                AppData appdata = new AppData();

                /*
                 * if (appdata.IsReservedWord(Identifier))
                 * {
                 *  throw new GeneralException(string.Format(SharedStrings.RESERVED_WORD, Identifier.ToUpperInvariant()));
                 * }*/

                if (this.Context.MemoryRegion.IsVariableInScope(Identifier))
                {
                    if (this.Context.MemoryRegion.TryGetVariable(this.Identifier, out var))
                    {
                        if (var.VarType != VariableType.Permanent)
                        {
                            this.Context.AnalysisCheckCodeInterface.Dialog(SharedStrings.DUPLICATE_VARIABLE_DEFINITION + StringLiterals.COLON + Identifier, CommandNames.DEFINE);
                        }
                    }
                    else
                    {
                        this.Context.AnalysisCheckCodeInterface.Dialog(SharedStrings.DUPLICATE_VARIABLE_DEFINITION + StringLiterals.COLON + Identifier, CommandNames.DEFINE);
                    }
                }
                else if (this.Context.GroupVariableList.ContainsKey(this.Identifier))
                {
                    this.Context.AnalysisCheckCodeInterface.Dialog(SharedStrings.DUPLICATE_VARIABLE_DEFINITION + StringLiterals.COLON + Identifier, CommandNames.DEFINE);
                }
                #endregion Preconditions

                CommandProcessorResults results = new CommandProcessorResults();
                string       dataTypeName       = VariableTypeIndicator.Trim().ToUpperInvariant();
                DataType     type          = GetDataType(dataTypeName);
                string       variableScope = Variable_Scope.Trim().ToUpperInvariant();
                VariableType vt            = VariableType.Standard;
                if (!string.IsNullOrEmpty(variableScope))
                {
                    vt = this.GetVariableScopeIdByName(variableScope);
                }

                var = new Variable(Identifier, type, vt);
                string promptString = Define_Prompt.Trim().Replace("\"", string.Empty);
                if (!string.IsNullOrEmpty(promptString))
                {
                    promptString = promptString.Replace("(", string.Empty).Replace(")", string.Empty);
                    promptString.Replace("\"", string.Empty);
                }
                var.PromptText = promptString;
                this.Context.MemoryRegion.DefineVariable(var);

                if (var.VarType == VariableType.Standard || var.VarType == VariableType.Global)
                {
                    if (this.Context.VariableValueList.ContainsKey(var.Name.ToUpperInvariant()))
                    {
                        this.Context.VariableValueList.Remove(var.Name.ToUpperInvariant());
                    }



                    DataTable dataTable;

                    if (!this.Context.DataSet.Tables.Contains("variables"))
                    {
                        this.Context.DataSet.Tables.Add(new DataTable("variables"));
                    }

                    dataTable = this.Context.DataSet.Tables["variables"];
                    DataColumn C = new DataColumn(var.Name);

                    switch (var.DataType)
                    {
                    case DataType.Boolean:
                    case DataType.YesNo:
                        C.DataType = typeof(bool);
                        this.Context.VariableValueList.Add(var.Name.ToUpperInvariant(), false);
                        break;

                    case DataType.Date:
                    case DataType.DateTime:
                        C.DataType = typeof(DateTime);
                        this.Context.VariableValueList.Add(var.Name.ToUpperInvariant(), DateTime.Now);
                        break;

                    case DataType.Number:
                        C.DataType = typeof(double);
                        this.Context.VariableValueList.Add(var.Name.ToUpperInvariant(), 0.0);
                        break;

                    case DataType.Time:
                        C.DataType = typeof(System.TimeSpan);
                        this.Context.VariableValueList.Add(var.Name.ToUpperInvariant(), new TimeSpan());
                        break;

                    case DataType.PhoneNumber:
                    case DataType.Text:
                    case DataType.Unknown:
                    case DataType.Object:
                    default:
                        C.DataType = typeof(string);
                        this.Context.VariableValueList.Add(var.Name.ToUpperInvariant(), "");
                        break;
                    }

                    if (dataTable.Columns.Contains(C.ColumnName))
                    {
                        dataTable.Columns.Remove(C.ColumnName);
                    }
                    dataTable.Columns.Add(C);

                    this.Context.SyncVariableAndOutputTable();

                    if (this.Expression != null)
                    {
                        object vresult = null;
                        if (this.Context.VariableExpressionList.ContainsKey(this.Identifier.ToUpperInvariant()))
                        {
                            this.Context.VariableExpressionList[this.Identifier.ToUpperInvariant()] = this.Expression;
                        }
                        else
                        {
                            this.Context.VariableExpressionList.Add(this.Identifier.ToUpperInvariant(), this.Expression);
                        }

                        if (this.Context.CurrentDataRow != null)
                        {
                            vresult = this.Expression.Execute();
                            if (vresult == null)
                            {
                                this.Context.CurrentDataRow[var.Name] = DBNull.Value;
                            }
                            else
                            {
                                this.Context.CurrentDataRow[var.Name] = vresult;
                            }
                        }
                        else
                        {
                            dataTable = this.Context.DataSet.Tables["output"];
                            if (dataTable.Rows.Count == 0)
                            {
                                DataRow R = dataTable.NewRow();
                                dataTable.Rows.Add(R);
                            }

                            this.Context.GetOutput(DefineMapDataFunction);

                            /*
                             * vresult = null;
                             * for (int i = 0; i < dataTable.Rows.Count; i++)
                             * {
                             *  this.Context.CurrentDataRow = dataTable.Rows[i];
                             *  vresult = this.Expression.Execute();
                             *  if (vresult == null)
                             *  {
                             *      this.Context.CurrentDataRow[var.Name] = DBNull.Value;
                             *  }
                             *  else
                             *  {
                             *      this.Context.CurrentDataRow[var.Name] = vresult;
                             *  }
                             * }
                             * this.Context.CurrentDataRow = null;*/
                        }
                    }
                }
                Context.DefineVarList.Clear();

                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("COMMANDNAME", CommandNames.DEFINE);
                this.Context.AnalysisCheckCodeInterface.Display(args);

                return(results);
            }
            catch (Exception ex)
            {
                Epi.Diagnostics.Debugger.Break();
                Epi.Diagnostics.Debugger.LogException(ex);
                throw ex;
            }
        }
示例#4
0
        /// <summary>
        /// Processes the results of the command - PostProcess is necessary
        /// </summary>
        /// <param name="results"></param>
        public void ProcessCommandResults(CommandProcessorResults results)
        {
            if (results != null)
            {
                PostProcess(results);
                // 12/09/2008 Don't show  gridtable in output window.
                if (!results.Actions.Contains(Action.GridTable) && !results.Actions.Contains(Action.Update))
                {
                    //ROUTEOUT & CLOSEOUT commands do not have HTML output. They update the Output file.
                    if (results.Actions.Contains(Action.OutputFileName))
                        if ((results.HtmlOutput.Equals(string.Empty)))
                            outputWindow.SetOutputFile(results.FileNameOutput);

                    outputWindow.SendToOutput(results);
                }
            }
        }
 private string DialogResponse(CommandProcessorResults results)
 {
     return string.Empty;
 }