public static int UpdateHomePagePopup(SqlConnection conn, HomePagePopup model) { const string sql1 = @"SELECT PKID FROM Configuration.dbo.HomePagePopupConfig WITH ( NOLOCK ) WHERE Sort = @Sort "; var sqlParam1 = new[] { new SqlParameter("@Sort", model.Sort) }; var pkid = SqlHelper.ExecuteScalar(conn, CommandType.Text, sql1, sqlParam1); if (pkid != null && (int)pkid != model.PKID) { return(-1); } const string sql = @"UPDATE Configuration.dbo.HomePagePopupConfig SET Description=@Description, ImageUrl=@ImageUrl, LinkUrl=@LinkUrl, MGPageUrl=@MGPageUrl, MiniGramId=@MiniGramId, Channel=@Channel, Position=@Position, TargetGroups=@TargetGroups, Sort=@Sort, Period=@Period, StartVersion=@StartVersion, EndVersion=@EndVersion, StartDateTime=@StartDateTime, EndDateTime=@EndDateTime, IsEnabled=@IsEnabled, NoticeChannel=@NoticeChannel, NewNoticeChannel=@NewNoticeChannel WHERE PKID=@PKID"; var sqlParam = new[] { new SqlParameter("@PKID", model.PKID), new SqlParameter("@Description", model.Description), new SqlParameter("@ImageUrl", model.ImageUrl), new SqlParameter("@LinkUrl", model.LinkUrl), new SqlParameter("@MGPageUrl", model.MGPageUrl), new SqlParameter("@MiniGramId", model.MiniGramId), new SqlParameter("@Channel", model.Channel), new SqlParameter("@Position", model.Position), new SqlParameter("@TargetGroups", model.TargetGroups), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Period", model.Period), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@StartDateTime", model.StartDateTime), new SqlParameter("@EndDateTime", model.EndDateTime), new SqlParameter("@IsEnabled", model.IsEnabled), new SqlParameter("@NoticeChannel", model.NoticeChannel), new SqlParameter("@NewNoticeChannel", model.NewNoticeChannel) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParam)); }
public int UpdateHomePagePopup(HomePagePopup model) { try { return(handler.UpdateHomePagePopup(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "UpdateHomepagePopup", ex); Logger.Log(Level.Error, exception, "UpdateHomepagePopup"); throw ex; } }
public static int InsertHomePagePopup(SqlConnection conn, HomePagePopup model) { const string sql1 = @"SELECT COUNT(0) FROM Configuration.dbo.HomePagePopupConfig WITH ( NOLOCK ) WHERE Sort = @Sort "; var sqlParam1 = new[] { new SqlParameter("@Sort", model.Sort) }; var count = (int)SqlHelper.ExecuteScalar(conn, CommandType.Text, sql1, sqlParam1); if (count > 0) { return(-1); } const string sql = @"INSERT INTO Configuration.dbo.HomePagePopupConfig (Description, ImageUrl, LinkUrl, Channel, Position, TargetGroups, Sort, Period, StartVersion, EndVersion, StartDateTime, EndDateTime, IsEnabled, CreateTime, Creator, NoticeChannel, NewNoticeChannel) VALUES( @Description, @ImageURL, @LinkUrl, @Channel, @Position, @TargetGroups, @Sort, @Period, @StartVersion, @EndVersion, @StartDateTime, @EndDateTime, @IsEnabled, GETDATE(), @Creator, @NoticeChannel, @NewNoticeChannel ); SELECT @@IDENTITY;"; var sqlParam = new[] { new SqlParameter("@Description", model.Description), new SqlParameter("@ImageUrl", model.ImageUrl), new SqlParameter("@LinkUrl", model.LinkUrl), new SqlParameter("@Channel", model.Channel), new SqlParameter("@Position", model.Position), new SqlParameter("@TargetGroups", model.TargetGroups), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Period", model.Period), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@StartDateTime", model.StartDateTime), new SqlParameter("@EndDateTime", model.EndDateTime), new SqlParameter("@IsEnabled", model.IsEnabled), new SqlParameter("@Creator", model.Creator), new SqlParameter("@NoticeChannel", model.NoticeChannel), new SqlParameter("@NewNoticeChannel", model.NewNoticeChannel) }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParam))); }
public int UpdateHomePagePopup(HomePagePopup model) { return(DalHomePagePopup.UpdateHomePagePopup(conn, model)); }
public int InsertHomePagePopup(HomePagePopup model) { return(DalHomePagePopup.InsertHomePagePopup(conn, model)); }
public JsonResult AddOrUpdate(HomePagePopup popup) { if (!string.IsNullOrWhiteSpace(popup.StartVersion)) { popup.StartVersion = popup.StartVersion.Trim(); } if (!string.IsNullOrWhiteSpace(popup.EndVersion)) { popup.EndVersion = popup.EndVersion.Trim(); } if (popup.PKID < 0) { var result = DownloadAppManager.InsertHomePagePopup(popup); if (result > 0) { var oprLog = new OprLog { ObjectID = result, ObjectType = "HPPopup", AfterValue = "优先级: " + popup.Sort + ", 周期:" + popup.Period + ", 目标群体:" + (string.IsNullOrWhiteSpace(popup.TargetGroups) ? "" : popup.TargetGroups), Author = HttpContext.User.Identity.Name, Operation = "新建弹窗" }; new OprLogManager().AddOprLog(oprLog); } if (popup.IsEnabled && popup.StartDateTime <= DateTime.Now && popup.EndDateTime >= DateTime.Now) { return(Json(result + ",1")); } return(Json(result + ",0")); } else { var result = DownloadAppManager.UpdateHomePagePopup(popup); if (result > 0) { if (popup.IsEnabled && popup.StartDateTime <= DateTime.Now && popup.EndDateTime >= DateTime.Now) { result = 2; } else { result = 1; } var oprLog = new OprLog { ObjectID = popup.PKID, ObjectType = "HPPopup", AfterValue = "优先级: " + popup.Sort + ", 周期:" + popup.Period + ", 目标群体:" + (string.IsNullOrWhiteSpace(popup.TargetGroups) ? "" : popup.TargetGroups), Author = HttpContext.User.Identity.Name, Operation = "更新弹窗" }; new OprLogManager().AddOprLog(oprLog); } return(Json(result)); } }