Beispiel #1
0
        public static List <ContentInfo> GetContentsByAccessFile(string filePath, SiteInfo siteInfo, ChannelInfo nodeInfo)
        {
            var contentInfoList = new List <ContentInfo>();

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

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

                    var oleDt = dataset.Tables[0];

                    if (oleDt.Rows.Count > 0)
                    {
                        var tableStyleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, nodeInfo);

                        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;
                        //    attributeNames.Add(!string.IsNullOrEmpty(nameValueCollection[columnName])
                        //        ? nameValueCollection[columnName]
                        //        : columnName);
                        //}

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

                            if (!string.IsNullOrEmpty(contentInfo.Title))
                            {
                                contentInfo.SiteId       = siteInfo.Id;
                                contentInfo.ChannelId    = nodeInfo.Id;
                                contentInfo.LastEditDate = DateTime.Now;

                                contentInfoList.Add(contentInfo);
                            }
                        }
                    }
                }
            }

            return(contentInfoList);
        }
Beispiel #2
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);
        }