public static List <Transaction> GetAllRunning(string exePath) { List <Transaction> list = new List <Transaction>(); string sql = "SELECT Guid, ExePath,ProcessId, StartedAt, Application, EndedAt, Enabled FROM Transactions WHERE Enabled =" + SqliteDbHelper.SQLBoolean(true); if (!string.IsNullOrEmpty(exePath)) { sql += " AND ExePath =" + SqliteDbHelper.SQLString(exePath); } System.Data.DataSet transData = SqliteDbHelper.GetData(sql); if (transData != null) { if (transData.Tables.Count > 0) { if (transData.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow dr in transData.Tables[0].Rows) { Transaction transaction = new Transaction(SqliteDbHelper.ToString(dr["Guid"])); transaction.ProcessId = SqliteDbHelper.ToInt(dr["ProcessId"]); transaction.Application = SqliteDbHelper.ToString(dr["Application"]); transaction.ExeName = SqliteDbHelper.ToString(dr["ExePath"]); transaction.StartedAt = SqliteDbHelper.ToNullableDateTime(dr["StartedAt"]); transaction.EndedAt = SqliteDbHelper.ToNullableDateTime(dr["EndedAt"]); transaction.Enabled = SqliteDbHelper.ToBoolean(dr["Enabled"]); list.Add(transaction); } } } } return(list); }
/// <summary> /// Get licence info of a licences by id /// </summary> /// <param name="id">Id</param> /// <returns></returns> public static Licence GetInfo(string exePath) { string sql = "SELECT ExePath, Type, TimeInterval,MaxTime, ConcurrentLicences ,LastRunStart,LastRunEnd , Enabled FROM " + TABLE_NAME + " WHERE ExePath = {0} "; sql = string.Format(sql, SqliteDbHelper.SQLString(exePath)); System.Data.DataSet transData = SqliteDbHelper.GetData(sql); if (transData != null) { if (transData.Tables.Count > 0) { if (transData.Tables[0].Rows.Count > 0) { System.Data.DataRow dr = transData.Tables[0].Rows[0]; Licence Licence = new Licence(SqliteDbHelper.ToString(dr["ExePath"])); Licence.Type = (LicenceType)Enum.Parse(typeof(LicenceType), SqliteDbHelper.ToString(dr["Type"])); Licence.TimeInterval = SqliteDbHelper.ToInt(dr["TimeInterval"]); Licence.MaxTime = SqliteDbHelper.ToInt(dr["MaxTime"]); Licence.ConcurrentLicences = SqliteDbHelper.ToInt(dr["ConcurrentLicences"]); Licence.LastRunStart = SqliteDbHelper.ToNullableDateTime(dr["LastRunStart"]); Licence.LastRunEnd = SqliteDbHelper.ToNullableDateTime(dr["LastRunEnd"]); Licence.Enabled = SqliteDbHelper.ToBoolean(dr["Enabled"]); return(Licence); } } } return(null); }
public static Transaction Get(string guid) { string sql = "SELECT Guid, ExePath,Application,ProcessId, StartedAt, EndedAt, Enabled FROM Transactions WHERE Guid = {0} AND Enabled =" + SqliteDbHelper.SQLBoolean(true); sql = string.Format(sql, SqliteDbHelper.SQLString(guid)); System.Data.DataSet transData = SqliteDbHelper.GetData(sql); if (transData != null) { if (transData.Tables.Count > 0) { if (transData.Tables[0].Rows.Count == 1) { System.Data.DataRow dr = transData.Tables[0].Rows[0]; Transaction transaction = new Transaction(SqliteDbHelper.ToString(dr["Guid"])); transaction.ProcessId = SqliteDbHelper.ToInt(dr["ProcessId"]); transaction.Application = SqliteDbHelper.ToString(dr["Application"]); transaction.ExeName = SqliteDbHelper.ToString(dr["ExePath"]); transaction.StartedAt = SqliteDbHelper.ToNullableDateTime(dr["StartedAt"]); transaction.EndedAt = SqliteDbHelper.ToNullableDateTime(dr["EndedAt"]); transaction.Enabled = SqliteDbHelper.ToBoolean(dr["Enabled"]); return(transaction); } } } return(null); }
/// <summary> /// Get all Licences /// </summary> /// <returns></returns> private static List <Licence> GetAllLicences(LicenceType type, bool?enabled = null) { List <Licence> Licences = new List <Licence>(); string sWHERE = " WHERE "; string sAND = string.Empty; string sql = "SELECT ExePath, Type, TimeInterval,MaxTime, ConcurrentLicences ,LastRunStart,LastRunEnd , Enabled FROM " + TABLE_NAME; switch (type) { case LicenceType.TRIGGERBASE: sql = sql + sWHERE + sAND + " Type = 'TRIGGERBASE' "; sWHERE = string.Empty; sAND = " AND "; break; case LicenceType.PERIODIC: sql = sql + sWHERE + sAND + " Type = 'PERIODIC' "; sWHERE = string.Empty; sAND = " AND "; break; case LicenceType.NONE: break; } if (enabled.HasValue) { if (enabled.Value) { sql = sql + sWHERE + sAND + " Enabled = '1'"; } else { sql = sql + sWHERE + sAND + " Enabled = '0'"; } sWHERE = string.Empty; sAND = " AND "; } System.Data.DataSet transData = SqliteDbHelper.GetData(sql); if (transData != null) { if (transData.Tables.Count > 0) { if (transData.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow dr in transData.Tables[0].Rows) { Licence Licence = new Licence(SqliteDbHelper.ToString(dr["ExePath"])); Licence.Type = (LicenceType)Enum.Parse(typeof(LicenceType), SqliteDbHelper.ToString(dr["Type"])); Licence.TimeInterval = SqliteDbHelper.ToInt(dr["TimeInterval"]); Licence.MaxTime = SqliteDbHelper.ToInt(dr["MaxTime"]); Licence.ConcurrentLicences = SqliteDbHelper.ToInt(dr["ConcurrentLicences"]); Licence.LastRunStart = SqliteDbHelper.ToNullableDateTime(dr["LastRunStart"]); Licence.LastRunEnd = SqliteDbHelper.ToNullableDateTime(dr["LastRunEnd"]); Licence.Enabled = SqliteDbHelper.ToBoolean(dr["Enabled"]); Licences.Add(Licence); } } } } return(Licences); }