Exemplo n.º 1
0
        public static PollInfo GetPollInfo(int siteId, int channelId, int contentId)
        {
            var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId);
            var pollInfo     = pollInfoList.FirstOrDefault(x => x.ChannelId == channelId && x.ContentId == contentId) ??
                               Repository.CreateDefaultPoll(siteId, channelId, contentId);

            return(pollInfo ?? Repository.CreateDefaultPoll(siteId, channelId, contentId));
        }
Exemplo n.º 2
0
        public static PollInfo GetPollInfo(int siteId, int pollId)
        {
            var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId);

            return(pollInfoList.FirstOrDefault(x => x.Id == pollId));
        }
Exemplo n.º 3
0
        public static List <PollInfo> GetPollInfoList(int siteId, int channelId)
        {
            var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId);

            return(pollInfoList.Where(pollInfo => pollInfo.ChannelId == channelId).OrderBy(pollInfo => pollInfo.Taxis == 0 ? int.MaxValue : pollInfo.Taxis).ToList());
        }
Exemplo n.º 4
0
 public static void ClearCache(int siteId)
 {
     PollManagerCache.Clear(siteId);
 }
Exemplo n.º 5
0
        //        public static string GetTemplateHtml(string templateType, string directoryName)
        //        {
        //            var htmlPath = Context.PluginApi.GetPluginPath(PollUtils.PluginId, $"templates/{directoryName}/index.html");

        //            var html = CacheUtils.Get<string>(htmlPath);
        //            if (html != null) return html;

        //            html = PollUtils.ReadText(htmlPath);
        //            var startIndex = html.IndexOf("<body", StringComparison.Ordinal) + 5;
        //            var length = html.IndexOf("</body>", StringComparison.Ordinal) - startIndex;
        //            html = html.Substring(startIndex, length);
        //            html = html.Substring(html.IndexOf('\n'));

        ////            var jsPath = Context.PluginApi.GetPluginPath(PollUtils.PluginId, $"assets/js/{templateType}.js");
        ////            var javascript = PollUtils.ReadText(jsPath);
        ////            html = html.Replace(
        ////                $@"<script src=""../../assets/js/{templateType}.js"" type=""text/javascript""></script>",
        ////                $@"<script type=""text/javascript"">
        ////{javascript}
        ////</script>");
        //            html = html.Replace("../../", "{stl.rootUrl}/SiteFiles/plugins/SS.Poll/");
        //            html = html.Replace("../", "{stl.rootUrl}/SiteFiles/plugins/SS.Poll/templates/");

        //            CacheUtils.InsertHours(htmlPath, html, 1);
        //            return html;
        //        }

        public static void UpdateCache(PollInfo pollInfo)
        {
            PollManagerCache.Update(pollInfo);
        }
Exemplo n.º 6
0
        public static PollInfo GetPollInfo(int siteId, string title)
        {
            var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId);

            return(pollInfoList.FirstOrDefault(x => x.Title == title));
        }