示例#1
0
        public static bool CreateAccessFileForContents(string filePath, PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo, List <int> contentIDArrayList, List <string> displayAttributes, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
            FileUtils.DeleteFileIfExists(filePath);

            var sourceFilePath = SiteServerAssets.GetPath(SiteServerAssets.Default.AccessMdb);

            FileUtils.CopyFile(sourceFilePath, filePath);

            var relatedidentityes = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId);

            var modelInfo     = ContentModelManager.GetContentModelInfo(publishmentSystemInfo, nodeInfo.ContentModelId);
            var tableStyle    = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, modelInfo.TableName, relatedidentityes);

            styleInfoList = ContentUtility.GetAllTableStyleInfoList(publishmentSystemInfo, tableStyle, styleInfoList);
            var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);

            var accessDAO = new AccessDao(filePath);

            var createTableSqlString = accessDAO.GetCreateTableSqlString(nodeInfo.NodeName, styleInfoList, displayAttributes);

            accessDAO.ExecuteSqlString(createTableSqlString);

            bool isExport;

            var insertSqlArrayList = accessDAO.GetInsertSqlStringArrayList(nodeInfo.NodeName, publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId, tableStyle, tableName, styleInfoList, displayAttributes, contentIDArrayList, isPeriods, dateFrom, dateTo, checkedState, out isExport);

            foreach (string insertSql in insertSqlArrayList)
            {
                accessDAO.ExecuteSqlString(insertSql);
            }

            return(isExport);
        }
示例#2
0
        public static void CreateExcelFileForContents(string filePath, PublishmentSystemInfo publishmentSystemInfo,
                                                      NodeInfo nodeInfo, List <int> contentIdList, List <string> displayAttributes, bool isPeriods, string startDate,
                                                      string endDate, ETriState checkedState)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
            FileUtils.DeleteFileIfExists(filePath);

            var head = new List <string>();
            var rows = new List <List <string> >();

            var relatedidentityes =
                RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId);
            var modelInfo          = ContentModelManager.GetContentModelInfo(publishmentSystemInfo, nodeInfo.ContentModelId);
            var tableStyle         = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, modelInfo.TableName,
                                                                             relatedidentityes);

            tableStyleInfoList = ContentUtility.GetAllTableStyleInfoList(publishmentSystemInfo, tableStyle,
                                                                         tableStyleInfoList);

            var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);

            foreach (var tableStyleInfo in tableStyleInfoList)
            {
                if (displayAttributes.Contains(tableStyleInfo.AttributeName))
                {
                    head.Add(tableStyleInfo.DisplayName);
                }
            }

            if (contentIdList == null || contentIdList.Count == 0)
            {
                contentIdList = BaiRongDataProvider.ContentDao.GetContentIdList(tableName, nodeInfo.NodeId, isPeriods,
                                                                                startDate, endDate, checkedState);
            }

            foreach (var contentId in contentIdList)
            {
                var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);
                if (contentInfo != null)
                {
                    var row = new List <string>();

                    foreach (var tableStyleInfo in tableStyleInfoList)
                    {
                        if (displayAttributes.Contains(tableStyleInfo.AttributeName))
                        {
                            var value = contentInfo.GetExtendedAttribute(tableStyleInfo.AttributeName);
                            row.Add(StringUtils.StripTags(value));
                        }
                    }

                    rows.Add(row);
                }
            }

            CsvUtils.Export(filePath, head, rows);
        }
示例#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 void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID", "ReturnUrl");

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

            _nodeInfo = NodeManager.GetNodeInfo(1, nodeId);
            var    contentId   = Body.GetQueryInt("ID");
            string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId);

            ReturnUrl  = $@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID=1&NodeId={nodeId}";
            ReturnPUrl = $@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID=1&NodeId={ (Body.GetQueryInt("PNodeID")==0? nodeId:Body.GetQueryInt("PNodeID"))}";
            //ReturnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));
            _isAjaxSubmit = Body.GetQueryBool("isAjaxSubmit");
            _isPreview    = Body.GetQueryBool("isPreview");

            _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo);
            _tableName  = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo);
            //_tableName = "model_content";
            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId);
            ContentInfo contentInfo = null;

            if (_isAjaxSubmit == false)
            {
                if (contentId == 0)
                {
                    if (_nodeInfo != null && _nodeInfo.Additional.IsContentAddable == false)
                    {
                        PageUtils.RedirectToErrorPage("此栏目不能添加内容!");
                        return;
                    }

                    if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentAdd))
                    {
                        if (!Body.IsAdministratorLoggin)
                        {
                            PageUtils.RedirectToLoginPage();
                            return;
                        }
                        else
                        {
                            PageUtils.RedirectToErrorPage("您无此栏目的添加内容权限!");
                            return;
                        }
                    }
                }
                else
                {
                    contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId);
                    if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentEdit))
                    {
                        if (!Body.IsAdministratorLoggin)
                        {
                            PageUtils.RedirectToLoginPage();
                            return;
                        }
                        PageUtils.RedirectToErrorPage("您无此栏目的修改内容权限!");
                        return;
                    }
                }

                if (!IsPostBack)
                {
                    var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemId, _nodeInfo.NodeId);
                    var pageTitle = (contentId == 0) ?
                                    $"添加{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}"
                        : $"编辑{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}";
                    BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, pageTitle, nodeNames, string.Empty);

                    LtlPageTitle.Text  = pageTitle;
                    LtlPageTitle.Text += $@"
<script language=""javascript"" type=""text/javascript"">
var previewUrl = '{PagePreview.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentId, 0, 0)}';
</script>
";

                    if (PublishmentSystemInfo.Additional.IsAutoSaveContent && PublishmentSystemInfo.Additional.AutoSaveContentInterval > 0)
                    {
                        LtlPageTitle.Text += $@"
<input type=""hidden"" id=""savedContentID"" name=""savedContentID"" value=""{contentId}"">
<script language=""javascript"" type=""text/javascript"">setInterval(""autoSave()"",{PublishmentSystemInfo.Additional.AutoSaveContentInterval*1000});</script>
";
                    }
                    //专题
                    if (contentId == 0)
                    {
                        var specialParentId = DataProvider.NodeDao.GetSpecialParentId();
                        NodeIdDic = new Dictionary <NodeInfo, List <NodeInfo> >();
                        if (nodeId != 0 && nodeId == specialParentId)
                        {
                            PhSpecial.Visible  = true;
                            PhCategory.Visible = true;
                            var             specialNodeIdList = DataProvider.NodeDao.GetNodeInfoListByParentId(1, specialParentId);
                            List <NodeInfo> secondLevel       = new List <NodeInfo>();
                            foreach (var nodeInfo in specialNodeIdList)
                            {
                                var secondChild = DataProvider.NodeDao.GetNodeInfoListByParentId(1, nodeInfo.NodeId);
                                if (secondChild != null && secondChild.Count > 0)
                                {
                                    NodeIdDic.Add(nodeInfo, secondChild);
                                }
                            }
                            if (NodeIdDic != null && NodeIdDic.Count > 0)
                            {
                                KeyValuePair <NodeInfo, List <NodeInfo> > kv = NodeIdDic.First();
                                var defaultItem = new ListItem(kv.Key.NodeName, kv.Key.NodeId.ToString());
                                defaultItem.Selected = true;
                                TbSpecial.Items.Add(defaultItem);
                                foreach (var info in kv.Value)
                                {
                                    TbCategory.Items.Add(new ListItem(info.NodeName, info.NodeId.ToString()));
                                }
                                foreach (var info in specialNodeIdList)
                                {
                                    if (info.NodeId != kv.Key.NodeId)
                                    {
                                        TbSpecial.Items.Add(new ListItem(info.NodeName, info.NodeId.ToString()));
                                    }
                                }
                            }
                        }
                        else
                        {
                            //信息类型
                            var childSpecial = DataProvider.NodeDao.GetNodeInfoListByParentId(1, nodeId);
                            if (childSpecial != null && childSpecial.Count > 0)
                            {
                                PhCategory.Visible = true;
                                foreach (var nodeInfo in childSpecial)
                                {
                                    var item = new ListItem(nodeInfo.NodeName, nodeInfo.NodeId.ToString());
                                    TbCategory.Items.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        PhSpecial.Visible  = false;
                        PhCategory.Visible = true;
                        TbCategory.Items.Add(new ListItem(_nodeInfo.NodeName, _nodeInfo.NodeId.ToString()));
                        //if (_nodeInfo.ParentsCount == 1)
                        //{
                        //    PhSpecial.Visible = false;
                        //    PhCategory.Visible = true;
                        //    TbSpecial.Items.Add(new ListItem(_nodeInfo.NodeName, _nodeInfo.NodeId.ToString()));
                        //}else if(_nodeInfo.ParentsCount == 1)
                    }


                    //转移
                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, PublishmentSystemId, _nodeInfo.NodeId, AppManager.Cms.Permission.Channel.ContentTranslate))
                    {
                        PhTranslate.Visible = PublishmentSystemInfo.Additional.IsTranslate;
                        DivTranslateAdd.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(PublishmentSystemId, true));

                        ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true);
                        ControlUtils.SelectListItems(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy));
                    }
                    else
                    {
                        PhTranslate.Visible = false;
                    }

                    //内容属性
                    var excludeAttributeNames = TableManager.GetExcludeAttributeNames(_tableStyle);
                    AcAttributes.AddExcludeAttributeNames(excludeAttributeNames);

                    if (excludeAttributeNames.Count == 0)
                    {
                        PhContentAttributes.Visible = false;
                    }
                    else
                    {
                        PhContentAttributes.Visible = true;
                        foreach (var attributeName in excludeAttributeNames)
                        {
                            var styleInfo = TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, attributeName, _relatedIdentities);
                            if (styleInfo.IsVisible)
                            {
                                var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                                if (contentId > 0)
                                {
                                    listItem.Selected = TranslateUtils.ToBool(contentInfo?.GetExtendedAttribute(styleInfo.AttributeName));
                                }
                                else
                                {
                                    if (TranslateUtils.ToBool(styleInfo.DefaultValue))
                                    {
                                        listItem.Selected = true;
                                    }
                                }
                                CblContentAttributes.Items.Add(listItem);
                            }
                        }
                    }

                    //内容组
                    var contentGroupNameList = DataProvider.ContentGroupDao.GetContentGroupNameList(PublishmentSystemId);

                    if (!PublishmentSystemInfo.Additional.IsGroupContent || contentGroupNameList.Count == 0)
                    {
                        PhContentGroup.Visible = false;
                    }
                    else
                    {
                        foreach (var groupName in contentGroupNameList)
                        {
                            var item = new ListItem(groupName, groupName);
                            if (contentId > 0)
                            {
                                item.Selected = StringUtils.In(contentInfo?.ContentGroupNameCollection, groupName);
                            }
                            CblContentGroupNameCollection.Items.Add(item);
                        }
                    }

                    //标签
                    if (!PublishmentSystemInfo.Additional.IsRelatedByTags)
                    {
                        PhTags.Visible = false;
                    }
                    else
                    {
                        var tagScript = @"
<script type=""text/javascript"">
function getTags(tag){
	$.get('[url]&tag=' + encodeURIComponent(tag) + '&r=' + Math.random(), function(data) {
		if(data !=''){
			var arr = data.split('|');
			var temp='';
			for(i=0;i<arr.length;i++)
			{
				temp += '<li><a>'+arr[i].replace(tag,'<b>' + tag + '</b>') + '</a></li>';
			}
			var myli='<ul>'+temp+'</ul>';
			$('#tagTips').html(myli);
			$('#tagTips').show();
		}else{
            $('#tagTips').hide();
        }
		$('#tagTips li').click(function () {
			var tag = $('#TbTags').val();
			var i = tag.lastIndexOf(' ');
			if (i > 0)
			{
				tag = tag.substring(0, i) + ' ' + $(this).text();
			}else{
				tag = $(this).text();	
			}
			$('#TbTags').val(tag);
			$('#tagTips').hide();
		})
	});	
}
$(document).ready(function () {
$('#TbTags').keyup(function (e) {
    if (e.keyCode != 40 && e.keyCode != 38) {
        var tag = $('#TbTags').val();
		var i = tag.lastIndexOf(' ');
		if (i > 0){ tag = tag.substring(i + 1);}
        if (tag != '' && tag != ' '){
            window.setTimeout(""getTags('"" + tag + ""');"", 200);
        }else{
            $('#tagTips').hide();
        }
    }
}).blur(function () {
	window.setTimeout(""$('#tagTips').hide();"", 200);
})});
</script>
<div id=""tagTips"" class=""inputTips""></div>
";
                        LtlTags.Text = tagScript.Replace("[url]", AjaxCmsService.GetTagsUrl(PublishmentSystemId));
                    }

                    if (contentId == 0)
                    {
                        var formCollection = new NameValueCollection();
                        if (Body.IsQueryExists("isUploadWord"))
                        {
                            var isFirstLineTitle  = Body.GetQueryBool("isFirstLineTitle");
                            var isFirstLineRemove = Body.GetQueryBool("isFirstLineRemove");
                            var isClearFormat     = Body.GetQueryBool("isClearFormat");
                            var isFirstLineIndent = Body.GetQueryBool("isFirstLineIndent");
                            var isClearFontSize   = Body.GetQueryBool("isClearFontSize");
                            var isClearFontFamily = Body.GetQueryBool("isClearFontFamily");
                            var isClearImages     = Body.GetQueryBool("isClearImages");
                            var contentLevel      = Body.GetQueryInt("contentLevel");
                            var fileName          = Body.GetQueryString("fileName");

                            formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName);
                        }

                        AcAttributes.SetParameters(formCollection, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, false, IsPostBack);
                    }
                    else
                    {
                        AcAttributes.SetParameters(contentInfo?.Attributes, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, true, IsPostBack);
                        TbTags.Text = contentInfo?.Tags;
                    }

                    if (HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentCheck))
                    {
                        PhStatus.Visible = true;
                        int checkedLevel;
                        var isChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, _nodeInfo.NodeId, out checkedLevel);
                        if (Body.IsQueryExists("contentLevel"))
                        {
                            checkedLevel = TranslateUtils.ToIntWithNagetive(Body.GetQueryString("contentLevel"));
                            if (checkedLevel != LevelManager.LevelInt.NotChange)
                            {
                                isChecked = checkedLevel >= PublishmentSystemInfo.CheckContentLevel;
                            }
                        }

                        LevelManager.LoadContentLevelToEdit(RblContentLevel, PublishmentSystemInfo, nodeId, contentInfo, isChecked, checkedLevel);
                    }
                    else
                    {
                        PhStatus.Visible = false;
                    }

                    BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()"));
                    //自动检测敏感词
                    ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(PublishmentSystemInfo));
                }
                else
                {
                    AcAttributes.SetParameters(Request.Form, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities,
                                               _tableStyle, _tableName, contentId != 0, IsPostBack);
                }
                DataBind();
            }
            else
            {
                var    success = false;
                string errorMessage;
                var    savedContentId = SaveContentInfo(true, _isPreview, out errorMessage);
                if (savedContentId > 0)
                {
                    success = true;
                }

                string jsonString = $@"{{success:'{success.ToString().ToLower()}',savedContentID:'{savedContentId}'}}";

                PageUtils.ResponseToJson(jsonString);
            }
        }
示例#6
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);
        }
示例#7
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);
        }