/// <summary> /// /// </summary> /// <param name="ds"></param> /// <returns></returns> public static feedbackInfo GetModelFromDs(DataSet ds) { feedbackInfo model = new feedbackInfo(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["userid"].ToString() != "") { model.userid = int.Parse(ds.Tables[0].Rows[0]["userid"].ToString()); } if (ds.Tables[0].Rows[0]["typeid"].ToString() != "") { model.typeid = (feedbacktype)int.Parse(ds.Tables[0].Rows[0]["typeid"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.cont = ds.Tables[0].Rows[0]["cont"].ToString(); if (ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = (feedbackstatus)int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } if (ds.Tables[0].Rows[0]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString()); } model.reply = ds.Tables[0].Rows[0]["reply"].ToString(); if (ds.Tables[0].Rows[0]["replyer"].ToString() != "") { model.replyer = int.Parse(ds.Tables[0].Rows[0]["replyer"].ToString()); } if (ds.Tables[0].Rows[0]["replytime"].ToString() != "") { model.replytime = DateTime.Parse(ds.Tables[0].Rows[0]["replytime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="uid"></param> /// <returns></returns> public feedbackInfo GetCacheModel(int id) { feedbackInfo model = new feedbackInfo(); string cacheKey = string.Format(CACHE_KEY, id); model = (feedbackInfo)viviapi.Cache.WebCache.GetCacheService().RetrieveObject(cacheKey); if (model == null) { IDictionary <string, object> sqldepparms = new Dictionary <string, object>(); sqldepparms.Add("id", id); SqlDependency sqlDep = DataBase.AddSqlDependency(cacheKey, SQL_TABLE, SQL_FIELDS, "[id]=@id", sqldepparms); model = GetModel(id); viviapi.Cache.WebCache.GetCacheService().AddObject(cacheKey, model); } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Update(feedbackInfo model) { try { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@userid", SqlDbType.Int, 4), new SqlParameter("@typeid", SqlDbType.TinyInt, 1), new SqlParameter("@title", SqlDbType.NVarChar, 50), new SqlParameter("@cont", SqlDbType.NVarChar, 200), new SqlParameter("@status", SqlDbType.TinyInt, 1), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@reply", SqlDbType.NVarChar, 50), new SqlParameter("@replyer", SqlDbType.Int, 4), new SqlParameter("@replytime", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.userid; parameters[2].Value = (int)model.typeid; parameters[3].Value = model.title; parameters[4].Value = model.cont; parameters[5].Value = (int)model.status; parameters[6].Value = model.addtime; parameters[7].Value = model.reply; parameters[8].Value = model.replyer; parameters[9].Value = model.replytime; bool success = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_feedback_update", parameters) > 0; if (success) { ClearCache(model.id); } return(success); } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(feedbackInfo model) { try { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@userid", SqlDbType.Int, 4), new SqlParameter("@typeid", SqlDbType.TinyInt, 1), new SqlParameter("@title", SqlDbType.NVarChar, 50), new SqlParameter("@cont", SqlDbType.NVarChar, 200), new SqlParameter("@status", SqlDbType.TinyInt, 1), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@reply", SqlDbType.NVarChar, 50), new SqlParameter("@replyer", SqlDbType.Int, 4), new SqlParameter("@replytime", SqlDbType.DateTime), new SqlParameter("@clientip", SqlDbType.VarChar, 20) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.userid; parameters[2].Value = model.typeid; parameters[3].Value = model.title; parameters[4].Value = model.cont; parameters[5].Value = model.status; parameters[6].Value = model.addtime; parameters[7].Value = model.reply; parameters[8].Value = model.replyer; parameters[9].Value = model.replytime; parameters[10].Value = model.clientip; DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_feedback_add", parameters); return((int)parameters[0].Value); } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(0); } }