public ViewResult Index(int pageId = 1)
        {
            var entries = Services.Entry.GetList().OrderByDescending(e => e.DateCreated);

            IEnumerable<Entry> mainEntryList;
            PageList mainPageList = null;

            if (Services.Config.Current.IsPagingEnabled)
            {
                IEnumerable<Entry> list = entries;
                if (!Services.User.Current.IsAdmin)
                    list = entries.Where(x => x.IsPublished ?? true);
                int amount = list.Count();
                list = PaggingQuery<Entry>.ToPageList(list, Services.Config.Current.PageAmount, pageId);

                mainEntryList = list;
                mainPageList = new PageList(pageId, amount, Services.Config.Current.PageAmount);
            }
            else
            {
                mainEntryList = entries;
            }

            var model = new IndexModel()
                            {
                                Entries = mainEntryList.Select(EntrySummaryModelAdapter.Convert),
                                Pagging = mainPageList
                            };

            return View(model);
        }
 public virtual IPageList<Customer> GetAllCustomers(bool isDelete = false, int pageIndex = 0, int pageSize = int.MaxValue)
 {
     var query = _CustomerRepository.Table;
     query = query.Where(q => !q.IsDelete);
     query = query.OrderByDescending(q => q.CreateTime);
     var customer = new PageList<Customer>(query,pageIndex,pageSize);
 }
        public ActionResult Datagrid(string orderId, string orderStatus)
        {
            DatagridObject datagrid = null;
            ICriteria icr;
            IList<OrderModel> listHotel;

            if (ObjectUtil.IsAllNullOrEmpty(new string[] { orderId, orderStatus })==ObjectUtil.RESULT_ALL_NULL)
            {
                icr = BaseZdBiz.CreateCriteria<OrderModel>(this.getPager());
                listHotel = icr.List<OrderModel>();
                int count=BaseZdBiz.CountDistinct(icr,"id");
                datagrid = DatagridObject.ToDatagridObject(listHotel, count);
            }
            else {
                icr = BaseZdBiz.CreateCriteria<OrderModel>();
                if (!string.IsNullOrEmpty(orderStatus))
                {
                    icr.Add(Restrictions.Eq("orderStatus", orderStatus));
                }
                if (!string.IsNullOrEmpty(orderId))
                {
                    icr.Add(Restrictions.Eq("id", Convert.ToInt32(orderId)));
                }
                listHotel = icr.List<OrderModel>();
                PageList<OrderModel> pagerList = new PageList<OrderModel>(listHotel, this.getPager());
                datagrid = DatagridObject.ToDatagridObject<OrderModel>(pagerList);

            }

            return  JsonText(datagrid,JsonRequestBehavior.AllowGet);
        }
Exemple #4
0
 public FilesModel()
 {
     filePageList = new FilePageList();
     FoldPageList = new PageList();
     FoldList = new List<FoldInfo>();
     FileList = new List<FileInfo>();
 }
 protected DatagridObject createDatagrid()
 {
     ICriteria icr = BaseZdBiz.CreateCriteria<RoleModel>();
     IList<RoleModel> list = icr.List<RoleModel>();
     PageList<RoleModel> pageList = new PageList<RoleModel>(list,this.getPager());
     DatagridObject datagrid = DatagridObject.ToDatagridObject<RoleModel>(pageList);
     return datagrid;
 }
 public ActionResult DatagridHotBrand()
 {
     DatagridObject datagrid = null;
     ICriteria icr = BaseZdBiz.CreateCriteria<HotBrandModel>();
     IList<HotBrandModel> hotBrands = icr.List<HotBrandModel>();
     PageList<HotBrandModel> pagerList = new PageList<HotBrandModel>(hotBrands, this.getPager());
     datagrid = DatagridObject.ToDatagridObject<HotBrandModel>(pagerList);
     return JsonText(datagrid, JsonRequestBehavior.AllowGet);
 }
 public ActionResult DatagridOuterLink()
 {
     DatagridObject datagrid = null;
     ICriteria icr = BaseZdBiz.CreateCriteria<OuterLinkModel>();
     icr.AddOrder(Order.Desc("recLevel"));
     IList<OuterLinkModel> hotBrands = icr.List<OuterLinkModel>();
     PageList<OuterLinkModel> pagerList = new PageList<OuterLinkModel>(hotBrands, this.getPager());
     datagrid = DatagridObject.ToDatagridObject<OuterLinkModel>(pagerList);
     return JsonText(datagrid, JsonRequestBehavior.AllowGet);
 }
        public ActionResult DatagridHotelOrder()
        {
            ELongApiBiz elongBiz = ELongApiBiz.GetInstant();
            GetHotelOrderCondition condition = new GetHotelOrderCondition();
            HotelOrderPartialForGetHotelOrderList[] hotelArray= elongBiz.queryHotelOrderList(condition);

            IList<HotelOrderPartialForGetHotelOrderList> hotelList = hotelArray.ToList();

            PageList<HotelOrderPartialForGetHotelOrderList> hotelPageList = new PageList<HotelOrderPartialForGetHotelOrderList>(hotelList,this.getPager());
            DatagridObject datagrid = DatagridObject.ToDatagridObject(hotelPageList);
            return JsonText(datagrid ,JsonRequestBehavior.AllowGet);
        }
Exemple #9
0
 /// <summary>
 /// 获取标签列表
 /// <br/>
 /// 分页
 /// </summary>
 /// <param name="page"></param>
 /// <param name="size"></param>
 /// <param name="filter"></param>
 /// <returns></returns>
 public PageList<TagInfo> GetList(int page, int size, string filter)
 {
     PageList<TagInfo> list = new PageList<TagInfo>();
     using (TagInfoDal dal = new TagInfoDal())
     {
         int count = 0;
         list.Data = dal.GetList(page, size, filter, ref count);
         list.RecordCount = count;
         list.CurPage = page;
         list.PageSize = size;
     }
     return list;
 }
Exemple #10
0
 public PageList<Reply> GetList(int page, int pageSize, string filter)
 {
     PageList<Reply> pa = new PageList<Reply>();
     using (ReplyDal dal = new ReplyDal())
     {
         int rowCount = 0;
         pa.CurPage = page;
         pa.PageSize = pageSize;
         pa.Data = dal.GetList(page, pageSize, filter, "", ref rowCount);
         pa.RecordCount = rowCount;
     }
     return pa;
 }
 private DatagridObject createUserDatagrid(string  status)
 {
     DatagridObject datagrid = null;
     ICriteria icr;
     IList<UserModel> listHotel;
     icr = BaseZdBiz.CreateCriteria<UserModel>();
     icr.Add(Restrictions.Eq("status", status));
     new UserModel().setOrderBy(ref icr);
     listHotel = icr.List<UserModel>();
     PageList<UserModel> pagerList = new PageList<UserModel>(listHotel, this.getPager());
     datagrid =DatagridObject.ToDatagridObject<UserModel>(pagerList);
     return datagrid;
 }
        unsafe public void PageMetaDataListConstructorTest()
        {
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);

            using (PageList target = new PageList(Globals.MemoryPool))
            {
                target.Dispose();
            }
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
            using (PageList target2 = new PageList(Globals.MemoryPool))
            {
                target2.AllocateNewPage(1);
                Assert.AreNotEqual(0, Globals.MemoryPool.AllocatedBytes);
            }

            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
        }
        // GET: PhotoGallery
        public ActionResult Index(string filter = null, int page = 1, int pagesize = 20)
        {
            var records = new PageList<Photo>();
            ViewBag.filter = filter;
            records.Content =
                _bd.Photos.Where(x => filter == null || (x.Description.Contains(filter)))
                    .OrderByDescending(x => x.PhotoId)
                    .Skip((page - 1)*pagesize)
                    .Take(pagesize)
                    .ToList();

            records.TotalRecords = _bd.Photos.Where(x => filter == null || (x.Description.Contains(filter))).Count();
            records.CurrentPage = page;
            records.PageSize = pagesize;

            return View(records);
        }
Exemple #14
0
        public PageList<PostViewModel> Get(int page = 1, string channel = null, string group = null,
                                           string category = null, string tag = null,
                                           string date = null, string search = null)
        {
            var data = Query.Post.GetAll(
                p => p.PostStatus == (int) PostStatusEnum.Publish,
                new OrderByExpression<Post, DateTime>(p => p.CreateDate, OrderMode.DESC));

            data = data.Where(p => p.Group.Channel.Url == channel || string.IsNullOrEmpty(channel))
                       .Where(p => p.Group.Url == group || string.IsNullOrEmpty(group))
                       .Where(p => p.Categorys.Any(c => c.Url == category) || string.IsNullOrEmpty(category))
                       .Where(p => p.Tags.Any(t => t.Name == tag) || string.IsNullOrEmpty(tag))
                       .Where(p => p.Title.Contains(search) || string.IsNullOrEmpty(search));
            var count = data.Count();
            var list = data.Skip((page - 1)*Config.Setting.PAGE_SIZE).Take(Config.Setting.PAGE_SIZE).ToList();

            //保存搜索记录
            if (!string.IsNullOrEmpty(search))
            {
                var log = Log.CreateSearchLog(search);
                Command.Instance.Create(log);
            }

            var result = new PageList<PostViewModel>(Config.Setting.PAGE_SIZE)
                {
                    DataList = list.ToViewModels(),
                    TotalCount = count
                };

            //生成Http-head link
            PageHelper.SetLinkHeader(result, "/api/article", page, new Dictionary<string, object>
                {
                    {"channel", channel},
                    {"group", group},
                    {"category", category},
                    {"tag", tag},
                    {"date", date},
                    {"search", search},
                });

            return result;
        }
        public ActionResult TableMemberReward(string statue)
        {
            MemberModel member = this.getAuthMember();

            ICriteria icr = BaseZdBiz.CreateCriteria<MemberRewardModel>();
            if (string.IsNullOrEmpty(statue))
            {
                icr.Add(Restrictions.Eq("memberFk", member.id));
            }
            else
            {
                string[] states = statue.Split(',');
                icr.Add(Restrictions.And(Restrictions.Eq("memberFk", member.id), Restrictions.In("orderStatus", states)));
            }

            IList<MemberRewardModel> orders = icr.List<MemberRewardModel>();
            PageList<MemberRewardModel> pageList = new PageList<MemberRewardModel>(orders, this.getPager());
            ViewData[typeof(MemberRewardModel).Name] = pageList;
            return View();
        }
        private DatagridObject createDatagrid(string status, string qNameType, string qNameVal)
        {
            DatagridObject datagrid = null;
            ICriteria icr;
            IList<BrandModel> listHotel;

            icr = BaseZdBiz.CreateCriteria<BrandModel>();
            bool isQuery = !string.IsNullOrEmpty(qNameType) && !string.IsNullOrEmpty(qNameVal);
            icr.Add(Restrictions.Eq("status", status));

            if (isQuery) {
                icr.Add(Restrictions.Or(Restrictions.Like("brandNameLong", "%" + qNameVal + "%"), Restrictions.Like("brandName", "%" + qNameVal + "%")));
            }

            new BrandModel().setOrderBy(ref icr);
            listHotel = icr.List<BrandModel>();
            PageList<BrandModel> pagerList = new PageList<BrandModel>(listHotel, this.getPager());
            datagrid = DatagridObject.ToDatagridObject<BrandModel>(pagerList);
            return datagrid;
        }
        public void AllocateNewPageTest()
        {
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
            using (PageList target = new PageList(Globals.MemoryPool))
            {
                Assert.AreEqual(0, target.AllocateNewPage(0));
                Assert.AreEqual(Globals.MemoryPool.PageSize * 1, Globals.MemoryPool.AllocatedBytes);
                Assert.AreEqual(1, target.AllocateNewPage(2));
                Assert.AreEqual(Globals.MemoryPool.PageSize * 2, Globals.MemoryPool.AllocatedBytes);
                target.DoCollection(32, new HashSet<int>(new int[] { 1 }), GetEventArgs());
                Assert.AreEqual(Globals.MemoryPool.PageSize * 1, Globals.MemoryPool.AllocatedBytes);
                Assert.AreEqual(0, target.AllocateNewPage(0));
                Assert.AreEqual(2, target.AllocateNewPage(24352));

                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(0, 0));
                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(1, 0));
                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(2, 0));
            }
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
        }
 public ActionResult Index(int page = 1,int pageSize = 10)
 {
     TempData["pageSize"] = pageSize;
     TempData["page"] = page;
     List<BorrowEntry> borrowList = libRepo.BorrowEntryRepo.List();
     PageList<BorrowEntry> pglist = new PageList<BorrowEntry>(borrowList, page, pageSize);
     switch (pglist.Categorized())
     {
         case PageListResult.Ok: { return View(pglist); }
         case PageListResult.Empty:
             {
                 TempData["ErrorNoti"] = "No borrowed list to show.";
                 return View();
             }
         default:
             {
                 TempData["ErrorNoti"] = "Invalid list view parameter please refresh this page to try again.";
                 return View();
             }
     }
 }
 public ActionResult ViewAll(int page = 1,int pageSize = 10)
 {
     TempData["pageSize"] = pageSize;
     TempData["page"] = page;
     List<News> newsList = libRepo.NewsRepo.List().OrderByDescending(news => news.PostTime).ToList();
     PageList<News> pglist = new PageList<News>(newsList, page, pageSize);
     switch (pglist.Categorized())
     {
         case PageListResult.Ok: { return View(pglist); }
         case PageListResult.Empty:
             {
                 TempData["ErrorNoti"] = "No news list to show now.";
                 return View();
             }
         default:
             {
                 TempData["ErrorNoti"] = "Invalid list view parameter please refresh this page to try again.";
                 return View();
             }
     }
 }
 public ActionResult BorrowHistory(int page = 1,int pageSize = 10)
 {
     string username;
     username = HttpContext.User.Identity.Name.ToString().Substring(2);
     Member currentMember = libRepo.MemberRepo.ListWhere(target => target.UserName == username).SingleOrDefault();
     List<BorrowEntry> EntryList = currentMember.GetRelatedBorrowEntry(ref libRepo);
     PageList<BorrowEntry> pglist = new PageList<BorrowEntry>(EntryList,page,pageSize);
     TempData["BorrowCount"] = EntryList.Count();
     switch (pglist.Categorized())
     {
         case PageListResult.Ok: { return View(pglist); }
         case PageListResult.Empty:
             {
                 TempData["ErrorNoti"] = "No borrow history to show.Please do transaction to see your history.";
                 return View();
             }
         default:
             {
                 TempData["ErrorNoti"] = "Invalid list view parameter please refresh this page to try again.";
                 return View();
             }
     }
 }
        private DatagridObject createDatagrid(string  status,string orderStatus)
        {
            DatagridObject datagrid = null;
            ICriteria icr;
            IList<OrderModel> listHotel;
            icr = BaseZdBiz.CreateCriteria<OrderModel>();
            if (string.IsNullOrEmpty(orderStatus))
            {
                icr.Add(Restrictions.Eq("status", status));
            }
            else {
                icr.Add(Restrictions.And(Restrictions.Eq("status", status), Restrictions.Eq("orderStatus", orderStatus)));
            }

            new OrderModel().setOrderBy(ref icr);
            listHotel = icr.List<OrderModel>();
            PageList<OrderModel> pagerList = new PageList<OrderModel>(listHotel, this.getPager());
            datagrid = DatagridObject.ToDatagridObject<OrderModel>(pagerList);
            return datagrid;
        }
        public void TestInitialise()
        {
            this.roleList.Add(new Role { Id = "role-1" });
            this.roleList.Add(new Role { Id = "role-2" });
            this.roleList.Add(new Role { Id = "originator", SystemDefined = true, RoleName = "originator" });
            Dictionary<string, string> user1Roles = new Dictionary<string, string>
                                                    {
                    { "role-2", "role-2" }
                };
            Dictionary<string, string> user2Roles = new Dictionary<string, string>
                                                    {
                    { "role-2", "role-2" }
                };
            Dictionary<string, string> user3Roles = new Dictionary<string, string>
                                                    {
                    { "role-1", "role-1" }
                };

            this.userList.Add(new User { Id = "user-1", EmailAddress = "*****@*****.**", Roles = user1Roles });
            this.userList.Add(new User { Id = "user-2", EmailAddress = "*****@*****.**", Roles = user2Roles });
            this.userList.Add(new User { Id = "user-3", EmailAddress = "*****@*****.**", Roles = user3Roles });

            this.action = new EmailWorkflowTransitionAction
                          {
                AttachPdf = false,
                Condition = null,
                Content = "The email body goes here",
                Recipients = this.recipientList,
                Subject = "The subject line",
                EmailLinks = new List<string>()
            };
            this.application = new Application
                               {
                Id = "123456",
                FormId = "654321",
                ApplicationData = new ApplicationData()
            };

            this.systemSettings.Uris[SystemUriType.BaseSite] = "test.iapply.web";

            this.emptyPageList = new PageList
                                 {
                                     new UserPage
                                     {
                                         Controls = new ControlList()
                                     }
                                 };

            this.getUserFn = criteria =>
            {
                UserList users = new UserList();
                if (criteria.RoleIds != null)
                {
                    foreach (var role in criteria.RoleIds)
                    {
                        users.AddRange(this.userList.Where(u => u.HasRole(role)));
                    }
                }

                if (criteria.UserIds != null)
                {
                    foreach (var user in criteria.UserIds)
                    {
                        users.AddRange(this.userList.Where(u => u.Id == user));
                    }
                }

                return users;
            };
        }
 /// <summary>
 /// 分页获取泛型数据列表
 /// </summary>
 public PageList<ZSystem.Model.t_Operation> GetPageList(PageInfo pi)
 {
     pi.RecordCount = GetCount();
     pi.Compute();
     
     PageList<ZSystem.Model.t_Operation> pl = new PageList<ZSystem.Model.t_Operation>(pi);
     using (DbDataReader dr = dbHelper.ExecuteReader(CommandType.Text, "SELECT * FROM t_Operation", null))
     {
         pl.List = GetPageList(dr, pi.FirstIndex, pi.PageSize);
     }
     return pl;
 }
        public void EmailUserWithPdf()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), new ApplicationPdfWriter(), string.Format("{0}/iapply.pdf", System.IO.Path.GetTempPath()), "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            this.action.AttachPdf = true;
            this.application.ApplicationData.Add("Test", "Test");
            this.recipientList.Users.Add("user-1");

            ControlList controlList = new ControlList();
            TextControl textControl = new TextControl
                                      {
                                          Name = "Test",
                                          Label = "Test"
                                      };
            controlList.Add(textControl);

            PageList pages = new PageList
                             {
                                 new UserPage
                                 {
                                     Controls = controlList
                                 }
                             };
            EventResult result = handler.Handle(null, this.action, this.application, pages, this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(1, message.To.Count);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(1, message.Attachments.Count);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
Exemple #25
0
        /// <summary>
        /// 查找指定条件的部门分页集合
        /// </summary>
        /// <param name="departmentSearcher">部门查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
        public PageList<Department> FindList(DepartmentSearcher departmentSearcher, Pager pager, ICTransaction tran)
        {
            PageList<Department> resultList = new PageList<Department>();
            PageDataTable pageDataTable = this.FindDataTable(departmentSearcher, pager, tran);
            Department ele = null;

            if (pageDataTable != null)
            {
                resultList = new PageList<Department>();
                resultList.PageIndex = pageDataTable.PageIndex;
                resultList.TotalCount = pageDataTable.TotalCount;

                if (pageDataTable.RecordList != null && pageDataTable.RecordList.Rows.Count > 0)
                {
                    foreach (DataRow aRow in pageDataTable.RecordList.Rows)
                    {
                        ele = new Department();

                        if (!(aRow["DepartmentId"] is DBNull))
                        {
                            ele.DepartmentId = aRow["DepartmentId"].ToString();
                        }

                        if (!(aRow["CompanyId"] is DBNull))
                        {
                            ele.CompanyId = aRow["CompanyId"].ToString();
                        }

                        if (!(aRow["DepartmentCode"] is DBNull))
                        {
                            ele.DepartmentCode = aRow["DepartmentCode"].ToString();
                        }

                        if (!(aRow["CreaterId"] is DBNull))
                        {
                            ele.CreaterId = aRow["CreaterId"].ToString();
                        }

                        if (!(aRow["CreateTime"] is DBNull))
                        {
                            ele.CreateTime = Convert.ToDateTime(aRow["CreateTime"]);
                        }

                        if (!(aRow["Name"] is DBNull))
                        {
                            ele.Name = aRow["Name"].ToString();
                        }

                        if (!(aRow["RVersion"] is DBNull))
                        {
                            ele.RVersion = Convert.ToInt32(aRow["RVersion"]);
                        }

                        if (!(aRow["Status"] is DBNull))
                        {
                            ele.Status = Convert.ToInt32(aRow["Status"]);
                        }

                        if (!(aRow["UpdateTime"] is DBNull))
                        {
                            ele.UpdateTime = Convert.ToDateTime(aRow["UpdateTime"]);
                        }

                        if (!(aRow["UpdatorId"] is DBNull))
                        {
                            ele.UpdatorId = aRow["UpdatorId"].ToString();
                        }

                        resultList.RecordList.Add(ele);
                    }
                }
            }

            return resultList;
        }
Exemple #26
0
 /// <summary>Undoes the last edit, so page text reverts to previous contents.
 /// The function doesn't affect other actions like renaming.</summary>
 /// <param name="comment">Revert comment.</param>
 /// <param name="isMinorEdit">Minor edit mark (pass true for minor edit).</param>
 public void Revert(string comment, bool isMinorEdit)
 {
     if (string.IsNullOrEmpty(title))
         throw new WikiBotException(Bot.Msg("No title specified for page to revert."));
     PageList pl = new PageList(site);
     if (Bot.useBotQuery == true && site.botQuery == true &&
         site.botQueryVersions.ContainsKey("ApiQueryRevisions.php"))
         pl.FillFromPageHistoryEx(title, 2, false);
     else
         pl.FillFromPageHistory(title, 2);
     if (pl.Count() != 2)
     {
         Console.Error.WriteLine(Bot.Msg("Can't revert page \"{0}\"."), title);
         return;
     }
     pl[1].Load();
     Save(pl[1].text, comment, isMinorEdit);
     Console.WriteLine(Bot.Msg("Page \"{0}\" was reverted."), title);
 }
Exemple #27
0
 /// <summary>Finds all internal wikilinks in page text, excluding interwiki
 /// links, links to sister projects, categories, embedded images and links in
 /// image descriptions.</summary>
 /// <returns>Returns the PageList object, in which page titles are the wikilinks,
 /// found in text.</returns>
 public PageList GetLinks()
 {
     MatchCollection matches = Site.wikiLinkRE.Matches(text);
     StringCollection exclLinks = new StringCollection();
     exclLinks.AddRange(GetInterWikiLinks());
     exclLinks.AddRange(GetSisterWikiLinks(true));
     string str;
     int fragmentPosition;
     PageList pl = new PageList(site);
     for (int i = 0; i < matches.Count; i++)
     {
         str = matches[i].Groups[1].Value;
         if (str.StartsWith(site.namespaces["6"] + ":", true, site.langCulture) ||
             str.StartsWith(Site.wikiNSpaces["6"] + ":", true, site.langCulture) ||
             str.StartsWith(site.namespaces["14"] + ":", true, site.langCulture) ||
             str.StartsWith(Site.wikiNSpaces["14"] + ":", true, site.langCulture))
             continue;
         str = str.TrimStart(':');
         if (exclLinks.Contains(str))
             continue;
         fragmentPosition = str.IndexOf("#");
         if (fragmentPosition != -1)
             str = str.Substring(0, fragmentPosition);
         pl.Add(new Page(site, str));
     }
     return pl;
 }
Exemple #28
0
 /// <summary>Undoes all last edits of last page contributor, so page text reverts to
 /// previous contents. The function doesn't affect other operations
 /// like renaming or protecting.</summary>
 /// <param name="comment">Revert comment.</param>
 /// <param name="isMinorEdit">Minor edit mark (pass true for minor edit).</param>
 /// <returns>Returns true if last edits were undone.</returns>
 public bool UndoLastEdits(string comment, bool isMinorEdit)
 {
     if (string.IsNullOrEmpty(title))
         throw new WikiBotException(Bot.Msg("No title specified for page to revert."));
     PageList pl = new PageList(site);
     string lastEditor = "";
     for (int i = 50; i <= 5000; i *= 10)
     {
         if (Bot.useBotQuery == true && site.botQuery == true &&
             site.botQueryVersions.ContainsKey("ApiQueryRevisions.php"))
             pl.FillFromPageHistoryEx(title, i, false);
         else
             pl.FillFromPageHistory(title, i);
         lastEditor = pl[0].lastUser;
         foreach (Page p in pl)
             if (p.lastUser != lastEditor)
             {
                 p.Load();
                 Save(p.text, comment, isMinorEdit);
                 Console.WriteLine(
                     Bot.Msg("Last edits of page \"{0}\" by user {1} were undone."),
                     title, lastEditor);
                 return true;
             }
         if (pl.pages.Count < i)
             break;
         pl.Clear();
     }
     Console.Error.WriteLine(Bot.Msg("Can't undo last edits of page \"{0}\" by user {1}."),
         title, lastEditor);
     return false;
 }
        /// <summary>
        /// Determines the optimal page on which <paramref name="dataSource"/> should be run, by interrogating the
        /// <see cref="F:ResponseFieldMap"/> to find the earliest page which contains a mapped control,
        /// and returns the id of the optimal page.
        /// </summary>
        /// <param name="dataSource">The data source to interrogate.</param>
        /// <param name="pageList">The page list containing the full control definitions.</param>
        /// <returns>The id of the optimal page on which <paramref name="dataSource"/> should be run.</returns>
        private int DetermineOptimalPageId(ProductDataSource dataSource, PageList pageList)
        {
            const int defaultVal = int.MaxValue;
            Dictionary<string, int> controlPageIndexes = pageList.AccumulateControlPageIndexes();
            List<string> targetFields = dataSource.ResponseFieldMap.Select(map => map.Target).ToList();
            int min = defaultVal;
            foreach (string target in targetFields)
            {
                if (controlPageIndexes.Keys.Contains(target))
                {
                    min = Math.Min(controlPageIndexes[target], min);
                }
            }

            return min == defaultVal ? -1 : pageList[min].PageId;
        }
Exemple #30
0
        public IPageList FindPage( Type t, String condition, ObjectPage pager )
        {
            String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() );
            logger.Debug( "FindPage=>" + t.FullName );
            IList list = getListFromCache( key, t );
            if (list == null) return null;

            IPageList result = new PageList();

            ObjectPage pageInfo = getPagerInfo( key );
            if (pageInfo == null) return null;

            result.Results = list;
            result.PageCount = pageInfo.PageCount;
            result.RecordCount = pageInfo.RecordCount;
            result.Size = pageInfo.getSize();
            result.PageBar = pageInfo.PageBar;
            result.Current = pageInfo.getCurrent();

            return result;
        }