internal static void RunCreateViewDdl(string viewCreateDdl)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.ExecuteSql(scope.DbConnection, viewCreateDdl);
     }
 }
示例#2
0
 internal static void RemoveUserQueryAttrs(Content dbContent)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RemoveUserQueryAttrs(scope.DbConnection, dbContent.Id);
     }
 }
示例#3
0
 /// <summary>
 /// Удалить записи в таблице union_contents для всех полей union-контента
 /// </summary>
 internal static void RemoveUnionAttrs(Content unionContent)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RemoveUnionAttrsByUnionContent(scope.DbConnection, unionContent.Id);
     }
 }
 public void MultipleRemove(int parentId, IEnumerable <int> entityIDs, int?userId, int?groupId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RemoveChildContentPermissions(scope.DbConnection, entityIDs.ToList(), userId, groupId);
     }
 }
示例#5
0
            public VirtualFieldRelationsStorage(int rootContentId)
            {
                if (_storage == null)
                {
                    _storage = new Dictionary <int, VirtualFieldRelationStorageItem>();
                }

                if (_contentIds == null)
                {
                    _contentIds = new Queue <int>();
                }

                _contentIds.Enqueue(rootContentId);
                if (!_storage.ContainsKey(rootContentId))
                {
                    var item = new VirtualFieldRelationStorageItem {
                        ScopeCount = 1
                    };
                    _storage.Add(rootContentId, item);
                    using (var scope = new QPConnectionScope())
                    {
                        var dt = Common.LoadVirtualFieldsRelations(scope.DbConnection, rootContentId);
                        item.Data = MapperFacade.VirtualFieldsRelationMapper.GetBizList(dt.AsEnumerable().ToList()).Distinct().ToArray();
                    }
                }
                else
                {
                    _storage[rootContentId].ScopeCount++;
                }
            }
示例#6
0
        internal static void Delete(int id)
        {
            using (var scope = new QPConnectionScope())
            {
                if (QPContext.DatabaseType == DatabaseType.SqlServer)
                {
                    ChangeDeleteBindingsTriggerState(false);
                }

                var bindings = QPContext.EFContext.ContentWorkflowBindSet.Where(n => n.WorkflowId == id).ToArray();
                DefaultRepository.SimpleDeleteBulk(bindings);

                var bindings2 = QPContext.EFContext.ArticleWorkflowBindSet.Where(n => n.WorkflowId == id).ToArray();
                DefaultRepository.SimpleDeleteBulk(bindings2);

                var waits = QPContext.EFContext.WaitingForApprovalSet.Include(n => n.Article.WorkflowBinding)
                            .Where(n => n.Article.WorkflowBinding.WorkflowId == id).ToArray();
                DefaultRepository.SimpleDeleteBulk(waits);

                DefaultRepository.Delete <WorkflowDAL>(id);

                if (QPContext.DatabaseType == DatabaseType.SqlServer)
                {
                    ChangeDeleteBindingsTriggerState(true);
                }
            }
        }
示例#7
0
 internal static void CopyArticleWorkflowBind(int sourceSiteId, int destinationSiteId, string relationsBetweenItemsXml)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.CopyArticleWorkflowBind(scope.DbConnection, sourceSiteId, destinationSiteId, relationsBetweenItemsXml);
     }
 }
示例#8
0
 internal static int[] GetReferencedAggregatedContentIds(int contentId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.GetReferencedAggregatedContentIds(scope.DbConnection, contentId));
     }
 }
示例#9
0
 internal static Dictionary <int, Dictionary <int, int> > GetAggregatedArticleIdsMap(int contentId, int[] articleIds)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.GetAggregatedArticleIdsMap(scope.DbConnection, contentId, articleIds));
     }
 }
示例#10
0
 /// <summary>
 /// Возвращает список контекстных меню
 /// </summary>
 /// <returns>список контекстных меню</returns>
 internal static List <ContextMenu> GetList()
 {
     using (var scope = new QPConnectionScope())
     {
         return(MapperFacade.ContextMenuRowMapper.GetBizList(Common.GetContextMenusList(scope.DbConnection, QPContext.CurrentUserId).ToList()));
     }
 }
示例#11
0
 /// <summary>
 /// Возвращает список статусов действий
 /// </summary>
 internal static IEnumerable <BackendActionStatus> GetStatusesList(string menuCode, int entityId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(MapperFacade.BackendActionStatusMapper.GetBizList(Common.GetMenuStatusList(scope.DbConnection, QPContext.CurrentUserId, menuCode, entityId).ToList()));
     }
 }
示例#12
0
 /// <summary>
 /// Возвращает контекстное меню по его коду
 /// </summary>
 internal static ContextMenu GetByCode(string menuCode, bool loadItems = false)
 {
     using (var scope = new QPConnectionScope())
     {
         return(MapperFacade.ContextMenuRowMapper.GetBizObject(Common.GetContextMenuByCode(scope.DbConnection, QPContext.CurrentUserId, menuCode, loadItems)));
     }
 }
示例#13
0
 internal static void RefreshView(string viewName)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RefreshView(scope.DbConnection, viewName);
     }
 }
示例#14
0
 internal static void CreateFrontendViews(int contentId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.CreateFrontedViews(scope.DbConnection, contentId);
     }
 }
示例#15
0
 internal static void CleanWorkflowContentIds(int workflowId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.CleanWorkflowContentBindedIds(scope.DbConnection, workflowId);
     }
 }
示例#16
0
 internal static IEnumerable <int> BatchRemoveContents(int siteId, int contentsToRemove)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.RemovingActions_BatchRemoveContents(siteId, contentsToRemove, scope.DbConnection));
     }
 }
示例#17
0
 internal static void SetWorkflowBindedContentId(int workflowId, int contentId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.SetWorkflowBindedContentId(scope.DbConnection, workflowId, contentId);
     }
 }
示例#18
0
 internal static bool IsArticlePermissionsAllowed(int contentId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.IsArticlePermissionsAllowed(scope.DbConnection, contentId));
     }
 }
示例#19
0
 internal static void SaveHistoryStatus(int id, int systemStatusTypeId, string comment, int currentUserId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.AddHistoryStatus(scope.DbConnection, id, systemStatusTypeId, currentUserId, comment);
     }
 }
示例#20
0
 internal static void CopyCustomActions(int sourceId, int destinationId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.CopyContentCustomActions(scope.DbConnection, sourceId, destinationId);
     }
 }
 public void RemoveAll(int parentId, int?userId, int?groupId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RemoveChildContentPermissions(scope.DbConnection, parentId, userId, groupId);
     }
 }
示例#22
0
 internal static int GetDefaultGroupId(int siteId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.GetDefaultGroupId(scope.DbConnection, siteId));
     }
 }
        public ChildEntityPermission Read(int parentId, int entityId, int?userId, int?groupId)
        {
            using (var scope = new QPConnectionScope())
            {
                DataRow row;
                if (userId.HasValue)
                {
                    row = Common.GetChildContentPermissionForUser(scope.DbConnection, parentId, entityId, userId.Value);
                }
                else if (groupId.HasValue)
                {
                    row = Common.GetChildContentPermissionForGroup(scope.DbConnection, parentId, entityId, groupId.Value);
                }
                else
                {
                    throw new ArgumentNullException(nameof(groupId));
                }

                if (row?.Field <decimal?>("LevelId") == null)
                {
                    return(null);
                }

                var containsHide = row.Table.Columns.Contains("Hide");
                return(ChildEntityPermission.Create(null, parentId, userId, groupId, Convert.ToInt32(row.Field <decimal>("LevelId")), row.Field <bool>("PropagateToItems"), containsHide && row.Field <bool>("Hide")));
            }
        }
示例#24
0
 internal static void UpdateContentModification(int contentId)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.UpdateContentModification(scope.DbConnection, contentId);
     }
 }
示例#25
0
        /// <summary>
        /// Обновить привязку базовых полей к UQ-контенту
        /// </summary>
        internal static void RebuildUserQueryAttrs(Content dbContent)
        {
            dbContent = ContentRepository.GetById(dbContent.Id);

            // определить какие контенты используются
            // и построить словарь используемых контентов
            var usedContentIds  = dbContent.UserQueryContentViewSchema.SelectUniqContentIDs();
            var usedContents    = ContentRepository.GetList(usedContentIds);
            var usedContentDict = new Dictionary <int, Dictionary <string, int> >();

            foreach (var uc in usedContents)
            {
                usedContentDict.Add(uc.Id, new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase));
                foreach (var f in uc.Fields)
                {
                    usedContentDict[uc.Id].Add(f.Name, f.Id);
                }
            }

            var userQueryAttr = dbContent.UserQueryContentViewSchema
                                .Where(c => c.ContentId.HasValue) // только колонки из контентов
                                .Where(c => usedContentDict[c.ContentId.Value].ContainsKey(c.ColumnName))
                                .Select(c => new UserQueryAttr
            {
                UserQueryContentId = dbContent.Id,
                BaseFieldId        = usedContentDict[c.ContentId.Value][c.ColumnName]
            });

            var records = MapperFacade.UserQueryAttrMapper.GetDalList(userQueryAttr.ToList()).AsEnumerable();

            using (var scope = new QPConnectionScope())
            {
                Common.BatchInsertUserQueryAttrs(scope.DbConnection, records);
            }
        }
示例#26
0
        internal static ListResult <ContentListItem> GetList(ContentListFilter filter, ListCommand cmd, int[] selectedContentIDs = null, int workflowId = 0)
        {
            using (var scope = new QPConnectionScope())
            {
                var options = new ContentPageOptions
                {
                    ContentName    = filter.ContentName,
                    SiteId         = filter.SiteId,
                    IsVirtual      = filter.IsVirtual,
                    GroupId        = filter.GroupId,
                    Mode           = filter.Mode,
                    SelectedIDs    = selectedContentIDs,
                    UserId         = QPContext.CurrentUserId,
                    UseSecurity    = !QPContext.IsAdmin,
                    IsAdmin        = QPContext.IsAdmin,
                    SortExpression = cmd.SortExpression,
                    StartRecord    = cmd.StartRecord,
                    PageSize       = cmd.PageSize,
                    LanguageId     = QPContext.CurrentUserIdentity.LanguageId,
                    CustomFilter   = filter.CustomFilter
                };

                var rows = Common.GetContentsPage(scope.DbConnection, options, out var totalRecords);
                return(new ListResult <ContentListItem> {
                    Data = MapperFacade.ContentListItemRowMapper.GetBizList(rows.ToList()), TotalRecords = totalRecords
                });
            }
        }
示例#27
0
 /// <summary>
 /// Для виртуального поля, возвращает ID всех реальных базовых полей
 /// </summary>
 internal static IEnumerable <int> GetRealBaseFieldIds(int virtualFieldId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.GetRealBaseFieldIds(scope.DbConnection, virtualFieldId));
     }
 }
示例#28
0
 internal static IEnumerable <int> GetBindedContetnsIds(int workflowId)
 {
     using (var scope = new QPConnectionScope())
     {
         return(Common.GetWorkflowContentBindedIds(scope.DbConnection, workflowId).Select(x => Converter.ToInt32(x.Field <decimal>("CONTENT_ID"))));
     }
 }
示例#29
0
 /// <summary>
 /// Удалить записи в таблице union_contents для базовых полей
 /// </summary>
 internal static void RemoveUnionAttrs(List <int> baseFieldIds)
 {
     using (var scope = new QPConnectionScope())
     {
         Common.RemoveUnionAttrsByBaseFields(scope.DbConnection, baseFieldIds);
     }
 }
示例#30
0
 /// <summary>
 /// Возвращает информацию о столбцах View
 /// </summary>
 internal static IEnumerable <UserQueryColumn> GetViewSchema(string viewName)
 {
     using (var scope = new QPConnectionScope())
     {
         return(DataTableToUserQueryColumns(Common.GetViewColumnUsage(scope.DbConnection, viewName)));
     }
 }