public string GetLastSortOrder(string tableName, string sortOrderColName, string where = null) { var result = "0"; try { var whereCnd = ConvertionHelper.GetWhere(where); var sql = string.Format(@"SELECT {0} FROM {1} {2} ORDER BY CAST({0} AS INTEGER) DESC", sortOrderColName, tableName, whereCnd); var tbl = GetTable(sql); if (tbl.Rows.Count <= 0) { return(result); } result = string.IsNullOrEmpty(tbl.Rows[0][sortOrderColName].ToString()) ? "0" : tbl.Rows[0][sortOrderColName].ToString(); SLLog.WriteInfo("GetLastSortOrder", "Getting last sort order successfully! => " + result, true); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "GetLastSortOrder Error!", Ex = ex, }); if (Settings.ThrowExceptions) { throw new Exception("GetLastSortOrder Error!", ex); } } return(result); }
public string GetNextSortOrder(string tableName, string sortOrderColName, string where = null) { var lstSortOrder = string.Empty; try { var result = GetLastSortOrder(tableName, sortOrderColName, where); lstSortOrder = Convert.ToString(Convert.ToInt32(result) + 1); SLLog.WriteInfo("GetNextSortOrder", "Getting next sort order successfully! => " + lstSortOrder, true); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "GetNextSortOrder Error!", Ex = ex, }); if (Settings.ThrowExceptions) { throw new Exception("GetNextSortOrder Error!", ex); } } return(lstSortOrder); }
public DataTable GetTableSchema(string tableName) { DataTable schemaTbl = new DataTable(); try { var sql = string.Format("SELECT * FROM {0}", tableName); schemaTbl = m_Execute.ExecuteReadTableSchema(sql); SLLog.WriteInfo("GetTableSchema", "Getting Schema Table successfully!", true); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "GetTableSchema Error!", Ex = ex, }); if (Settings.ThrowExceptions) { throw new Exception("GetTableSchema Error!", ex); } } return(schemaTbl); }
public DataTable GetTable(string sql) { var dt = new DataTable(); try { dt = m_Execute.ExecuteReadTable(sql); SLLog.WriteInfo("GetTable", "Getting Table successfully!", true); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "GetTable Error!", Ex = ex, }); if (Settings.ThrowExceptions) { throw new Exception("GetTable Error!", ex); } } return(dt); }
public void InitLogger(string logFileName, string logPath = null, string logId = "", int debugLevel = DebugLevelConstants.Medium, bool onlyConsoleOutput = false) { if (string.IsNullOrEmpty(logPath)) { logPath = Environment.CurrentDirectory; } if (string.IsNullOrEmpty(logId)) { logId = DbFactorySettings.Type.ToString(); } SLLog.Logger = new DbLogger(logPath, logFileName, logId, debugLevel, onlyConsoleOutput); SLLog.WriteInfo("InitLogger", "Logger successfully initialized!"); }
public void InitLogger(string logFileName, string logPath = null) { if (string.IsNullOrEmpty(logPath)) { logPath = SLContext.CurrentCtx.LogDirectory; } else { SLContext.CurrentCtx.LogDirectory = logPath; } SLLog.Logger = new Logger.Logger(logPath, logFileName, "SimpleReport.ReportService"); SLLog.WriteInfo("InitLogger", "Logger successfully initialized!"); }
private void LogTester() { SLLog.WriteInfo("LogTester", "TestInfo!"); SLLog.WriteWarning("LogTester", ToString(), "TestWarning"); try { throw new ApplicationException("TestException!"); } catch (Exception ex) { SLLog.WriteError(new LogData { FunctionName = "LogTester", Source = ToString(), Ex = ex, }); } Task.Run(() => { SLLog.WriteInfo("LogTester", "TestInfo (Thread)!"); SLLog.WriteWarning("LogTester", ToString(), "TestWarning (Thread)!"); try { throw new ApplicationException("TestException (Thread)!"); } catch (Exception ex) { SLLog.WriteError(new LogData { FunctionName = "LogTester", Source = ToString(), Ex = ex, }); } }); }