using (var conn = new SqlConnection(connectionString))
{
conn.Open();
using (IDbTransaction tran = conn.BeginTransaction())
{
try
{
flag = await conn.ExecuteAsync(Applysql, Item, tran) > 0;
if (Item.Status==1)
{
flag = await conn.ExecuteAsync(Usersql, Item, tran) > 0;
var list = await userRepository.Get(new User() { Id = Item.Creater });
String hingeString = JsonConvert.SerializeObject(list);
flag = GetuiHelper.Send(Item.Creater, hingeString);
}
flag = await conn.ExecuteAsync(Enterprisesql, Item, tran) > 0;
tran.Commit();提交事务
conn.Close();
}
catch (Exception ex)
{
flag = false;
tran.Rollback();回滚事务
conn.Close();
}
}
}