internal static void LogSlowQuery(DateTime logTime, string log) { if (SkipSlowQueries) { return; } string sessionid = ""; int espaceid = 0, tenantid = 0, userid = 0; if (System.Web.HttpContext.Current != null) // if inside a web application { AppInfo.GetAppInfoInformation(out espaceid, out tenantid, out sessionid, out userid); // if this is a query to get AppInfo information -> do not log if (espaceid == 0) { return; } } var logger = new OutSystems.HubEdition.RuntimePlatform.Log.GeneralLog(); logger.Write(logTime, sessionid, espaceid, tenantid, userid, log, OutSystems.HubEdition.RuntimePlatform.Log.GeneralLogType.WARNING.ToString(), "SLOWSQL", ""); }
private void GetRecordList <T>(String sqlCommand, OSList <T> list) { OSList <T> auxList = (OSList <T>)Helper.ReflectionHelper.CreateInstance(list.GetType()); /* * OleDbDataReader dataReader; * string connectionString = "Provider=SQLOLEDB.1;Password=a6Intruder;Persist Security Info=True;User ID=pedrolopes;Initial Catalog=MusicDB;Data Source=musicdb.c0d9wnivbgn8.eu-central-1.rds.amazonaws.com"; * System.Data.OleDb.OleDbConnection oleDbConnection = new System.Data.OleDb.OleDbConnection(connectionString); * OleDbConnection connection = new OleDbConnection(connectionString); * OleDbCommand command =new OleDbCommand(sqlCommand, connection); * connection.Open(); * dataReader = command.ExecuteReader(); */ try { using (CommittableTransaction commitableTransaction = dbaProvider.GetCommittableTransaction()) { using (Command cmd = commitableTransaction.CreateCommand(sqlCommand)) { // Results are read using a standard IDataReader object using (IDataReader dataReader = cmd.ExecuteReader()) { auxList.Reader = dataReader; auxList.StartIteration(); while (!auxList.Eof) { auxList.Read(); list.Data.Add(auxList.CurrentRec); auxList.Advance(); } auxList.CloseDataReader(); } } } } catch (Exception ex) { log.Write(System.DateTime.Now, AppInfo.GetAppInfo().OsContext.Session.SessionID, AppInfo.GetAppInfo().eSpaceId, AppInfo.GetAppInfo().Tenant.Id, AppInfo.GetAppInfo().OsContext.Session.UserId, ex.Message, "Error", "MusicDBExternalData", "0"); throw ex; } }