Example #1
0
        /// <summary>
        ///  Get content values ready for insert/update
        /// </summary>
        public static ContentValues genContentValues(List <object> colsAndValues)
        {
            ContentValues contVals = new ContentValues();

            for (int i = 0; i < colsAndValues.Count; i += 2)
            {
                object val = colsAndValues[i + 1];
                if (val == null)
                {
                    contVals.putNull((string)colsAndValues[i]);
                }
                else if (val is string)
                {
                    contVals.put((string)colsAndValues[i], (string)val);
                }
                else if (val is int?)
                {
                    contVals.put((string)colsAndValues[i], (int?)val);
                }
                else if (val is long?)
                {
                    contVals.put((string)colsAndValues[i], (long?)val);
                }
                else if (val is sbyte[])
                {
                    contVals.put((string)colsAndValues[i], (sbyte[])val);
                }
                else if (val is FsID)
                {
                    contVals.put((string)colsAndValues[i], ((FsID)val).Val);
                }
            }

            return(contVals);
        }
Example #2
0
    //company
    //todo: register
    public long RegisterCompany(int userId, String companyName)
    {
        ContentValues values = new ContentValues();

        values.put("UserId", userId);
        values.put("CompanyName", companyName);
        return(db.insert("Companies", null, values));
    }
Example #3
0
    //connection
    //todo: register a connection
    public long RegisterConnection(int companyId, String connectionName)
    {
        ContentValues values = new ContentValues();

        values.put("CompanyId", companyId);
        values.put("ConnectionName", connectionName);
        return(db.insert("Connections", null, values));
    }
Example #4
0
    public long UpdateCompany(int companyId, int userId, String companyName)
    {
        ContentValues values = new ContentValues();

        values.put("CompanyId", companyId);
        values.put("UserId", userId);
        values.put("CompanyName", companyName);

        return(db.update("Companies", values, "CompanyId='" + String.valueOf(companyId) + "'", null));
    }
Example #5
0
    //evidence
    //todo: register an evidence
    public long RegisterEvidence(String checkInTime, String checkOutTime, int connectionId, int companyId, int userId)
    {
        ContentValues values = new ContentValues();

        values.put("CheckInTime", checkInTime);
        values.put("CheckOutTime", checkOutTime);
        values.put("ConnectionId", connectionId);
        values.put("CompanyId", companyId);
        values.put("UserId", userId);
        return(db.insert("Evidence", null, values));
    }
Example #6
0
    public long UpdateUser(int userId, String name, String surname, String username, String password)
    {
        ContentValues values = new ContentValues();

        values.put("FirstName", name);
        values.put("LastName", surname);
        values.put("Username", username);
        values.put("Password", password);

        return(db.update("Users", values, "UserId='" + String.valueOf(userId) + "'", null));
    }
Example #7
0
    //users
    public long RegisterUser(String name, String surname, String username, String password)
    {
        ContentValues values = new ContentValues();

        values.put("FirstName", name);
        values.put("LastName", surname);
        values.put("Username", username);
        values.put("Password", password);

        return(db.insert("Users", null, values));
    }
Example #8
0
    //todo: update evidence for checkout

    public long UpdateEvidence(int evidenceId, String checkInTime, String checkOutTime, int connectionId, int companyId, int userId)
    {
        ContentValues values = new ContentValues();

        values.put("CheckInTime", checkInTime);
        values.put("CheckOutTime", checkOutTime);
        values.put("ConnectionId", connectionId);
        values.put("CompanyId", companyId);
        values.put("UserId", userId);

        return(db.update("Evidence", values, "EvidenceId='" + String.valueOf(evidenceId) + "'", null));
    }
Example #9
0
            public long insert(string content)
            {
                ContentValues contentValues = new ContentValues();

                contentValues.put(KEY_CONTENT, content);
                return(sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues));
            }
Example #10
0
        /// <summary>
        /// Store an entry. </summary>
        /// <param name="values"> object describing the values to store. </param>
        /// <returns> database identifier. </returns>
        public virtual long?put(ContentValues values)
        {
            /* Try SQLite */
            if (mIMDB == null)
            {
                try
                {
                    /* Insert data */
                    long id = Database.insertOrThrow(mManager.TableName, null, values);

                    /* Purge oldest entry if capacity reached */
                    Cursor cursor = getCursor(null, null);
                    int    count  = cursor.Count;
                    if (count > CAPACITY)
                    {
                        cursor.moveToNext();
                        delete(cursor.getLong(0));
                    }
                    cursor.close();

                    /* Return id */
                    return(id);
                }
                catch (Exception e)
                {
                    switchToInMemory("put", e);
                }
            }

            /* If failed over in-memory */
            values.put(PRIMARY_KEY, mIMDBAutoInc);
            mIMDB[mIMDBAutoInc] = values;
            return(mIMDBAutoInc++);
        }
Example #11
0
        /// <summary>
        /// Convert a cursor to a content values </summary>
        private ContentValues buildValues(Cursor cursor)
        {
            ContentValues values = new ContentValues();

            for (int i = 0; i < cursor.ColumnCount; i++)
            {
                if (cursor.isNull(i))
                {
                    continue;
                }
                string key = cursor.getColumnName(i);
                if (key.Equals(PRIMARY_KEY))
                {
                    values.put(key, cursor.getLong(i));
                }
                else
                {
                    object specimen = mManager.Schema.get(key);
                    if (specimen is sbyte[])
                    {
                        values.put(key, cursor.getBlob(i));
                    }
                    else if (specimen is double?)
                    {
                        values.put(key, cursor.getDouble(i));
                    }
                    else if (specimen is float?)
                    {
                        values.put(key, cursor.getFloat(i));
                    }
                    else if (specimen is int?)
                    {
                        values.put(key, cursor.getInt(i));
                    }
                    else if (specimen is long?)
                    {
                        values.put(key, cursor.getLong(i));
                    }
                    else if (specimen is short?)
                    {
                        values.put(key, cursor.getShort(i));
                    }
                    else
                    {
                        values.put(key, cursor.getString(i));
                    }
                }
            }
            return(values);
        }