Пример #1
0
        public void ReadDataSource(DataTable table)
        {
            if (table != null)
            {
                IMemoryRegion region = MemoryRegion;
                FieldCollectionMaster dataFields = new FieldCollectionMaster();
                Project tempProject = new Project();
                View tempView = new View(tempProject);
                Page tempPage = new Page(tempView);

                DataInfo.PrimaryTable = table;

                List<IField> listOfFields = new List<IField>();

                foreach (DataColumn column in table.Columns)
                {
                    IField field = (IField)tempPage.CreateField(MetaFieldType.Text);
                    field.Name = column.ColumnName;
                    RenderableField tempField = (RenderableField)field;
                    tempField.PromptText = column.ColumnName;
                    tempField.SourceTable = table.TableName;
                    listOfFields.Add(tempField);
                }

                foreach (IField field in listOfFields)
                {
                    region.DefineVariable((IDataField)field);
                }

                if (CurrentRead != null && CurrentRead.IsEpi7ProjectRead && CurrentProject != null && CurrentProject.Views.Exists(CurrentRead.Identifier))
                {
                    View view = CurrentProject.Views[CurrentRead.Identifier];

                    foreach (IField field in view.Fields)
                    {
                        if (field is GroupField)
                        {
                            IVariable v = new DataSourceVariable(field.Name, DataType.Unknown);
                            region.DefineVariable(v);
                        }
                    }
                }

                foreach (KeyValuePair<string, List<string>> kvp in GroupVariableList)
                {
                    IVariable v = new DataSourceVariable(kvp.Key, DataType.Unknown);
                    region.DefineVariable(v);
                }
            }
        }
Пример #2
0
        private DataRow GetDataTable(DataColumn dataColumn, string tableText, string pattern, Dictionary<string, string> formatStrings, DataRow[] rows, DataTable table)
        {
            pattern = string.Empty;

            IVariable var = (IVariable)this.Context.GetVariable(dataColumn.ColumnName);
            if (var != null)
            {
                if (var.VarType == VariableType.DataSource || var.VarType == VariableType.DataSourceRedefined)
                {
                    formatStrings.TryGetValue(var.Name, out pattern);
                }
                else
                {
                    tableText = "Defined";
                }
            }
            else
            {
                //tableText = "Defined";
                var = new DataSourceVariable(dataColumn.ColumnName, DataType.Unknown);
            }

            DataRow row = table.NewRow();

            if (
                this.Context.CurrentRead != null &&
                this.Context.CurrentRead.IsEpi7ProjectRead &&
                this.Context.CurrentProject.Views.Exists(this.Context.CurrentRead.Identifier) &&
                this.Context.CurrentProject.Views[this.Context.CurrentRead.Identifier].Fields.Exists(var.Name)
                )
            {
                Epi.Fields.Field field = this.Context.CurrentProject.Views[this.Context.CurrentRead.Identifier].Fields[var.Name];
                if (field is FieldWithSeparatePrompt)
                {
                    row[ColumnNames.PROMPT] = ((FieldWithSeparatePrompt)field).PromptText;
                }
                else
                {
                    row[ColumnNames.PROMPT] = var.PromptText;
                }
                //Fiexes for Issue: 943
                if (field.FieldType.ToString() == MetaFieldType.Checkbox.ToString())
                {
                    row[ColumnNames.FIELDTYPE] = "Checkbox";
                }
                else
                {
                    row[ColumnNames.FIELDTYPE] = field.FieldType.ToString();
                }

            }
            else
            {
                row[ColumnNames.PROMPT] = var.PromptText;
                if (var.VarType == VariableType.Permanent)
                {
                    row[ColumnNames.FIELDTYPE] = var.DataType.ToString();
                }
                else
                {

                    if (this.Context.DataSet.Tables.Contains("output"))
                    {
                        row[ColumnNames.FIELDTYPE] = GetVariableType(this.Context.DataSet.Tables["output"].Columns[var.Name].DataType.ToString());
                    }
                    else
                    {
                        row[ColumnNames.FIELDTYPE] = var.DataType.ToString();
                    }
                }

            }

            row[ColumnNames.VARIABLE] = var.Name;

            row[ColumnNames.FORMATVALUE] = pattern;
            row[ColumnNames.SPECIALINFO] = var.VarType.ToString();
            row[ColumnNames.TABLE] = tableText;

            //  table.Rows.Add(row);

            return row;
        }