コード例 #1
0
        public int GetTableUsedNum(string tableENName, string auxiliaryTableType)
        {
            var tableType = EAuxiliaryTableTypeUtils.GetEnumType(auxiliaryTableType);
            var usedNum   = BaiRongDataProvider.TableCollectionDao.GetTableUsedNum(tableENName, tableType);

            return(usedNum);
        }
コード例 #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("TableName", "TableType");

            _tableName = Body.GetQueryString("TableName");
            _tableType = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("TableType"));

            if (!IsPostBack)
            {
                EDataTypeUtils.AddListItemsToAuxiliaryTable(DataType);

                if (Body.IsQueryExists("TableMetadataID"))
                {
                    var tableMetadataId = Body.GetQueryInt("TableMetadataID");
                    var info            = BaiRongDataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
                    if (info != null)
                    {
                        AttributeName.Text    = info.AttributeName;
                        AttributeName.Enabled = false;
                        ControlUtils.SelectListItemsIgnoreCase(DataType, info.DataType.ToString());
                        DataLength.Text = info.DataLength.ToString();
                    }
                }
            }
        }
コード例 #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (Body.IsQueryExists("ENName"))
                {
                    var tableEnName = Body.GetQueryString("ENName");
                    var info        = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableInfo(tableEnName);
                    info.TableCnName = TableCNName.Text;
                    info.Description = Description.Text;
                    try
                    {
                        BaiRongDataProvider.TableCollectionDao.Update(info);

                        Body.AddAdminLog("修改辅助表", $"辅助表:{tableEnName}");

                        SuccessMessage("辅助表修改成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "辅助表修改失败!");
                    }
                }
                else
                {
                    var TableENNameList = BaiRongDataProvider.TableCollectionDao.GetTableEnNameList();
                    if (TableENNameList.IndexOf(TableENName.Text) != -1)
                    {
                        FailMessage("辅助表添加失败,辅助表标识已存在!");
                    }
                    else if (BaiRongDataProvider.TableStructureDao.IsTableExists(TableENName.Text))
                    {
                        FailMessage("辅助表添加失败,数据库中已存在此表!");
                    }
                    else
                    {
                        var info = new AuxiliaryTableInfo();
                        info.TableEnName        = TableENName.Text;
                        info.TableCnName        = TableCNName.Text;
                        info.Description        = Description.Text;
                        info.AuxiliaryTableType = EAuxiliaryTableTypeUtils.GetEnumType(AuxiliaryTableType.SelectedValue);
                        try
                        {
                            BaiRongDataProvider.TableCollectionDao.Insert(info);

                            Body.AddAdminLog("添加辅助表",
                                             $"辅助表:{TableENName.Text}");

                            SuccessMessage("辅助表添加成功!");
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "辅助表添加失败!");
                        }
                    }
                }
            }
        }
コード例 #4
0
        public void rblTableType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlTableName.Items.Clear();
            var tableType = EAuxiliaryTableTypeUtils.GetEnumType(rblTableType.SelectedValue);
            var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(tableType);

            foreach (AuxiliaryTableInfo tableInfo in tableList)
            {
                var li = new ListItem(tableInfo.TableCnName + "(" + tableInfo.TableEnName + ")", tableInfo.TableEnName);
                ddlTableName.Items.Add(li);
            }
        }
コード例 #5
0
        public void ImportContentModelInfo(bool overwrite)
        {
            if (!FileUtils.IsFileExists(_filePath))
            {
                return;
            }
            var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath));

            foreach (AtomEntry entry in feed.Entries)
            {
                var modelId = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ModelID");

                if (!string.IsNullOrEmpty(modelId))
                {
                    var contentModelInfo = new ContentModelInfo
                    {
                        ModelId   = modelId,
                        SiteId    = _publishmentSystemId,
                        ModelName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ModelName"),
                        IsSystem  =
                            TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSystem")),
                        TableName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "TableName"),
                        TableType =
                            EAuxiliaryTableTypeUtils.GetEnumType(
                                AtomUtility.GetDcElementContent(entry.AdditionalElements, "TableType")),
                        IconUrl     = AtomUtility.GetDcElementContent(entry.AdditionalElements, "IconUrl"),
                        Description = AtomUtility.GetDcElementContent(entry.AdditionalElements, "Description")
                    };

                    var auxiliaryTableInfo = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableInfo(modelId);
                    if (auxiliaryTableInfo != null && auxiliaryTableInfo.TableEnName == modelId)
                    {
                        if (overwrite)
                        {
                            BaiRongDataProvider.ContentModelDao.Update(contentModelInfo);
                        }
                        else
                        {
                            var importContentModelId = BaiRongDataProvider.ContentModelDao.GetImportContentModelId(_publishmentSystemId, contentModelInfo.ModelId);
                            contentModelInfo.ModelId = importContentModelId;
                            BaiRongDataProvider.ContentModelDao.Insert(contentModelInfo);
                        }
                    }
                    else
                    {
                        BaiRongDataProvider.ContentModelDao.Insert(contentModelInfo);
                    }
                }
            }
        }
コード例 #6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("TableName", "TableType");

            _tableName = Body.GetQueryString("TableName");
            _tableType = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("TableType"));

            if (!IsPostBack)
            {
            }
        }
コード例 #7
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _tableName      = Body.GetQueryString("tableName");
            _tableType      = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("tableType"));
            _tableStyle     = ETableStyleUtils.GetStyleType(_tableType);
            _redirectUrl    = GetRedirectUrl(_tableName, _tableType);
            _attributeNames = TableManager.GetAttributeNameList(_tableStyle, _tableName);

            if (IsPostBack)
            {
                return;
            }

            BreadCrumbSys(AppManager.Sys.LeftMenu.Auxiliary, $"虚拟字段管理({_tableName})", AppManager.Sys.Permission.SysAuxiliary);

            //删除样式
            if (Body.IsQueryExists("DeleteStyle"))
            {
                DeleteStyle();
            }
            else if (Body.IsQueryExists("SetTaxis"))
            {
                SetTaxis();
            }

            var styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, _tableName, new List <int> {
                0
            });

            DgContents.DataSource     = styleInfoList;
            DgContents.ItemDataBound += dgContents_ItemDataBound;
            DgContents.DataBind();

            AddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(0, _tableName, string.Empty, _tableStyle, _redirectUrl));
            AddStyles.Attributes.Add("onclick", ModalTableStylesAdd.GetOpenWindowString(_tableName, _tableStyle, _redirectUrl));
            Import.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_tableName, _tableStyle));
            Export.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableStyle, _tableName));
        }
コード例 #8
0
        public EAuxiliaryTableType GetTableType(string tableEnName)
        {
            var type = EAuxiliaryTableType.BackgroundContent;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableEnname, EDataType.VarChar, 50, tableEnName),
            };

            using (var rdr = ExecuteReader(SqlSelectTableType, parms))
            {
                if (rdr.Read())
                {
                    type = EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, 0));
                }
                rdr.Close();
            }

            return(type);
        }
コード例 #9
0
        /// <summary>
        /// 将频道模板中的辅助表导入发布系统中,返回修改了的表名对照
        /// 在导入辅助表的同时检查发布系统辅助表并替换对应表
        /// </summary>
        public NameValueCollection ImportAuxiliaryTables(int publishmentSystemId, bool isUserTables)
        {
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                return(null);
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var nameValueCollection = new NameValueCollection();
            var tableNamePrefix     = publishmentSystemInfo.PublishmentSystemDir + "_";

            var filePaths = DirectoryUtils.GetFilePaths(_directoryPath);

            foreach (var filePath in filePaths)
            {
                var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                var tableName = AtomUtility.GetDcElementContent(feed.AdditionalElements, "TableENName");
                var tableType = EAuxiliaryTableTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, "AuxiliaryTableType"));

                if (!isUserTables)
                {
                    nameValueCollection[tableName] = NodeManager.GetTableName(publishmentSystemInfo, tableType);
                    continue;
                }

                var tableCnName      = AtomUtility.GetDcElementContent(feed.AdditionalElements, "TableCNName");
                var serializedString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "SerializedString");

                var tableNameToInsert = string.Empty;//需要增加的表名,空代表不需要添加辅助表

                var tableInfo = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableInfo(tableName);
                if (tableInfo == null)//如果当前系统无此表名
                {
                    tableNameToInsert = tableName;
                }
                else
                {
                    var serializedStringForExistTable = TableManager.GetSerializedString(tableName);

                    if (!string.IsNullOrEmpty(serializedString))
                    {
                        if (serializedString != serializedStringForExistTable)//仅有此时,导入表需要修改表名
                        {
                            tableNameToInsert = tableNamePrefix + tableName;
                            tableCnName       = tableNamePrefix + tableCnName;
                            nameValueCollection[tableName] = tableNameToInsert;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(tableNameToInsert))//需要添加
                {
                    if (!BaiRongDataProvider.TableStructureDao.IsTableExists(tableNameToInsert))
                    {
                        tableInfo = new AuxiliaryTableInfo
                        {
                            TableEnName               = tableNameToInsert,
                            TableCnName               = tableCnName,
                            AttributeNum              = 0,
                            AuxiliaryTableType        = tableType,
                            IsCreatedInDb             = false,
                            IsChangedAfterCreatedInDb = false,
                            Description               = AtomUtility.GetDcElementContent(feed.AdditionalElements, "Description")
                        };

                        BaiRongDataProvider.TableCollectionDao.Insert(tableInfo);

                        var tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(tableInfo.AuxiliaryTableType);

                        var attributeNameList =
                            TableManager.GetAttributeNameList(tableStyle, tableInfo.TableEnName, true);
                        attributeNameList.AddRange(
                            TableManager.GetHiddenAttributeNameList(tableStyle));

                        foreach (AtomEntry entry in feed.Entries)
                        {
                            var metaInfo = new TableMetadataInfo
                            {
                                AuxiliaryTableEnName = tableNameToInsert,
                                AttributeName        =
                                    AtomUtility.GetDcElementContent(entry.AdditionalElements, "AttributeName"),
                                DataType = EDataTypeUtils.GetEnumType(
                                    AtomUtility.GetDcElementContent(entry.AdditionalElements, "DataType")),
                                DataLength = TranslateUtils.ToInt(
                                    AtomUtility.GetDcElementContent(entry.AdditionalElements, "DataLength")),
                                Taxis =
                                    TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements,
                                                                                         "Taxis")),
                                IsSystem = TranslateUtils.ToBool(
                                    AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSystem"))
                            };

                            if (attributeNameList.IndexOf(metaInfo.AttributeName.Trim().ToLower()) != -1)
                            {
                                continue;
                            }

                            if (metaInfo.IsSystem)
                            {
                                continue;
                            }

                            BaiRongDataProvider.TableMetadataDao.Insert(metaInfo);
                        }

                        BaiRongDataProvider.TableMetadataDao.CreateAuxiliaryTable(tableNameToInsert);
                    }
                }

                var tableNameToChange = (!string.IsNullOrEmpty(tableNameToInsert)) ? tableNameToInsert : tableName;
                //更新发布系统后台内容表及栏目表
                if (tableType == EAuxiliaryTableType.BackgroundContent)
                {
                    publishmentSystemInfo.AuxiliaryTableForContent = tableNameToChange;
                    DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);
                }
                else if (tableType == EAuxiliaryTableType.GovPublicContent)
                {
                    publishmentSystemInfo.AuxiliaryTableForGovPublic = tableNameToChange;
                    DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);
                }
                else if (tableType == EAuxiliaryTableType.GovInteractContent)
                {
                    publishmentSystemInfo.AuxiliaryTableForGovInteract = tableNameToChange;
                    DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);
                }
                else if (tableType == EAuxiliaryTableType.JobContent)
                {
                    publishmentSystemInfo.AuxiliaryTableForJob = tableNameToChange;
                    DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);
                }
                else if (tableType == EAuxiliaryTableType.VoteContent)
                {
                    publishmentSystemInfo.AuxiliaryTableForVote = tableNameToChange;
                    DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo);
                }
            }

            return(nameValueCollection);
        }
コード例 #10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            ContentModelInfo modelInfo;

            if (Body.IsQueryExists("ModelID"))
            {
                var modelId = Body.GetQueryString("ModelID");
                modelInfo = BaiRongDataProvider.ContentModelDao.GetContentModelInfo(modelId, PublishmentSystemId);

                modelInfo.ModelName   = tbModelName.Text;
                modelInfo.TableName   = ddlTableName.SelectedValue;
                modelInfo.TableType   = EAuxiliaryTableTypeUtils.GetEnumType(rblTableType.SelectedValue);
                modelInfo.IconUrl     = tbIconUrl.Text;
                modelInfo.Description = tbDescription.Text;
            }
            else
            {
                modelInfo = new ContentModelInfo
                {
                    ModelId     = tbModelID.Text,
                    SiteId      = PublishmentSystemId,
                    ModelName   = tbModelName.Text,
                    IsSystem    = false,
                    TableName   = ddlTableName.SelectedValue,
                    TableType   = EAuxiliaryTableTypeUtils.GetEnumType(rblTableType.SelectedValue),
                    IconUrl     = tbIconUrl.Text,
                    Description = tbDescription.Text
                };
            }

            if (Body.IsQueryExists("ModelID"))
            {
                try
                {
                    BaiRongDataProvider.ContentModelDao.Update(modelInfo);
                    Body.AddSiteLog(PublishmentSystemId, "修改内容模型", $"内容模型:{modelInfo.ModelName}");
                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "内容模型修改失败!");
                }
            }
            else
            {
                var isFail        = false;
                var modelInfoList = ContentModelManager.GetContentModelInfoList(PublishmentSystemInfo);
                foreach (var contentModelInfo in modelInfoList)
                {
                    if (contentModelInfo.ModelId == tbModelID.Text)
                    {
                        FailMessage("内容模型添加失败,模型标识已存在!");
                        isFail = true;
                        break;
                    }
                    else if (contentModelInfo.ModelName == tbModelName.Text)
                    {
                        FailMessage("内容模型添加失败,模型名称已存在!");
                        isFail = true;
                        break;
                    }
                }
                if (!isFail)
                {
                    try
                    {
                        BaiRongDataProvider.ContentModelDao.Insert(modelInfo);
                        Body.AddSiteLog(PublishmentSystemId, "添加内容模型", $"内容模型:{modelInfo.ModelName}");
                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "内容模型添加失败!");
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }
コード例 #11
0
        public List <AuxiliaryTableInfo> GetAuxiliaryTableListCreatedInDb()
        {
            var list = new List <AuxiliaryTableInfo>();

            string sqlString =
                $"SELECT TableENName, TableCNName, AttributeNum, AuxiliaryTableType, IsCreatedInDB, IsChangedAfterCreatedInDB, IsDefault, Description FROM bairong_TableCollection WHERE IsCreatedInDB = '{true}' ORDER BY IsCreatedInDB DESC, TableENName";

            using (var rdr = ExecuteReader(sqlString))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new AuxiliaryTableInfo(GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }

            return(list);
        }
コード例 #12
0
        public ContentModelInfo GetContentModelInfo(string modelId, int siteId)
        {
            ContentModelInfo contentModelInfo = null;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmModelId, EDataType.VarChar, 50, modelId),
                GetParameter(ParmSiteId, EDataType.Integer, siteId)
            };

            using (var rdr = ExecuteReader(SqlSelect, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    contentModelInfo = new ContentModelInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(contentModelInfo);
        }
コード例 #13
0
        public AuxiliaryTableInfo GetAuxiliaryTableInfo(string tableEnName)
        {
            AuxiliaryTableInfo info = null;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmTableEnname, EDataType.VarChar, 50, tableEnName)
            };

            using (var rdr = ExecuteReader(SqlSelectTable, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    info = new AuxiliaryTableInfo(GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(info);
        }
コード例 #14
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _tableType     = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("TableType"));
            _tableName     = Body.GetQueryString("TableName");
            _attributeName = Body.GetQueryString("AttributeName");

            if (!IsPostBack)
            {
                var metadataInfo = TableManager.GetTableMetadataInfo(_tableName, _attributeName);

                if (metadataInfo != null)
                {
                    lblAttributeName.Text     = metadataInfo.AttributeName;
                    AuxiliaryTableENName.Text = metadataInfo.AuxiliaryTableEnName;
                    DataType.Text             = metadataInfo.DataType.ToString();
                    DataLength.Text           = metadataInfo.DataLength.ToString();

                    var styleInfo = TableStyleManager.GetTableStyleInfo(EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), metadataInfo.AuxiliaryTableEnName, metadataInfo.AttributeName, new List <int> {
                        0
                    });

                    if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.CheckBox, EInputType.Radio, EInputType.SelectMultiple, EInputType.SelectOne))
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = false;
                        RowSetItems.Visible     = true;
                        if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.CheckBox, EInputType.Radio))
                        {
                            RowIsHorizontal.Visible = true;
                        }
                    }
                    else if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.Text, EInputType.TextArea, EInputType.TextEditor))
                    {
                        RowDefaultValue.Visible = true;
                        RowSetItems.Visible     = RowIsHorizontal.Visible = false;
                    }
                    else
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = RowSetItems.Visible = false;
                    }

                    if (metadataInfo.IsSystem)
                    {
                        RowDefaultValue.Visible = RowIsHorizontal.Visible = RowSetItems.Visible = false;
                    }

                    DisplayName.Text = styleInfo.DisplayName;
                    HelpText.Text    = styleInfo.HelpText;
                    IsVisible.Text   = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                    IsValidate.Text  = StringUtils.GetTrueImageHtml(styleInfo.Additional.IsValidate);
                    InputType.Text   = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));

                    DefaultValue.Text = styleInfo.DefaultValue;
                    IsHorizontal.Text = StringUtils.GetBoolText(styleInfo.IsHorizontal);

                    var styleItems = BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                    MyRepeater.DataSource     = TableStyleManager.GetStyleItemDataSet(styleItems.Count, styleItems);
                    MyRepeater.ItemDataBound += MyRepeater_ItemDataBound;
                    MyRepeater.DataBind();
                }
                else
                {
                    FailMessage("此字段为虚拟字段,在数据库中不存在!");
                    phAttribute.Visible = false;
                }
            }
        }
コード例 #15
0
ファイル: PageTableMetadata.cs プロジェクト: yankaics/cms-1
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("ENName", "TableType");
            _showSqlTable = Body.IsQueryExists("ShowCrateDBCommand");

            _tableName   = Body.GetQueryString("ENName").Trim();
            _tableType   = EAuxiliaryTableTypeUtils.GetEnumType(Body.GetQueryString("TableType"));
            _redirectUrl = GetRedirectUrl(_tableName, _tableType, PublishmentSystemId);

            var tableInfo = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableInfo(_tableName);

            if (Body.IsQueryExists("Delete"))
            {
                var tableMetadataId = Body.GetQueryInt("TableMetadataID");

                try
                {
                    var tableMetadataInfo = BaiRongDataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
                    BaiRongDataProvider.TableMetadataDao.Delete(tableMetadataId);

                    Body.AddAdminLog("删除辅助表字段", $"辅助表:{_tableName},字段名:{tableMetadataInfo.AttributeName}");

                    SuccessDeleteMessage();
                    PageUtils.Redirect(_redirectUrl);
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (Body.IsQueryExists("DeleteStyle"))//删除样式
            {
                var attributeName = Body.GetQueryString("AttributeName");
                if (TableStyleManager.IsExists(0, _tableName, attributeName))
                {
                    try
                    {
                        TableStyleManager.Delete(0, _tableName, attributeName);

                        Body.AddAdminLog("删除辅助表字段样式", $"辅助表:{_tableName},字段名:{attributeName}");

                        SuccessDeleteMessage();
                        PageUtils.Redirect(_redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailDeleteMessage(ex);
                    }
                }
            }
            else if (Body.IsQueryExists("CreateDB"))
            {
                try
                {
                    BaiRongDataProvider.TableMetadataDao.CreateAuxiliaryTable(_tableName);
                    tableInfo.IsChangedAfterCreatedInDb = false;

                    Body.AddAdminLog("创建辅助表", $"辅助表:{_tableName}");

                    SuccessMessage("辅助表创建成功!");
                    PageUtils.Redirect(_redirectUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "<br>辅助表创建失败,失败原因为:" + ex.Message + "<br>请检查创建表SQL命令");
                    var sqlString = BaiRongDataProvider.AuxiliaryTableDataDao.GetCreateAuxiliaryTableSqlString(_tableName);
                    LtlSqlString.Text = sqlString.Replace("\r\n", "<br>").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
                    _showSqlTable     = true;
                }
            }
            else if (Body.IsQueryExists("DeleteDB"))
            {
                try
                {
                    BaiRongDataProvider.TableMetadataDao.DeleteAuxiliaryTable(_tableName);
                    tableInfo.IsChangedAfterCreatedInDb = false;

                    Body.AddAdminLog("删除辅助表", $"辅助表:{_tableName}");

                    SuccessMessage("辅助表删除成功!");
                    PageUtils.Redirect(_redirectUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "<br>辅助表删除失败,失败原因为:" + ex.Message + "<br>");
                }
            }
            else if (Body.IsQueryExists("ReCreateDB"))
            {
                try
                {
                    BaiRongDataProvider.TableMetadataDao.ReCreateAuxiliaryTable(_tableName, tableInfo.AuxiliaryTableType);
                    DataProvider.NodeDao.UpdateContentNumToZero(_tableName, tableInfo.AuxiliaryTableType);
                    tableInfo.IsChangedAfterCreatedInDb = false;

                    Body.AddAdminLog("重建辅助表", $"辅助表:{_tableName}");

                    SuccessMessage("辅助表重建成功!");
                    PageUtils.Redirect(_redirectUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "<br>辅助表重建失败,失败原因为:" + ex.Message + "<br>请检查创建表SQL命令");
                    var sqlString = BaiRongDataProvider.AuxiliaryTableDataDao.GetCreateAuxiliaryTableSqlString(_tableName);
                    LtlSqlString.Text = sqlString.Replace("\r\n", "<br>").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
                    _showSqlTable     = true;
                }
            }
            else if (Body.IsQueryExists("ShowCrateDBCommand"))
            {
                var sqlString = BaiRongDataProvider.AuxiliaryTableDataDao.GetCreateAuxiliaryTableSqlString(_tableName);
                LtlSqlString.Text = sqlString.Replace("\r\n", "<br>").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
            }
            else if (Body.IsQueryExists("SetTaxis"))
            {
                SetTaxis();
            }

            _tableIsRealCreated = BaiRongDataProvider.TableStructureDao.IsTableExists(_tableName);

            _usedNum = BaiRongDataProvider.TableCollectionDao.GetTableUsedNum(_tableName, tableInfo.AuxiliaryTableType);

            DivSyncTable.Visible = IsNeedSync(_tableIsRealCreated, tableInfo.IsChangedAfterCreatedInDb);

            if (!IsPostBack)
            {
                BreadCrumbSys(AppManager.Sys.LeftMenu.Auxiliary, $"辅助表字段管理({_tableName})", AppManager.Sys.Permission.SysAuxiliary);

                DgContents.DataSource     = BaiRongDataProvider.TableMetadataDao.GetDataSource(_tableName);
                DgContents.ItemDataBound += dgContents_ItemDataBound;
                DgContents.DataBind();

                BtnAddColumn.Attributes.Add("onclick", ModalTableMetadataAdd.GetOpenWindowStringToAdd(_tableName, _tableType));

                BtnBatchAddColumn.Attributes.Add("onclick", ModalTableMetadataAddBatch.GetOpenWindowStringToAdd(_tableName, _tableType));
            }
        }
コード例 #16
0
        public List <AuxiliaryTableInfo> GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(params EAuxiliaryTableType[] eAuxiliaryTableTypeArray)
        {
            var auxiliaryTableTypeList = new List <string>();

            foreach (var eAuxiliaryTableType in eAuxiliaryTableTypeArray)
            {
                auxiliaryTableTypeList.Add(EAuxiliaryTableTypeUtils.GetValue(eAuxiliaryTableType));
            }

            string sqlString =
                $"SELECT TableENName, TableCNName, AttributeNum, AuxiliaryTableType, IsCreatedInDB, IsChangedAfterCreatedInDB, IsDefault, Description FROM bairong_TableCollection WHERE AuxiliaryTableType IN ({TranslateUtils.ToSqlInStringWithQuote(auxiliaryTableTypeList)}) AND IsCreatedInDB = '{true}' ORDER BY IsCreatedInDB DESC, TableENName";

            var list = new List <AuxiliaryTableInfo>();

            using (var rdr = ExecuteReader(sqlString))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new AuxiliaryTableInfo(GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }

            return(list);
        }
コード例 #17
0
 public string GetAuxiliatyTableType(string auxiliaryTableType)
 {
     return(EAuxiliaryTableTypeUtils.GetText(EAuxiliaryTableTypeUtils.GetEnumType(auxiliaryTableType)));
 }
コード例 #18
0
        public List <ContentModelInfo> GetContentModelInfoList(int siteId)
        {
            var    arraylist = new List <ContentModelInfo>();
            string sqlString =
                $"SELECT ModelID, SiteID, ModelName, IsSystem, TableName, TableType, IconUrl, Description FROM bairong_ContentModel WHERE SiteID = {siteId}";

            using (var rdr = ExecuteReader(sqlString))
            {
                while (rdr.Read())
                {
                    var i = 0;
                    arraylist.Add(new ContentModelInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), EAuxiliaryTableTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i)));
                }
                rdr.Close();
            }

            return(arraylist);
        }