コード例 #1
0
ファイル: KspMods.cs プロジェクト: jawsper/KspModManager
        public KspMods(string a_InstallationDirectory, string a_ModPath )
        {
            InstallationDirectory = a_InstallationDirectory;
            ModDirectory = a_ModPath;

            db = new SQLiteConnection("kmm.sqlite");

            // make sure the table exists
            if (db.GetTableInfo("KMMInfo").Count == 0)
            {
                db.CreateTable<KMMInfo>();
            }

            var tables = new Type[] { typeof(InstalledMods), typeof(ModFiles), typeof(InstalledFiles) };

            foreach (var table in tables)
            {
                var info = db.GetTableInfo(table.Name);
                if (info.Count == 0)
                    db.CreateTable(table);
            }

            // oh noez it does not match
            if (db.Table<KMMInfo>().Count() == 0 || db.Table<KMMInfo>().First().Version != GetAssemblyVersion())
            {
                // salvage data
                var installed_mods = db.Table<InstalledMods>().ToList();
                db.DropTable<InstalledMods>();
                db.CreateTable<InstalledMods>();
                db.InsertAll(installed_mods);

                var mod_files = db.Table<ModFiles>().ToList();
                db.DropTable<ModFiles>();
                db.CreateTable<ModFiles>();
                db.InsertAll(mod_files);

                var installed_files = db.Table<InstalledFiles>().ToList();
                db.DropTable<InstalledFiles>();
                db.CreateTable<InstalledFiles>();
                db.InsertAll(installed_files);
            }

            // make sure the table is filled
            if (db.Table<KMMInfo>().Count() == 0)
            {
                var nfo = new KMMInfo()
                {
                    Version = GetAssemblyVersion()
                };
                db.Insert(nfo);
            }
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
                    Thread.Sleep (1000); // Simulate a long loading process on app startup.

                    string path = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
                    SQLiteConnection dbConn = new SQLiteConnection (System.IO.Path.Combine (path, DbName));
                    var tb1 = dbConn.GetTableInfo("user");
                    if (tb1.Count==0) {
                StartActivity (typeof(SignUp));
                    } else
                StartActivity (typeof(login));
        }
コード例 #3
0
ファイル: DAL.cs プロジェクト: samfar5161/RSVP4
        public DAL()
        {
            // set database path
            var dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath
                                                    (System.Environment.SpecialFolder.MyDocuments), "Events.sqlite");

            // create new connection
            db = new SQLiteConnection(dbPath);

            if (db.GetTableInfo("Event").Count == 0)
            {
                db.CreateTable <Event>();
            }

            if (db.GetTableInfo("Login").Count == 0)
            {
                db.CreateTable <Login>();
            }

            // debug
            //db.DropTable<Event>();
            //db.DropTable<Login>();
        }
コード例 #4
0
ファイル: SQLiteScrobbler.cs プロジェクト: roberdjp/lastfm
        public override Task<IEnumerable<Scrobble>> GetCachedAsync()
        {
            using (var db = new SQLiteConnection(DatabasePath, SQLiteOpenFlags.ReadOnly))
            {
                var tableInfo = db.GetTableInfo(typeof (Scrobble).Name);
                if (!tableInfo.Any())
                {
                    return Task.FromResult(Enumerable.Empty<Scrobble>());
                }

                var cached = db.Query<Scrobble>("SELECT * FROM Scrobble");
                db.Close();

                return Task.FromResult(cached.AsEnumerable());
            }
        }
コード例 #5
0
ファイル: Vault.cs プロジェクト: prabjotsingh50/hackathon_1
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.Vault);
            Button gmail = FindViewById<Button> (Resource.Id.GM);

            gmail.Click += delegate {
                string path = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
                SQLiteConnection dbConn = new SQLiteConnection (System.IO.Path.Combine (path, DbName));
                var tb1 = dbConn.GetTableInfo("Mail");
                if(tb1.Count == 0)
                {
                    StartActivity(typeof(gmail));
                }
                else
                    StartActivity(typeof(gmail1));
            };
        }
コード例 #6
0
        //This function creates database Table.
        private bool createTable(string path)
        {
            try {
                var connection = new SQLiteConnection (path);
                var info = connection.GetTableInfo ("GcmMessage");

                //Check if the table exists. If it does not create one else return the table exists
                if (!info.Any ()) {
                    connection.CreateTable<GcmMessage> ();
                    return true;
                } else {
                    return true;
                }

            } catch (SQLiteException ex) {

                return false;
            }
        }
コード例 #7
0
ファイル: DAL.cs プロジェクト: samfar5161/RSVP4
        // Inserts an event into the Event table
        public bool InsertEventToDB(Event ev)
        {
            if (db.GetTableInfo("Event").Count == 0)
            {
                db.CreateTable <Event>();
            }

            int numberOfRows = db.Insert(ev);

            if (numberOfRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
ファイル: SQLiteScrobbler.cs プロジェクト: roberdjp/lastfm
        private void Cache(IEnumerable<Scrobble> scrobbles)
        {
            using (var db = new SQLiteConnection(DatabasePath, SQLiteOpenFlags.ReadWrite))
            {
                var tableInfo = db.GetTableInfo(typeof (Scrobble).Name);
                if (!tableInfo.Any())
                {
                    db.CreateTable<Scrobble>();
                }

                db.BeginTransaction();
                foreach (var scrobble in scrobbles)
                {
                    db.Insert(scrobble);
                }
                db.Commit();

                db.Close();
            }
        }
コード例 #9
0
        public static bool AddIntoTrakkedMovie(TrakkedMovie movie)
        {
            var folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var db = new SQLiteConnection(Path.Combine(folder, "movies.db"));

            var tb = db.GetTableInfo("TrakkedMovie");

            if (tb.Count == 0)
            {
                db.CreateTable<TrakkedMovie>();
            }
            var rowsAffected = 0;
            var itemFromDB = from s in db.Table<TrakkedMovie>()
                where s.TMDBID.Equals(movie.TMDBID) && s.username.Equals(movie.username)
                select s;
            var myItem = itemFromDB.FirstOrDefault();
            if (myItem == null)
            {
                Console.WriteLine("Item was not found");
                db.Insert(movie);
                return true;
            }

            myItem.TMDBID = movie.TMDBID;
            myItem.username = movie.username;

            rowsAffected = db.Update(myItem);
            
            var query = db.Table<TrakkedMovie>();

            foreach (var trakkedMovie in query)
            {
                Console.WriteLine(trakkedMovie.TMDBID);
            }

            return rowsAffected > 0;
        }
コード例 #10
0
ファイル: LineStore.cs プロジェクト: yingfangdu/BNR
        public static void loadItemsFromArchive()
        {
            // Archive method of saving
            //			string path = lineArchivePath();
            //			var unarchiver = (NSMutableArray)NSKeyedUnarchiver.UnarchiveFile(path);
            //			if (unarchiver != null) {
            //				for (int i = 0; i < unarchiver.Count; i++) {
            //					completeLines.Add(unarchiver.GetItem<Line>(i));
            //				}
            //			}

            string dbPath = GetDBPath();
            SQLiteConnection db;
            if (!File.Exists(dbPath)) {
                db = new SQLiteConnection(dbPath);
                db.CreateTable<Line>();

                var columnInfo = db.GetTableInfo("Lines");
                foreach (SQLiteConnection.ColumnInfo ci in columnInfo) {
                    //Console.WriteLine("Collumn Info: {0}", ci.Name);
                }

                db.Close();
                db = null;
            }
            db = new SQLiteConnection(dbPath);
            completeLines = db.Query<Line>("SELECT * FROM Lines");

            //			foreach (Line line in completeLines) {
            //				//line.setColor();
            //				//Console.WriteLine("Line bx {0}, by {1}, ex {2}, ey {3}", line.begin.X, line.begin.Y, line.end.X, line.end.Y);
            //			}

            db.Close();
            db = null;
        }
コード例 #11
0
ファイル: FormMain.cs プロジェクト: cuplexProjects/C-Projects
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (this.xmlImporter == null || this.xmlImporter.XMLDocumentNodes == null)
            {
                MessageBox.Show("Please load xml first");
                return;
            }

            this.openFileDialog1.Filter   = "Sqlite db files(*.db)|*.db";
            this.openFileDialog1.FileName = "database.db";

            if (this.openFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            string path = this.openFileDialog1.FileName;

            try
            {
                using (var conn = new SQLite.SQLiteConnection(path, SQLiteOpenFlags.ReadWrite, true))
                {
                    List <SQLiteConnection.ColumnInfo> tableInfo = conn.GetTableInfo("sms");

                    StringBuilder sbColumnNames  = new StringBuilder();
                    StringBuilder sbColumnValues = new StringBuilder();

                    int i = 1;
                    foreach (SQLiteConnection.ColumnInfo sqliteColumn in tableInfo)
                    {
                        sbColumnNames.Append(sqliteColumn.Name + ",");
                        sbColumnValues.Append("@a" + i + ",");
                        i++;
                    }

                    string query = "INSERT INTO sms (" + sbColumnNames.ToString().Trim(',') + ") VALUES (" + sbColumnValues.ToString().Trim(',') + ")";

                    foreach (XMLDataElement xmlDocumentNode in this.xmlImporter.XMLDocumentNodes)
                    {
                        SQLiteCommand insertSQL = new SQLiteCommand(conn)
                        {
                            CommandText = query
                        };

                        i = 1;
                        foreach (SQLiteConnection.ColumnInfo sqliteColumn in tableInfo)
                        {
                            if (sqliteColumn.Name == "body")
                            {
                                insertSQL.Bind("@a" + i, xmlDocumentNode.ElementValue);
                            }
                            else
                            {
                                insertSQL.Bind("@a" + i, xmlDocumentNode.ElementProperties[sqliteColumn.Name]);
                            }
                            i++;
                        }

                        insertSQL.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #12
0
 public bool TableExists(SQLiteConnection connection, string tableName) => connection.GetTableInfo(tableName).Any();
コード例 #13
0
ファイル: LoginActivity.cs プロジェクト: mokth/merpV3
        private bool CheckIfColumnExists()
        {
            bool isfound = true;
            try {
                using (SQLite.SQLiteConnection Conn = new SQLiteConnection (pathToDatabase)) {
                    //var col =Conn.GetTableInfo("GeoLocation");
                    //	isfound=(col.Count >2);
                    var col = Conn.GetTableInfo("Item");
                    isfound=(col.Count >12);

                }
            } catch {
                isfound = false;
            }
            return isfound;
        }
コード例 #14
0
ファイル: LocalBhasvicDB.cs プロジェクト: graceannx/Bhasvic10
        // Method needed to identify if the Table has ever been created

        static public List <SQLiteConnection.ColumnInfo> getTableInfo(string tableName)
        {
            List <SQLiteConnection.ColumnInfo> l = db.GetTableInfo(tableName);

            return(l);
        }