Exemplo n.º 1
0
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="newSort">新排序,排序编号必须大于0</param>
        public void ModifySort(int newSort)
        {
            if (newSort <= 0)
            {
                throw new Exception("请填写正确的排序编号");
            }
            Sort = newSort;
            //其它分组顺延
            IQuery  sortQuery        = QueryManager.Create <AuthorityGroupQuery>(r => r.Parent == (parent.CurrentValue == null ? 0 : parent.CurrentValue.SysNo) && r.Sort >= newSort);
            IModify modifyExpression = ModifyFactory.Create();

            modifyExpression.Add <AuthorityGroupQuery>(r => r.Sort, 1);
            repository.Modify(modifyExpression, sortQuery);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="newSortIndex">新排序,排序编号必须大于0</param>
        public void ModifySortIndex(int newSortIndex)
        {
            if (newSortIndex <= 0)
            {
                throw new Exception("请填写正确的角色排序");
            }
            _sortIndex = newSortIndex;
            //其它角色顺延
            IQuery  sortQuery        = QueryFactory.Create <RoleQuery>(r => r.Parent == (_parent.CurrentValue == null ? 0 : _parent.CurrentValue.SysNo) && r.SortIndex >= newSortIndex);
            IModify modifyExpression = ModifyFactory.Create();

            modifyExpression.Add <RoleQuery>(r => r.SortIndex, 1);
            roleRepository.Modify(modifyExpression, sortQuery);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="newSort">新排序,排序编号必须大于0</param>
        public void ModifySort(int newSort)
        {
            if (newSort <= 0)
            {
                throw new Exception("请填写正确的角色排序");
            }
            sort = newSort;
            //其它角色顺延
            IQuery  sortQuery        = QueryFactory.Create <RoleQuery>(r => r.Parent == (parent.CurrentValue == null ? 0 : parent.CurrentValue.SysNo) && r.Sort >= newSort);
            IModify modifyExpression = ModifyFactory.Create();

            modifyExpression.Add <RoleQuery>(r => r.Sort, 1);
            repository.Modify(modifyExpression, sortQuery);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="newSort">新排序,排序编号必须大于0</param>
        public void ModifySort(int newSort)
        {
            if (newSort < 1)
            {
                throw new Exception("请填写正确的排序号");
            }
            Sort = newSort;
            //同级后面的数据排序顺延
            var     parentId         = parent.CurrentValue?.Id ?? 0;
            IQuery  sortQuery        = QueryManager.Create <OperationGroupEntity>(r => r.Parent == parentId && r.Sort >= newSort);
            IModify modifyExpression = ModifyFactory.Create();

            modifyExpression.Add <OperationGroupEntity>(r => r.Sort, 1);
            repository.Modify(modifyExpression, sortQuery);
        }
Exemplo n.º 5
0
        protected override void Process(IModify <Photo> items)
        {
            using (IPhotoRepository flickr = repositoryFactory.CreatePhotoRepository())
            {
                PhotoSize size = Bucket.Instance.For.Item(PhotoColumns.Photosize).Value == null
                                     ? PhotoSize.Square
                                     : (PhotoSize)Bucket.Instance.For.Item(PhotoColumns.Photosize).Value;

                ViewMode viewMode = Bucket.Instance.For.Item(PhotoColumns.Viewmode).Value == null
                                        ? ViewMode.Public
                                        : (ViewMode)Bucket.Instance.For.Item(PhotoColumns.Viewmode).Value;

                int index = Bucket.Instance.Entity.ItemsToSkipFromStart + 1;
                if (index == 0)
                {
                    index = index + 1;
                }

                int itemsToTake = 100;

                if (Bucket.Instance.Entity.ItemsToFetch != null)
                {
                    itemsToTake = Bucket.Instance.Entity.ItemsToFetch.Value;
                }

                bool fetchRecent = true;

                /// if there is not tag text, tag or id methioned in search , also want to get my list of images,
                fetchRecent &= string.IsNullOrEmpty((string)Bucket.Instance.For.Item(PhotoColumns.Searchtext).Value);
                fetchRecent &= viewMode != ViewMode.Owner;
                fetchRecent &= string.IsNullOrEmpty((string)Bucket.Instance.For.Item(PhotoColumns.User).Value);
                fetchRecent &= string.IsNullOrEmpty((string)Bucket.Instance.For.Item(PhotoColumns.Nsid).Value);

                bool unique = Bucket.Instance.For.Item(PhotoColumns.ID).Unique&&
                              !string.IsNullOrEmpty((string)Bucket.Instance.For.Item(PhotoColumns.ID).Value);

                Bucket.Instance.Entity.OrderBy.IfUsed.Process(delegate
                {
                    fetchRecent = false;
                });

                /// unique property has higher precendence over general search query.
                if (unique)
                {
                    using (IAuthRepository authRepository = repositoryFactory.CreateAuthRepository())
                    {
                        GenerateToken(viewMode, authRepository);
                        Photo photo = flickr.GetPhotoDetail((string)Bucket.Instance.For.Item(PhotoColumns.ID).Value,
                                                            size);

                        if (photo != null)
                        {
                            items.Add(photo);
                        }
                    }
                }
                else if (fetchRecent)
                {
                    items.AddRange(flickr.GetMostInteresting(index, itemsToTake, size));
                    //items.AddRange();
                }
                else
                {
                    using (IAuthRepository authRepository = repositoryFactory.CreateAuthRepository())
                    {
                        AuthToken token = GenerateToken(viewMode, authRepository);
                        items.AddRange(flickr.Search(index, itemsToTake, size, token == null ? string.Empty : token.Id,
                                                     ProcessSearchQuery(flickr, viewMode)));
                    }
                }
            }
        }