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)); }
public static PollInfo GetPollInfo(int siteId, int pollId) { var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId); return(pollInfoList.FirstOrDefault(x => x.Id == pollId)); }
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()); }
public static void ClearCache(int siteId) { PollManagerCache.Clear(siteId); }
// 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); }
public static PollInfo GetPollInfo(int siteId, string title) { var pollInfoList = PollManagerCache.GetCachePollInfoList(siteId); return(pollInfoList.FirstOrDefault(x => x.Title == title)); }