Example #1
0
 /// <summary>
 /// 查询排序
 /// </summary>
 /// <param name="queryConditions"></param>
 /// <param name="orderList"></param>
 /// <returns></returns>
 public IList <T> GetPaged(IList <ICriterion> queryConditions, IList <Order> orderList, int pageIndex, int pageSize, out int count)
 {
     //1.符合条件的总记录数
     count = ActiveRecordBase.Count(typeof(T), queryConditions.ToArray());
     //2.符合条件的分页获取对象集
     return(ActiveRecordBase.SlicedFindAll(typeof(T), pageIndex * pageSize, pageSize, orderList.ToArray(), queryConditions.ToArray()) as IList <T>);
 }
        virtual public IList <place> getUserPlaces(int statusId, int limit)
        {
            IList <place> temp       = new List <place>();
            users         user       = userService.getUserFull();
            IList <place> userplaces = user.Places;

            if (statusId > 0)
            {
                object[] obj = new object[userplaces.Count];
                int      i   = 0;
                foreach (place p in userplaces)
                {
                    obj[i] = p.id;
                    i++;
                }
                List <AbstractCriterion> baseEx = new List <AbstractCriterion>();
                baseEx.Add(Expression.In("id", obj));
                List <AbstractCriterion> statusEx = new List <AbstractCriterion>();
                statusEx.AddRange(baseEx);
                statusEx.Add(Expression.Eq("status", ActiveRecordBase <status> .Find(statusId)));
                if (limit == 0)
                {
                    limit = 99999;
                }
                Order[] ord = new Order[1];
                ord[0] = Order.Asc("prime_name");
                temp   = ActiveRecordBase <place> .SlicedFindAll(0, limit, ord, statusEx.ToArray());
            }
            else
            {
                temp = userplaces;
            }
            return(temp);
        }
        /// <summary> </summary>
        public void trashbin()
        {
            PropertyBag["postingtypes"] = ActiveRecordBase <posting_type> .FindAll();

            List <AbstractCriterion> baseEx = new List <AbstractCriterion>();

            baseEx.Add(Expression.Eq("deleted", true));
            int limit = 99999;

            Order[] ord = new Order[1];
            ord[0] = Order.Asc("name");
            PropertyBag["trashbin"] = ActiveRecordBase <_base> .SlicedFindAll(0, limit, ord, baseEx.ToArray());

            RenderView("../admin/trashbin");
        }
        /// <summary> </summary>
        public void empty_trash()
        {
            PropertyBag["postingtypes"] = ActiveRecordBase <posting_type> .FindAll();

            List <AbstractCriterion> baseEx = new List <AbstractCriterion>();

            baseEx.Add(Expression.Eq("deleted", true));
            int limit = 99999;

            Order[] ord = new Order[1];
            ord[0] = Order.Asc("name");
            dynamic[] items = ActiveRecordBase <_base> .SlicedFindAll(0, limit, ord, baseEx.ToArray());

            foreach (dynamic item in items)
            {
                //if (item.owner.baseid == userService.getUser().baseid) { // add item.users.Contains(userService.getUser()) and has rights
                Flash["message"] = "All files in the trashbin have been <strong>deleted forever!</strong>. If this was by mistake, please contact your web contact and request for a database restore.";
                //logger.writelog("Removed " + item.post_type.name + " from the trash", getView(), getAction(), item.baseid);
                postingService.delete_item_forever(item);

                /* } else {
                 *   Flash["message"] = "You can't undelete something you don't own.  Contact the owner, " + item.owner.display_name + ", for farther action.";
                 *   logger.writelog("Attepted to restore an event they didn't own", getView(), getAction(), item.baseid);
                 * }*/
            }


            items = ActiveRecordBase <_base> .SlicedFindAll(0, limit, ord, baseEx.ToArray());

            if (items.Count() > 0)
            {
                String message = "";
                foreach (dynamic item in items)
                {
                    if (item.owner.baseid == userService.getUser().baseid)
                    {
                        message += item.post_type.name + " (owner: " + item.owner + ")" + "<br/>";
                    }
                }
                Flash["error"] = "Some files have not been deleted since you didn't have rights to do so. Files Skiped:<br/><ul>" + message + "</ul><br/>Contact the owners of the content for them to share it with you.";
            }
            RedirectToAction("trashbin");
        }
Example #5
0
        /// <summary> </summary>
        virtual public IList <posting> getUserPostings(int limit, Boolean published_only)
        {
            IList <posting> temp = new List <posting>();
            appuser         user = this;

            if (user.postings.Count > 0)
            {
                IList <posting> userevents = user.postings;
                if (published_only)
                {
                    object[] obj = new object[userevents.Count];
                    int      i   = 0;
                    foreach (posting p in userevents)
                    {
                        obj[i] = p.baseid;
                        i++;
                    }
                    List <AbstractCriterion> baseEx = new List <AbstractCriterion>();
                    baseEx.Add(Expression.In("id", obj));
                    baseEx.Add(Expression.Eq("deleted", false));
                    List <AbstractCriterion> statusEx = new List <AbstractCriterion>();
                    statusEx.AddRange(baseEx);
                    //statusEx.Add(Expression.Eq("status", ActiveRecordBase<status>.Find(statusId)));
                    if (limit == 0)
                    {
                        limit = 99999;
                    }
                    Order[] ord = new Order[1];
                    ord[0] = Order.Asc("name");
                    temp   = ActiveRecordBase <posting> .SlicedFindAll(0, limit, ord, statusEx.ToArray());
                }
                else
                {
                    temp = userevents;
                }
            }
            return(temp);
        }
Example #6
0
        /// <summary>
        /// 分页获取满足条件的实体
        /// </summary>
        /// <param name="queryConditions">查询条件</param>
        /// <param name="orderList">排序属性列表</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页实体数</param>
        /// <param name="count">总实体数</param>
        /// <returns></returns>
        public IList <T> Qry(IList <ICriterion> queryConditions, IList <Order> orderList, int pageIndex, int pageSize, out int count)
        {
            if (queryConditions == null)
            {
                queryConditions = new List <ICriterion>();
            }
            //根据查询条件获取满足条件的对象总数
            count = ActiveRecordBase.Count(
                typeof(T)
                , queryConditions.ToArray());

            if (orderList == null)
            {
                orderList = new List <Order>();
            }
            //根据查询条件分页获取对象集合
            return(ActiveRecordBase.SlicedFindAll(
                       typeof(T)
                       , (pageIndex - 1) * pageSize
                       , pageSize
                       , orderList.ToArray()
                       , queryConditions.ToArray()
                       ) as IList <T>);
        }
Example #7
0
        /// <summary>
        /// 获取分页数据(带排序功能)
        /// </summary>
        /// <param name="pagesize">每页显示记录数</param>
        /// <param name="pageindex">当前页码(从1开始,ref变量)</param>
        /// <param name="pagecount">总页数(out变量)</param>
        /// <param name="orders">排序规则</param>
        /// <param name="criteria">查询条件</param>
        /// <returns></returns>
        public static T[] FindAllByPage(int pagesize, ref int pageindex, out int rowscount, out int pagecount, NHibernate.Expression.Order[] orders, params NHibernate.Expression.ICriterion[] criteria)
        {
            doPage(pagesize, ref pageindex, out rowscount, out pagecount, criteria);

            return(ActiveRecordBase <T> .SlicedFindAll((pageindex - 1) *pagesize, pagesize, orders, criteria));
        }