void context_AcquireRequestState(object sender, EventArgs e) { // 获取应用程序 HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; // 获取Url string requestUrl = application.Request.Url.ToString(); string AppRelative = application.Request.AppRelativeCurrentExecutionFilePath; string Url = AppRelative.Substring(2); string requestPage = requestUrl.Substring(requestUrl.LastIndexOf('/') + 1); if (!string.IsNullOrEmpty(context.Request.QueryString["MoudleId"])) { try { string Usercode = Authentication.GetUserCode(); string MoudleId = context.Request.QueryString["MoudleId"]; syslogLogic logic = new syslogLogic(); syslogInfo info = new syslogInfo(); info.MOUDLEID = Convert.ToInt64(MoudleId); info.USERCODE = Usercode; info.SJ = DateTime.Now; logic.Insert(info); } catch (Exception ex) { } } }
/// <summary> /// 得到列表 /// </summary> /// <param name="ent"></param> /// <returns></returns> public List<syslogInfo> GetsyslogList(string Where) { List<syslogInfo> list = new List<syslogInfo>(); using(DbDataReader reader = DataBaseManage.ExecuteReader(DalSql+Where)) { while (reader.Read()) { syslogInfo ent = new syslogInfo(); SetEnt(ent, reader); list.Add(ent); } } return list; }
/// <summary> /// 根据Id得到 /// </summary> /// <param name="ent"></param> /// <returns></returns> public syslogInfo Getsyslog( long ID) { syslogInfo ent = null; string sql = DalSql; sql = sql + " And ID=@ID "; MySqlParameter[] paras = new MySqlParameter[] { new MySqlParameter("ID",ID) }; using(DbDataReader reader = DataBaseManage.ExecuteReader(sql, paras)) { if (reader.Read()) { ent = new syslogInfo(); SetEnt(ent, reader); } } return ent; }
public int Update(syslogInfo ent) { return dao.Update(ent,null); }
public int Insert(syslogInfo ent) { return dao.Insert(ent,null); }
public int Delete(syslogInfo ent) { return dao.Delete(ent, null); }
private int RunCommandWithTransatcion(syslogInfo ent, string vSql, IDbTransaction TRANS) { if (null == TRANS) { MySqlParameter[] paras = new MySqlParameter[ent.Column.Count]; for (int i = 0; i < ent.Column.Count; i++) { paras[i] = new MySqlParameter(); paras[i].ParameterName = ent.Column[i].FieldName; paras[i].DbType = ent.Column[i].FieldType; paras[i].Value = ent.Column[i].FieldValue; } return DataBaseManage.ExecuteSql(vSql, paras); } else { System.Data.IDbCommand CM = TRANS.Connection.CreateCommand(); CM.CommandText = vSql; CM.CommandType = CommandType.Text; CM.Transaction = TRANS; GetEntityDeleteParameter(CM, ent); try { return CM.ExecuteNonQuery(); } catch (System.Exception e) { if (isDebug) throw new Exception(e.Message); return 0; } } }
public void SetEnt(syslogInfo ent, IDataReader dr) { ent.ID = MyConvert.ToLong(dr["ID"]); ent.USERCODE = MyConvert.ToString(dr["USERCODE"]); ent.MOUDLEID = MyConvert.ToLong(dr["MOUDLEID"]); ent.SJ = MyConvert.ToDateTime(dr["SJ"]); }