Beispiel #1
1
        public async Task <List <ShipLocationHistoryResult> > GetRawGeolocationsForShip(ShipToken ship)
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            var connection = new SQLite.Net.SQLiteConnection(
                TinyIoC.TinyIoCContainer.Current.Resolve <ISQLitePlatform>(),
                TinyIoC.TinyIoCContainer.Current.Resolve <IFolderProvider>().MapDatabasePath);


            List <ShipLocationHistoryResult> mainShipLocationResults = new List <ShipLocationHistoryResult> ();

            var query = connection.Table <shipLocationDate>().Where(r => r.shipID == ship.ID && r.shiplocationdatetype == "log");           //.OrderBy (r => r.startdate);

            int locationIndex = 1;

            foreach (var shipLocation in query)
            {
                var possibleLocation = connection.Table <locationJSON> ().Where(l => l.name == shipLocation.locationname).FirstOrDefault();

                if (possibleLocation == null)
                {
                    //We purposely skip some locations when processing. May want to re-think that!
                    continue;
                }

                DateTime startDate;
                DateTime endDate;

                var hasStartDate = string.IsNullOrEmpty(shipLocation.startdate) ? false : DateTime.TryParse(shipLocation.startdate, out startDate);
                var hasEndDate   = string.IsNullOrEmpty(shipLocation.enddate) ? false : DateTime.TryParse(shipLocation.enddate, out endDate);

                mainShipLocationResults.Add(new ShipLocationHistoryResult()
                {
                    Location              = shipLocation.locationname,
                    PossibleEndDate       = hasStartDate ? startDate : default(DateTime),
                    PossibleStartDate     = hasEndDate ? endDate : default(DateTime),
                    ShipToken             = ship,
                    LocationIndex         = locationIndex++,
                    LocationGeocodeResult = possibleLocation != null ? JsonConvert.DeserializeObject <GeocodeResultMain> (possibleLocation.geocodeJSON) : null,
                    LocationGuid          = shipLocation.locationguid
                });

                /*foreach (var location in locations) {
                 *      List<GeocodeResultMain> results = new List<GeocodeResultMain> ();
                 *      var query = connection.Table<locationJSON> ().Where (l => l.name == location);
                 *      foreach (var locationJSONEntry in query) {
                 *              mainGeocodeResults.Add(JsonConvert.DeserializeObject<GeocodeResultMain>(locationJSONEntry.geocodeJSON));
                 *      }*/
            }

            sw.Stop();

            System.Diagnostics.Debug.WriteLine($"Total geolocation query time: {sw.ElapsedMilliseconds} ms");

            return(mainShipLocationResults);
        }
        public DatabaseContext()
        {
            var storage = ServiceLocator.Current.GetInstance<ISettings>().GetValue<bool>(ParamsLocalEnum.DbRoaming.ToString()) ? Windows.Storage.ApplicationData.Current.RoamingFolder : Windows.Storage.ApplicationData.Current.LocalFolder;

            var path = Path.Combine(storage.Path, ServiceLocator.Current.GetInstance<ISettings>().GetValue<string>(ParamsLocalEnum.DbName.ToString()));
            Context = new SQLite.Net.SQLiteConnection(new SQLitePlatformWinRT(), path);
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			Xamarin.Forms.Forms.Init (this, bundle);

			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
			var path = Path.Combine(documentsPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists(path))
			{
				var s = Resources.OpenRawResource(Resource.Raw.TodoSQLite);  // RESOURCE NAME ###

				// create a write stream
				FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				// write to the stream
				ReadWriteStream(s, writeStream);
			}


			var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
			var conn = new SQLite.Net.SQLiteConnection(plat, path);


			var a = new App ();
			// Set the database connection string
			App.SetDatabaseConnection (conn);
			App.SetTextToSpeech (new Speech ());

			LoadApplication (a);
		}
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "quinieleros.db3";
            string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                /*var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.totalSQLite);  // RESOURCE NAME ###*/

                // create a write stream

                /*using (StreamReader sr = new StreamReader (Resource.Raw.totalSQLite)) {

                    FileStream writeStream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
                    // write to the stream
                    ReadWriteStream (sr, writeStream);
                }*/
            }

            var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            // Return the database connection
            return conn;
        }
        public static void Startup()
        {
            #if __MOBILE__
            SQLite.Net.SQLiteConnection connection = null;
            SQLite.Net.Interop.ISQLitePlatform platform = null;
            string dbLocation = "videoDB.db3";
            #endif

            #if XAMARIN_ANDROID
            var library = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            dbLocation = Path.Combine(library, dbLocation);
            platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            #elif XAMARIN_IOS
            var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var library = Path.Combine(docsPath, "../Library/");
            dbLocation = Path.Combine(library, dbLocation);
            platform = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            #elif WINDOWS_PHONE
            platform = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();
            #elif NETFX_CORE
            platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT();
            #endif

            ServiceContainer.Register<IMovieService>(() => new MovieService());
            #if __MOBILE__
            connection = new SQLite.Net.SQLiteConnection(platform, dbLocation);
            ServiceContainer.Register<IStorageService>(() => new StorageService(connection));
            ServiceContainer.Register<IMessageDialog>(() => new Video.PlatformSpecific.MessageDialog());
            #endif
            ServiceContainer.Register<MoviesViewModel>();
            ServiceContainer.Register<MovieViewModel>();
        }
Beispiel #6
0
        public AcessoDados()
        {
            var config = DependencyService.Get<iConfig> ();
            _conexao = new SQLite.Net.SQLiteConnection (config.Plataforma, System.IO.Path.Combine (config.DiretorioDB, "bancodados.db3"));

            _conexao.CreateTable<User> ();
        }
Beispiel #7
0
        public int save()
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                var infoTable = conn.GetTableInfo("User");

                if (!infoTable.Any())
                {
                  //  conn.DropTable<User>();
                    conn.CreateTable<User>();

                }
                var info = conn.GetMapping(typeof(User));

                if (this._user.UserID == 0)
                { 
                    //var i = conn.InsertOrReplace(this._user);
                    var i = conn.Insert(this._user);
                    conn.Commit();
                   // this._user.UserID = i;
                    return i;
                }
                else
                {
                    var i = conn.Update(this._user);
                    return i;
                }
                

            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SpeakingActivityContext = this; // HACK: for SpeakButtonRenderer to get an Activity/Context reference

            Xamarin.Forms.Forms.Init (this, bundle);

            var sqliteFilename = "TodoSQLite.db3";
            string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine (path);
            if (!File.Exists(path))
            {
                var s = Resources.OpenRawResource(Resource.Raw.TodoSQLite);  // RESOURCE NAME ###

                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }

            var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            // Set the database connection string
            App.SetDatabaseConnection (conn);

            SetPage (App.GetMainPage ());
        }
Beispiel #9
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
			var conn = new SQLite.Net.SQLiteConnection(plat, path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

//			window.RootViewController = new HybridRazorViewController ();
			window.RootViewController = new UINavigationController(new NativeListViewController ());

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
        public CardViewModel()
        {
            try
            {
                currentModel = new CardCurrent();
                firstStart = true;
                previousCardModified = false;
                goingBack = false;
                goingBackNumberOfCards = 1;
                imageNumber = 0;
                id = 0;

                //There was a problem with database initialization
                using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
                {
                    verbs = db.Table<Verbs>().ToList();
                    adjectives = db.Table<Adjectives>().ToList();
                    nouns = db.Table<Nouns>().ToList();
                    images = db.Table<Images>().ToList();
                    if (verbs.Count == 0 || adjectives.Count == 0 || nouns.Count == 0 || images.Count == 0)
                    {
                        Debug.WriteLine("Database not initialized");
                        App app = new App();
                        app.Initialize();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Beispiel #11
0
        public void init()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma,
                                                       System.IO.Path.Combine(config.Diretorio, "banco1.db3"));
            CreateAllTables();
        }
Beispiel #12
0
 // Retrieve the specific contact from the database.
 public User ReadUser(string username, string password)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         var existingUser = conn.Query <User>("SELECT * FROM User WHERE Username = '******' AND Password = '******'").FirstOrDefault();
         return(existingUser);
     }
 }
Beispiel #13
0
 // Retrieve the specific contact from the database.
 public Post GetPost(int post_id)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         var existingPost = (conn.Table <Post>().Where(c => c.Post_id == post_id)).Single();
         return(existingPost);
     }
 }
Beispiel #14
0
 public LedgerAccount()
 {
     this.InitializeComponent();
     conn      = new Connection().GetConnection();
     viewModel = new AccountViewModel();
     ledgers   = viewModel.AccountLedgerList();
     LoadListView();
 }
Beispiel #15
0
        public ViewModelBase()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados3.db3"));
            _conexao.CreateTable <ProdutoCompra>();
            _conexao.CreateTable <SettingsModel>();
        }
Beispiel #16
0
        public AcessoDados()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados2.db3"));

            _conexao.CreateTable <ProdutoCompra>();
        }
Beispiel #17
0
 public SQLiteController()
 {
     //Create db and tables if they do not exist
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <User>();
     conn.CreateTable <Score>();
 }
Beispiel #18
0
        public MainPage()
        {
            this.InitializeComponent();
            MyFrame.Navigate(typeof(HomeFrame));
            HomeListBoxItem.IsSelected = true;

            conn = new Connection().GetConnection();
        }
Beispiel #19
0
        public SQLite.Net.SQLiteConnection GetConnection(string filename)
        {
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, filename);
            var    plat = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();
            var    conn = new SQLite.Net.SQLiteConnection(plat, path);

            return(conn);
        }
Beispiel #20
0
 public TodayList()
 {
     this.InitializeComponent();
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <Category>();
     loadListView();
 }
        public AcessoDadosAmigos()
        {
            var config = DependencyService.Get <IConfig>();           //utiliza dependency para verificar qual plataforma esta sendo utilizada

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados.db3"));

            _conexao.CreateTable <Amigos>();
        }
 public sign_up()
 {
     this.InitializeComponent();
     this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <irfan>();
 }
 public DataBaseAccess()
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var hasCreated = conn.CreateTable <Registre>();
         var query      = conn.Table <Registre>();
     }
 }
        public AllOrdersDetails()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            LoadDetails();
        }
Beispiel #25
0
        public EditUser()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            userName = UserManager.getUserName();
            UserComboBox.ItemsSource = userName;
        }
        public EditCategory()
        {
            this.InitializeComponent();
            categoryList = CategoryManager.comboCategory();
            CategoryComboBox.ItemsSource = categoryList;

            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
        }
Beispiel #27
0
        public ViewModelBase()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados1.db3"));
            _conexao.CreateTable <Entidade>();
            _conexao.CreateTable <Estabelecimento>();
            _conexao.CreateTable <ePortaria.Model.Controle>();
        }
        public async void ThirdCase()
        {

            
            var path =await DataLoggerService.CreateDatabase("db.dat");

            var connection = new SQLite.Net.SQLiteConnection(new SQLitePlatformWinRT(), path);

        }
		public SQLite.Net.SQLiteConnection GetConnection ()
		{
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
			var path = Path.Combine(documentsPath, sqliteFilename);

			var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
			var conn = new SQLite.Net.SQLiteConnection(plat, path);
			return conn;
		}
 public void AddRegister(Registre registre)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         conn.Insert(new Registre {
             RegistreDate = registre.RegistreDate
         });
     }
 }
        // Insert the new contact in the Contacts table.
        public UniqueExpenseItem GetUniqueExpense(int _ItemID)
        {
            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
            {
                UniqueExpenseItem regularItem = conn.Table <UniqueExpenseItem>().Where((v) => (v.Id == _ItemID)).FirstOrDefault();

                return(regularItem);
            }
        }
Beispiel #32
0
        public static ObservableCollection <SentinelsDataset> getNobOgrList(String filter = null)
        {
            string path = Settings.FullPathSQLite;
            //\\192.168.18.182\C$\Data\Users\DefaultAccount\AppData\Local\Packages\06fb6d66-31b3-4beb-893c-2e0d9fe465f1_3asabdzxmrwg6\LocalState\Project1\settings.sqlite
            var conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            NobOgrList.Clear();

            if (filter == null)
            {
                //List<Sentinels> rows = conn.Table<Sentinels>().ToList();
                //var rows = conn.Query<Sentinels>("select *,(case NobetGunu WHEN 'PAZARTESİ' then 0 WHEN 'SALI' then 1 WHEN 'ÇARŞAMBA' then 2 WHEN 'PERŞEMBE' then 3 WHEN 'CUMA' then 4 END) as workdayno from Sentinels order by workdayno").ToList();

                var Sentinels = conn.Query <SentinelsDataset>("select * from SentinelsDataset");

                var rows = (from e in Sentinels
                            select new SentinelsDataset()
                {
                    id = e.id,
                    SentinelFullName = e.SentinelFullName,
                    SentryLocation = e.SentryLocation,
                    SentryDate = e.SentryDate,
                    DayNO = (DayEnum)Enum.Parse(typeof(DayEnum), e.SentryDate)
                }).OrderBy(e => e.DayNO);

                // rows.ForEach(x => { NobOgrList.Add(x); });

                foreach (var x in rows)
                {
                    NobOgrList.Add(x);
                }
            }

            else
            {
                string flt       = $"%{filter}%";
                var    Sentinels = conn.Query <SentinelsDataset>("select * from SentinelsDataset where SentryLocation LIKE ? OR SentinelFullName LIKE ? OR  SentryDate LIKE ?", flt, flt, flt).ToList();
                var    rows      = (from e in Sentinels
                                    select new SentinelsDataset()
                {
                    id = e.id,
                    SentinelFullName = e.SentinelFullName,
                    SentryLocation = e.SentryLocation,
                    SentryDate = e.SentryDate,
                    DayNO = (DayEnum)Enum.Parse(typeof(DayEnum), e.SentryDate)
                }).OrderBy(e => e.DayNO);

                // rows.ForEach(x => { NobOgrList.Add(x); });

                foreach (var x in rows)
                {
                    NobOgrList.Add(x);
                }
            }

            return(NobOgrList);
        }
Beispiel #33
0
 public Day(DateTime date)
 {
     Database       = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     this.date_time = date;
     this.InfoByDay = GetWorkerListing();
     this.ListOfAvailableService  = GetServiceListing();
     this.ListOfAvailableSchedule = GetScheduleListing();
     OpenContentDialogBox         = new RelayCommand(OpenContentDialogBoxExecute);
 }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var filename = "Notes.db";
            var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, filename);

            var platfrom = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();
            var connection = new SQLite.Net.SQLiteConnection(platfrom, path);
            return connection;
        }
Beispiel #35
0
        public SQLite.Net.SQLiteConnection GetConnection(string filename)
        {
            string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var    path          = Path.Combine(documentsPath, filename);
            var    plat          = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            var    conn          = new SQLite.Net.SQLiteConnection(plat, path);

            return(conn);
        }
Beispiel #36
0
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var path = DependencyService.Get <IDatabase> ().Path;

            var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            return(conn);
        }
        public DriverActivitiesPage()
        {
            this.InitializeComponent();
            db   = new Database();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyDataBase.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            Debug.WriteLine(dristr);
        }
Beispiel #38
0
 private static ObservableCollection <Deputado> ListarDeputadosPorEstadoBanco(string uf)
 {
     using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         var deputados = conexao.Query <Deputado>("select * from deputado where Uf = " + "\"" + uf + "\"").ToList <Deputado>();
         ObservableCollection <Deputado> ListaDeputados = new ObservableCollection <Deputado>(deputados);
         return(ListaDeputados);
     }
 }
 public SQLite.Net.SQLiteConnection GetConnection()
 {
     var sqliteFilename = "CoinJar.db3";
     string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);
     // Create the connection
     var conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     // Return the database connection
     return conn;
 }
 public AccountSubtypeAdd()
 {
     this.InitializeComponent();
     conn = new Connection().GetConnection();
     conn.CreateTable <AccountSubtype>();
     viewModel = new AccountSubtypeViewModel();
     id        = -1;
     PageLoad();
 }
Beispiel #41
0
 public MainPage()
 {
     this.InitializeComponent();
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
                         "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new
                                            SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <Logindata>();
 }
Beispiel #42
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            #region Database setup
            var    sqliteFilename = "TodoSQLite.db3";
            string documentsPath  = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);             // Documents folder
            var    path           = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                var s = Resources.OpenRawResource(RazorTodo.Resource.Raw.TodoSQLite);                  // RESOURCE NAME ###

                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }

            var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            // Set the database connection string
            App.SetDatabaseConnection(conn);
            #endregion

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView> (Resource.Id.webView);
            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new RazorWebViewClient(this));

            // Render the view from the type generated from RazorView.cshtml
            var model = App.Database.GetItems().ToList();


            List <List <Data> > lista = model
                                        .GroupBy(u => u.Group)
                                        .Select(grp => grp.ToList())
                                        .ToList();

            var template = new TodoList()
            {
                Model = lista
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
        /// <summary>
        /// Initializes The GUI by adding all history from the SQLite db
        /// </summary>
        private void InitializeGUI()
        {
            var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "GameHistoryDB.sqlite");
            SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath);

            var games = from g in conn.Table<GameHistory>()
                        select g;

              ListGameHistory.ItemsSource = games.ToList();
        }
Beispiel #44
0
 //Delete all contactlist or delete Contacts table
 public void DeleteAllContact()
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.DropTable <Contacts>();
         conn.CreateTable <Contacts>();
         conn.Dispose();
         conn.Close();
     }
 }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var filename = "Student.db3";
            var documentspath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var path = Path.Combine(documentspath, filename);

            var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var connection = new SQLite.Net.SQLiteConnection(platform, path);
            return connection;
        }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "TodoSQLite.db3";
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);

            var plat = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            // Return the database connection
            return conn;
        }
 /// <summary>
 /// Deletes a individual card in a pack
 /// </summary>
 /// <param name="pack">A packnumber where you want the card to be removed</param>
 /// <param name="card">Cardnumber the be removed</param>
 public void DeleteSavedCard(int pack, int card)
 {
     using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
     {
         IEnumerable<SavedCards> entityQuery = db.Table<SavedCards>().Where(x => x.PackNumber == pack && x.CardNumber == card);  // from savedCards in context.SavedCardPacks where savedCards.packNumber == pack && savedCards.packCard == card select savedCards;
         foreach (SavedCards savedCard in entityQuery)
         {
             db.Delete(savedCard);
         }
     }
 }
 /// <summary>
 /// Deletes all cards in a pack
 /// </summary>
 /// <param name="pack">Pack which you want to remove</param>
 public void DeleteSavedPack(int pack)
 {
     using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
     {
         IEnumerable<SavedCards> packQuery = db.Table<SavedCards>().Where(card => card.PackNumber == pack);
         foreach (SavedCards savedCard in packQuery)
         {
             db.Delete(savedCard);
         }
     }
 }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "MyDataBase.db3";
            string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // Create the connection
            var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);
            // Return the database connection
            return conn;
        }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var fileName = "Actu.db3";
            var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var libraryPath = Path.Combine (documentsPath, "..", "Library");
            var path = Path.Combine (libraryPath, fileName);

            var platform = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS ();
            var connection = new SQLite.Net.SQLiteConnection (platform, path);

            return connection;
        }
Beispiel #51
0
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            // Create the connection
            var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS ();
            var conn = new SQLite.Net.SQLiteConnection (plat, FilePath);
            // Return the database connection

            var d = conn.GetTableInfo ("Person");

            var m = conn.Table<Person> ().Table;

            return conn;
        }
Beispiel #52
0
        public static void SetupDatabase()
        {
            var sqliteFilename = "codemania.db3";
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            var conn = new SQLite.Net.SQLiteConnection(plat, path, true);

            Console.WriteLine(path);

            App.SetSqlConnection(conn);
        }
Beispiel #53
0
        public static User getByUserID(int userID)
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            User user = new User();

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                user = (from u in conn.Table<User>()
                         where u.UserID == userID
                         select u
                         ).ToList().FirstOrDefault();
            }
            return user;
        }
Beispiel #54
0
        public static Day getByDayID(int dayID)
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            Day day = new Day();

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                day = (from d in conn.Table<Day>()
                        where d.DayID == dayID
                        select d
                         ).ToList().FirstOrDefault();
            }
            return day;
        }
Beispiel #55
0
	public SQLite.Net.SQLiteConnection GetConnection()
	{
		var sqliteFilename = "TodoSQLite.db3"; 
		string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
		// Documents folder 
		string libraryPath = Path.Combine(documentsPath, "..", "Library");
		// Library folder 
		var path = Path.Combine(libraryPath, sqliteFilename);
		// Create the connection 
		var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(); 
		var conn = new SQLite.Net.SQLiteConnection(plat, path);
		// Return the database connection 
		return conn;
	}
 /// <summary>
 /// Reorders saved cards pivot page cards after delete. 
 /// </summary>
 /// <param name="pack">The pack number where a card was removed</param>
 /// <param name="cardPosition">Position number of the card where card was removed</param>
 public void ReOrderSavedCards(int pack, int cardPosition)
 {
     int newCardPosition = cardPosition;
     using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
     {
         IEnumerable<SavedCards> reOrderQuery = db.Table<SavedCards>()
         .Where(card => card.PackNumber == pack && card.CardNumber > cardPosition);
         foreach (SavedCards savedCard in reOrderQuery)
         {
             savedCard.CardNumber = newCardPosition;
             db.Update(savedCard);
             newCardPosition++;
         }
     }
 }
Beispiel #57
0
        public static List<Eat> getAll()
        {
            List<Eat> lm = new List<Eat> { };

            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                lm = (from m in conn.Table<Eat>()
                      select m).ToList();

            }

            return lm;
        }
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "BetDatabase.db3";
            string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            string libraryPath = Path.Combine (documentsPath, "..", "Library");
            var path = Path.Combine (libraryPath, sqliteFilename);

            /*	if (!File.Exists (path)) {
                File.Copy (sqliteFilename, path);
            }	*/

            var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            var conn = new SQLite.Net.SQLiteConnection (plat, path);

            return conn;
        }
Beispiel #59
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			#region Database setup
			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
			var path = Path.Combine(documentsPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists(path))
			{
				var s = Resources.OpenRawResource(RazorTodo.Resource.Raw.TodoSQLite);  // RESOURCE NAME ###

				// create a write stream
				FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				// write to the stream
				ReadWriteStream(s, writeStream);
			}

			var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
			var conn = new SQLite.Net.SQLiteConnection(plat, path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);
			#endregion

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			var webView = FindViewById<WebView> (Resource.Id.webView);
			webView.Settings.JavaScriptEnabled = true;

			// Use subclassed WebViewClient to intercept hybrid native calls
			webView.SetWebViewClient (new RazorWebViewClient (this));

			// Render the view from the type generated from RazorView.cshtml
			var model = App.Database.GetItems ().ToList();
			var template = new TodoList () { Model = model };
			var page = template.GenerateString ();

			// Load the rendered HTML into the view with a base URL 
			// that points to the root of the bundled Assets folder
			webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
		}
        public MainPage()
        {
            InitializeComponent();

            Forms.Init();

            var sqliteFilename = "TodoSQLite.db3";
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);

            var plat = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();
            var conn = new SQLite.Net.SQLiteConnection(plat, path);

            // Set the database connection string
            Todo.App.SetDatabaseConnection(conn);

            Content = Todo.App.GetMainPage().ConvertPageToUIElement(this);
        }