Exemple #1
0
        public void Publish(int siteId, int contentId, int userId, IEnumerable <AbstractItemData> items, int statusId)
        {
            _logger.LogDebug($"publish. siteId: {siteId}, contentId: {contentId}, userId: {userId}, statusId: {statusId}, items: {SerializeData(items.Select(x => new { x.Id, x.ExtensionId }))}");

            _qpDbConnector.BeginTransaction(IsolationLevel.Serializable);

            try
            {
                var siteName = _qpMetadataManager.GetSiteName(siteId);

                // update content
                var values = items.Select(x => new Dictionary <string, string>
                {
                    { ContentItemIdFieldName, x.Id.ToString(CultureInfo.InvariantCulture) },
                    { StatusTypeIdFieldName, statusId.ToString(CultureInfo.InvariantCulture) }
                });

                _logger.LogDebug($"publish. mass update. contentId: {contentId}, values: {SerializeData(values)}");

                _qpDbConnector.DbConnector.MassUpdate(contentId, values, userId);

                //update extention
                var extentionValues = items
                                      .Where(x => x.ExtensionId.HasValue)
                                      .GroupBy(x => x.ExtensionId.Value, x => x.Id);
                foreach (var item in extentionValues)
                {
                    var contentName = _qpMetadataManager.GetContentName(item.Key);
                    _qpContentManager
                    .Connect()
                    .SiteName(siteName)
                    .IsIncludeArchive(true)
                    .IsShowSplittedArticle(true)
                    .StatusName(_statusNames)
                    .ContentId(item.Key)
                    .ContentName(contentName)
                    .Where($"ItemId in ({string.Join(",", item.Select(x => x))})")
                    .ChangeStatus(userId, statusId);
                }
                _qpDbConnector.CommitTransaction();
            }
            catch
            {
                _qpDbConnector.RollbackTransaction();
                throw;
            }
        }
Exemple #2
0
        public QpContentData GetContent(int siteId, string contentName, IDbTransaction transaction = null)
        {
            _logger.LogDebug($"getContent. siteId: {siteId}, contentName: {contentName}");
            var siteName = _qpMetadataManager.GetSiteName(siteId);
            var contents = _qpContentManager
                           .Connect()
                           .SiteName(siteName)
                           .ContentName("CONTENT")
                           .Fields("CONTENT_ID, CONTENT_NAME, NET_CONTENT_NAME")
                           .Where($"NET_CONTENT_NAME = '{contentName}'")
                           .GetRealData();

            var result = contents.PrimaryContent.Select()
                         .Select(x => new QpContentData
            {
                Id   = int.Parse(x["CONTENT_ID"].ToString()),
                Name = x["NET_CONTENT_NAME"].ToString()
            }).ToList();

            _logger.LogDebug($"getContent. contentId: {result.FirstOrDefault()?.Id}, contentName: {result.FirstOrDefault()?.Name }");

            return(result.FirstOrDefault());
        }