public override void OnCreate(SQLiteDatabase db)
        {
            SKLogging.WriteLog(TAG, "On create resources database !!!", SKLogging.LogDebug);
            string createMapResourcesTable =
                new StringBuilder("CREATE TABLE IF NOT EXISTS ").Append(MapsDAO.MAPS_TABLE).Append(" (")
                .Append(MapsDAO.KEY).Append(" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
                                            "").Append(MapsDAO.CODE).Append(" TEXT UNIQUE, ").Append(MapsDAO.PARENT_CODE)
                .Append(" TEXT, ").Append(MapsDAO.REGION).Append(" TEXT, ").Append(MapsDAO.NAMES).Append(" TEXT, " +
                                                                                                         "").Append(MapsDAO.SKM_FILE_PATH).Append(" TEXT, ").Append(MapsDAO.ZIP_FILE_PATH)
                .Append(" TEXT, ").Append(MapsDAO.TXG_FILE_PATH).Append(" TEXT, ")
                .Append(MapsDAO.TXG_FILE_SIZE).Append(" INTEGER, " +
                                                      "").Append(MapsDAO.SKM_AND_ZIP_FILES_SIZE)
                .Append(" INTEGER, ").Append(MapsDAO.SKM_FILE_SIZE).Append(" INTEGER, " +
                                                                           "").Append(MapsDAO.UNZIPPED_FILE_SIZE)
                .Append(" INTEGER, ").Append(MapsDAO.BOUNDING_BOX_LATITUDE_MAX).Append(" DOUBLE, ")
                .Append(MapsDAO.BOUNDING_BOX_LATITUDE_MIN).Append(" DOUBLE, ")
                .Append(MapsDAO.BOUNDING_BOX_LONGITUDE_MAX).Append(" DOUBLE, ")
                .Append(MapsDAO.BOUNDING_BOX_LONGITUDE_MIN).Append(" DOUBLE, " +
                                                                   "").Append(MapsDAO.SUBTYPE)
                .Append(" TEXT, ").Append(MapsDAO.STATE).Append(" INTEGER, ")
                .Append(MapsDAO.NO_DOWNLOADED_BYTES).Append(" INTEGER, ").Append(MapsDAO.FLAG_ID)
                .Append(" INTEGER, ").Append(MapsDAO.DOWNLOAD_PATH).Append(" TEXT)").ToString();

            db.BeginTransaction();
            db.ExecSQL(createMapResourcesTable);
            db.SetTransactionSuccessful();
            db.EndTransaction();
        }
Ejemplo n.º 2
0
        public void HandlePositiveButtonClick(object sender, DialogClickEventArgs e)
        {
            try
            {
                //signature = Activity.FindViewById<SignaturePadView>(Resource.Id.signatureFrame);
                Bitmap       imagen = signature.GetImage();
                MemoryStream ms     = new MemoryStream();
                //ByteArrayOutputStream bos = new ByteArrayOutputStream();
                imagen.Compress(Bitmap.CompressFormat.Png, 100, ms);
                byte[] bArray = ms.ToArray();

                //string id = Guid.NewGuid().ToString();
                System.Console.WriteLine("GUID: " + guid);
                loadConnection();
                db.BeginTransaction();
                //Se almacena en base de datos el BLOB con su respectivo GUID
                try
                {
                    string          sql        = "INSERT INTO IMAGENES (Nombre,Imagen) VALUES(?,?)";
                    SQLiteStatement insertStmt = db.CompileStatement(sql);
                    insertStmt.ClearBindings();
                    insertStmt.BindString(1, guid);
                    insertStmt.BindBlob(2, bArray);
                    insertStmt.ExecuteInsert();
                    db.SetTransactionSuccessful();
                    db.EndTransaction();
                    db.Close();
                    try
                    {
                        if (actor.Equals("notificando", StringComparison.Ordinal))
                        {
                            ManejoBaseDatos.Abrir();
                            ManejoBaseDatos.Actualizar("Notificaciones", "ValidacionNotificando", "S", "CodigoNotificacion=" + codigo + "");
                            ManejoBaseDatos.Cerrar();
                        }
                        if (actor.Equals("testigo", StringComparison.Ordinal))
                        {
                            ManejoBaseDatos.Abrir();
                            ManejoBaseDatos.Actualizar("Notificaciones", "ValidacionTestigo", "S", "CodigoNotificacion=" + codigo + "");
                            ManejoBaseDatos.Cerrar();
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine("Error almacenando confirmacion de firma: " + ex.ToString());
                        Toast.MakeText(this.Activity, "Error guardando confirmacion", ToastLength.Short).Show();
                    }
                }
                catch (Exception ex) { System.Console.WriteLine("Error guardando imagen en db: " + ex.ToString()); }

                Toast.MakeText(this.Activity, "Firma capturada de forma exitosa", ToastLength.Short).Show();
            }
            catch (Exception ex) { System.Console.WriteLine("ERROR guardando la imagen: " + ex.ToString()); }
        }
Ejemplo n.º 3
0
 private void beginTransaction(SQLiteDatabase mDatabase)
 {
     if (allowTransaction)
     {
         mDatabase.BeginTransaction();
     }
     else
     {
         writeLock.Lock();
         writeLocked = true;
     }
 }
Ejemplo n.º 4
0
 public void Insert(double Latitude, double Longitude)
 {
     if (db != null)
     {
         db.BeginTransaction();
         ContentValues values = new ContentValues();
         values.Put("ID", Guid.NewGuid().ToString());
         values.Put("latitude", Latitude);
         values.Put("longitude", Longitude);
         db.Insert("Points", null, values);
         db.EndTransaction();
     }
 }
        public override ContentProviderResult[] ApplyBatch(IList <ContentProviderOperation> operations)
        {
            SQLiteDatabase db = mOpenHelper.WritableDatabase;

            db.BeginTransaction();
            try {
                int numOperations = operations.Count;
                ContentProviderResult[] results = new ContentProviderResult[numOperations];
                for (int i = 0; i < numOperations; i++)
                {
                    results[i] = operations[i].Apply(this, results, i);
                }
                db.SetTransactionSuccessful();
                return(results);
            } finally {
                db.EndTransaction();
            }
        }
Ejemplo n.º 6
0
        public bool updateUser(User user, int mode)
        {
            bool success = false;

            if (mDBHelper == null)
            {
                return(success);
            }
            try
            {
                mDatabase = mDBHelper.WritableDatabase;
                beginTransaction(mDatabase);

                if (user != null)
                {
                    mDatabase.BeginTransaction();
                    string where = "user_id = ? and group_id = ?";
                    string[]      whereValue = { user.getUserId(), user.getGroupId() };
                    ContentValues cv         = new ContentValues();

                    cv.Put("user_id", user.getUserInfo());
                    cv.Put("user_info", user.getUserInfo());
                    cv.Put("group_id", user.getGroupId());
                    cv.Put("update_time", DateTime.Now.Millisecond);
                    if (mDatabase.Update(DBHelper.TABLE_USER, cv, where, whereValue) < 0)
                    {
                        return(false);
                    }

                    // 1更新,直接删掉已有feature  2追加
                    if (mode == 1)
                    {
                        if (mDatabase.Delete(DBHelper.TABLE_FEATURE, where, whereValue) < 0)
                        {
                            return(false);
                        }
                        foreach (Feature feature in user.getFeatureList())
                        {
                            if (!addFeature(feature, mDatabase))
                            {
                                return(false);
                            }
                        }
                    }
                    else if (mode == 2)
                    {
                        foreach (Feature feature in user.getFeatureList())
                        {
                            if (!addFeature(feature, mDatabase))
                            {
                                return(false);
                            }
                        }
                    }
                }
                setTransactionSuccessful(mDatabase);
                success = true;
            }
            catch (Java.Lang.Exception)
            {
                endTransaction(mDatabase);
            }
            return(success);
        }
Ejemplo n.º 7
0
 public static void beginTransaction(this SQLiteDatabase db)
 {
     db.BeginTransaction();
 }