public IList <InformationPictureInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select InformationId,PictureId from InformationPicture order by LastUpdatedDate desc " ); IList <InformationPictureInfo> list = new List <InformationPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { InformationPictureInfo model = new InformationPictureInfo(); model.InformationId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <InformationPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select InformationId,PictureId from InformationPicture "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <InformationPictureInfo> list = new List <InformationPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { InformationPictureInfo model = new InformationPictureInfo(); model.InformationId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <InformationPictureInfo> 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, InformationId,PictureId from InformationPicture " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <InformationPictureInfo> list = new List <InformationPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { InformationPictureInfo model = new InformationPictureInfo(); model.InformationId = reader.GetGuid(1); model.PictureId = reader.GetGuid(2); list.Add(model); } } } return(list); }
public InformationPictureInfo GetModel(object InformationId) { InformationPictureInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 InformationId,PictureId from InformationPicture where InformationId = @InformationId " ); SqlParameter parm = new SqlParameter("@InformationId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(InformationId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm)) { if (reader != null) { if (reader.Read()) { model = new InformationPictureInfo(); model.InformationId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); } } } return(model); }
public int Insert(InformationPictureInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"insert into InformationPicture (PictureId) values (@PictureId) " ); SqlParameter[] parms = { new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
public int Update(InformationPictureInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update InformationPicture set PictureId = @PictureId where InformationId = @InformationId " ); SqlParameter[] parms = { new SqlParameter("@InformationId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.InformationId; parms[1].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
public void SaveInformation(HttpContext context) { try { string id = context.Request.Form["ctl00$cphMain$hId"].Trim(); string sTitle = context.Request.Form["ctl00$cphMain$txtTitle"].Trim(); string sSummary = context.Request.Form["ctl00$cphMain$txtSummary"].Trim(); string sSource = context.Request.Form["ctl00$cphMain$txtSource"].Trim(); string sRemark = context.Request.Form["ctl00$cphMain$txtRemark"].Trim(); string sContent = context.Request.Form["content"].Trim(); string sIsDisable = context.Request.Form["isDisable"].Trim(); string sViewType = context.Request.Form["rdViewType"].Trim(); string sSort = context.Request.Form["ctl00$cphMain$txtSort"].Trim(); sSort = sSort == "" ? "0" : sSort; string sViewCount = context.Request.Form["ctl00$cphMain$txtViewCount"].Trim(); sViewCount = sViewCount == "" ? "0" : sViewCount; string sPictureIdList = context.Request.Form["pictureId"].TrimEnd(','); string sIsPush = context.Request.Form["isPush"].Trim(); sContent = HttpUtility.HtmlDecode(sContent); Guid gId = Guid.Empty; if (id != "") { Guid.TryParse(id, out gId); } InformationInfo model = new InformationInfo(); model.LastUpdatedDate = DateTime.Now; model.Remark = sRemark; model.Id = gId; model.Title = sTitle; model.Summary = sSummary; model.Source = sSource; model.ContentText = sContent; model.Sort = int.Parse(sSort); model.ViewCount = int.Parse(sViewCount); model.ViewType = byte.Parse(sViewType); model.IsDisable = bool.Parse(sIsDisable); model.IsPush = bool.Parse(sIsPush); if (string.IsNullOrWhiteSpace(model.ContentText)) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } Information bll = new Information(); InformationPicture bllPP = new InformationPicture(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); if (effect > 0) { bllPP.Delete(model.Id); if (!string.IsNullOrWhiteSpace(sPictureIdList)) { foreach (string sPictureId in sPictureIdList.Split(',')) { InformationPictureInfo infoPP = new InformationPictureInfo(); Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); infoPP.InformationId = model.Id; infoPP.PictureId = pictureId; bllPP.InsertModel(infoPP); } } } } else { model.LastUpdatedDate = DateTime.Now; Guid anformationId = bll.InsertByOutput(model); if (!anformationId.Equals(Guid.Empty)) { effect = 1; if (!string.IsNullOrWhiteSpace(sPictureIdList)) { foreach (string sPictureId in sPictureIdList.Split(',')) { InformationPictureInfo infoPP = new InformationPictureInfo(); Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); infoPP.InformationId = anformationId; infoPP.PictureId = pictureId; bllPP.InsertModel(infoPP); } } } } 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 (model.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>", "xwfb", "", model.Title, "1"); 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 + "\"}"); } }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(InformationPictureInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(InformationPictureInfo model) { return(dal.Insert(model)); }