private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string inputTemplateString) { var parsedContent = string.Empty; pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BjTemplates); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BShowLoading); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BValidate); pageInfo.AddPageScriptsIfNotExists("SiteServer.CMS.Parser.StlElement", $@"<link href=""{SiteFilesAssets.Vote.GetStyleUrl(pageInfo.ApiUrl)}"" type=""text/css"" rel=""stylesheet"" /> "); var contentInfo = contextInfo.ContentInfo as VoteContentInfo; if (contentInfo == null && contextInfo.ContentId > 0) { contentInfo = DataProvider.VoteContentDao.GetContentInfo(pageInfo.PublishmentSystemInfo, contextInfo.ContentId); } if (contentInfo != null) { var voteTemplate = new VoteTemplate(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo); var contentBuilder = new StringBuilder(voteTemplate.GetTemplate(inputTemplateString)); StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo); parsedContent = contentBuilder.ToString(); } return(parsedContent); }
public IHttpActionResult Main(int publishmentSystemId, int channelId, int contentId) { try { var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); return(Ok(VoteTemplate.GetJsonString(publishmentSystemInfo, channelId, contentId, true, string.Empty))); } catch (Exception ex) { return(InternalServerError(ex)); } }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string theme, string inputTemplateString) { var parsedContent = string.Empty; var contentInfo = contextInfo.ContentInfo as VoteContentInfo; if (contentInfo == null && contextInfo.ContentID > 0) { contentInfo = DataProvider.VoteContentDao.GetContentInfo(pageInfo.PublishmentSystemInfo, contextInfo.ContentID); } if (contentInfo != null) { var voteTemplate = new VoteTemplate(pageInfo.PublishmentSystemInfo, contentInfo.NodeId, contentInfo); var contentBuilder = new StringBuilder(voteTemplate.GetTemplate(inputTemplateString)); StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo); parsedContent = contentBuilder.ToString(); } return(parsedContent); }
public void Main(int publishmentSystemId, int nodeId, int contentId) { var body = new RequestBody(); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); try { var contentInfo = DataProvider.VoteContentDao.GetContentInfo(publishmentSystemInfo, contentId); if ((contentInfo.EndDate - DateTime.Now).Seconds <= 0) { throw new Exception("对不起,投票已经结束"); } var cookieName = DataProvider.VoteOperationDao.GetCookieName(publishmentSystemId, nodeId, contentId); if (CookieUtils.IsExists(cookieName)) { throw new Exception("对不起,不能重复投票"); } var optionIdArrayList = TranslateUtils.StringCollectionToIntList(HttpContext.Current.Request.Form["voteOption_" + contentId]); foreach (int optionId in optionIdArrayList) { DataProvider.VoteOptionDao.AddVoteNum(optionId); } DataProvider.VoteOperationDao.Insert(new VoteOperationInfo(0, publishmentSystemId, nodeId, contentId, PageUtils.GetIpAddress(), body.UserName, DateTime.Now)); HttpContext.Current.Response.Write(VoteTemplate.GetCallbackScript(publishmentSystemInfo, nodeId, contentId, true, string.Empty)); CookieUtils.SetCookie(cookieName, true.ToString(), DateTime.MaxValue); } catch (Exception ex) { //HttpContext.Current.Response.Write(VoteTemplate.GetCallbackScript(publishmentSystemInfo, nodeId, contentId, false, ex.Message)); HttpContext.Current.Response.Write(VoteTemplate.GetCallbackScript(publishmentSystemInfo, nodeId, contentId, false, "程序出错。")); } HttpContext.Current.Response.End(); }