public IList <ActivityPictureNewInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select ActivityId,PictureId from ActivityPictureNew order by LastUpdatedDate desc " ); IList <ActivityPictureNewInfo> list = new List <ActivityPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { ActivityPictureNewInfo model = new ActivityPictureNewInfo(); model.ActivityId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <ActivityPictureNewInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, ActivityId,PictureId from ActivityPictureNew " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <ActivityPictureNewInfo> list = new List <ActivityPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { ActivityPictureNewInfo model = new ActivityPictureNewInfo(); model.ActivityId = reader.GetGuid(1); model.PictureId = reader.GetGuid(2); list.Add(model); } } } return(list); }
public IList <ActivityPictureNewInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select ActivityId,PictureId from ActivityPictureNew "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <ActivityPictureNewInfo> list = new List <ActivityPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { ActivityPictureNewInfo model = new ActivityPictureNewInfo(); model.ActivityId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public ActivityPictureNewInfo GetModel(object ActivityId) { ActivityPictureNewInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 ActivityId,PictureId from ActivityPictureNew where ActivityId = @ActivityId " ); SqlParameter parm = new SqlParameter("@ActivityId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(ActivityId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm)) { if (reader != null) { while (reader.Read()) { model = new ActivityPictureNewInfo(); model.ActivityId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); } } } return(model); }
public int Update(ActivityPictureNewInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update ActivityPictureNew set PictureId = @PictureId where ActivityId = @ActivityId " ); SqlParameter[] parms = { new SqlParameter("@ActivityId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.ActivityId; parms[1].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
public int Insert(ActivityPictureNewInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"insert into ActivityPictureNew (ActivityId,PictureId) values (@ActivityId,@PictureId) " ); SqlParameter[] parms = { new SqlParameter("@ActivityId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.ActivityId; parms[1].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(ActivityPictureNewInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(ActivityPictureNewInfo model) { return(dal.Insert(model)); }
public void SaveActivitySubject(HttpContext context) { try { string id = context.Request.Form["ctl00$cphMain$hId"].Trim(); string sTitle = context.Request.Form["ctl00$cphMain$txtTitle"].Trim(); string sContent = context.Request.Form["content"].Trim(); string sPictureId = context.Request.Form["pictureId"].Trim(); string startDate = context.Request.Form["ctl00$cphMain$startDate"].Trim(); string endDate = context.Request.Form["ctl00$cphMain$endDate"].Trim(); string sSort = context.Request.Form["ctl00$cphMain$txtSort"].Trim(); string sMaxVoteCount = context.Request.Form["ctl00$cphMain$txtMaxVoteCount"].Trim(); sMaxVoteCount = sMaxVoteCount == "" ? "0" : sMaxVoteCount; string sMaxSignUpCount = context.Request.Form["ctl00$cphMain$txtMaxSignUpCount"].Trim(); sMaxSignUpCount = sMaxSignUpCount == "" ? "0" : sMaxSignUpCount; string sActualSignUpCount = context.Request.Form["ctl00$cphMain$txtActualSignUpCount"].Trim(); sActualSignUpCount = sActualSignUpCount == "" ? "0" : sActualSignUpCount; string sUpdateSignUpCount = context.Request.Form["ctl00$cphMain$txtUpdateSignUpCount"].Trim(); sUpdateSignUpCount = sUpdateSignUpCount == "" ? "0" : sUpdateSignUpCount; string sViewCount = context.Request.Form["ctl00$cphMain$txtViewCount"].Trim(); sViewCount = sViewCount == "" ? "0" : sViewCount; string sSignUpRule = context.Request.Form["signUpRule"].Trim(); string sHideAttr = context.Request.Form["hideAttr"].Trim(); string sIsPrize = context.Request.Form["isPrize"].Trim(); string sPrizeProbability = context.Request.Form["ctl00$cphMain$txtPrizeProbability"].Trim(); sPrizeProbability = sPrizeProbability == "" ? "0" : sPrizeProbability; string sPrizeRule = context.Request.Form["PrizeRule"].Trim(); string sIsDisable = context.Request.Form["isDisable"].Trim(); bool isPush = bool.Parse(context.Request.Form["isPush"].Trim()); sContent = HttpUtility.HtmlDecode(sContent); sSignUpRule = HttpUtility.HtmlDecode(sSignUpRule); sPrizeRule = HttpUtility.HtmlDecode(sPrizeRule); Guid gId = Guid.Empty; if (id != "") { Guid.TryParse(id, out gId); } Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); ActivitySubjectNewInfo model = new ActivitySubjectNewInfo(); model.LastUpdatedDate = DateTime.Now; model.Remark = ""; model.Id = gId; model.Title = sTitle; model.ContentText = sContent; model.StartDate = DateTime.Parse(startDate); model.EndDate = DateTime.Parse(endDate); model.Sort = int.Parse(sSort); model.MaxVoteCount = int.Parse(sMaxVoteCount); model.MaxSignUpCount = int.Parse(sMaxSignUpCount); model.SignUpCount = int.Parse(sActualSignUpCount); model.VirtualSignUpCount = int.Parse(sUpdateSignUpCount); model.ViewCount = int.Parse(sViewCount); model.SignUpRule = sSignUpRule; model.HiddenAttribute = sHideAttr.Length > 0 ? sHideAttr.TrimEnd(',') : sHideAttr; model.IsPrize = bool.Parse(sIsPrize); model.PrizeProbability = int.Parse(sPrizeProbability); model.PrizeRule = sPrizeRule; model.IsDisable = bool.Parse(sIsDisable); if (string.IsNullOrWhiteSpace(model.ContentText)) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } if (string.IsNullOrWhiteSpace(model.SignUpRule)) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } ActivitySubjectNew bll = new ActivitySubjectNew(); ActivityPictureNew bllAP = new ActivityPictureNew(); ActivityPictureNewInfo infoAP = new ActivityPictureNewInfo(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); if (effect > 0) { infoAP.ActivityId = model.Id; infoAP.PictureId = pictureId; bllAP.Delete(model.Id); bllAP.Insert(infoAP); } } else { model.InsertDate = DateTime.Now; Guid activityId = bll.InsertByOutput(model); if (!activityId.Equals(Guid.Empty)) { effect = 1; if (!pictureId.Equals(Guid.Empty)) { infoAP.ActivityId = activityId; infoAP.PictureId = pictureId; bllAP.Insert(infoAP); } } } if (effect == 110) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}"); return; } if (effect < 1) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Error + "\"}"); return; } if (isPush) { #region 推送信息到推送服务系统 try { PushContentService pushProxy = new PushContentService(); if (System.Configuration.ConfigurationManager.AppSettings["PushServiceUrl"] != null) { pushProxy.Url = System.Configuration.ConfigurationManager.AppSettings["PushServiceUrl"].ToString(); } string sxml = ""; sxml = string.Format(@"<XmlParameters><ReceivePushContent><PushType>{0}</PushType><PushContent>{1}</PushContent><Title>{2}</Title><PushParam>{3}</PushParam></ReceivePushContent></XmlParameters>", "hd", "", model.Title, "1##" + model.Id); //string rt = pushProxy.ReceivePushContent(sxml); pushProxy.ReceivePushContentAsync(sxml); } catch { } #endregion } context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\"}"); } catch (Exception ex) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}"); } }