示例#1
0
        public static string GetSerializedString(string tableName)
        {
            var builder    = new StringBuilder();
            var list       = GetTableMetadataInfoList(tableName);
            var sortedlist = new SortedList();

            foreach (var metadataInfo in list)
            {
                if (metadataInfo.IsSystem == false)
                {
                    /*
                     * AttributeName,
                     * DataType,
                     * DataLength,
                     * CanBeNull,
                     * DBDefaultValue
                     * */
                    string serialize =
                        $"AttributeName:{metadataInfo.AttributeName};DataType:{EDataTypeUtils.GetValue(metadataInfo.DataType)};DataLength={metadataInfo.DataLength}";
                    sortedlist.Add(metadataInfo.AttributeName, serialize);
                }
            }

            foreach (string attributeName in sortedlist.Keys)
            {
                builder.Append(sortedlist[attributeName]);
            }

            return(builder.ToString());
        }
示例#2
0
        private static AtomEntry GetAtomEntry(TableMetadataInfo metaInfo)
        {
            var entry = AtomUtility.GetEmptyEntry();

            AtomUtility.AddDcElement(entry.AdditionalElements, "TableMetadataID", metaInfo.TableMetadataId.ToString());
            AtomUtility.AddDcElement(entry.AdditionalElements, "AuxiliaryTableENName", metaInfo.AuxiliaryTableEnName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "AttributeName", metaInfo.AttributeName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "DataType", EDataTypeUtils.GetValue(metaInfo.DataType));
            AtomUtility.AddDcElement(entry.AdditionalElements, "DataLength", metaInfo.DataLength.ToString());
            AtomUtility.AddDcElement(entry.AdditionalElements, "Taxis", metaInfo.Taxis.ToString());
            AtomUtility.AddDcElement(entry.AdditionalElements, "IsSystem", metaInfo.IsSystem.ToString());

            return(entry);
        }
        private void SetColumns(NameValueCollection columnsMap)
        {
            Columns.Items.Clear();
            ColumnsToMatch.Items.Clear();

            var tableColumnInfoList    = BaiRongDataProvider.TableStructureDao.GetTableColumnInfoList(GetDatabaseConnectionString(), DatabaseName.SelectedValue, RelatedTableName.SelectedValue);
            var columnToMatchArrayList = new ArrayList();

            foreach (var tableColumnInfo in tableColumnInfoList)
            {
                string text =
                    $"{tableColumnInfo.ColumnName}({EDataTypeUtils.GetValue(tableColumnInfo.DataType)} {tableColumnInfo.Length})";
                var value         = tableColumnInfo.ColumnName.ToLower();
                var columnToMatch = columnsMap[value];
                if (!string.IsNullOrEmpty(columnToMatch))
                {
                    var tableMetadataInfoToMatch = TableManager.GetTableMetadataInfo(TableNameToMatch.Text, columnToMatch);
                    if (tableMetadataInfoToMatch != null)
                    {
                        columnToMatchArrayList.Add(columnToMatch);
                        text += " -> " +
                                $"{tableMetadataInfoToMatch.AttributeName}({EDataTypeUtils.GetValue(tableMetadataInfoToMatch.DataType)} {tableMetadataInfoToMatch.DataLength})";
                        value += "&" + columnToMatch;
                    }
                }
                Columns.Items.Add(new ListItem(text, value));
            }

            var tableMetadataInfoList = TableManager.GetTableMetadataInfoList(TableNameToMatch.Text);

            foreach (var tableMetadataInfo in tableMetadataInfoList)
            {
                var value = tableMetadataInfo.AttributeName.ToLower();
                if (!columnToMatchArrayList.Contains(tableMetadataInfo.AttributeName))
                {
                    string text =
                        $"{tableMetadataInfo.AttributeName}({EDataTypeUtils.GetValue(tableMetadataInfo.DataType)} {tableMetadataInfo.DataLength})";
                    ColumnsToMatch.Items.Add(new ListItem(text, value));
                }
            }

            SaveColumnsMap(columnsMap);
        }
        public void RelatedTable_Changed(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(RelatedTableName.SelectedValue))
            {
                RelatedIdentity.Items.Clear();
                RelatedOrderBy.Items.Clear();
            }
            else
            {
                var tableColumnInfoList = BaiRongDataProvider.TableStructureDao.GetTableColumnInfoList(GetDatabaseConnectionString(), DatabaseName.SelectedValue, RelatedTableName.SelectedValue);
                RelatedIdentity.Items.Clear();
                RelatedOrderBy.Items.Clear();
                var item = new ListItem("请选择主键字段名称", string.Empty);
                RelatedIdentity.Items.Add(item);
                item = new ListItem("请选择排序字段名称", string.Empty);
                RelatedOrderBy.Items.Add(item);
                foreach (var tableColumnInfo in tableColumnInfoList)
                {
                    item = new ListItem(
                        $"{tableColumnInfo.ColumnName}({EDataTypeUtils.GetValue(tableColumnInfo.DataType)} {tableColumnInfo.Length})", tableColumnInfo.ColumnName);
                    if (StringUtils.EqualsIgnoreCase(tableColumnInfo.ColumnName, RelatedIdentityHidden.Value))
                    {
                        item.Selected = true;
                    }
                    RelatedIdentity.Items.Add(item);
                }

                foreach (var tableColumnInfo in tableColumnInfoList)
                {
                    item = new ListItem(
                        $"{tableColumnInfo.ColumnName}({EDataTypeUtils.GetValue(tableColumnInfo.DataType)} {tableColumnInfo.Length})", tableColumnInfo.ColumnName);
                    if (StringUtils.EqualsIgnoreCase(tableColumnInfo.ColumnName, RelatedOrderByHidden.Value))
                    {
                        item.Selected = true;
                    }
                    RelatedOrderBy.Items.Add(item);
                }
            }
        }
示例#5
0
        public void Update(TableMetadataInfo info)
        {
            var isSqlChanged = true;
            var originalInfo = GetTableMetadataInfo(info.TableMetadataId);

            if (originalInfo != null)
            {
                if (info.AuxiliaryTableEnName == originalInfo.AuxiliaryTableEnName &&
                    info.AttributeName == originalInfo.AttributeName &&
                    info.DataType == originalInfo.DataType &&
                    info.DataLength == originalInfo.DataLength &&
                    info.Taxis == originalInfo.Taxis)
                {
                    isSqlChanged = false;
                }
            }

            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmAuxiliaryTableEnname, EDataType.VarChar, 50, info.AuxiliaryTableEnName),
                GetParameter(ParmAttributeName, EDataType.VarChar, 50, info.AttributeName),
                GetParameter(ParmDataType, EDataType.VarChar, 50, EDataTypeUtils.GetValue(info.DataType)),
                GetParameter(ParmDataLength, EDataType.Integer, info.DataLength),
                GetParameter(ParmIsSystem, EDataType.VarChar, 18, info.IsSystem.ToString()),
                GetParameter(ParmTableMetadataId, EDataType.Integer, info.TableMetadataId)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                ExecuteNonQuery(conn, SqlUpdateTableMetadata, updateParms);
                if (isSqlChanged)
                {
                    BaiRongDataProvider.TableCollectionDao.UpdateIsChangedAfterCreatedInDb(true, info.AuxiliaryTableEnName);
                }
                TableManager.IsChanged = true;
            }
        }
示例#6
0
        internal void InsertWithTransaction(TableMetadataInfo info, EAuxiliaryTableType tableType, int taxis, IDbTransaction trans)
        {
            var sqlString = "INSERT INTO bairong_TableMetadata (AuxiliaryTableENName, AttributeName, DataType, DataLength, Taxis, IsSystem) VALUES (@AuxiliaryTableENName, @AttributeName, @DataType, @DataLength, @Taxis, @IsSystem)";

            var insertParms = new IDataParameter[]
            {
                GetParameter(ParmAuxiliaryTableEnname, EDataType.VarChar, 50, info.AuxiliaryTableEnName),
                GetParameter(ParmAttributeName, EDataType.VarChar, 50, info.AttributeName),
                GetParameter(ParmDataType, EDataType.VarChar, 50, EDataTypeUtils.GetValue(info.DataType)),
                GetParameter(ParmDataLength, EDataType.Integer, info.DataLength),
                GetParameter(ParmTaxis, EDataType.Integer, taxis),
                GetParameter(ParmIsSystem, EDataType.VarChar, 18, info.IsSystem.ToString())
            };

            ExecuteNonQuery(trans, sqlString, insertParms);
            if (info.StyleInfo != null)
            {
                info.StyleInfo.TableName     = info.AuxiliaryTableEnName;
                info.StyleInfo.AttributeName = info.AttributeName;
                BaiRongDataProvider.TableStyleDao.InsertWithTransaction(info.StyleInfo, EAuxiliaryTableTypeUtils.GetTableStyle(tableType), trans);
                TableStyleManager.IsChanged = true;
            }
            TableManager.IsChanged = true;
        }
示例#7
0
        public void Insert(TableMetadataInfo info)
        {
            var sqlString = "INSERT INTO bairong_TableMetadata (AuxiliaryTableENName, AttributeName, DataType, DataLength, Taxis, IsSystem) VALUES (@AuxiliaryTableENName, @AttributeName, @DataType, @DataLength, @Taxis, @IsSystem)";

            var insertParms = new IDataParameter[]
            {
                GetParameter(ParmAuxiliaryTableEnname, EDataType.VarChar, 50, info.AuxiliaryTableEnName),
                GetParameter(ParmAttributeName, EDataType.VarChar, 50, info.AttributeName),
                GetParameter(ParmDataType, EDataType.VarChar, 50, EDataTypeUtils.GetValue(info.DataType)),
                GetParameter(ParmDataLength, EDataType.Integer, info.DataLength),
                GetParameter(ParmTaxis, EDataType.Integer, GetMaxTaxis(info.AuxiliaryTableEnName) + 1),
                GetParameter(ParmIsSystem, EDataType.VarChar, 18, info.IsSystem.ToString())
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                ExecuteNonQuery(conn, sqlString, insertParms);

                BaiRongDataProvider.TableCollectionDao.UpdateAttributeNum(info.AuxiliaryTableEnName);
                BaiRongDataProvider.TableCollectionDao.UpdateIsChangedAfterCreatedInDb(true, info.AuxiliaryTableEnName);
                TableManager.IsChanged = true;
            }
        }