/// <summary> /// 得到一个对象实体 /// </summary> public BWJSLog.Model.ApiInvokingLog GetModel(int ApiInvokingLogId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ApiInvokingLogId, ResponseDate, ResponseData, IsDeleted, CreateId, CreateDate, CompanyId, BusinessType, RelationId, ClassName, MethodName, ApiUrl, RequestDate, RequestData "); strSql.Append(" from dbo.[ApiInvokingLog] "); strSql.Append(" where ApiInvokingLogId=@ApiInvokingLogId"); SqlParameter[] parameters = { new SqlParameter("@ApiInvokingLogId", SqlDbType.Int, 4) }; parameters[0].Value = ApiInvokingLogId; BWJSLog.Model.ApiInvokingLog model = new BWJSLog.Model.ApiInvokingLog(); DataSet ds = BWJSLogHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJSLog.Model.ApiInvokingLog DataRowToModel(DataRow row) { BWJSLog.Model.ApiInvokingLog model = new BWJSLog.Model.ApiInvokingLog(); if (row != null) { if (row["ApiInvokingLogId"].ToString() != "") { model.ApiInvokingLogId = int.Parse(row["ApiInvokingLogId"].ToString()); } if (row["ResponseDate"].ToString() != "") { model.ResponseDate = DateTime.Parse(row["ResponseDate"].ToString()); } model.ResponseData = row["ResponseData"].ToString(); if (row["IsDeleted"].ToString() != "") { model.IsDeleted = int.Parse(row["IsDeleted"].ToString()); } if (row["CreateId"].ToString() != "") { model.CreateId = int.Parse(row["CreateId"].ToString()); } if (row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["CompanyId"].ToString() != "") { model.CompanyId = int.Parse(row["CompanyId"].ToString()); } if (row["BusinessType"].ToString() != "") { model.BusinessType = int.Parse(row["BusinessType"].ToString()); } if (row["RelationId"].ToString() != "") { model.RelationId = int.Parse(row["RelationId"].ToString()); } model.ClassName = row["ClassName"].ToString(); model.MethodName = row["MethodName"].ToString(); model.ApiUrl = row["ApiUrl"].ToString(); if (row["RequestDate"].ToString() != "") { model.RequestDate = DateTime.Parse(row["RequestDate"].ToString()); } model.RequestData = row["RequestData"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJSLog.Model.ApiInvokingLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dbo.[ApiInvokingLog] set "); strSql.Append(" ResponseDate = @ResponseDate , "); strSql.Append(" ResponseData = @ResponseData , "); strSql.Append(" IsDeleted = @IsDeleted , "); strSql.Append(" CreateId = @CreateId , "); strSql.Append(" CreateDate = @CreateDate , "); strSql.Append(" CompanyId = @CompanyId , "); strSql.Append(" BusinessType = @BusinessType , "); strSql.Append(" RelationId = @RelationId , "); strSql.Append(" ClassName = @ClassName , "); strSql.Append(" MethodName = @MethodName , "); strSql.Append(" ApiUrl = @ApiUrl , "); strSql.Append(" RequestDate = @RequestDate , "); strSql.Append(" RequestData = @RequestData "); strSql.Append(" where ApiInvokingLogId=@ApiInvokingLogId "); SqlParameter[] parameters = { new SqlParameter("@ApiInvokingLogId", model.ApiInvokingLogId), new SqlParameter("@ResponseDate", model.ResponseDate), new SqlParameter("@ResponseData", model.ResponseData), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@CompanyId", model.CompanyId), new SqlParameter("@BusinessType", model.BusinessType), new SqlParameter("@RelationId", model.RelationId), new SqlParameter("@ClassName", model.ClassName), new SqlParameter("@MethodName", model.MethodName), new SqlParameter("@ApiUrl", model.ApiUrl), new SqlParameter("@RequestDate", model.RequestDate), new SqlParameter("@RequestData", model.RequestData) }; int rows = BWJSLogHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJSLog.Model.ApiInvokingLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dbo.[ApiInvokingLog]("); strSql.Append("ResponseDate,ResponseData,IsDeleted,CreateId,CreateDate,CompanyId,BusinessType,RelationId,ClassName,MethodName,ApiUrl,RequestDate,RequestData"); strSql.Append(") values ("); strSql.Append("@ResponseDate,@ResponseData,@IsDeleted,@CreateId,@CreateDate,@CompanyId,@BusinessType,@RelationId,@ClassName,@MethodName,@ApiUrl,@RequestDate,@RequestData"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@ResponseDate", model.ResponseDate), new SqlParameter("@ResponseData", model.ResponseData), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@CompanyId", model.CompanyId), new SqlParameter("@BusinessType", model.BusinessType), new SqlParameter("@RelationId", model.RelationId), new SqlParameter("@ClassName", model.ClassName), new SqlParameter("@MethodName", model.MethodName), new SqlParameter("@ApiUrl", model.ApiUrl), new SqlParameter("@RequestDate", model.RequestDate), new SqlParameter("@RequestData", model.RequestData) }; object obj = BWJSLogHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }