public List<Model.Query.TrialRecordQuery> GetTrialRecordList(TrialRecordQuery store, out int totalCount) { try { return _ITrialRecordDao.GetTrialRecordList(store,out totalCount); } catch (Exception ex) { throw new Exception("TrialRecordMgr-->GetTrialRecordList-->" + ex.Message, ex); } }
public int TrialRecordUpdate(TrialRecordQuery query) { try { return _ITrialRecordDao.TrialRecordUpdate(query); } catch (Exception ex) { throw new Exception("TrialRecordMgr-->TrialRecordUpdate-->" + ex.Message, ex); } }
public TrialRecordQuery GetTrialRecordById(TrialRecordQuery query) { try { return _ITrialRecordDao.GetTrialRecordById(query); } catch (Exception ex) { throw new Exception("TrialRecordMgr-->GetTrialRecordById-->" + ex.Message, ex); } }
public List<Model.Query.TrialRecordQuery> GetTrialRecordList(TrialRecordQuery store, out int totalCount) { StringBuilder sql = new StringBuilder(); StringBuilder sqlWhere = new StringBuilder(); StringBuilder sqlCount = new StringBuilder(); StringBuilder sqlFrom = new StringBuilder(); totalCount = 0; sqlCount.Append("select count(tr.record_id) as totalCount "); sql.Append(" SELECT tr.record_id,tr.trial_id,tr.user_id,tr.apply_time,tr.`status` ,pat.`name`,pat.event_type,pat.paper_id,pat.event_id as trial_id,u.user_email,u.user_name "); sqlFrom.Append(" from trial_record tr "); sqlFrom.Append(" LEFT JOIN users u on u.user_id=tr.user_id "); sqlFrom.Append(" LEFT JOIN promotions_amount_trial pat on pat.id = tr.trial_id "); sqlWhere.Append(" where 1 =1 and apply_time<>'0001-01-01 00:00:00' and ! ISNULL(apply_time) "); sqlWhere.AppendFormat(" and tr.trial_id='{0}' ", store.trial_id); if (store.record_id != 0) { sqlWhere.AppendFormat(" and tr.record_id='{0}' ", store.record_id); } if (store.status != 0) { sqlWhere.AppendFormat(" and tr.status='{0}' ", store.status); } if (store.IsPage) { DataTable _dt = _access.getDataTable(sqlCount.ToString() + sqlFrom.ToString() + sqlWhere.ToString()); if (_dt != null && _dt.Rows.Count > 0) { totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]); } } sqlWhere.AppendFormat(" order by tr.record_id desc limit {0},{1};", store.Start, store.Limit); try { return _access.getDataTableForObj<TrialRecordQuery>(sql.ToString() + sqlFrom.ToString() + sqlWhere.ToString()); } catch (Exception ex) { throw new Exception("TrialRecordDao-->GetTrialRecordList-->" + ex.Message + sql.ToString() + sqlFrom.ToString() + sqlWhere.ToString(), ex); } }
public bool VerifyMaxCount(TrialRecordQuery query) { try { return _ITrialRecordDao.VerifyMaxCount(query); } catch (Exception ex) { throw new Exception("TrialRecordMgr-->VerifyMaxCount-->" + ex.Message, ex); } }
public HttpResponseBase VerifyMaxCount() { TrialRecordQuery query = new TrialRecordQuery(); string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["status"])) { query.status = Convert.ToInt32(Request.Params["status"]); } if (!string.IsNullOrEmpty(Request.Params["trial_id"])) { query.trial_id = Convert.ToInt32(Request.Params["trial_id"]); } _ITrialRecordMgr = new TrialRecordMgr(mySqlConnectionString); if (_ITrialRecordMgr.VerifyMaxCount(query)) { json = "{success:true}"; } else { json = "{failure:true}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{failure:true}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 更改活動使用狀態 /// </summary> /// <returns>數據庫操作結果</returns> public JsonResult TrialRecordUpdate() { string jsonStr = string.Empty; try { _ITrialRecordMgr = new TrialRecordMgr(mySqlConnectionString); TrialRecordQuery model = new TrialRecordQuery(); if (!string.IsNullOrEmpty(Request.Params["record_id"])) { model.record_id = Convert.ToInt32(Request.Params["record_id"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["user_email"])) { model.user_email = Request.Params["user_email"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["status"])) { model.status = Convert.ToInt32(Request.Params["status"].ToString()); } if (_ITrialRecordMgr.TrialRecordUpdate(model) > 0) { return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); return Json(new { success = "false" }); } }
public HttpResponseBase GetTrialRecordList() { string json = string.Empty; TrialRecordQuery query = new TrialRecordQuery(); List<TrialRecordQuery> store = new List<TrialRecordQuery>(); int totalCount = 0; _ITrialRecordMgr = new TrialRecordMgr(mySqlConnectionString); try { query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 if (!string.IsNullOrEmpty(Request.Params["trial_id"])) { query.trial_id = Convert.ToInt32(Request.Params["trial_id"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["luquStatus"])) { query.status = Convert.ToInt32(Request.Params["luquStatus"]); } if (!string.IsNullOrEmpty(Request.Params["relation_id"])) { query.record_id = Convert.ToInt32(Request.Params["relation_id"]); } //Request.Params["eventId"].ToString(); store = _ITrialRecordMgr.GetTrialRecordList(query, out totalCount); if (Convert.ToBoolean(Request.Params["isSecret"])) { foreach (var item in store) { if (!string.IsNullOrEmpty(item.user_name)) { item.user_name = item.user_name.Substring(0, 1) + "**"; } item.user_email = item.user_email.Split('@')[0] + "@***"; } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public bool VerifyMaxCount(TrialRecordQuery query) { StringBuilder sql = new StringBuilder(); StringBuilder sqlCount = new StringBuilder(); try { sql.AppendFormat("select show_number from promotions_amount_trial where id={0};", query.trial_id); sqlCount.AppendFormat("select count(trial_id) as Count from trial_record where trial_id={0} and `status`={1};", query.trial_id, query.status); DataTable _dtSql = _access.getDataTable(sql.ToString()); DataTable _dtSqlCount = _access.getDataTable(sqlCount.ToString()); if (Convert.ToInt32(_dtSql.Rows[0]["show_number"]) > Convert.ToInt32(_dtSqlCount.Rows[0]["Count"])) { return true; } else { return false; } } catch (Exception ex) { throw new Exception("TrialRecordDao-->VerifyMaxCount-->" + sql.ToString() + sqlCount.ToString() + ex.Message, ex); } throw new NotImplementedException(); }
/// <summary> /// 根據id獲取一條記錄的信息 /// </summary> /// <param name="query"></param> /// <returns></returns> public TrialRecordQuery GetTrialRecordById(TrialRecordQuery query) { StringBuilder strSql = new StringBuilder(); try { strSql.AppendFormat("select trial_id,user_email,user_name,is_show_name,user_skin,content,share_time,kuser,kdate,muser,mdate from trial_record where record_id='{0}'", query.record_id); return _access.getSinggleObj<TrialRecordQuery>(strSql.ToString()); } catch (Exception ex) { throw new Exception("TrialRecordDao-->GetTrialRecordById-->" + ex.Message + strSql.ToString(), ex); } }
/// <summary> /// 更新試用狀態 /// </summary> /// <param name="query"></param> /// <returns></returns> public int TrialRecordUpdate(TrialRecordQuery query) { StringBuilder strSql = new StringBuilder(); try { strSql.AppendFormat("set sql_safe_updates = 0; update trial_record set status='{0}' where record_id='{1}'; set sql_safe_updates = 1;", query.status, query.record_id); return _access.execCommand(strSql.ToString()); } catch (Exception ex) { throw new Exception("TrialRecordDao-->TrialRecordUpdate-->" + strSql.ToString() + ex.Message, ex); } }