예제 #1
0
파일: NodeManager.cs 프로젝트: wl147/mycms
        public static ETableStyle GetTableStyle(PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo)
        {
            var modelInfo = ContentModelManager.GetContentModelInfo(publishmentSystemInfo, nodeInfo.ContentModelId);

            if (!string.IsNullOrEmpty(modelInfo?.TableName))
            {
                return(EAuxiliaryTableTypeUtils.GetTableStyle(modelInfo.TableType));
            }
            var tableStyle = ETableStyle.BackgroundContent;

            if (EContentModelTypeUtils.Equals(EContentModelType.GovPublic, nodeInfo.ContentModelId))
            {
                tableStyle = ETableStyle.GovPublicContent;
            }
            else if (EContentModelTypeUtils.Equals(EContentModelType.GovInteract, nodeInfo.ContentModelId))
            {
                tableStyle = ETableStyle.GovInteractContent;
            }
            else if (EContentModelTypeUtils.Equals(EContentModelType.Vote, nodeInfo.ContentModelId))
            {
                tableStyle = ETableStyle.VoteContent;
            }
            else if (EContentModelTypeUtils.Equals(EContentModelType.Job, nodeInfo.ContentModelId))
            {
                tableStyle = ETableStyle.JobContent;
            }
            else if (EContentModelTypeUtils.Equals(EContentModelType.UserDefined, nodeInfo.ContentModelId))
            {
                tableStyle = ETableStyle.UserDefined;
            }
            return(tableStyle);
        }
예제 #2
0
        public string GetEditStyleHtml(int tableMetadataId, string attributeName)
        {
            var tableStyle       = EAuxiliaryTableTypeUtils.GetTableStyle(_tableType);
            var styleInfo        = TableStyleManager.GetTableStyleInfo(tableStyle, _tableName, attributeName, null);
            var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(0, _tableName, attributeName, tableStyle, _redirectUrl);

            var editText = "设置";

            if (styleInfo.TableStyleId != 0)//数据库中有样式
            {
                editText = "修改";
            }
            string retval = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{editText}</a>";

            if (styleInfo.TableStyleId == 0)
            {
                return(retval);
            }

            var attributes = new NameValueCollection
            {
                { "DeleteStyle", true.ToString() },
                { "TableMetadataID", tableMetadataId.ToString() },
                { "AttributeName", attributeName }
            };
            var deleteUrl = PageUtils.AddQueryString(_redirectUrl, attributes);

            retval +=
                $@"&nbsp;&nbsp;<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>";
            return(retval);
        }
예제 #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var nodeId = Body.GetQueryInt("NodeID", PublishmentSystemId);

            _nodeInfo    = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId);
            _modelInfo   = ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId);
            _tableStyle  = EAuxiliaryTableTypeUtils.GetTableStyle(_modelInfo.TableType);
            _redirectUrl = GetRedirectUrl(PublishmentSystemId, nodeId);

            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId);

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdConfigration, AppManager.Cms.LeftMenu.Configuration.IdConfigurationContentModel, "内容字段管理", AppManager.Cms.Permission.WebSite.Configration);

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

                InfoMessage(
                    $"在此编辑内容模型字段,子栏目默认继承父栏目字段设置; 辅助表:{BaiRongDataProvider.TableCollectionDao.GetTableCnName(_modelInfo.TableName)}({_modelInfo.TableName}); 内容模型:{_modelInfo.ModelName}");
                NodeManager.AddListItems(NodeIDDropDownList.Items, PublishmentSystemInfo, false, true, true, Body.AdministratorName);
                ControlUtils.SelectListItems(NodeIDDropDownList, nodeId.ToString());

                var styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, _modelInfo.TableName, _relatedIdentities);

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

                AddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(PublishmentSystemId, 0, _relatedIdentities, _modelInfo.TableName, string.Empty, _tableStyle, _redirectUrl));
                AddStyles.Attributes.Add("onclick", ModalTableStylesAdd.GetOpenWindowString(PublishmentSystemId, _relatedIdentities, _modelInfo.TableName, _tableStyle, _redirectUrl));
                Import.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_modelInfo.TableName, _tableStyle, PublishmentSystemId, nodeId));
                Export.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableStyle, _modelInfo.TableName, PublishmentSystemId, nodeId));
            }
        }
예제 #4
0
        private void LoadDisplayAttributeCheckBoxList()
        {
            var nodeInfo          = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);
            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
            var modelInfo         = ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, nodeInfo.ContentModelId);
            var tableStyle        = EAuxiliaryTableTypeUtils.GetTableStyle(modelInfo.TableType);
            var styleInfoList     = TableStyleManager.GetTableStyleInfoList(tableStyle, modelInfo.TableName, relatedIdentities);

            styleInfoList = ContentUtility.GetAllTableStyleInfoList(PublishmentSystemInfo, tableStyle, styleInfoList);

            foreach (var styleInfo in styleInfoList)
            {
                var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                listItem.Selected = styleInfo.IsVisible;
                cblDisplayAttributes.Items.Add(listItem);
            }
        }
예제 #5
0
        public static List <BackgroundContentInfo> GetContentsByCsvFile(string filePath, PublishmentSystemInfo publishmentSystemInfo,
                                                                        NodeInfo nodeInfo)
        {
            var contentInfoList = new List <BackgroundContentInfo>();

            List <string>         head;
            List <List <string> > rows;

            CsvUtils.Import(filePath, out head, out rows);

            if (rows.Count > 0)
            {
                var relatedidentityes =
                    RelatedIdentities.GetChannelRelatedIdentities(
                        publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId);
                var modelInfo = ContentModelManager.GetContentModelInfo(publishmentSystemInfo,
                                                                        nodeInfo.ContentModelId);
                var tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(modelInfo.TableType);
                // ArrayList tableStyleInfoArrayList = TableStyleManager.GetTableStyleInfoArrayList(ETableStyle.BackgroundContent, publishmentSystemInfo.AuxiliaryTableForContent, relatedidentityes);

                var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle,
                                                                                 modelInfo.TableName, relatedidentityes);
                tableStyleInfoList = ContentUtility.GetAllTableStyleInfoList(publishmentSystemInfo,
                                                                             tableStyle, tableStyleInfoList);
                var nameValueCollection = new NameValueCollection();

                foreach (var styleInfo in tableStyleInfoList)
                {
                    nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
                }

                var attributeNames = new List <string>();
                foreach (var columnName in head)
                {
                    if (!string.IsNullOrEmpty(nameValueCollection[columnName]))
                    {
                        attributeNames.Add(nameValueCollection[columnName]);
                    }
                    else
                    {
                        attributeNames.Add(columnName);
                    }
                }

                foreach (var row in rows)
                {
                    var contentInfo = new BackgroundContentInfo();
                    if (row.Count != attributeNames.Count)
                    {
                        continue;
                    }

                    for (var i = 0; i < attributeNames.Count; i++)
                    {
                        var attributeName = attributeNames[i];
                        if (!string.IsNullOrEmpty(attributeName))
                        {
                            var value = row[i];
                            contentInfo.SetExtendedAttribute(attributeName, value);
                        }
                    }

                    if (!string.IsNullOrEmpty(contentInfo.Title))
                    {
                        contentInfo.PublishmentSystemId = publishmentSystemInfo.PublishmentSystemId;
                        contentInfo.NodeId       = nodeInfo.NodeId;
                        contentInfo.LastEditDate = DateTime.Now;

                        contentInfoList.Add(contentInfo);
                    }
                }
            }

            return(contentInfoList);
        }
예제 #6
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var attributeNameList = TranslateUtils.StringCollectionToStringList(Request.Form["attributeName"]);
            var dataTypeList      = TranslateUtils.StringCollectionToStringList(Request.Form["dataType"]);
            var dataLengthList    = TranslateUtils.StringCollectionToStringList(Request.Form["dataLength"]);

            for (var i = 0; i < attributeNameList.Count; i++)
            {
                if (dataTypeList.Count < attributeNameList.Count)
                {
                    dataTypeList.Add(string.Empty);
                }
                if (dataLengthList.Count < attributeNameList.Count)
                {
                    dataLengthList.Add(string.Empty);
                }
            }

            var tableStyle             = EAuxiliaryTableTypeUtils.GetTableStyle(_tableType);
            var attributeNameArrayList = TableManager.GetAttributeNameList(tableStyle, _tableName, true);

            attributeNameArrayList.AddRange(TableManager.GetHiddenAttributeNameList(tableStyle));

            for (var i = 0; i < attributeNameList.Count; i++)
            {
                var attributeName = attributeNameList[i];
                var dataType      = dataTypeList[i];
                var dataLength    = dataLengthList[i];

                if (attributeNameArrayList.IndexOf(attributeName.Trim().ToLower()) != -1)
                {
                    FailMessage("字段添加失败,字段名已存在!");
                }
                else if (!SqlUtils.IsAttributeNameCompliant(attributeName))
                {
                    FailMessage("字段名不符合系统要求!");
                }
                else
                {
                    var info = new TableMetadataInfo
                    {
                        AuxiliaryTableEnName = _tableName,
                        AttributeName        = attributeName,
                        DataType             = EDataTypeUtils.GetEnumType(dataType)
                    };

                    var hashtable = new Hashtable
                    {
                        [EDataType.DateTime] = new[] { "8", "false" },
                        [EDataType.Integer]  = new[] { "4", "false" },
                        [EDataType.NChar]    = new[] { "50", "true" },
                        [EDataType.NText]    = new[] { "16", "false" },
                        [EDataType.NVarChar] = new[] { "255", "true" }
                    };

                    var strArr = (string[])hashtable[EDataTypeUtils.GetEnumType(dataType)];
                    if (strArr[1].Equals("false"))
                    {
                        dataLength = strArr[0];
                    }

                    if (string.IsNullOrEmpty(dataLength))
                    {
                        dataLength = strArr[0];
                    }

                    info.DataLength = int.Parse(dataLength);
                    if (info.DataType == EDataType.NVarChar || info.DataType == EDataType.NChar)
                    {
                        var maxLength = SqlUtils.GetMaxLengthForNVarChar();
                        if (info.DataLength <= 0 || info.DataLength > maxLength)
                        {
                            FailMessage($"字段修改失败,数据长度的值必须位于 1 和 {maxLength} 之间");
                            return;
                        }
                    }
                    info.IsSystem = false;

                    try
                    {
                        BaiRongDataProvider.TableMetadataDao.Insert(info);

                        Body.AddAdminLog("添加辅助表字段",
                                         $"辅助表:{_tableName},字段名:{info.AttributeName}");

                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, ex.Message);
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }
예제 #7
0
        public void ImportTableStyles(int publishmentSystemId)
        {
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                return;
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var importObject        = new ImportObject(publishmentSystemId);
            var tableNameCollection = importObject.GetTableNameCache();

            var styleDirectoryPaths = DirectoryUtils.GetDirectoryPaths(_directoryPath);

            foreach (var styleDirectoryPath in styleDirectoryPaths)
            {
                var tableName = PathUtils.GetDirectoryName(styleDirectoryPath);
                if (!string.IsNullOrEmpty(tableNameCollection?[tableName]))
                {
                    tableName = tableNameCollection[tableName];
                }

                ETableStyle tableStyle;

                if (BaiRongDataProvider.TableCollectionDao.IsTableExists(tableName))
                {
                    var tableType = BaiRongDataProvider.TableCollectionDao.GetTableType(tableName);
                    tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(tableType);
                }
                else
                {
                    tableStyle = PublishmentSystemManager.GetTableStyle(publishmentSystemInfo, tableName);
                }

                var attributeNamePaths = DirectoryUtils.GetDirectoryPaths(styleDirectoryPath);
                foreach (var attributeNamePath in attributeNamePaths)
                {
                    var attributeName = PathUtils.GetDirectoryName(attributeNamePath);
                    var filePaths     = DirectoryUtils.GetFilePaths(attributeNamePath);
                    foreach (var filePath in filePaths)
                    {
                        var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                        var taxis           = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "Taxis"), 0);
                        var displayName     = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DisplayName");
                        var helpText        = AtomUtility.GetDcElementContent(feed.AdditionalElements, "HelpText");
                        var isVisible       = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisible"));
                        var isVisibleInList = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsVisibleInList"));
                        var isSingleLine    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsSingleLine"));
                        var inputType       = EInputTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputType"));
                        var defaultValue    = AtomUtility.GetDcElementContent(feed.AdditionalElements, "DefaultValue");
                        var isHorizontal    = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsHorizontal"));
                        var extendValues    = AtomUtility.GetDcElementContent(feed.AdditionalElements, "ExtendValues");

                        int relatedIdentity;
                        if (tableStyle == ETableStyle.Site)
                        {
                            relatedIdentity = publishmentSystemId;
                        }
                        else
                        {
                            var orderString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "OrderString");

                            if (!string.IsNullOrEmpty(orderString))
                            {
                                relatedIdentity = DataProvider.NodeDao.GetNodeId(publishmentSystemId, orderString);
                            }
                            else
                            {
                                relatedIdentity = publishmentSystemId;
                            }
                        }

                        if (relatedIdentity <= 0 ||
                            TableStyleManager.IsExists(relatedIdentity, tableName, attributeName))
                        {
                            continue;
                        }

                        var styleInfo = new TableStyleInfo(0, relatedIdentity, tableName, attributeName, taxis, displayName, helpText, isVisible, isVisibleInList, isSingleLine, EInputTypeUtils.GetValue(inputType), defaultValue, isHorizontal, extendValues);

                        var styleItems = new List <TableStyleItemInfo>();
                        foreach (AtomEntry entry in feed.Entries)
                        {
                            var itemTitle  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemTitle");
                            var itemValue  = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ItemValue");
                            var isSelected = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSelected"));

                            styleItems.Add(new TableStyleItemInfo(0, 0, itemTitle, itemValue, isSelected));
                        }

                        if (styleItems.Count > 0)
                        {
                            styleInfo.StyleItems = styleItems;
                        }

                        TableStyleManager.InsertWithTaxis(styleInfo, tableStyle);
                    }
                }
            }
        }
예제 #8
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);
        }
예제 #9
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

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

                var info = BaiRongDataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
                info.AuxiliaryTableEnName = _tableName;
                info.AttributeName        = AttributeName.Text;
                info.DataType             = EDataTypeUtils.GetEnumType(DataType.SelectedValue);

                var hashtable = new Hashtable
                {
                    [EDataType.DateTime] = new[] { "8", "false" },
                    [EDataType.Integer]  = new[] { "4", "false" },
                    [EDataType.NChar]    = new[] { "50", "true" },
                    [EDataType.NText]    = new[] { "16", "false" },
                    [EDataType.NVarChar] = new[] { "255", "true" }
                };

                var strArr = (string[])hashtable[EDataTypeUtils.GetEnumType(DataType.SelectedValue)];
                if (strArr[1].Equals("false"))
                {
                    DataLength.Text = strArr[0];
                }

                info.DataLength = int.Parse(DataLength.Text);
                if (info.DataType == EDataType.NVarChar || info.DataType == EDataType.NChar)
                {
                    var maxLength = SqlUtils.GetMaxLengthForNVarChar();
                    if (info.DataLength <= 0 || info.DataLength > maxLength)
                    {
                        FailMessage($"字段修改失败,数据长度的值必须位于 1 和 {maxLength} 之间");
                        return;
                    }
                }

                try
                {
                    BaiRongDataProvider.TableMetadataDao.Update(info);

                    Body.AddAdminLog("修改辅助表字段",
                                     $"辅助表:{_tableName},字段名:{info.AttributeName}");

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, ex.Message);
                }
            }
            else
            {
                var tableStyle        = EAuxiliaryTableTypeUtils.GetTableStyle(_tableType);
                var attributeNameList = TableManager.GetAttributeNameList(tableStyle, _tableName, true);
                attributeNameList.AddRange(TableManager.GetHiddenAttributeNameList(tableStyle));
                if (attributeNameList.IndexOf(AttributeName.Text.Trim().ToLower()) != -1)
                {
                    FailMessage("字段添加失败,字段名已存在!");
                }
                else if (!SqlUtils.IsAttributeNameCompliant(AttributeName.Text))
                {
                    FailMessage("字段名不符合系统要求!");
                }
                else
                {
                    var info = new TableMetadataInfo
                    {
                        AuxiliaryTableEnName = _tableName,
                        AttributeName        = AttributeName.Text,
                        DataType             = EDataTypeUtils.GetEnumType(DataType.SelectedValue)
                    };

                    var hashtable = new Hashtable
                    {
                        [EDataType.DateTime] = new[] { "8", "false" },
                        [EDataType.Integer]  = new[] { "4", "false" },
                        [EDataType.NChar]    = new[] { "50", "true" },
                        [EDataType.NText]    = new[] { "16", "false" },
                        [EDataType.NVarChar] = new[] { "255", "true" }
                    };

                    var strArr = (string[])hashtable[EDataTypeUtils.GetEnumType(DataType.SelectedValue)];
                    if (strArr[1].Equals("false"))
                    {
                        DataLength.Text = strArr[0];
                    }

                    info.DataLength = int.Parse(DataLength.Text);
                    if (info.DataType == EDataType.NVarChar || info.DataType == EDataType.NChar)
                    {
                        var maxLength = SqlUtils.GetMaxLengthForNVarChar();
                        if (info.DataLength <= 0 || info.DataLength > maxLength)
                        {
                            FailMessage($"字段修改失败,数据长度的值必须位于 1 和 {maxLength} 之间");
                            return;
                        }
                    }
                    info.IsSystem = false;

                    try
                    {
                        BaiRongDataProvider.TableMetadataDao.Insert(info);

                        Body.AddAdminLog("添加辅助表字段",
                                         $"辅助表:{_tableName},字段名:{info.AttributeName}");

                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, ex.Message);
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }
예제 #10
0
        public void SyncTable(string tableEnName)
        {
            var list         = GetTableMetadataInfoList(tableEnName);
            var databaseName = SqlUtils.GetDatabaseNameFormConnectionString(WebConfigUtils.ConnectionString);
            var tableId      = BaiRongDataProvider.TableStructureDao.GetTableId(WebConfigUtils.ConnectionString, databaseName, tableEnName);
            var columnlist   = BaiRongDataProvider.TableStructureDao.GetTableColumnInfoList(WebConfigUtils.ConnectionString, databaseName, tableEnName, tableId);

            var sqlList = new List <string>();

            //添加新增/修改字段SQL语句
            foreach (var metadataInfo in list)
            {
                if (metadataInfo.IsSystem)
                {
                    continue;
                }
                var columnExists = false;
                foreach (var columnInfo in columnlist)
                {
                    if (StringUtils.EqualsIgnoreCase(columnInfo.ColumnName, metadataInfo.AttributeName))
                    {
                        columnExists = true;
                        if (!BaiRongDataProvider.TableStructureDao.IsColumnEquals(metadataInfo, columnInfo))
                        {
                            var alterSqllist = GetAlterDropColumnSqls(tableEnName, columnInfo.ColumnName);
                            foreach (var sql in alterSqllist)
                            {
                                sqlList.Add(sql);
                            }
                            alterSqllist = GetAlterAddColumnSqls(tableEnName, metadataInfo);
                            foreach (var sql in alterSqllist)
                            {
                                sqlList.Add(sql);
                            }
                        }
                        break;
                    }
                }
                if (!columnExists)
                {
                    var alterSqlList = GetAlterAddColumnSqls(tableEnName, metadataInfo);
                    foreach (var sql in alterSqlList)
                    {
                        sqlList.Add(sql);
                    }
                }
            }

            //添加删除字段SQL语句
            var tableType = BaiRongDataProvider.TableCollectionDao.GetTableType(tableEnName);
            var hiddenAttributeNameList = TableManager.GetHiddenAttributeNameList(EAuxiliaryTableTypeUtils.GetTableStyle(tableType));

            foreach (var columnInfo in columnlist)
            {
                if (hiddenAttributeNameList.Contains(columnInfo.ColumnName.ToLower()))
                {
                    continue;
                }
                var isNeedDelete = true;
                foreach (var metadataInfo in list)
                {
                    if (StringUtils.EqualsIgnoreCase(columnInfo.ColumnName, metadataInfo.AttributeName))
                    {
                        isNeedDelete = false;
                        break;
                    }
                }
                if (isNeedDelete)
                {
                    var alterSqlList = GetAlterDropColumnSqls(tableEnName, columnInfo.ColumnName);
                    foreach (var sql in alterSqlList)
                    {
                        sqlList.Add(sql);
                    }
                }
            }
            BaiRongDataProvider.DatabaseDao.ExecuteSql(sqlList);
            BaiRongDataProvider.TableCollectionDao.UpdateIsChangedAfterCreatedInDb(false, tableEnName);
        }
예제 #11
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;
        }
예제 #12
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;
                }
            }
        }
예제 #13
0
        void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var tableMetadataId = SqlUtils.EvalInt(e.Item.DataItem, "TableMetadataID");
                var attributeName   = SqlUtils.EvalString(e.Item.DataItem, "AttributeName");
                var dataType        = SqlUtils.EvalString(e.Item.DataItem, "DataType");
                var dataLength      = SqlUtils.EvalInt(e.Item.DataItem, "DataLength");
                var isSystem        = SqlUtils.EvalString(e.Item.DataItem, "IsSystem");

                var ltlAttributeName = e.Item.FindControl("ltlAttributeName") as Literal;
                var ltlDisplayName   = e.Item.FindControl("ltlDisplayName") as Literal;
                var ltlIsVisible     = e.Item.FindControl("ltlIsVisible") as Literal;
                var ltlValidate      = e.Item.FindControl("ltlValidate") as Literal;
                var ltlDataType      = e.Item.FindControl("ltlDataType") as Literal;
                var ltlInputType     = e.Item.FindControl("ltlInputType") as Literal;
                var upLinkButton     = e.Item.FindControl("UpLinkButton") as HyperLink;
                var downLinkButton   = e.Item.FindControl("DownLinkButton") as HyperLink;
                var ltlStyle         = e.Item.FindControl("ltlStyle") as Literal;
                var ltlEditValidate  = e.Item.FindControl("ltlEditValidate") as Literal;
                var ltlEditUrl       = e.Item.FindControl("ltlEditUrl") as Literal;
                var ltlDeleteUrl     = e.Item.FindControl("ltlDeleteUrl") as Literal;

                var showPopWinString = ModalTableMetadataView.GetOpenWindowString(_tableType, _tableName, attributeName);
                ltlAttributeName.Text =
                    $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{attributeName}</a>";

                var styleInfo = TableStyleManager.GetTableStyleInfo(EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _tableName, attributeName, null);
                ltlDisplayName.Text = styleInfo.DisplayName;

                ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

                ltlDataType.Text  = EDataTypeUtils.GetTextByAuxiliaryTable(EDataTypeUtils.GetEnumType(dataType), dataLength);
                ltlInputType.Text = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));

                if (IsSystem(isSystem))
                {
                    if (upLinkButton != null)
                    {
                        upLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                       new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "UP" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                    if (downLinkButton != null)
                    {
                        downLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                         new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "DOWN" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                }

                ltlStyle.Text = GetEditStyleHtml(tableMetadataId, attributeName);

                showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _tableName, styleInfo.AttributeName, EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _redirectUrl);
                ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

                ltlEditUrl.Text = GetEditHtml(isSystem, tableMetadataId);

                if (!IsSystem(isSystem))
                {
                    var attributes = new NameValueCollection
                    {
                        { "Delete", true.ToString() },
                        { "TableMetadataID", tableMetadataId.ToString() }
                    };
                    var deleteUrl = PageUtils.AddQueryString(_redirectUrl, attributes);
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除辅助字段“{attributeName}”,确认吗?');"">删除字段</a>";
                }
            }
        }
예제 #14
0
        public static ArrayList GetContentsByAccessFile(string filePath, PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo)
        {
            var contentInfoArrayList = new ArrayList();

            var accessDao  = new AccessDao(filePath);
            var tableNames = accessDao.GetTableNames();

            if (tableNames != null && tableNames.Length > 0)
            {
                foreach (var tableName in tableNames)
                {
                    string sqlString = $"SELECT * FROM [{tableName}]";
                    var    dataset   = accessDao.ReturnDataSet(sqlString);

                    var oleDt = dataset.Tables[0];

                    if (oleDt.Rows.Count > 0)
                    {
                        var relatedidentityes = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId);

                        var modelInfo  = ContentModelManager.GetContentModelInfo(publishmentSystemInfo, nodeInfo.ContentModelId);
                        var tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(modelInfo.TableType);

                        var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, modelInfo.TableName, relatedidentityes);

                        var nameValueCollection = new NameValueCollection();

                        foreach (var styleInfo in tableStyleInfoList)
                        {
                            nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
                        }

                        var attributeNames = new ArrayList();
                        for (var i = 0; i < oleDt.Columns.Count; i++)
                        {
                            var columnName = oleDt.Columns[i].ColumnName;
                            if (!string.IsNullOrEmpty(nameValueCollection[columnName]))
                            {
                                attributeNames.Add(nameValueCollection[columnName]);
                            }
                            else
                            {
                                attributeNames.Add(columnName);
                            }
                        }

                        foreach (DataRow row in oleDt.Rows)
                        {
                            var contentInfo = new BackgroundContentInfo();

                            for (var i = 0; i < oleDt.Columns.Count; i++)
                            {
                                var attributeName = attributeNames[i] as string;
                                if (!string.IsNullOrEmpty(attributeName))
                                {
                                    var value = row[i].ToString();
                                    contentInfo.SetExtendedAttribute(attributeName, value);
                                }
                            }

                            if (!string.IsNullOrEmpty(contentInfo.Title))
                            {
                                contentInfo.PublishmentSystemId = publishmentSystemInfo.PublishmentSystemId;
                                contentInfo.NodeId       = nodeInfo.NodeId;
                                contentInfo.LastEditDate = DateTime.Now;

                                contentInfoArrayList.Add(contentInfo);
                            }
                        }
                    }
                }
            }

            return(contentInfoArrayList);
        }