private string connectionString;
private void SaveCustomerInfo() {
var entityConnStr = ConfigurationManager.ConnectionStrings["DcsEntities"].ConnectionString;
if(!string.IsNullOrEmpty(entityConnStr)) {
var entityConnection = new EntityConnectionStringBuilder(entityConnStr);
this.connectionString = entityConnection.ProviderConnectionString;
}
var db = DbHelper.GetDbHelp(this.connectionString);
var sqlInsert = db.GetInsertSql("reportquerylog ", "Id", new[] {
"UserId","EnterpriseId","CreateTime","PageName"
});
using(var conn = db.CreateDbConnection()) {
conn.Open();
var ts = conn.BeginTransaction();
try {
var cmd = db.CreateDbCommand(sqlInsert, conn, null);
// cmd.Parameters.Add(db.CreateDbParameter("Id", Guid.NewGuid()));
cmd.Parameters.Add(db.CreateDbParameter("UserId", Utils.GetCurrentUserInfo().LoginId));
cmd.Parameters.Add(db.CreateDbParameter("EnterpriseId", Utils.GetCurrentUserInfo().EnterpriseId));
cmd.Parameters.Add(db.CreateDbParameter("CreateTime", DateTime.Now));
cmd.Parameters.Add(db.CreateDbParameter("PageName", "23"));
cmd.ExecuteNonQuery();
ts.Commit();
} catch(Exception) {
ts.Rollback();
} finally {
conn.Close();
}
}
}