Exemplo n.º 1
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public ViewColumnMapping(
     IProperty property,
     ViewColumn column,
     ViewMapping viewMapping)
     : base(property, column, viewMapping)
 {
 }
Exemplo n.º 2
0
        private ViewColumn ConvertRowToViewColumn(DataRow dr)
        {
            var tmp = new ViewColumn(dr["schema_name"].ToString(), dr["table_name"].ToString(), dr["column_name"].ToString());

            tmp.OrdinalPosition = Convert.ToInt32(dr["ordinal_position"]);
            tmp.IsNullable      = this.ParseBoolean(dr["is_nullable"].ToString());
            tmp.DataType        = this.ParseDataType(dr["data_type"].ToString());
            if (dr["character_max_length"] != DBNull.Value)
            {
                tmp.CharacterMaxLength = Convert.ToInt64(dr["character_max_length"]);
            }
            if (dr["numeric_precision"] != DBNull.Value)
            {
                tmp.NumericPrecision = Convert.ToInt32(dr["numeric_precision"]);
            }
            if (dr["numeric_scale"] != DBNull.Value)
            {
                tmp.NumericScale = Convert.ToInt32(dr["numeric_scale"]);
            }
            if (dr["default_value"] != DBNull.Value)
            {
                tmp.DefaultValue = this.ParseDefaultValue(dr["default_value"].ToString(), tmp.DataType);
            }
            if (dr["privileges"] != DBNull.Value)
            {
                tmp.Privileges = this.ParsePrivileges(dr["privileges"].ToString());
            }
            //result.Add(tmp);
            return(tmp);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Binds the template.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="module">The module.</param>
        /// <param name="column">The column.</param>
        private void BindTemplate(Grid grid, ModuleConfig module, ViewColumn column)
        {
            if (column.Template == null)
            {
                return;
            }

            // Remove any template with the same name
            //foreach (GridServerTemplate existingTemplate in grid.ServerTemplates)
            for (int index = 0; index < grid.ServerTemplates.Count; index++)
            {
                if (String.Compare(grid.ServerTemplates[index].ID, column.Template.TemplateId, true) == 0)
                {
                    grid.ServerTemplates.RemoveAt(index);
                }
            }

            string    url      = String.Empty;
            ITemplate template = new SimpleTemplate((UserControl)grid.Parent, module.Name, column.Template);

            // Add server template to grid
            ComponentArt.Web.UI.GridServerTemplate gst = new ComponentArt.Web.UI.GridServerTemplate();
            gst.Template = (ITemplate)template;

            gst.ID = column.Template.TemplateId;

            BindColumnTemplateProperties(gst.Template, column.Template);
            grid.ServerTemplates.Add(gst);
            grid.Controls.Add(gst);
        }
Exemplo n.º 4
0
        public ViewColumn GetViewColumn()
        {
            ViewColumn data = new ViewColumn()
            {
                IsId                        = this.IsId,
                IsLastname                  = this.IsLastname,
                IsFirstname                 = this.IsFirstname,
                IsSecondname                = this.IsSecondname,
                IsBirthday                  = this.IsBirthday,
                IsSex                       = this.IsSex,
                IsPolicySeries              = this.IsPolicySeries,
                IsPolicyNumber              = this.IsPolicyNumber,
                IsUnifiedPolicyNumber       = this.IsUnifiedPolicyNumber,
                IsDocumentSeries            = this.IsDocumentSeries,
                IsDocumentNumber            = this.IsDocumentNumber,
                IsSNILS                     = this.IsSNILS,
                IsLivingFullAddressString   = this.IsLivingFullAddressString,
                IsOfficialFullAddressString = this.IsOfficialFullAddressString,
                IsTemporaryPolicyNumber     = this.IsTemporaryPolicyNumber,
                IsTemporaryPolicyDate       = this.IsTemporaryPolicyDate,
                IsPhone                     = this.IsPhone
            };

            return(data);
        }
        /// <summary>
        /// 获取视图结果参数列表
        /// </summary>
        /// <param name="viewName"></param>
        /// <returns></returns>
        public Task <IEnumerable <ViewColumn> > GetViewColumns(string viewName)
        {
            return(Task.Factory.StartNew((_viewName) =>
            {
                var name = (string)_viewName;
                using (var dbConnection = CreateDbConnection())
                {
                    var sql = "sp_mshelpcolumns";
                    var cmd = dbConnection
                              .GetCommand(sql, CommandType.StoredProcedure)
                              .AddParameter("@tablename", name.Trim(), DbType.String);

                    var da = new SqlDataAdapter((SqlCommand)cmd);
                    var dataTable = new DataTable();
                    da.Fill(dataTable);

                    var list = new List <ViewColumn>();
                    foreach (DataRow row in dataTable.Rows)
                    {
                        var column = new ViewColumn()
                        {
                            ColumnName = row["col_name"]?.ToString(),
                            ColumnType = row["col_typename"]?.ToString(),
                            ColumnLength = row["col_len"]?.ToString()
                        };
                        list.Add(column);
                    }
                    return list.AsEnumerable();
                }
            }, viewName));
        }
 public Task Show(ViewColumn viewColumn) =>
 languageServer.SendRequestAsync(
     ShowCustomViewRequest.Method,
     new ShowCustomViewRequest
 {
     Id         = Id,
     ViewColumn = viewColumn
 });
Exemplo n.º 7
0
 public async Task Show(ViewColumn viewColumn)
 {
     await languageServer.SendRequestAsync(
         ShowCustomViewRequest.Method,
         new ShowCustomViewRequest
     {
         Id         = this.Id,
         ViewColumn = viewColumn
     }
         );
 }
 public Task Show(ViewColumn viewColumn)
 {
     return
         (this.messageSender.SendRequestAsync(
              ShowCustomViewRequest.Type,
              new ShowCustomViewRequest
     {
         Id = this.Id,
         ViewColumn = viewColumn
     }, true));
 }
Exemplo n.º 9
0
        public CheckClientReport(List <CheckClient> listCheckClient, long?countDublicate, CheckClientSearchCriteria criteriaSearch, ViewColumn viewColumn)
        {
            ListCheckClient = listCheckClient;
            CountDublicate  = countDublicate;
            ViewColumn      = viewColumn;

            TextCheck = string.Empty;
            if (criteriaSearch.IsLastname)
            {
                TextCheck = TextCheck + "Фамилия, ";
            }
            if (criteriaSearch.IsFirstname)
            {
                TextCheck = TextCheck + "Имя, ";
            }
            if (criteriaSearch.IsSecondname)
            {
                TextCheck = TextCheck + "Отчество, ";
            }
            if (criteriaSearch.IsBirthday)
            {
                TextCheck = TextCheck + "Дата рождения, ";
            }
            if (criteriaSearch.IsSex)
            {
                TextCheck = TextCheck + "Пол, ";
            }
            if (criteriaSearch.IsPolicySeries)
            {
                TextCheck = TextCheck + "Серия полиса, ";
            }
            if (criteriaSearch.IsPolicyNumber)
            {
                TextCheck = TextCheck + "Номер полиса, ";
            }
            if (criteriaSearch.IsUnifiedPolicyNumber)
            {
                TextCheck = TextCheck + "ЕНП, ";
            }
            if (criteriaSearch.IsDocumentSeries)
            {
                TextCheck = TextCheck + "Серия паспорта, ";
            }
            if (criteriaSearch.IsDocumentNumber)
            {
                TextCheck = TextCheck + "Номер паспорта, ";
            }
            if (!string.IsNullOrEmpty(TextCheck))
            {
                TextCheck = TextCheck.Trim(',', ' ');
            }

            TemplatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "Templates", "CheckClientReport.xlsx");
        }
Exemplo n.º 10
0
 /// <summary>
 /// Binds the column properties.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="node">The node.</param>
 private void BindColumnProperties(GridColumn column, ViewColumn node)
 {
     // Bind all attributes
     foreach (string key in node.Attributes.Keys)
     {
         if (String.Compare(key, ViewColumn._HeadingTextAttributeName, false) == 0)
         {
             ReflectionHelper.BindProperty(column, key, node.GetLocalizedHeadingString());
         }
         else
         {
             ReflectionHelper.BindProperty(column, key, node.Attributes[key]);
         }
     }
 }
        /// <summary>
        /// 获取视图结果参数列表
        /// </summary>
        /// <param name="viewName"></param>
        /// <returns></returns>
        public Task <IEnumerable <ViewColumn> > GetViewColumns(string viewName)
        {
            return(Task.Factory.StartNew((_viewName) =>
            {
                var name = (string)_viewName;
                using (var dbConnection = CreateDbConnection())
                {
                    var sql = $"DESCRIBE {name};";
                    var dataTable = dbConnection.ExecuteDataTable(sql);

                    var columns = new List <ViewColumn>();
                    foreach (DataRow row in dataTable.Rows)
                    {
                        var type = row["Type"]?.ToString();
                        var columnType = "";
                        var columnLenth = "0";
                        if (type.Contains("("))
                        {
                            columnType = type.Split('(')[0];
                            columnLenth = type.Split('(')[1].Replace("(", "").Replace(")", "");
                        }
                        else
                        {
                            columnType = type;
                        }
                        var column = new ViewColumn()
                        {
                            ColumnName = row["Field"]?.ToString(),
                            ColumnLength = columnLenth,
                            ColumnType = columnType
                        };
                        columns.Add(column);
                    }
                    return columns.AsEnumerable();
                }
            }, viewName));
        }
Exemplo n.º 12
0
 public ViewColumnRelationElement(ViewColumn column)
 {
     this.column = column;
 }
 /// <inheritdoc/>
 /// <exception cref="NotSupportedException">Method is not supported.</exception>
 protected override IPathNode VisitViewColumn(ViewColumn viewColumn)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 14
0
        public List <ViewSheet> LoadTemplateDataByStream(Stream stream, string templateID, bool isPriview)
        {
            Workbook dodelDatabook = new Workbook(stream);
            var      list          = new List <ViewSheet>();

            int defaultFirstColumn = 1;
            int defaultFirstRow    = 3;

            var sheetDatas = TemplateSheetOperator.Instance.GetList(templateID);

            foreach (Worksheet item in dodelDatabook.Worksheets)
            {
                if (!item.IsVisible)
                {
                    continue;
                }
                if (item.Cells.MaxDataRow >= 0 && item.Cells.MaxDataColumn >= 0)
                {
                    ViewSheet sheet = new ViewSheet();

                    sheet.firstcolumn = defaultFirstColumn;
                    sheet.firstrow    = defaultFirstRow;

                    sheet.code    = item.Name;
                    sheet.name    = item.Name;
                    sheet.title   = item.Cells[0, 0].StringValue;
                    sheet.remark  = "";
                    sheet.columns = new List <ViewColumn>();
                    var sheetData = sheetDatas.FirstOrDefault(x => x.TemplateSheetName == item.Name);
                    if (sheetData != null)
                    {
                        sheet.firstrow    = sheetData.RowNum + 1;
                        sheet.firstcolumn = sheetData.ColumnNum;
                        sheet.remark      = sheetData.TemplateSheetRemark;
                        sheet.title       = sheetData.TemplateSheetTitle;
                    }
                    if (sheetData == null && !isPriview)
                    {
                        continue;
                    }
                    List <Model.TemplateConfig> configs = new List <Model.TemplateConfig>();
                    if (sheetData != null)
                    {
                        configs = TemplateConfigOperator.Instance.GetList(templateID, sheetData.ID).ToList();
                    }
                    configs = configs.OrderBy(x => x.SortIndex).ToList();
                    for (int i = 0; i <= item.Cells.MaxDataColumn; i++)
                    {
                        if (i >= sheet.firstcolumn - 1)
                        {
                            ViewColumn column = new ViewColumn();
                            column.bgcolor  = "255,255,255";
                            column.code     = "";
                            column.digit    = 0;
                            column.required = false;
                            column.sort     = i;
                            column.type     = "Text";
                            column.name     = item.Cells[sheet.firstrow - 1 - 1, i].StringValue;
                            if (configs.Count >= i + 1)
                            {
                                var config = configs[i];
                                column.bgcolor  = config.BGColor;
                                column.code     = "";
                                column.digit    = config.Digit;
                                column.required = config.IsRequired == 1;
                                column.sort     = i;
                                column.type     = config.FieldType;

                                var currentCell        = item.Cells[sheet.firstrow - 1 - 1, i];
                                var currentRowIndex    = currentCell.Row;
                                var currentColumnIndex = currentCell.Column;
                                var range = currentCell.GetMergedRange();
                                if (currentCell.IsMerged && (currentCell.Row != range.FirstRow || currentCell.Column != range.FirstColumn))
                                {
                                    //列合并
                                    if (range.ColumnCount > 1)
                                    {
                                        currentColumnIndex = range.FirstColumn;
                                    }
                                    //行合并
                                    if (range.RowCount > 1)
                                    {
                                        currentRowIndex = range.FirstRow;
                                    }
                                    currentCell = item.Cells[currentRowIndex, currentColumnIndex];
                                }
                                var cellValue = currentCell.StringValue;
                                //如果当前列至少在第三行(第一行是标题 第二行是标题起始 如果是在第二行就没必要合并列文本)
                                if (currentCell.Row > 1)
                                {
                                    currentCell = item.Cells[currentCell.Row - 1, currentColumnIndex];
                                    while (currentCell.IsMerged && currentCell.Row > 0)
                                    {
                                        var r = currentCell.GetMergedRange();
                                        currentCell = item.Cells[r.FirstRow, r.FirstColumn];
                                        cellValue   = currentCell.StringValue + "-" + cellValue;
                                        currentCell = item.Cells[currentCell.Row - 1, currentCell.Column];
                                    }
                                }
                                column.name = cellValue;

                                var selectList = TemplateConfigSelectOperator.Instance.GetList(templateID, sheetData.ID, config.ID);
                                if (selectList != null && selectList.Count > 0)
                                {
                                    column.range = string.Join(",", selectList.OrderBy(x => x.SortIndex).Select(x => x.SelectedValue).ToList());
                                }
                            }
                            sheet.columns.Add(column);
                        }
                    }
                    var rows = TemplateOperator.Instance.ReadDataRowFromWorksheet(item, sheet.columns, sheet.firstrow, sheet.firstcolumn, 3);
                    sheet.rows = rows;
                    list.Add(sheet);
                }
            }
            return(list);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 通过文件流以及配置信息读取转换格式后的业务数据
        /// </summary>
        /// <param name="stream">excel文件流</param>
        /// <param name="formatType">文件格式</param>
        /// <param name="sheetDatas">sheet配置集合</param>
        /// <param name="configList">列配置集合</param>
        /// <param name="rangeList">列下拉列表配置集合</param>
        /// <returns></returns>
        public List <ViewSheet> ReadExcelData(Stream stream, SaveFormat formatType, List <TemplateSheet> sheetDatas, List <Model.TemplateConfig> configList, List <Model.TemplateConfigSelect> rangeList)
        {
            Workbook dodelDatabook = new Workbook(stream);
            var      list          = new List <ViewSheet>();

            int defaultFirstColumn = 1;
            int defaultFirstRow    = 3;

            foreach (Worksheet item in dodelDatabook.Worksheets)
            {
                if (!item.IsVisible)
                {
                    continue;
                }

                var sheetData = sheetDatas.FirstOrDefault(x => x.TemplateSheetName == item.Name);
                if (sheetData == null)
                {
                    continue;
                }
                if (item.Cells.MaxDataRow >= 0 && item.Cells.MaxDataColumn >= 0)
                {
                    ViewSheet sheet = new ViewSheet();
                    sheet.changeflag  = true;
                    sheet.edit        = false;
                    sheet.firstcolumn = defaultFirstColumn;
                    sheet.firstrow    = defaultFirstRow;

                    sheet.code        = item.Name;
                    sheet.name        = item.Name;
                    sheet.title       = item.Cells[0, 0].StringValue;
                    sheet.remark      = "";
                    sheet.columns     = new List <ViewColumn>();
                    sheet.firstrow    = sheetData.RowNum + 1;
                    sheet.firstcolumn = sheetData.ColumnNum;
                    sheet.remark      = sheetData.TemplateSheetRemark;
                    sheet.title       = sheetData.TemplateSheetTitle;
                    List <Model.TemplateConfig> configs = configList.FindAll(x => x.TemplateSheetID == sheetData.ID);
                    configs = configs.OrderBy(x => x.SortIndex).ToList();
                    for (int i = 0; i <= item.Cells.MaxDataColumn; i++)
                    {
                        if (i >= sheet.firstcolumn - 1)
                        {
                            ViewColumn column = new ViewColumn();
                            column.bgcolor  = "255,255,255";
                            column.code     = "";
                            column.digit    = 0;
                            column.required = false;
                            column.sort     = i;
                            column.type     = "Text";
                            column.name     = item.Cells[sheet.firstrow - 1 - 1, i].StringValue;


                            //获取单元格公式
                            column.isformula = item.Cells[sheet.firstrow - 1, i].IsFormula;
                            if (column.isformula)
                            {
                                column.tempformula = item.Cells[sheet.firstrow - 1, i].Formula;
                                column.cellformula = GetFormulaForTempFormula(column.tempformula);
                            }

                            var currentCell = item.Cells[sheet.firstrow - 1 - 1, i];
                            var cellValue   = GetColumnSpanHeaderText(item, currentCell);

                            column.name = cellValue;


                            if (configs.Count > i + 1 - sheet.firstcolumn)
                            {
                                var config = configs[i + 1 - sheet.firstcolumn];
                                column.bgcolor  = config.BGColor;
                                column.code     = "";
                                column.digit    = config.Digit;
                                column.required = config.IsRequired == 1;
                                column.sort     = i;
                                column.type     = config.FieldType;
                                column.name     = config.FieldName;
                                var selectList = rangeList.FindAll(x => x.TemplateSheetID == sheetData.ID && x.TemplateConfigID == config.ID);
                                //TemplateConfigSelectOperator.Instance.GetList(templateID, sheetData.ID, config.ID);
                                if (selectList != null && selectList.Count > 0)
                                {
                                    column.range = string.Join(",", selectList.OrderBy(x => x.SortIndex).Select(x => x.SelectedValue).ToList());
                                }
                                //获取单元格公式
                                column.isformula = config.IsFormula == 1;
                                if (column.isformula)
                                {
                                    column.tempformula = config.TempFormula;
                                    column.cellformula = config.CellFormula;
                                }
                            }
                            sheet.columns.Add(column);
                            if (sheet.columns.Count > 0)
                            {
                                sheet.columns[0].select = true;
                            }
                        }
                    }
                    var rows = TemplateOperator.Instance.ReadDataRowFromWorksheet(item, sheet.columns, sheet.firstrow, sheet.firstcolumn, 3);
                    sheet.rows = rows;
                    list.Add(sheet);
                    if (list.Count > 0)
                    {
                        list[0].select = true;
                    }
                }
            }

            return(list);
        }
Exemplo n.º 16
0
        private void GetViews(int idForm)
        {
            XmlForm = FormXmlService.LoadXmlForm(idForm);

            FormsBoardViewModel.GroupViews = new List <ViewsGroupViewModel>();
            var groupViews = XmlForm.SelectNodes("//body/views/group");

            foreach (XmlNode nodeGroup in groupViews)
            {
                if (nodeGroup.SelectSingleNode("visible") != null)
                {
                    var visibleNode = nodeGroup.SelectSingleNode("visible").InnerText;
                    if (!FormXmlService.ValidateConditions(null, visibleNode))
                    {
                        continue;
                    }
                }

                var titleGroup = nodeGroup["title"].InnerText;
                if (titleGroup.Equals("User()"))
                {
                    titleGroup = UserUtil.DisplayUserName;
                }

                var groupView = new ViewsGroupViewModel
                {
                    Title = titleGroup,
                    Views = new List <ViewFormsViewModel>()
                };

                var views = nodeGroup.SelectNodes("view");
                foreach (XmlNode nodeView in views)
                {
                    if (nodeView.SelectSingleNode("visible") != null)
                    {
                        var visibleNode = nodeView.SelectSingleNode("visible").InnerText;
                        if (!FormXmlService.ValidateConditions(null, visibleNode))
                        {
                            continue;
                        }
                    }

                    var view = new ViewFormsViewModel
                    {
                        Id          = int.Parse(nodeView["viewId"].InnerText),
                        Title       = nodeView["name"].InnerText,
                        GroupBy     = nodeView["groupBy"] == null ? "" : nodeView["groupBy"].InnerText,
                        ViewColumns = new List <ViewColumn>()
                    };

                    var columns = nodeView.SelectNodes("columns/column");
                    foreach (XmlNode nodeColumn in columns)
                    {
                        var column = new ViewColumn
                        {
                            Name              = nodeColumn["name"].InnerText,
                            ControlId         = nodeColumn["controlId"] == null ? null : nodeColumn["controlId"].InnerText,
                            FunctionControlId = nodeColumn["functionControlId"] == null ? null : nodeColumn["functionControlId"].InnerText
                        };

                        view.ViewColumns.Add(column);
                    }

                    groupView.Views.Add(view);
                }

                FormsBoardViewModel.GroupViews.Add(groupView);
            }
        }
Exemplo n.º 17
0
        public static Database DatabaseFactory(Extractor extractor, IEnumerable <DBLint.DataAccess.DBObjects.Schema> selectedSchemas, IEnumerable <DBLint.DataAccess.DBObjects.TableID> ignoredTables)
        {
            var database          = new Database(extractor.DatabaseName, extractor.Database);
            var ignoredDictionary = DictionaryFactory.CreateTableID <TableID>();

            foreach (var ignoredTable in ignoredTables)
            {
                var tblid = new TableID(extractor.DatabaseName, ignoredTable.SchemaName, ignoredTable.TableName);
                ignoredDictionary.Add(tblid, tblid);
            }

            using (var db = database)
            {
                var dbSchemas = extractor.Database.GetSchemas();
                foreach (var dbSchema in dbSchemas)
                {
                    using (var schema = new Schema(db.DatabaseName, dbSchema.SchemaName))
                    {
                        if (!selectedSchemas.Any(p => p.Equals(dbSchema)))
                        {
                            continue;
                        }
                        schema.Database = db;
                        db._schemas.Add(schema);

                        #region Table and table columns

                        var dbTables = extractor.Database.GetTables(schema.SchemaName);
                        var tables   = from dbTable in dbTables
                                       orderby dbTable.TableName
                                       select dbTable;

                        foreach (var dbTable in tables)
                        {
                            var table = new DataTable(db.DatabaseName, schema.SchemaName, dbTable.TableName, extractor.Database);

                            if (ignoredDictionary.ContainsKey(table))
                            {
                                database.IgnoredTables.Add(table);
                                continue;
                            }

                            schema._tables.Add(table);
                            db.tableDictionary.Add(table, table);
                            table.Database = db;
                            table.Schema   = schema;
                        }

                        var dbColumns = extractor.Database.GetColumns(schema.SchemaName);

                        var columnID = new ColumnID(extractor.DatabaseName, schema.SchemaName, null, null);
                        foreach (var dbColumn in dbColumns)
                        {
                            columnID.TableName  = dbColumn.TableName;
                            columnID.ColumnName = dbColumn.ColumnName;
                            if (db.tableDictionary.ContainsKey(columnID))
                            {
                                var column = new Column(db.DatabaseName, schema.SchemaName, dbColumn.TableName, dbColumn.ColumnName);
                                var table  = db.tableDictionary[column];
                                table._columns.Add(column);
                                column.DataType           = dbColumn.DataType;
                                column.DefaultValue       = dbColumn.DefaultValue;
                                column.OrdinalPosition    = dbColumn.OrdinalPosition;
                                column.CharacterMaxLength = dbColumn.CharacterMaxLength;
                                column.IsNullable         = dbColumn.IsNullable;
                                column.NumericPrecision   = dbColumn.NumericPrecision;
                                column.NumericScale       = dbColumn.NumericScale;
                                column.Table      = table;
                                column.Schema     = schema;
                                column.Database   = db;
                                column.IsSequence = dbColumn.IsSequence;
                                column.IsDefaultValueAFunction = dbColumn.DefaultIsFunction;
                            }
                        }

                        #endregion

                        #region Views and view columns

                        var dbViews = extractor.Database.GetViews(schema.SchemaName);
                        var views   = from dbView in dbViews
                                      orderby dbView.ViewName
                                      select dbView;

                        foreach (var dbView in views)
                        {
                            var view = new View(db.DatabaseName, schema.SchemaName, dbView.ViewName);

                            schema._views.Add(view);
                            db.viewDictionary.Add(view, view);
                            view.Database = db;
                            view.Schema   = schema;
                        }

                        var dbViewColumns = extractor.Database.GetViewColumns(schema.SchemaName);
                        var viewColumnID  = new ViewColumnID(extractor.DatabaseName, schema.SchemaName, null, null);

                        foreach (var dbViewColumn in dbViewColumns)
                        {
                            viewColumnID.ViewName   = dbViewColumn.ViewName;
                            viewColumnID.ColumnName = dbViewColumn.ColumnName;

                            if (db.viewDictionary.ContainsKey(viewColumnID))
                            {
                                var viewColumn = new ViewColumn(db.DatabaseName, schema.SchemaName, dbViewColumn.ViewName, dbViewColumn.ColumnName);
                                var view       = db.viewDictionary[viewColumn];
                                view._columns.Add(viewColumn);
                                viewColumn.Database           = db;
                                viewColumn.Schema             = schema;
                                viewColumn.View               = view;
                                viewColumn.DataType           = dbViewColumn.DataType;
                                viewColumn.DefaultValue       = dbViewColumn.DefaultValue;
                                viewColumn.OrdinalPosition    = dbViewColumn.OrdinalPosition;
                                viewColumn.CharacterMaxLength = dbViewColumn.CharacterMaxLength;
                                viewColumn.IsNullable         = dbViewColumn.IsNullable;
                                viewColumn.NumericPrecision   = dbViewColumn.NumericPrecision;
                                viewColumn.NumericScale       = dbViewColumn.NumericScale;
                                viewColumn.Privileges         = dbViewColumn.Privileges;
                            }
                        }

                        #endregion

                        // Adding functions
                        var functions = extractor.Database.GetFunctions(schema.SchemaName);
                        foreach (var function in functions)
                        {
                            var f = new Function(
                                database.DatabaseName,
                                function.SchemaName,
                                function.RoutineName);
                            f.Database = database;
                            f.Schema   = schema;

                            schema._functions.Add(f);
                        }

                        var fParameters = extractor.Database.GetFunctionsParameters(schema.SchemaName);
                        foreach (var fParameter in fParameters)
                        {
                            var fp = new Parameter(database.DatabaseName, fParameter.SchemaName, fParameter.RoutineName, fParameter.ParameterName);
                            fp.Database = schema.Database;
                            fp.Schema   = schema;

                            fp.DataType           = fParameter.DataType;
                            fp.Direction          = fParameter.Direction;
                            fp.CharacterMaxLength = fParameter.CharacterMaxLength;
                            fp.NumericPrecision   = fParameter.NumericPrecision;
                            fp.NumericScale       = fParameter.NumericScale;
                            fp.OrdinalPosition    = fParameter.OrdinalPosition;

                            var tmpF = schema._functions.Where(f => f.FunctionName.Equals(fp.RoutineName)).FirstOrDefault();
                            if (tmpF != null)
                            {
                                fp.Routine = tmpF;
                                tmpF._parameters.Add(fp);
                            }
                        }

                        // Adding stored procedures
                        var storedProcedures = extractor.Database.GetStoredProcedures(schema.SchemaName);
                        foreach (var storedProcedure in storedProcedures)
                        {
                            var sp = new StoredProcedure(
                                database.DatabaseName,
                                storedProcedure.SchemaName,
                                storedProcedure.RoutineName);

                            sp.Database = database;
                            sp.Schema   = schema;

                            schema._storedProcedures.Add(sp);
                        }

                        var parameters = extractor.Database.GetStoredProceduresParameters(schema.SchemaName);
                        foreach (var parameter in parameters)
                        {
                            var p = new Parameter(database.DatabaseName, parameter.SchemaName, parameter.RoutineName, parameter.ParameterName);
                            p.Database = schema.Database;
                            p.Schema   = schema;

                            p.DataType           = parameter.DataType;
                            p.Direction          = parameter.Direction;
                            p.CharacterMaxLength = parameter.CharacterMaxLength;
                            p.NumericPrecision   = parameter.NumericPrecision;
                            p.NumericScale       = parameter.NumericScale;
                            p.OrdinalPosition    = parameter.OrdinalPosition;

                            var tmpSp = schema._storedProcedures.Where(sp => sp.StoredProcedureName.Equals(p.RoutineName)).FirstOrDefault();
                            if (tmpSp != null)
                            {
                                p.Routine = tmpSp;
                                tmpSp._parameters.Add(p);
                            }
                        }
                    }
                }
            }
            AddForeignKeys(extractor, database);
            AddPrimaryKeys(extractor, database);
            AddIndices(extractor, database);
            AddUniqueConstraints(extractor, database);

            foreach (var tbl in database.Tables)
            {
                tbl.Dispose();
            }

            foreach (var view in database.Views)
            {
                view.Dispose();
            }

            AddCardinalities(database.tableDictionary, extractor, selectedSchemas);

            database.Escaper = Escaper.GetEscaper(extractor.Database.DBMS);
            database.DBMS    = extractor.Database.DBMS;
            return(database);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Determines whether the specified node is visible.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>
 ///     <c>true</c> if the specified node is visible; otherwise, <c>false</c>.
 /// </returns>
 private bool IsVisible(ViewColumn node)
 {
     // TODO: implement personalization here
     return(true); // always visible node.Visible;
 }