public static string ExecuteTrans(List <string> list, List <DynamicParameters> parms = null) { string result = "成功"; string connectstring = ConnStrings.Replace("DBType=SqlServer", "").Replace("DBType=Oracle", "").Replace("DBType=MySql", ""); using (IDbConnection dbConnection = new SqlConnection(connectstring)) { dbConnection.Open(); IDbTransaction dbTransaction = dbConnection.BeginTransaction(); try { int num = 0; using (List <string> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; bool flag2 = parms != null && parms.Count - 1 >= num; if (flag2) { dbConnection.Execute(current, parms[num], dbTransaction, CommandTimeout, CommandType.Text); } else { dbConnection.Execute(current, null, dbTransaction, CommandTimeout, CommandType.Text); } num++; } } dbTransaction.Commit(); AppLog.WriteDbLog(dbConnection.ConnectionString, string.Join(",", list.ToArray()), result, null); } catch (Exception ex) { dbTransaction.Rollback(); AppLog.WriteDbLog(dbConnection.ConnectionString, string.Join(",", list.ToArray()), result + "->" + ex.Message, null); return(result); } } return("OK"); }
public static string GetConnectionString(string connectionName = "TicketDB") { return(ConnStrings.GetConnString(connectionName)); }