public VoteContentInfo GetContentInfo(PublishmentSystemInfo publishmentSystemInfo, int contentId) { VoteContentInfo info = null; if (contentId > 0) { if (!string.IsNullOrEmpty(publishmentSystemInfo.AuxiliaryTableForVote)) { string sqlWhere = $"WHERE ID = {contentId}"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(publishmentSystemInfo.AuxiliaryTableForVote, SqlUtils.Asterisk, sqlWhere); using (var rdr = ExecuteReader(sqlSelect)) { if (rdr.Read()) { info = new VoteContentInfo(); BaiRongDataProvider.DatabaseDao.ReadResultsToExtendedAttributes(rdr, info); } rdr.Close(); } } } if (info != null) { info.AfterExecuteReader(); } return(info); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (this.contentID == 0) { var contentInfo = new VoteContentInfo(); try { InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = nodeID; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year) { FailMessage($"投票添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年"); return; } contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsChecked = false; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; if (string.IsNullOrEmpty(ddlEndDate.SelectedValue)) { contentInfo.EndDate = dtbEndDate.DateTime; } else { contentInfo.EndDate = TranslateUtils.ToDateTime(ddlEndDate.SelectedValue); } contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; var checkedLevel = 0; contentInfo.IsChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevel); contentInfo.CheckedLevel = checkedLevel; var contentID = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.Insert(voteOptionInfoArrayList); contentInfo.Id = contentID; } catch (Exception ex) { FailMessage(ex, $"投票添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentInfo.Id); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentInfo.Id, "添加投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, nodeID, contentInfo.Id, returnUrl)); } else { var contentInfo = DataProvider.VoteContentDao.GetContentInfo(PublishmentSystemInfo, contentID); try { InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.LastEditUserName = Body.AdministratorName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; contentInfo.EndDate = dtbEndDate.DateTime; contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; DataProvider.ContentDao.Update(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.UpdateVoteOptionInfoArrayList(PublishmentSystemId, nodeID, contentID, voteOptionInfoArrayList); } catch (Exception ex) { FailMessage(ex, $"投票修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentID); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentID, "修改投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(returnUrl); } } }
public VoteTemplate(PublishmentSystemInfo publishmentSystemInfo, int nodeId, VoteContentInfo contentInfo) { this._publishmentSystemInfo = publishmentSystemInfo; this._nodeId = nodeId; this._contentInfo = contentInfo; }