Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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.ToUpper()));
                }*/

                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().ToUpper();
                DataType type = GetDataType(dataTypeName);
                string variableScope = Variable_Scope.Trim().ToUpper();
                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.ToUpper()))
                    {
                        this.Context.VariableValueList.Remove(var.Name.ToUpper());
                    }

                    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.ToUpper(), false);
                            break;
                        case DataType.Date:
                        case DataType.DateTime:
                            C.DataType = typeof(DateTime);
                            this.Context.VariableValueList.Add(var.Name.ToUpper(), DateTime.Now);
                            break;
                        case DataType.Number:
                            C.DataType = typeof(double);
                            this.Context.VariableValueList.Add(var.Name.ToUpper(), 0.0);
                            break;
                        case DataType.Time:
                            C.DataType = typeof(System.TimeSpan);
                            this.Context.VariableValueList.Add(var.Name.ToUpper(), 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.ToUpper(), "");
                            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.ToUpper()))
                        {
                            this.Context.VariableExpressionList[this.Identifier.ToUpper()] = this.Expression;
                        }
                        else
                        {
                            this.Context.VariableExpressionList.Add(this.Identifier.ToUpper(), 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;
            }
        }
Ejemplo n.º 3
0
 private string DialogResponse(CommandProcessorResults results)
 {
     return string.Empty;
 }