public IEnumerable <CasePostPart> Get(CasePart casePart, int skip, int count)
 {
     return(Get(casePart, skip, count, VersionOptions.Published)
            .OrderByDescending(attrib => attrib.Get <CasePostAttribPart>().CaseYear)
            //    .OrderByDescending(attrib => attrib.Get<CasePostAttribPart>().CaseNumber)
            );
 }
 public int PostCount(CasePart casePart, VersionOptions versionOptions)
 {
     return(_contentManager.Query(versionOptions, "CasePost")
            .Join <CommonPartRecord>().Where(
                cr => cr.Container.Id == casePart.Id)
            .Count());
 }
 public IEnumerable <CasePostPart> Get(CasePart casePart, int skip, int count, VersionOptions versionOptions)
 {
     return(GetCaseQuery(casePart, versionOptions)
            .Slice(skip, count)
            .ToList()
            .Select(ci => ci.As <CasePostPart>()));
 }
        public static string CasesYearAction(this UrlHelper urlHelper, CasePart cAsePart, int year)
        {
            Orchard.Autoroute.Models.AutoroutePart asa = cAsePart.Get <Orchard.Autoroute.Models.AutoroutePart>();
            string autoRoutroot = asa.Path;

            return(autoRoutroot + "/" + year);
        }
        public static string GetRoortAction(this UrlHelper urlHelper, CasePart cAsePart)
        {
            Orchard.Autoroute.Models.AutoroutePart asa = cAsePart.Get <Orchard.Autoroute.Models.AutoroutePart>();
            string autoRoutroot = asa.Path;

            return(autoRoutroot);
        }
示例#6
0
        private XRpcArray MetaWecAseGetRecentPosts(
            UrlHelper urlHelper,
            string cAseId,
            string userName,
            string password,
            int numberOfPosts,
            IEnumerable <IXmlRpcDriver> drivers)
        {
            IUser user = ValidateUser(userName, password);

            // User needs to at least have permission to edit its own cAse posts to access the service
            _authorizationService.CheckAccess(Permissions.EditCasePost, user, null);

            CasePart cAse = _contentManager.Get <CasePart>(Convert.ToInt32(cAseId));

            if (cAse == null)
            {
                throw new ArgumentException();
            }

            var array = new XRpcArray();

            foreach (var cAsePost in _cAsePostService.Get(cAse, 0, numberOfPosts, VersionOptions.Latest))
            {
                var postStruct = CreateCaseStruct(cAsePost, urlHelper);

                foreach (var driver in drivers)
                {
                    driver.Process(postStruct);
                }

                array.Add(postStruct);
            }
            return(array);
        }
        public IEnumerable <CasePostPart> Get(CasePart cAsePart, int year, int skip, int pageSize)
        {
            IEnumerable <CasePostPart> cnt2 = Get(cAsePart, skip, pageSize, VersionOptions.Published)
                                              .Where(attrib => attrib.Get <CasePostAttribPart>().CaseYear == year)
                                              .OrderByDescending(attrib => attrib.Get <CasePostAttribPart>().CaseYear)
                                              .OrderByDescending(attrib => attrib.Get <CasePostAttribPart>().CaseNumber)
            ;

            return(cnt2);
        }
        private IContentQuery <ContentItem, CommonPartRecord> GetCaseQuery(CasePart cAse, VersionOptions versionOptions)
        {
            var cnt = _contentManager.Query(versionOptions, "CasePost")
                      .Join <CommonPartRecord>().Where(
                cr => cr.Container.Id == cAse.Id).OrderByDescending(cr => cr.CreatedUtc)
            ;



            return(cnt);
        }
        public static string CasesAutoroute(this UrlHelper urlHelper, CasePart cAsePart, int year, int casenum)
        {
            Orchard.Autoroute.Models.AutoroutePart asa = cAsePart.Get <Orchard.Autoroute.Models.AutoroutePart>();
            string autoRoutroot = asa.Path;

            if (urlHelper.RequestContext.HttpContext.Request.RawUrl.ToString().Length > 4)
            {
                return(urlHelper.RequestContext.HttpContext.Request.RawUrl + autoRoutroot + "/" + year + "/" + casenum);
            }
            return(autoRoutroot + "/" + year + "/" + casenum);
        }
示例#10
0
        public IEnumerable <KeyValuePair <ArchiveData, int> > GetArchives(CasePart cAsePart)
        {
            var query =
                from bar in _caseArchiveRepository.Table
                where bar.CasePart.Id == cAsePart.Id
                orderby bar.Year descending, bar.Month descending
            select bar;

            return
                (query.ToList().Select(
                     bar =>
                     new KeyValuePair <ArchiveData, int>(new ArchiveData(string.Format("{0}/{1}", bar.Year, bar.Month)),
                                                         bar.PostCount)));
        }
        public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageCases, T("Not allowed to create case")))
            {
                return(new HttpUnauthorizedResult());
            }

            CasePart cAse = Services.ContentManager.New <CasePart>("Case");

            if (cAse == null)
            {
                return(HttpNotFound());
            }

            var model = Services.ContentManager.BuildEditor(cAse);

            return(View(model));
        }
示例#12
0
        public ActionResult Rsd(string path)
        {
            Logger.Debug("RSD requested");

            var cAsePath = _rsdConstraint.FindPath(path);

            if (cAsePath == null)
            {
                return(HttpNotFound());
            }

            CasePart cAsePart = _cAseService.Get(cAsePath);

            if (cAsePart == null)
            {
                return(HttpNotFound());
            }

            const string manifestUri = "http://archipelago.phrasewise.com/rsd";

            var urlHelper = new UrlHelper(ControllerContext.RequestContext, _routeCollection);
            var url       = urlHelper.AbsoluteAction("", "", new { Area = "XmlRpc" });

            var options = new XElement(
                XName.Get("service", manifestUri),
                new XElement(XName.Get("engineName", manifestUri), "Orchard CMS"),
                new XElement(XName.Get("engineLink", manifestUri), "http://orchardproject.net"),
                new XElement(XName.Get("homePageLink", manifestUri), "http://orchardproject.net"),
                new XElement(XName.Get("apis", manifestUri),
                             new XElement(XName.Get("api", manifestUri),
                                          new XAttribute("name", "MetaWecAse"),
                                          new XAttribute("preferred", true),
                                          new XAttribute("apiLink", url),
                                          new XAttribute("cAseID", cAsePart.Id))));

            var doc = new XDocument(new XElement(
                                        XName.Get("rsd", manifestUri),
                                        new XAttribute("version", "1.0"),
                                        options));

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            return(Content(doc.ToString(), "text/xml"));
        }
示例#13
0
        public ActionResult ListByArchive(string path)
        {
            var cAsePath = _archiveConstraint.FindPath(path);
            var archive  = _archiveConstraint.FindArchiveData(path);

            if (cAsePath == null)
            {
                return(HttpNotFound());
            }

            if (archive == null)
            {
                return(HttpNotFound());
            }

            CasePart cAsePart = _cAseService.Get(cAsePath);

            if (cAsePart == null)
            {
                return(HttpNotFound());
            }


            if (archive.ToDateTime() == DateTime.MinValue)
            {
                // render the archive data
                return(new ShapeResult(this, Shape.Parts_Cases_CaseArchives(Case: cAsePart, Archives: _cAsePostService.GetArchives(cAsePart))));
            }

            var list = Shape.List();

            list.AddRange(_cAsePostService.Get(cAsePart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary")));

            _feedManager.Register(cAsePart, _services.ContentManager.GetItemMetadata(cAsePart).DisplayText);

            var viewModel = Shape.ViewModel()
                            .ContentItems(list)
                            .Case(cAsePart)
                            .ArchiveData(archive);

            return(View(viewModel));
        }
示例#14
0
        public virtual void Visit(CasePart casePart)
        {
            Result.Append("(CASE ");

            foreach (var when in casePart.Whens)
            {
                Result.Append("\n").Append("WHEN ");
                when.Item1.Accept(this);
                Result.Append(" THEN ");
                when.Item2.Accept(this);
            }

            if (casePart.ElsePart != null)
            {
                Result.Append("\n").Append("ELSE ");
                casePart.ElsePart.Accept(this);
            }

            Result.Append(" END) ");
        }
示例#15
0
        public static void Register(this IFeedManager feedManager, CasePart casePart, string blogTitle)
        {
            if (String.IsNullOrWhiteSpace(casePart.FeedProxyUrl))
            {
                feedManager.Register(blogTitle, "rss", new RouteValueDictionary {
                    { "containerid", casePart.Id }
                });
            }
            else
            {
                feedManager.Register(blogTitle, "rss", casePart.FeedProxyUrl);
            }

            if (casePart.EnableCommentsFeed)
            {
                feedManager.Register(blogTitle + " - Comments", "rss", new RouteValueDictionary {
                    { "commentedoncontainer", casePart.Id }
                });
            }
        }
示例#16
0
        private XRpcArray MetaWecAseGetUserCases(UrlHelper urlHelper,
                                                 string userName,
                                                 string password)
        {
            IUser user = ValidateUser(userName, password);

            XRpcArray array = new XRpcArray();

            foreach (CasePart cAse in _cAseService.Get())
            {
                // User needs to at least have permission to edit its own cAse posts to access the service
                if (_authorizationService.TryCheckAccess(Permissions.EditCasePost, user, cAse))
                {
                    CasePart cAsePart = cAse;
                    array.Add(new XRpcStruct()
                              .Set("url", urlHelper.AbsoluteAction(() => urlHelper.Case(cAsePart)))
                              .Set("cAseid", cAse.Id)
                              .Set("cAseName", _contentManager.GetItemMetadata(cAse).DisplayText));
                }
            }

            return(array);
        }
示例#17
0
        public IEnumerable <CasePostPart> Get(CasePart cAsePart, ArchiveData archiveData)
        {
            var query = GetCaseQuery(cAsePart, VersionOptions.Published);

            /* if (archiveData.Day > 0) {
             *   var dayDate = new DateTime(archiveData.Year, archiveData.Month, archiveData.Day);
             *
             *   query = query.Where(cr => cr.CreatedUtc >= dayDate && cr.CreatedUtc < dayDate.AddDays(1));
             * }
             * else if (archiveData.Month > 0)
             * {
             *   var monthDate = new DateTime(archiveData.Year, archiveData.Month, 1);
             *
             *   query = query.Where(cr => cr.CreatedUtc >= monthDate && cr.CreatedUtc < monthDate.AddMonths(1));
             * }
             * else {
             *   var yearDate = new DateTime(archiveData.Year, 1, 1);
             *
             *   query = query.Where(cr => cr.CreatedUtc >= yearDate && cr.CreatedUtc < yearDate.AddYears(1));
             * }
             */
            return(query.List().Select(ci => ci.As <CasePostPart>()));
        }
        public ActionResult Item(int caseId, PagerParameters pagerParameters)
        {
            IUser   user    = _workContextAccessor.GetContext().CurrentUser;
            dynamic dynUser = user.ContentItem;

            if (dynUser.UserRolesPart != null)
            {
                IEnumerable <string> userRoles = dynUser.UserRolesPart.Roles;
                //  isInRole = userRoles.Any(roles.Contains);
            }

            Pager    pager    = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            CasePart casePart = _caseService.Get(caseId, VersionOptions.Latest).As <CasePart>();

            if (casePart == null)
            {
                return(HttpNotFound());
            }

            var casePosts = _casePostService.Get(casePart, pager.GetStartIndex(), pager.PageSize, VersionOptions.Latest);

            //filtrt all not for intern


            //   var cAses = _cAseService.Get().Where(x => _authorizationService.TryCheckAccess(Permissions.MetaListCases, _workContextAccessor.GetContext().CurrentUser, x)).ToArray();
            //    bool isLawInter=_authorizationService.TryCheckAccess(Permissions.ListunpublishedCases, _workContextAccessor.GetContext().CurrentUser, casePart);
            //  if (isLawInter)
            // //   {
            //         casePosts = casePosts.Where(pub => pub.IsPublished == false).Where(  pub=> _casePostService.isInterAcquiered(pub.ContentItem.Id));
            //   }



            casePosts = casePosts.ToArray();
            foreach (CasePostPart postpart in casePosts)
            {
                _casePostService.GetCurrentState(postpart);
            }

            //_authorizationService.TryCheckAccess()


            var casePostsShapes = casePosts.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")).ToArray();


            var cAse = Services.ContentManager.BuildDisplay(casePart, "DetailAdmin");

            var list = Shape.List();

            list.AddRange(casePostsShapes);
            cAse.Content.Add(Shape.Parts_Cases_CasePost_ListAdmin(ContentItems: list), "5");

            var totalItemCount = _casePostService.PostCount(casePart, VersionOptions.Latest);

            //if (isLawInter)
            //   totalItemCount = _casePostService.PostCount(casePart, VersionOptions.Draft);

            cAse.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");

            return(View(cAse));
        }
示例#19
0
        private int MetaWecAseNewPost(
            string cAseId,
            string userName,
            string password,
            XRpcStruct content,
            bool publish,
            IEnumerable <IXmlRpcDriver> drivers)
        {
            IUser user = ValidateUser(userName, password);

            // User needs permission to edit or publish its own cAse posts
            _authorizationService.CheckAccess(publish ? Permissions.PublishCasePost : Permissions.EditCasePost, user, null);

            CasePart cAse = _contentManager.Get <CasePart>(Convert.ToInt32(cAseId));

            if (cAse == null)
            {
                throw new ArgumentException();
            }

            var title       = content.Optional <string>("title");
            var description = content.Optional <string>("description");
            var slug        = content.Optional <string>("wp_slug");

            var cAsePost = _contentManager.New <CasePostPart>("CasePost");

            // BodyPart
            if (cAsePost.Is <BodyPart>())
            {
                cAsePost.As <BodyPart>().Text = description;
            }

            //CommonPart
            if (cAsePost.Is <ICommonPart>())
            {
                cAsePost.As <ICommonPart>().Owner     = user;
                cAsePost.As <ICommonPart>().Container = cAse;
            }

            //TitlePart
            if (cAsePost.Is <TitlePart>())
            {
                cAsePost.As <TitlePart>().Title = HttpUtility.HtmlDecode(title);
            }

            //AutoroutePart
            dynamic dCasePost = cAsePost;

            if (dCasePost.AutoroutePart != null)
            {
                dCasePost.AutoroutePart.DisplayAlias = slug;
            }

            _contentManager.Create(cAsePost, VersionOptions.Draft);

            // try to get the UTC timezone by default
            var publishedUtc = content.Optional <DateTime?>("date_created_gmt");

            if (publishedUtc == null)
            {
                // take the local one
                publishedUtc = content.Optional <DateTime?>("dateCreated");
            }
            else
            {
                // ensure it's read as a UTC time
                publishedUtc = new DateTime(publishedUtc.Value.Ticks, DateTimeKind.Utc);
            }

            if (publish && (publishedUtc == null || publishedUtc <= DateTime.UtcNow))
            {
                _cAsePostService.Publish(cAsePost);
            }

            if (publishedUtc != null)
            {
                cAsePost.As <CommonPart>().CreatedUtc = publishedUtc;
            }

            foreach (var driver in drivers)
            {
                driver.Process(cAsePost.Id);
            }

            return(cAsePost.Id);
        }
示例#20
0
        public void RebuildArchive(CasePart casePart)
        {
            var first = _contentManager.Query <CasePostPart>().Where <CommonPartRecord>(bp => bp.Container.Id == casePart.Id).OrderBy <CommonPartRecord>(x => x.CreatedUtc).Slice(0, 1).FirstOrDefault();

            if (first == null)
            {
                return;
            }

            var last = _contentManager.Query <CasePostPart>().Where <CommonPartRecord>(bp => bp.Container.Id == casePart.Id).OrderByDescending <CommonPartRecord>(x => x.CreatedUtc).Slice(0, 1).FirstOrDefault();

            DateTime?start = DateTime.MaxValue;

            if (first.As <CommonPart>() != null)
            {
                start = first.As <CommonPart>().CreatedUtc;
            }

            DateTime?end = DateTime.MinValue;

            if (last.As <CommonPart>() != null)
            {
                end = last.As <CommonPart>().CreatedUtc;
            }

            // delete previous archive records
            foreach (var record in _caseArchiveRepository.Table.Where(x => x.CasePart.Id == casePart.Id))
            {
                _caseArchiveRepository.Delete(record);
            }

            if (!start.HasValue || !end.HasValue)
            {
                return;
            }

            // get the time zone for the current request
            var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;

            // build a collection of all the post dates
            var casePostDates = new List <DateTime>();
            var casePosts     = _contentManager.Query <CasePostPart>().Where <CommonPartRecord>(bp => bp.Container.Id == casePart.Id);

            foreach (var casePost in casePosts.List())
            {
                if (casePost.As <CommonPart>() != null)
                {
                    if (casePost.As <CommonPart>().CreatedUtc.HasValue)
                    {
                        DateTime timeZoneAdjustedCreatedDate = TimeZoneInfo.ConvertTimeFromUtc(casePost.As <CommonPart>().CreatedUtc.Value, timeZone);
                        casePostDates.Add(timeZoneAdjustedCreatedDate);
                    }
                }
            }

            for (int year = start.Value.Year; year <= end.Value.Year; year++)
            {
                for (int month = 1; month <= 12; month++)
                {
                    var fromDateUtc = new DateTime(year, month, 1);
                    var from        = TimeZoneInfo.ConvertTimeFromUtc(fromDateUtc, timeZone);
                    var to          = TimeZoneInfo.ConvertTimeFromUtc(fromDateUtc.AddMonths(1), timeZone);

                    // skip the first months of the first year until a month has posts
                    //  for instance, if started posting in May 2000, don't write counts for Jan 200 > April 2000... start May 2000
                    if (from < TimeZoneInfo.ConvertTimeFromUtc(new DateTime(start.Value.Year, start.Value.Month, 1), timeZone))
                    {
                        continue;
                    }
                    // skip the last months of the last year if no posts
                    //  for instance, no need to have archives for months in the future
                    if (to > end.Value.AddMonths(1))
                    {
                        continue;
                    }

                    //var count = _contentManager.Query<CasePostPart>().Where<CommonPartRecord>(x => x.CreatedUtc.Value >= from && x.CreatedUtc.Value < to).Count();
                    var count = casePostDates.Count(bp => bp >= @from && bp < to);

                    var newArchiveRecord = new CasePartArchiveRecord {
                        CasePart = casePart.ContentItem.Record, Year = year, Month = month, PostCount = count
                    };
                    _caseArchiveRepository.Create(newArchiveRecord);
                }
            }
        }
 public static string CaseLiveWriterManifest(this UrlHelper urlHelper, CasePart cAsePart)
 {
     return(urlHelper.AbsoluteAction(() => urlHelper.Action("Manifest", "LiveWriter", new { area = "XmlRpc" })));
 }
示例#22
0
 public int PostCount(CasePart casePart)
 {
     return(PostCount(casePart, VersionOptions.Published));
 }
 public static string CaseRsd(this UrlHelper urlHelper, CasePart cAsePart)
 {
     return(urlHelper.AbsoluteAction(() => urlHelper.Action("Rsd", "RemoteCasePublishing", new { path = cAsePart.As <IAliasAspect>().Path + "/rsd", area = "LawBookCases.Module" })));
 }
        public static string CaseArchiveYear(this UrlHelper urlHelper, CasePart cAsePart, int year)
        {
            var cAsePath = cAsePart.As <IAliasAspect>().Path;

            return(urlHelper.Action("ListByArchive", "CasePost", new { path = (string.IsNullOrWhiteSpace(cAsePath) ? "archive/" : cAsePath + "/archive/") + year.ToString(), area = "LawBookCases.Module" }));
        }
示例#25
0
 public IEnumerable <CasePostPart> Get(CasePart casePart, VersionOptions versionOptions)
 {
     return(GetCaseQuery(casePart, versionOptions).List().Select(ci => ci.As <CasePostPart>()));
 }
示例#26
0
 public IEnumerable <CasePostPart> Get(CasePart casePart)
 {
     return(Get(casePart, VersionOptions.Published));
 }
        public static string CaseArchiveDay(this UrlHelper urlHelper, CasePart cAsePart, int year, int month, int day)
        {
            var cAsePath = cAsePart.As <IAliasAspect>().Path;

            return(urlHelper.Action("ListByArchive", "CasePost", new { path = (string.IsNullOrWhiteSpace(cAsePath) ? "archive/" : cAsePath + "/archive/") + string.Format("{0}/{1}/{2}", year, month, day), area = "LawBookCases.Module" }));
        }
 public static string CaseForAdmin(this UrlHelper urlHelper, CasePart cAsePart)
 {
     return(urlHelper.Action("Item", "CaseAdmin", new { cAseId = cAsePart.Id, area = "LawBookCases.Module" }));
 }
 public static string CasePostCreate(this UrlHelper urlHelper, CasePart cAsePart)
 {
     return(urlHelper.Action("Create", "CasePostAdmin", new { cAseId = cAsePart.Id, area = "LawBookCases.Module" }));
 }