Exemplo n.º 1
0
        public static bool Delete(int processId)
        {
            string sql = "DELETE FROM Transactions WHERE ProcessId = {0}";

            sql = string.Format(sql, SqliteDbHelper.SQLNumber(processId));
            if (string.IsNullOrEmpty(SqliteDbHelper.ExecuteQuery(sql)))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool InsertAndUpdate()
        {
            string  sql         = string.Empty;
            Licence transaction = Licence.GetInfo(this.OldExePath);

            if (transaction == null)
            {
                sql = string.Format("INSERT INTO " + TABLE_NAME + "  (ExePath, Type, TimeInterval,MaxTime,ConcurrentLicences,LastRunStart,LastRunEnd  , Enabled) Values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})", SqliteDbHelper.SQLString(this.ExePath), SqliteDbHelper.SQLString(this.Type.ToString()), SqliteDbHelper.SQLNumber(this.TimeInterval), SqliteDbHelper.SQLNumber(this.MaxTime), SqliteDbHelper.SQLNumber(this.ConcurrentLicences), SqliteDbHelper.SQLDateTime(this.LastRunStart), SqliteDbHelper.SQLDateTime(this.LastRunEnd), SqliteDbHelper.SQLBoolean(this.Enabled));
            }
            else
            {
                this.LastRunEnd   = transaction.LastRunEnd;
                this.LastRunStart = transaction.LastRunStart;
                sql = string.Format("UPDATE " + TABLE_NAME + "  Set Type = {1}, TimeInterval = {2}, MaxTime ={3}, ConcurrentLicences = {4}, LastRunStart={5}, LastRunEnd={6}, Enabled = {7},ExePath = {8} WHERE ExePath = {0} ", SqliteDbHelper.SQLString(this.OldExePath), SqliteDbHelper.SQLString(this.Type.ToString()), SqliteDbHelper.SQLNumber(this.TimeInterval), SqliteDbHelper.SQLNumber(this.MaxTime), SqliteDbHelper.SQLNumber(this.ConcurrentLicences), SqliteDbHelper.SQLDateTime(this.LastRunStart), SqliteDbHelper.SQLDateTime(this.LastRunEnd), SqliteDbHelper.SQLBoolean(this.Enabled), SqliteDbHelper.SQLString(this.ExePath));
            }

            if (string.IsNullOrEmpty(SqliteDbHelper.ExecuteQuery(sql)))
            {
                _Saved = true;
                _Dirty = false;
            }
            return(_Saved);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Save the transaction,
        /// <para>If GUID not exists then insert new </para>
        ///  <para> Otherwise Update existing</para>
        /// </summary>
        /// <param name="forceInsert">Insert a new transaction force fully</param>
        /// <returns>Return true if saved, else false</returns>
        public bool Save(bool forceInsert = false)
        {
            string sql = string.Empty;

            if (forceInsert)
            {
                sql = string.Format("INSERT INTO Transactions (Guid, ProcessId, Application, ExePath, StartedAt, EndedAt, Enabled) Values ({0}, {1}, {2}, {3}, {4}, {5}, {6})", SqliteDbHelper.SQLString(this.Guid), SqliteDbHelper.SQLNumber(this.ProcessId), SqliteDbHelper.SQLString(this.Application), SqliteDbHelper.SQLString(this.ExeName), SqliteDbHelper.SQLDateTime(this.StartedAt), SqliteDbHelper.SQLDateTime(this.EndedAt), SqliteDbHelper.SQLBoolean(this.Enabled));
            }
            else
            {
                Transaction transaction = Transaction.Get(this.Guid);
                if (transaction != null) //ByJASPREET(09/jan/2015):it insert row sometime after delete by exe successfully.
                {
                    sql = string.Format("UPDATE Transactions Set ProcessId = {0}, Application = {1},ExePath = {2}, StartedAt = {3}, EndedAt = {4}, Enabled = {5} where Guid = {6} ", SqliteDbHelper.SQLNumber(this.ProcessId), SqliteDbHelper.SQLString(this.Application), SqliteDbHelper.SQLString(this.ExeName), SqliteDbHelper.SQLDateTime(this.StartedAt), SqliteDbHelper.SQLDateTime(this.EndedAt), SqliteDbHelper.SQLBoolean(this.Enabled), SqliteDbHelper.SQLString(this.Guid));
                }
            }
            if (string.IsNullOrEmpty(SqliteDbHelper.ExecuteQuery(sql)))
            {
                _Saved = true;
                _Dirty = false;
            }
            return(_Saved);
        }