예제 #1
0
        public ActionResult Index(string UserName, DateTime?Date, EFPagingInfo <CheckUser> p, int show = 1)
        {
            p.PageSize = 50;
            DateTime TrueDate;

            if (Date.HasValue)
            {
                TrueDate = new DateTime(Date.Value.Year, Date.Value.Month, Date.Value.Day);
            }
            else
            {
                TrueDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            }
            IPageOfItems <CheckUser> CheckUserList = new PageOfItems <CheckUser>(new List <CheckUser>(), 0, 10, 0, new Hashtable());;
            var CheckUserMoneyList = new List <CheckUserMoney>();
            var UsersList          = new List <CheckUserModel>();
            var CheckResultList    = new List <CheckResult>();
            int uid   = 0;
            int Count = 0;

            var CheckTaskList = this.Entity.CheckTask.Where(o => o.IsComplete == true).Select(o => o.TaskDate).ToList();
            var CheckTask     = this.Entity.CheckTask.FirstOrDefault(o => o.TaskDate == TrueDate);

            if (!UserName.IsNullOrEmpty())
            {
                uid = this.Entity.Users.Where(o => o.UserName == UserName).Select(o => o.Id).FirstOrDefault();
                p.SqlWhere.Add(o => o.UId == uid);
            }
            if (CheckTask != null)
            {
                p.SqlWhere.Add(o => o.TaskDate == CheckTask.TaskDate);
                if (show == 1)
                {
                    p.SqlWhere.Add(o => o.NowMoney != o.CheckMoney || o.NowFrozen != o.CheckFrozen);
                }
                p.OrderByList.Add("Id", "DESC");
                CheckUserList = Entity.Selects <CheckUser>(p);
                Count         = CheckUserList.TotalCount;

                var uids = CheckUserList.Select(o => o.UId).ToList();
                UsersList = this.Entity.Users.Where(o => uids.Contains(o.Id))
                            .Select(o => new CheckUserModel()
                {
                    Id = o.Id, TrueName = o.TrueName, UserName = o.UserName
                }).ToList();
                CheckUserMoneyList = this.Entity.CheckUserMoney.Where(o => uids.Contains(o.UId) && o.TaskDate == CheckTask.TaskDate).ToList();
            }
            ViewBag.CheckUserList      = CheckUserList;
            ViewBag.CheckUserMoneyList = CheckUserMoneyList;
            ViewBag.UsersList          = UsersList;
            ViewBag.CheckTask          = CheckTask;
            ViewBag.CheckTaskList      = CheckTaskList;
            ViewBag.TrueDate           = TrueDate;
            ViewBag.ExcelExport        = this.checkPower("ExcelExport");
            ViewBag.show       = show;
            ViewBag.Count      = Count;
            ViewBag.UserName   = UserName;
            ViewBag.SaveRemark = this.checkPower("Remark");
            return(View());
        }
        public ActionResult Index(PagerParameters pagerParameters, string searchIndex = null, string q = "")
        {
            var pager             = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchSettingPart = Services.WorkContext.CurrentSite.As <SearchSettingsPart>();
            var index             = !String.IsNullOrWhiteSpace(searchIndex) ? searchIndex.Trim() : searchSettingPart.SearchIndex;

            if (String.IsNullOrEmpty(index))
            {
                Services.Notifier.Error(T("Please define a default search index."));
                return(HttpNotFound());
            }

            IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            try {
                searchHits = _searchService.Query(
                    q, pager.Page, pager.PageSize,
                    Services.WorkContext.CurrentSite.As <SearchSettingsPart>().FilterCulture,
                    index,
                    searchSettingPart.GetSearchFields(index),
                    searchHit => searchHit);
            } catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list     = Shape.List();
            var foundIds = searchHits.Select(searchHit => searchHit.ContentItemId).ToList();

            // ignore search results which content item has been removed or unpublished
            var foundItems = _contentManager.GetMany <IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();

            foreach (var contentItem in foundItems)
            {
                list.Add(_contentManager.BuildDisplay(contentItem, searchSettingPart.DisplayType));
            }
            searchHits.TotalItemCount -= foundIds.Count() - foundItems.Count();

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new SearchViewModel {
                Query          = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition  = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition    = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems   = list,
                Pager          = pagerShape,
                IndexName      = index
            };

            //todo: deal with page requests beyond result count

            return(View(searchViewModel));
        }
예제 #3
0
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "")
        {
            Pager pager        = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var   searchFields = Services.WorkContext.CurrentSite.As <SearchSettingsPart>().SearchedFields;

            IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            try {
                searchHits = _searchService.Query(searchText, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As <SearchSettingsPart>().Record.FilterCulture,
                                                  searchFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();

            foreach (var contentItem in Services.ContentManager.GetMany <IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Published, QueryHints.Empty))
            {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);


            foreach (IShape item in list.Items)
            {
                item.Metadata.Type = "ContentPicker";
            }

            // retain the parameter in the pager links
            RouteData.Values["searchText"] = searchText;

            dynamic tab = Services.New.SearchContentTab()
                          .ContentItems(list)
                          .Pager(pagerShape)
                          .SearchText(searchText);

            return(new ShapeResult(this, Services.New.ContentPicker().Tab(tab)));
        }
        public ActionResult Index(PagerParameters pagerParameters, string searchIndex = null, string q = "") {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchSettingPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
            var index = !String.IsNullOrWhiteSpace(searchIndex) ? searchIndex.Trim() : searchSettingPart.SearchIndex;

            if (String.IsNullOrEmpty(index)) {
                Services.Notifier.Error(T("Please define a default search index."));
                return HttpNotFound();
            }

            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try {
                searchHits = _searchService.Query(
                    q, pager.Page, pager.PageSize,
                    Services.WorkContext.CurrentSite.As<SearchSettingsPart>().FilterCulture,
                    index,
                    searchSettingPart.GetSearchFields(index),
                    searchHit => searchHit);
            } catch(Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Shape.List();
            var foundIds = searchHits.Select(searchHit => searchHit.ContentItemId).ToList();

            // ignore search results which content item has been removed or unpublished
            var foundItems = _contentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();
            foreach (var contentItem in foundItems) {
                list.Add(_contentManager.BuildDisplay(contentItem, "Summary"));
            }
            searchHits.TotalItemCount -= foundIds.Count() - foundItems.Count();

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new SearchViewModel {
                Query = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems = list,
                Pager = pagerShape
            };

            //todo: deal with page requests beyond result count

            return View(searchViewModel);
        }
예제 #5
0
        public ActionResult Index(PagerParameters pagerParameters, string q = "")
        {
            Pager pager        = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var   searchFields = Services.WorkContext.CurrentSite.As <SearchSettingsPart>().SearchedFields;

            IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            try {
                searchHits = _searchService.Query(q, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As <SearchSettingsPart>().Record.FilterCulture,
                                                  searchFields,
                                                  searchHit => searchHit);
            } catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Shape.List();

            foreach (var contentItem in searchHits.Select(searchHit => _contentManager.Get(searchHit.ContentItemId)))
            {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(_contentManager.BuildDisplay(contentItem, "Summary"));
            }

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new SearchViewModel {
                Query          = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition  = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition    = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems   = list,
                Pager          = pagerShape
            };

            //todo: deal with page requests beyond result count

            return(View(searchViewModel));
        }
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "") {
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;

            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try {

                searchHits = _searchService.Query(searchText, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
                                                  searchFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();
            foreach (var contentItem in Services.ContentManager.GetMany<IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Published, QueryHints.Empty)) {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null) {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);


            foreach(IShape item in list.Items) {
                item.Metadata.Type = "ContentPicker";
            }

            // retain the parameter in the pager links
            RouteData.Values["searchText"] = searchText;

            dynamic tab = Services.New.SearchContentTab()
                .ContentItems(list)
                .Pager(pagerShape)
                .SearchText(searchText);

            return new ShapeResult(this, Services.New.ContentPicker().Tab(tab));
        }
예제 #7
0
        public ActionResult PostalCodeSearch(PagerParameters pagerParameters, string q = "")
        {
            // Strip spaces
            q = q.Replace(" ", "");
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            IPageOfItems <IContent> searchHits = new PageOfItems <IContent>(new IContent[] { });

            try
            {
                searchHits = _addressDirectoryService.GetItemsByPostalCodeSearch(q, pager.Page, pager.PageSize);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Invalid postal code search query: " + q);
            }

            var list = Shape.List();

            foreach (var contentItem in searchHits.Select(searchHit => searchHit.ContentItem))
            {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }
                list.Add(Services.ContentManager.BuildDisplay(contentItem, "Summary"));
            }

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new PostalCodeSearchViewModel
            {
                Query          = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition  = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition    = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems   = list,
                Pager          = pagerShape
            };

            //todo: deal with page requests beyond result count

            return(View((object)searchViewModel));
        }
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "")
        {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var adminSearchSettingsPart = Services.WorkContext.CurrentSite.As <AdminSearchSettingsPart>();
            var searchSettingsPart      = Services.WorkContext.CurrentSite.As <SearchSettingsPart>();

            IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            try {
                searchHits = _searchService.Query(
                    searchText, pager.Page, pager.PageSize,
                    searchSettingsPart.FilterCulture,
                    adminSearchSettingsPart.SearchIndex,
                    searchSettingsPart.GetSearchFields(adminSearchSettingsPart.SearchIndex),
                    searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();

            foreach (var contentItem in Services.ContentManager.GetMany <IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Latest, QueryHints.Empty))
            {
                // ignore search results which content item has been removed
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var viewModel = Services.New.ViewModel()
                            .ContentItems(list)
                            .Pager(pagerShape)
                            .SearchText(searchText);

            return(View(viewModel));
        }
예제 #9
0
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "")
        {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchSettingsPart = Services.WorkContext.CurrentSite.As <SearchSettingsPart>();

            IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            try {
                searchHits = _searchService.Query(searchText, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As <SearchSettingsPart>().Record.FilterCulture,
                                                  searchSettingsPart.SearchIndex,
                                                  searchSettingsPart.SearchedFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();

            foreach (var contentItem in Services.ContentManager.GetMany <IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Published, QueryHints.Empty))
            {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            dynamic viewModel = Services.New.ViewModel()
                                .ContentItems(list)
                                .Pager(pagerShape)
                                .SearchText(searchText);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return(View((object)viewModel));
        }
예제 #10
0
        public ActionResult Index(PagerParameters pagerParameters, string q = "") {
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;

            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try {

                searchHits = _searchService.Query(q, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
                                                  searchFields,
                                                  searchHit => searchHit);
            } catch(Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Shape.List();
            foreach (var contentItem in searchHits.Select(searchHit => _contentManager.Get(searchHit.ContentItemId))) {
                // ignore search results which content item has been removed or unpublished
                if(contentItem == null){
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(_contentManager.BuildDisplay(contentItem, "Summary"));
            }

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new SearchViewModel {
                Query = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems = list,
                Pager = pagerShape
            };

            //todo: deal with page requests beyond result count

            return View(searchViewModel);
        }
예제 #11
0
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "") {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var adminSearchSettingsPart = Services.WorkContext.CurrentSite.As<AdminSearchSettingsPart>();
            var searchSettingsPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
            
            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try {

                searchHits = _searchService.Query(
                    searchText, pager.Page, pager.PageSize,
                    searchSettingsPart.FilterCulture,
                    adminSearchSettingsPart.SearchIndex,
                    searchSettingsPart.GetSearchFields(adminSearchSettingsPart.SearchIndex),
                    searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();
            foreach (var contentItem in Services.ContentManager.GetMany<IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Latest, QueryHints.Empty)) {
                // ignore search results which content item has been removed
                if (contentItem == null) {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var viewModel = Services.New.ViewModel()
                .ContentItems(list)
                .Pager(pagerShape)
                .SearchText(searchText);

            return View(viewModel);
        }
예제 #12
0
        public ActionResult Index(PagerParameters pagerParameters, string searchText = "") {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchSettingsPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
            
            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try {

                searchHits = _searchService.Query(searchText, pager.Page, pager.PageSize,
                                                  Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
                                                  searchSettingsPart.SearchIndex,
                                                  searchSettingsPart.SearchedFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception) {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Services.New.List();
            foreach (var contentItem in Services.ContentManager.GetMany<IContent>(searchHits.Select(x => x.ContentItemId), VersionOptions.Published, QueryHints.Empty)) {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null) {
                    searchHits.TotalItemCount--;
                    continue;
                }

                list.Add(Services.ContentManager.BuildDisplay(contentItem, "SummaryAdmin"));
            }

            var pagerShape = Services.New.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            dynamic viewModel = Services.New.ViewModel()
                .ContentItems(list)
                .Pager(pagerShape)
                .SearchText(searchText);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return View((object)viewModel);
        }
예제 #13
0
        public IEnumerable <ContentItem> GetFilteredNotificationBatches(string keywords, DateTime?fromDate, DateTime?toDate, NotificationBatchSortBy sortBy)
        {
            var pager = new Pager(_siteService.GetSiteSettings(), new PagerParameters());
            var searchSettingsPart = _orchardServices.WorkContext.CurrentSite.As <SearchSettingsPart>();

            IEnumerable <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });

            searchHits = _searchService.Query(keywords, pager.Page, pager.PageSize,
                                              _orchardServices.WorkContext.CurrentSite.As <SearchSettingsPart>().Record.FilterCulture,
                                              searchSettingsPart.SearchIndex,
                                              searchSettingsPart.SearchedFields,
                                              searchHit => searchHit);

            var notificationBatchItems = _contentManager
                                         .Query(VersionOptions.Latest, Constants.NotificationBatchContentType)
                                         .ForContentItems(searchHits.Select(hit => hit.ContentItemId));

            if (fromDate != null && toDate != null)
            {
                notificationBatchItems = notificationBatchItems
                                         .Where <CommonPartRecord>(record => record.CreatedUtc >= fromDate.Value && record.CreatedUtc <= toDate.Value);
            }

            switch (sortBy)
            {
            case NotificationBatchSortBy.DateSent: notificationBatchItems = notificationBatchItems
                                                                            .OrderByDescending <CommonPartRecord>(record => record.PublishedUtc);
                break;

            case NotificationBatchSortBy.Title: notificationBatchItems = notificationBatchItems
                                                                         .OrderBy <TitlePartRecord>(record => record.Title);
                break;

            default:
                throw new ArgumentOutOfRangeException("sortBy");
            }

            return(notificationBatchItems.List());
        }
        public IEnumerable<ContentItem> GetFilteredNotificationBatches(string keywords, DateTime? fromDate, DateTime? toDate, NotificationBatchSortBy sortBy)
        {
            var pager = new Pager(_siteService.GetSiteSettings(), new PagerParameters());
            var searchSettingsPart = _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>();

            IEnumerable<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });

            searchHits = _searchService.Query(keywords, pager.Page, pager.PageSize,
                                              _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
                                              searchSettingsPart.SearchIndex,
                                              searchSettingsPart.SearchedFields,
                                              searchHit => searchHit);

            var notificationBatchItems = _contentManager
                .Query(VersionOptions.Latest, Constants.NotificationBatchContentType)
                .ForContentItems(searchHits.Select(hit => hit.ContentItemId));

            if (fromDate != null && toDate != null)
            {
                notificationBatchItems = notificationBatchItems
                    .Where<CommonPartRecord>(record => record.CreatedUtc >= fromDate.Value && record.CreatedUtc <= toDate.Value);
            }

            switch (sortBy)
            {
                case NotificationBatchSortBy.DateSent: notificationBatchItems = notificationBatchItems
                    .OrderByDescending<CommonPartRecord>(record => record.PublishedUtc);
                    break;
                case NotificationBatchSortBy.Title: notificationBatchItems = notificationBatchItems
                    .OrderBy<TitlePartRecord>(record => record.Title);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("sortBy");
            }

            return notificationBatchItems.List();
        }
예제 #15
0
        public ActionResult Rewriter(RewriterViewModel rewriterViewModel, PagerParameters pagerParameters)
        {
            if (!IsAuthorized())
            {
                return(new HttpUnauthorizedResult());
            }

            if (rewriterViewModel.TypeName == "Dynamic")
            {
                return(DynamicPageRewriter(new DynamicPageRewriterViewModel {
                    RewriterType = rewriterViewModel.RewriterType
                }));
            }

            var siteSettings = _workContext.CurrentSite;
            var pager        = new Pager(siteSettings, pagerParameters);

            var seoContentTypes = _seoService.ListSeoContentTypes();

            if (string.IsNullOrEmpty(rewriterViewModel.TypeName))
            {
                return(HttpNotFound());
            }
            var typeDefinition = seoContentTypes.SingleOrDefault(t => t.Name == rewriterViewModel.TypeName);

            if (typeDefinition == null)
            {
                return(HttpNotFound());
            }
            rewriterViewModel.TypeDisplayName         = typeDefinition.DisplayName;
            _orchardServices.WorkContext.Layout.Title = TitleForRewriter(rewriterViewModel.RewriterType, typeDefinition.DisplayName);

            var query = _contentManager.Query(VersionOptions.Latest, rewriterViewModel.TypeName);

            if (!String.IsNullOrEmpty(rewriterViewModel.Q))
            {
                IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });
                try
                {
                    ///TODO 1.9: make sure this to array function actually works
                    var searchSettings = siteSettings.As <SearchSettingsPart>();
                    searchHits = _searchService.Query(rewriterViewModel.Q, pager.Page, pager.PageSize, false,
                                                      searchSettings.SearchIndex, searchSettings.SearchFields.Keys.ToArray <string>(),
                                                      //searchSettings.SearchIndex, SearchSettingsHelper.GetSearchFields(searchSettings),
                                                      searchHit => searchHit);
                    // Could use this: http://orchard.codeplex.com/workitem/18664
                    // Converting to List, because the expression should contain an ICollection
                    var hitIds = searchHits.Select(hit => hit.ContentItemId).ToList();
                    query.Where <CommonPartRecord>(record => hitIds.Contains(record.Id));
                }
                catch (Exception ex) {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    _orchardServices.Notifier.Error(T("Invalid search query: {0}", ex.Message));
                }
            }

            switch (rewriterViewModel.Options.OrderBy)
            {
            case ContentsOrder.Modified:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc);
                break;

            case ContentsOrder.Published:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc);
                break;

            case ContentsOrder.Created:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc);
                break;
            }

            rewriterViewModel.Options.SelectedFilter = rewriterViewModel.TypeName;

            var pagerShape         = _shapeFactory.Pager(pager).TotalItemCount(query.Count());
            var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();

            var list = _shapeFactory.List();

            list.AddRange(
                pageOfContentItems.Select(
                    item => _prefixedEditorManager.BuildShape(item, (content => _contentManager.BuildDisplay(content, "SeoSummaryAdmin-" + rewriterViewModel.RewriterType)))
                    )
                );

            dynamic viewModel = _shapeFactory.ViewModel()
                                .ContentItems(list)
                                .Options(rewriterViewModel.Options)
                                .Pager(pagerShape);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation, despite
            // being it highly unlikely with Onestop, just in case...
            return(View((object)viewModel));
        }
        public ActionResult Index(FastOrder FastOrder, EFPagingInfo <Orders> p)
        {
            p.PageSize = 20;
            string STimeStr = string.Empty;
            string ETimeStr = string.Empty;
            string TNumStr  = string.Empty;

            if (FastOrder.STime == null || FastOrder.STime == DateTime.MinValue)
            {
                FastOrder.STime = DateTime.Now.AddDays(-1);
            }
            if (FastOrder.ETime == null || FastOrder.ETime == DateTime.MinValue)
            {
                FastOrder.ETime = DateTime.Now;
            }

            TimeSpan TS   = FastOrder.ETime.Subtract(FastOrder.STime);
            int      Days = TS.Days;

            if (Days > 31)
            {
                ViewBag.ErrorMsg = "统计时间间隔不能超过31天!";
                return(View("Error"));
            }
            STimeStr = " AND L.AddTime >= '" + FastOrder.STime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            ETimeStr = " AND L.AddTime <= '" + FastOrder.ETime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            if (!FastOrder.TNum.IsNullOrEmpty())
            {
                TNumStr = " AND L.TNum = '" + FastOrder.TNum.ToString() + "'";
            }
            int           s        = ((p.PageIndex == 0 ? 1 : p.PageIndex) - 1) * p.PageSize;
            int           e        = (p.PageIndex + 1) * p.PageSize;
            var           DataList = new List <FastShareProfitModel>();
            StringBuilder sql      = new StringBuilder();

            sql.Append(" select * From ( ");
            sql.Append(" select O.Id,row_number() OVER (ORDER BY O.Id DESC) AS RowNumber,O.TNum,O.OType,O.UserState,O.Amoney,ISNULL(L.UId,0) UId,ISNULL(L.LogType,0) LogType,ISNULL(Sum(L.Profit), 0) Profit,L.AddTime  ");
            sql.Append(" From FastOrder(nolock) O Left Join OrderProfitLog(nolock) L ON O.TNum=L.TNum AND L.IsDel=0 ");
            sql.Append(" Where O.IsDel=0 " + STimeStr + ETimeStr + TNumStr);
            sql.Append(" Group By O.Id,O.TNum,L.UId,O.Amoney,O.OType,O.UserState,L.LogType,L.AddTime ");
            sql.Append(" ) AS D Where RowNumber BETWEEN " + s.ToString() + " AND " + e.ToString() + " Order By Id desc");
            DataList = Entity.ExecuteStoreQuery <FastShareProfitModel>(sql.ToString(), null).ToList();

            StringBuilder sql2 = new StringBuilder();

            sql2.Append(" select Count(1) c From ( ");
            sql2.Append(" select O.Id ");
            sql2.Append(" From FastOrder(nolock) O Left Join OrderProfitLog(nolock) L ON O.TNum=L.TNum AND L.IsDel=0 ");
            sql2.Append(" Where O.IsDel=0 " + STimeStr + ETimeStr + TNumStr);
            sql2.Append(" Group By O.Id,O.TNum,L.UId,O.Amoney,O.OType,O.UserState,L.LogType,L.AddTime ");
            sql2.Append(" ) AS D ");
            int c = Entity.ExecuteStoreQuery <int>(sql2.ToString(), null).FirstOrDefault();

            DataList = new PageOfItems <FastShareProfitModel>(DataList, p.PageIndex, p.PageSize, c, null);

            var UIds      = DataList.Select(o => o.UId).ToList();
            var UsersList = this.Entity.Users.Where(o => UIds.Contains(o.Id)).ToList();

            ViewBag.UsersList = UsersList;
            ViewBag.DataList  = DataList;
            ViewBag.FastOrder = FastOrder;
            ViewBag.Xls       = this.checkPower("ExcelExport");
            return(View());
        }
예제 #17
0
        public ActionResult PostalCodeSearch(PagerParameters pagerParameters, string q = "")
        {
            // Strip spaces
            q = q.Replace(" ", "");
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            IPageOfItems<IContent> searchHits = new PageOfItems<IContent>(new IContent[] { });
            try
            {
                searchHits = _addressDirectoryService.GetItemsByPostalCodeSearch(q, pager.Page, pager.PageSize);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Invalid postal code search query: " + q);
            }

            var list = Shape.List();
            foreach (var contentItem in searchHits.Select(searchHit => searchHit.ContentItem))
            {
                // ignore search results which content item has been removed or unpublished
                if (contentItem == null)
                {
                    searchHits.TotalItemCount--;
                    continue;
                }
                list.Add(Services.ContentManager.BuildDisplay(contentItem, "Summary"));
            }

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new PostalCodeSearchViewModel
            {
                Query = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems = list,
                Pager = pagerShape
            };

            //todo: deal with page requests beyond result count

            return View((object)searchViewModel);
        }
예제 #18
0
        public ActionResult Index(PagerParameters pagerParameters, int? forumsHomeId, string q = "")
        {
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchSettingPart = _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>();
            ForumsHomePagePart forumsHomePagePart = null;

            if ( forumsHomeId != null ) {
                forumsHomePagePart = _contentManager.Get<ForumsHomePagePart>( forumsHomeId.Value );
            }

            string searchIndex = ForumSearchService.FORUMS_INDEX_NAME;

            if (forumsHomePagePart == null) {
                _orchardServices.Notifier.Error(T("Error: The search index was not found.  Searching failed.  Please review the logs for additional information"));
                Logger.Log(LogLevel.Error, new Exception(String.Format("The forums default search index '{0}' was not found.  Please manually create an index by this name and associate it with the Post contentitem",searchIndex)),null, null);
                return HttpNotFound();
            }

            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try
            {

                searchHits = _forumSearchService.Query(q, forumsHomeId, pager.Page, pager.PageSize,
                                                  _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>().FilterCulture,
                                                  searchIndex,
                                                  searchSettingPart.SearchedFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception)
            {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                _orchardServices.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Shape.List();
            var foundIds = searchHits.Select(searchHit => searchHit.ContentItemId).ToList();

            // ignore search results which content item has been removed or unpublished
            var foundItems = _contentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();
            foreach (var contentItem in foundItems)
            {
                if (contentItem.Is<PostPart>())
                {
                    if (contentItem.As<PostPart>().IsInappropriate == false)
                    {
                        list.Add(_contentManager.BuildDisplay(contentItem, "SearchResult"));
                    }
                }
            }

            searchHits.TotalItemCount -= foundIds.Count() - foundItems.Count();

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            dynamic menuShape = null;
            if (_orchardServices.WorkContext.CurrentUser != null)
            {
                menuShape = Shape.Parts_ForumMenu(ForumsHomePagePart: forumsHomePagePart, ShowRecent: true, ShowMarkAll: true, ReturnUrl: HttpContext.Request.Url.AbsoluteUri);    
            }

            
            //var search = _orchardServices.ContentManager.New("ForumSearch");
            var breadCrumb = Shape.Parts_BreadCrumb(ForumsHomePagePart:forumsHomePagePart);
            var searchShape = Shape.Parts_Forum_Search(ForumsHomeId: forumsHomePagePart.Id); ;

            var forumsSearchViewModel = new ForumsSearchViewModel
            {
                Query = q,
                ForumsHomeId = forumsHomeId,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems = list,
                Pager = pagerShape,
                ForumSearch = searchShape,
                ForumMenu = menuShape,
                BreadCrumb = breadCrumb
            };



            return View((object)forumsSearchViewModel);

        }
예제 #19
0
        public ActionResult Index(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, int?LowerLevel, int IsFirst = 0)
        {
            if (IsFirst == 0)
            {
                if (IsShowSupAgent == null)
                {
                    IsShowSupAgent = false;
                }
                if (checkPower("ALL"))
                {
                    IsAll = true;
                }
                LowerLevel    = LowerLevel == null ? 0 : LowerLevel;
                ViewBag.IsAll = IsAll;
                PageOfItems <Orders> OrdersList1 = new PageOfItems <Orders>(new List <Orders>(), 0, 10, 0, new Hashtable());
                ViewBag.OrdersList = OrdersList1;
                ViewBag.Orders     = Orders;
                //查询对应的商户
                List <int> UId1 = OrdersList1.Select(o => o.UId).Distinct().ToList();
                ViewBag.UsersList      = Entity.Users.Where(n => n.State == 1 && UId1.Contains(n.Id)).ToList();
                ViewBag.PayConfigList  = Entity.PayConfig.Where(n => n.State == 1).ToList();
                ViewBag.IsShowSupAgent = IsShowSupAgent;
                ViewBag.BasicAgent     = BasicAgent;
                SysSet SysSet1 = Entity.SysSet.FirstOrNew();
                ViewBag.SysSet     = SysSet1;
                ViewBag.Entity     = Entity;
                ViewBag.LowerLevel = LowerLevel;
                return(View());
            }
            //if (Orders.STime.IsNullOrEmpty())
            //{
            //    Orders.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            //}
            //if (Orders.ETime.IsNullOrEmpty())
            //{
            //    Orders.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            //}
            //if (!Orders.STime.IsNullOrEmpty() && !Orders.ETime.IsNullOrEmpty())
            //{
            //    DateTime ETime = Orders.ETime;
            //    p.SqlWhere.Add(f => f.PayTime > Orders.STime && f.PayTime < ETime);
            //}

            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            if (checkPower("ALL"))
            {
                IsAll = true;
            }
            ViewBag.IsAll = IsAll;

            /*有没有指定交易所属代理
             * 有:校验是否从属关系
             * 无:指定当前代理
             */
            if (!Orders.Agent.IsNullOrEmpty())
            {
                if (!IsBelongToAgent(Orders.Agent))
                {
                    ViewBag.ErrorMsg = "只能查询当前用户下属代理的交易";
                    return(View("Error"));
                }
            }
            else
            {
                Orders.Agent = this.BasicAgent.Id;
            }
            LowerLevel = LowerLevel == null ? 0 : LowerLevel;
            //没有"管理所有"权限的只能看到操作员自己的数据
            //if (!IsAll)
            //{
            //    p.SqlWhere.Add(f => f.AId == AdminUser.Id);//交易所属用户
            //}
            //else
            {
                IList <SysAgent> SysAgentList = null;
                if ((bool)IsShowSupAgent)
                {
                    IList <int> UID = new List <int>();
                    if (LowerLevel != 0)
                    {
                        SysAgent LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == LowerLevel).FirstOrNew();
                        SysAgentList = LowerLevelAgent.GetSupAgent(Entity);
                    }
                    else
                    {
                        SysAgentList = BasicAgent.GetSupAgent(Entity);//获取所有下级代理商信息
                    }
                    foreach (var s in SysAgentList)
                    {
                        UID.Add(s.Id);
                    }
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == Orders.Agent);//交易所属代理
                }
            }
            #region 筛选条件
            if (!Orders.OrderAddress.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.OrderAddress.Contains(Orders.OrderAddress));
            }
            if (!Orders.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == Orders.TNum);
            }
            if (!Orders.LagEntryDay.IsNullOrEmpty())
            {
                if (Orders.LagEntryDay == 99)
                {
                    p.SqlWhere.Add(f => f.LagEntryDay == 0);
                }
                else
                {
                    p.SqlWhere.Add(f => f.LagEntryDay > 0);
                }
            }
            if (!Orders.TrunType.IsNullOrEmpty())
            {
                if (Orders.TrunType == 1)
                {
                    p.SqlWhere.Add(f => f.TrunType == 1);
                }
                else
                {
                    p.SqlWhere.Add(f => f.TrunType == 0);
                }
            }

            if (!Orders.TName.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName.Contains(Orders.TName) || n.NeekName.Contains(Orders.TName) || n.UserName == Orders.TName).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }
            if (!Orders.PayWay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.PayWay == Orders.PayWay);
            }
            if (!Orders.STime.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AddTime >= Orders.STime);
            }
            if (!Orders.ETime.IsNullOrEmpty())
            {
                DateTime ETime = Orders.ETime.AddHours(23).AddMinutes(59).AddSeconds(59);
                p.SqlWhere.Add(f => f.AddTime <= ETime);
            }
            #region 交易类型条件判断
            p.SqlWhere.Add(f => f.TType == 2);//读取对应的类型
            if (Orders.TType == 2)
            {
                if (!Orders.TState.IsNullOrEmpty())
                {
                    p.SqlWhere.Add(f => f.TState == Orders.TState);
                }
            }
            #endregion
            #endregion
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <Orders> OrdersList = Entity.Selects <Orders>(p);
            ViewBag.OrdersList = OrdersList;
            ViewBag.Orders     = Orders;
            //查询对应的商户
            List <int> UId = OrdersList.Select(o => o.UId).Distinct().ToList();
            ViewBag.UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
            //因为上面判段过了,这里其实是不用的
            //if (checkPower("ALL"))
            //{
            //    ViewBag.UsersList = Entity.Users.Where(n => n.State == 1 && n.Agent == AdminUser.AgentId && UId.Contains(n.Id)).ToList();
            //}
            //else
            //{
            //    ViewBag.UsersList = Entity.Users.Where(n => n.State == 1 && n.AId == AdminUser.Id && UId.Contains(n.Id)).ToList();
            //}
            ViewBag.PayConfigList  = Entity.PayConfig.Where(n => n.State == 1).ToList();
            ViewBag.IsShowSupAgent = IsShowSupAgent;
            ViewBag.BasicAgent     = BasicAgent;
            SysSet SysSet = Entity.SysSet.FirstOrNew();
            ViewBag.SysSet     = SysSet;
            ViewBag.Entity     = Entity;
            ViewBag.LowerLevel = LowerLevel;
            return(View());
        }
        public ActionResult Index(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, int?LowerLevel, int IsFirst = 0)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            if (IsFirst == 0)
            {
                if (checkPower("ALL"))
                {
                    IsAll = true;
                }
                ViewBag.IsAll = IsAll;
                PageOfItems <Orders> OrdersList1 = new PageOfItems <Orders>(new List <Orders>(), 0, 10, 0, new Hashtable());
                ViewBag.OrdersList = OrdersList1;
                ViewBag.Orders     = Orders;
                //查询对应的商户
                List <int> UId1 = OrdersList1.Select(o => o.UId).Distinct().ToList();
                ViewBag.UsersList      = Entity.Users.Where(n => n.State == 1 && UId1.Contains(n.Id)).ToList();
                ViewBag.PayConfigList  = Entity.PayConfig.Where(n => n.State == 1).ToList();
                ViewBag.IsShowSupAgent = false;
                ViewBag.BasicAgent     = BasicAgent;
                SysSet SysSet1 = Entity.SysSet.FirstOrNew();
                ViewBag.SysSet     = SysSet1;
                ViewBag.Entity     = Entity;
                ViewBag.LowerLevel = 0;
                ViewBag.Edit       = this.checkPower("Edit");
                return(View());
            }

            if (checkPower("ALL"))
            {
                IsAll = true;
            }
            ViewBag.IsAll = IsAll;

            /*有没有指定交易所属代理
             * 有:校验是否从属关系
             * 无:指定当前代理
             */
            if (!Orders.Agent.IsNullOrEmpty())
            {
                if (!IsBelongToAgent(Orders.Agent))
                {
                    ViewBag.ErrorMsg = "只能查询当前用户下属代理的交易";
                    return(View("Error"));
                }
            }
            else
            {
                Orders.Agent = this.BasicAgent.Id;
            }
            LowerLevel = LowerLevel == null ? 0 : LowerLevel;
            //没有"管理所有"权限的只能看到操作员自己的数据
            if (!IsAll)
            {
                p.SqlWhere.Add(f => f.AId == AdminUser.Id);//交易所属用户
            }
            else
            {
                IList <SysAgent> SysAgentList = null;
                if ((bool)IsShowSupAgent)
                {
                    IList <int> UID = new List <int>();
                    if (LowerLevel != 0)
                    {
                        SysAgent LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == LowerLevel).FirstOrNew();
                        SysAgentList = LowerLevelAgent.GetSupAgent(Entity, true);
                    }
                    else
                    {
                        SysAgentList = BasicAgent.GetSupAgent(Entity, true);//获取所有下级代理商信息
                    }
                    UID = SysAgentList.Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == BasicAgent.Id);//读取全部分支机构
                }
            }
            #region 筛选条件
            if (!Orders.OrderAddress.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.OrderAddress.Contains(Orders.OrderAddress));
            }
            if (!Orders.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == Orders.TNum);
            }
            if (!Orders.LagEntryDay.IsNullOrEmpty())
            {
                if (Orders.LagEntryDay == 99)
                {
                    p.SqlWhere.Add(f => f.LagEntryDay == 0);
                }
                else
                {
                    p.SqlWhere.Add(f => f.LagEntryDay > 0);
                }
            }
            if (!Orders.TrunType.IsNullOrEmpty())
            {
                if (Orders.TrunType == 1)
                {
                    p.SqlWhere.Add(f => f.TrunType == 1);
                }
                else
                {
                    p.SqlWhere.Add(f => f.TrunType == 0);
                }
            }

            if (!Orders.TName.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName.Contains(Orders.TName) || n.NeekName.Contains(Orders.TName) || n.UserName == Orders.TName).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }
            if (!Orders.PayWay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.PayWay == Orders.PayWay);
            }
            if (!Orders.STime.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AddTime >= Orders.STime);
            }
            if (!Orders.ETime.IsNullOrEmpty())
            {
                DateTime ETime = Orders.ETime.AddHours(23).AddMinutes(59).AddSeconds(59);
                p.SqlWhere.Add(f => f.AddTime <= ETime);
            }
            #region 交易类型条件判断
            if (!Orders.TType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TType == Orders.TType);//读取对应的类型
                if (Orders.TType == 1)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        switch (Orders.TState)
                        {
                        case 1:    //未付
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                            break;

                        case 2:    //已付
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                            break;

                        case 3:    //待传证照
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                            break;

                        case 4:    //待审核
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                            break;

                        case 5:    //审核失败
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 4);
                            break;

                        case 6:    //退单
                            p.SqlWhere.Add(f => f.TState == 4);
                            break;

                        case 7:    //待入帐
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 0);
                            break;
                        }
                    }
                }
                if (Orders.TType == 2)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        p.SqlWhere.Add(f => f.TState == Orders.TState);
                    }
                }
                if (Orders.TType == 3)
                {
                    switch (Orders.TState)
                    {
                    case 1:    //未付
                        p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                        break;

                    case 2:    //已付
                        p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                        break;

                    case 3:    //待传证照
                        p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                        break;

                    case 4:    //待审核
                        p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                        break;

                    case 5:    //审核失败
                        p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 4);
                        break;
                    }
                }
                if (Orders.TType == 5)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        switch (Orders.TState)
                        {
                        case 99:    //未付
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                            break;

                        case 1:    //处理中
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 0);
                            break;

                        case 2:    //已汇出
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 2);
                            break;

                        case 4:    //出款中
                            p.SqlWhere.Add(f => (f.TState == 2 && f.PayState == 2 && f.IdCardState == 0) || (f.TState == 2 && f.PayState == 1 && f.IdCardState == 3));
                            break;

                        case 3:    //审核失败
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 4);
                            break;

                        case 5:    //退款中
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 3);
                            break;

                        case 6:    //已退款
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 4);
                            break;

                        case 7:    //待传身份证
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                            break;

                        case 8:    //已传身份证
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                            break;
                        }
                    }
                }
                if (Orders.TType == 6)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        p.SqlWhere.Add(f => f.TState == Orders.TState);
                    }
                }
                if (Orders.TType == 7 || Orders.TType == 8 || Orders.TType == 9)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        if (Orders.TState == 99)
                        {
                            p.SqlWhere.Add(f => f.TState == 0);
                        }
                        if (Orders.TState == 1)
                        {
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                        }
                        if (Orders.TState == 2)
                        {
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                        }
                        if (Orders.TState == 3)//退单
                        {
                            p.SqlWhere.Add(f => f.TState == 4);
                        }
                        if (Orders.TState == 4)//待入帐
                        {
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 0);
                        }
                        if (Orders.TState == 5)//待审核
                        {
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 2);
                        }
                        if (Orders.TState == 6)//待传证照
                        {
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 1);
                        }
                        if (Orders.TState == 7)//审核失败
                        {
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 4);
                        }
                    }
                }
                if (Orders.TType == 10)
                {
                    if (!Orders.TState.IsNullOrEmpty())
                    {
                        p.SqlWhere.Add(f => f.TState == Orders.TState);
                    }
                }
            }
            #endregion
            #endregion
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <Orders> OrdersList = Entity.Selects <Orders>(p);
            ViewBag.OrdersList = OrdersList;
            ViewBag.Orders     = Orders;
            //查询对应的商户
            List <int> UId = OrdersList.Select(o => o.UId).Distinct().ToList();
            ViewBag.UsersList      = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
            ViewBag.PayConfigList  = Entity.PayConfig.Where(n => n.State == 1).ToList();
            ViewBag.IsShowSupAgent = IsShowSupAgent;
            ViewBag.BasicAgent     = BasicAgent;
            SysSet SysSet = Entity.SysSet.FirstOrNew();
            ViewBag.SysSet     = SysSet;
            ViewBag.Entity     = Entity;
            ViewBag.LowerLevel = LowerLevel;
            ViewBag.Edit       = this.checkPower("Edit");
            return(View());
        }
예제 #21
0
        public ActionResult Search(PagerParameters pagerParameters, string q = "")
        {
       

            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var searchFields = _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;

            IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
            try
            {

                searchHits = _wikiPageService.IndexSearch(q, pager.Page, pager.PageSize,
                                                  _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
                                                  searchFields,
                                                  searchHit => searchHit);
            }
            catch (Exception exception)
            {
                Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
                _orchardServices.Notifier.Error(T("Invalid search query: {0}", exception.Message));
            }

            var list = Shape.List();
            var foundIds = searchHits.Select(searchHit => searchHit.ContentItemId).ToList();

            // ignore search results which content item has been removed or unpublished
            var foundItems = _orchardServices.ContentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();
            foreach (var contentItem in foundItems)
            {
                list.Add(_orchardServices.ContentManager.BuildDisplay(contentItem, "Summary"));
            }
            searchHits.TotalItemCount -= foundIds.Count() - foundItems.Count();

            var pagerShape = Shape.Pager(pager).TotalItemCount(searchHits.TotalItemCount);

            var searchViewModel = new SearchViewModel
            {
                Query = q,
                TotalItemCount = searchHits.TotalItemCount,
                StartPosition = (pager.Page - 1) * pager.PageSize + 1,
                EndPosition = pager.Page * pager.PageSize > searchHits.TotalItemCount ? searchHits.TotalItemCount : pager.Page * pager.PageSize,
                ContentItems = list,
                Pager = pagerShape
            };

            //todo: deal with page requests beyond result count

            return View(searchViewModel);
        }
예제 #22
0
        public ActionResult Rewriter(RewriterViewModel rewriterViewModel, PagerParameters pagerParameters)
        {
            // These Authorize() calls are mainly placeholders for future permissions, that's why they're copy-pasted around.
            if (!_authorizer.Authorize(Permissions.ManageSeo, T("You're not allowed to manage SEO settings.")))
            {
                return(new HttpUnauthorizedResult());
            }

            string title;

            switch (rewriterViewModel.RewriterType)
            {
            case "TitleRewriter":
                title = T("SEO Title Tag Rewriter").Text;
                break;

            case "DescriptionRewriter":
                title = T("SEO Description Tag Rewriter").Text;
                break;

            case "KeywordsRewriter":
                title = T("SEO Keywords Tag Rewriter").Text;
                break;

            default:
                return(new HttpNotFoundResult());
            }
            _orchardServices.WorkContext.Layout.Title = title;

            var siteSettings = _siteService.GetSiteSettings();
            var pager        = new Pager(siteSettings, pagerParameters);

            var seoContentTypes = _seoService.ListSeoContentTypes();
            var query           = _contentManager.Query(VersionOptions.Latest, seoContentTypes.Select(type => type.Name).ToArray());

            if (!String.IsNullOrEmpty(rewriterViewModel.Q))
            {
                IPageOfItems <ISearchHit> searchHits = new PageOfItems <ISearchHit>(new ISearchHit[] { });
                try {
                    searchHits = _searchService.Query(rewriterViewModel.Q, pager.Page, pager.PageSize, false,
                                                      siteSettings.As <SearchSettingsPart>().SearchedFields,
                                                      searchHit => searchHit);
                    // Could use this: http://orchard.codeplex.com/workitem/18664
                    // Converting to List, because the expression should contain an ICollection
                    var hitIds = searchHits.Select(hit => hit.ContentItemId).ToList();
                    query.Where <CommonPartRecord>(record => hitIds.Contains(record.Id));
                }
                catch (Exception ex) {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    _orchardServices.Notifier.Error(T("Invalid search query: {0}", ex.Message));
                }
            }

            if (!string.IsNullOrEmpty(rewriterViewModel.TypeName))
            {
                var typeDefinition = seoContentTypes.SingleOrDefault(t => t.Name == rewriterViewModel.TypeName);
                if (typeDefinition == null)
                {
                    return(HttpNotFound());
                }

                rewriterViewModel.TypeDisplayName = typeDefinition.DisplayName;
                query = query.ForType(rewriterViewModel.TypeName);
            }

            switch (rewriterViewModel.Options.OrderBy)
            {
            case ContentsOrder.Modified:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc);
                break;

            case ContentsOrder.Published:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc);
                break;

            case ContentsOrder.Created:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc);
                break;
            }

            rewriterViewModel.Options.SelectedFilter = rewriterViewModel.TypeName;

            var pagerShape         = _shapeFactory.Pager(pager).TotalItemCount(query.Count());
            var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();

            var list = _shapeFactory.List();

            list.AddRange(
                pageOfContentItems.Select(
                    item => _prefixedEditorManager.BuildShape(item, (content => _contentManager.BuildDisplay(content, "SeoSummaryAdmin-" + rewriterViewModel.RewriterType)))
                    )
                );

            dynamic viewModel = _shapeFactory.ViewModel()
                                .ContentItems(list)
                                .Options(rewriterViewModel.Options)
                                .Pager(pagerShape);

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation, despite
            // being it highly unlikely with Onestop, just in case...
            return(View((object)viewModel));
        }