示例#1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>

        private void ResetData()
        {
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Empty the Customer and Project tables
                db.DeleteAll <Customer>();
                db.DeleteAll <Project>();

                // Add seed customers and projects

                var newCustomer = new Customer()
                {
                    Name    = "Tailspin Toys",
                    City    = "Kent",
                    Contact = "Michelle Alexander"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Kids Game",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(60)
                });
            }
        }
示例#2
0
        private void Navigate()
        {
            App.Master.IsPresented = false;

            if (this.PageName == "LoginPage")
            {
                Settings.IsRemembered = "false";

                var mainViewModel = MainViewModel.GetInstance();
                mainViewModel.Token = null;
                mainViewModel.User  = null;

                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.DeleteAll <UserLocal>();
                    conn.DeleteAll <TokenResponse>();
                }

                Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
            else if (this.PageName == "MyProfilePage")
            {
                MainViewModel.GetInstance().MyProfile = new MyProfileViewModel();
                App.Navigator.PushAsync(new MyProfilePage());
            }
        }
示例#3
0
 private static void PerformSuspenedAction(string pathToDatabase)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
         db.DeleteAll <Item> ();
         db.DeleteAll <Trader> ();
         db.DeleteAll <AdUser> ();
     }
 }
示例#4
0
 public static void DeleteAllNumber()
 {
     using (var db = new SQLite.SQLiteConnection(App.DBPath))
     {
         db.DeleteAll <NumberInfo>();
         db.DeleteAll <BingoNumberInfo>();
     }
 }
示例#5
0
 private void TruncateTables(SQLite.SQLiteConnection connection)
 {
     connection.DeleteAll <MediaStatusEntity>();
     connection.DeleteAll <MediaTypeEntity>();
     connection.DeleteAll <VersionEntity>();
     connection.DeleteAll <FavoriteMusicEntity>();
     connection.DeleteAll <FavoriteSportEntity>();
 }
        private void btnDeleteAll_Click(object sender, RoutedEventArgs e)
        {
            var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            using (var db = new SQLite.SQLiteConnection(dbPath))
            {
                db.DeleteAll<User>();
                db.DeleteAll<AddressBookEntree>();
            }


            Frame rootFrame = Window.Current.Content as Frame;
            rootFrame.Navigate(typeof(Dashboard));
        }
示例#7
0
        private void btnDeleteAll_Click(object sender, RoutedEventArgs e)
        {
            var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (var db = new SQLite.SQLiteConnection(dbPath))
            {
                db.DeleteAll <User>();
                db.DeleteAll <AddressBookEntree>();
            }


            Frame rootFrame = Window.Current.Content as Frame;

            rootFrame.Navigate(typeof(Dashboard));
        }
示例#8
0
        private void Navigate()
        {
            //Ocultar Menú
            App.Master.IsPresented = false;

            if (this.PageName == "LoginPage")
            {
                Settings.Token     = string.Empty;
                Settings.TokenType = string.Empty;
                //-----------Por seguridad...
                var mainViewModel = MainViewModel.getInstance();
                mainViewModel.Token     = string.Empty;
                mainViewModel.TokenType = string.Empty;

                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.DeleteAll <UserLocal>();
                }

                Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
            else if (this.PageName == "MyProfilePage")
            {
                MainViewModel.getInstance().MyProfile = new MyProfileViewModel();
                App.Navigator.PushAsync(new MyProfilePage());
            }
        }
示例#9
0
        public void delete_sesion()
        {
            var mainViewModal = MainViewModel.GetInstance();

            Settings.IsRemembered = "false";
            mainViewModal.Token   = null;
            mainViewModal.User    = null;
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <UserLocal>();
            }
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <TokenResponse>();
            }
            //Borrar la box local
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <BoxLocal>();
            }
            //Borrar perfiles locales
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <ProfileLocal>();
            }
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <ForeingBox>();
            }
            //Borrar perfiles locales
            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                conn.DeleteAll <ForeingProfile>();
            }
        }
示例#10
0
        public SLManager(IRestService service, string LocalDataBasePath = null)
        {
            restService  = service;
            DataBasePath = LocalDataBasePath;
            DataBase     = new SQLite.SQLiteConnection(DataBasePath);

            DataBase.CreateTable <TransactionPageModel>();
            DataBase.CreateTable <TransactionModel>();
            DataBase.CreateTable <LocalFile>();

            DataBase.DeleteAll <TransactionPageModel>();
            DataBase.DeleteAll <TransactionModel>();

            Debug.WriteLine(@"DeviceUUID=" + SL.DeviceUUID);
            Debug.WriteLine(@"AreaGUID=" + SL.AreaGUID);
        }
        public static int Clear()
        {
            int records = conn.DeleteAll <Article>();

            //int records = conn.Execute("DELETE FROM Article");
            return(records);
        }
 public int BorrarTodo()
 {
     lock (locker)
     {
         return(database.DeleteAll <Receta>());
     }
 }
示例#13
0
        private void Navigate()
        {
            App.Master.IsPresented = false;
            if (this.PageName == "EnterPage")
            {
                Settings.Token     = string.Empty;
                Settings.TokenType = string.Empty;
                var mainViewModel = MainViewModel.GetInstance();
                mainViewModel.Token     = string.Empty;
                mainViewModel.TokenType = string.Empty;

                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.DeleteAll <UserLocal>();
                }


                Application.Current.MainPage = new NavigationPage(new EnterPage());
            }

            else if (this.PageName == "ProfilePage")
            {
                MainViewModel.GetInstance().Profile = new ProfileViewModel();
                App.Navigator.PushAsync(new ProfilePage());
            }
        }
示例#14
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Get a reference to the SQLite database
                this.DBPath = Path.Combine(
                    Windows.Storage.ApplicationData.Current.LocalFolder.Path, "budget.sqlite");

                // Initialize the database if necessary
                using (var db = new SQLite.SQLiteConnection(this.DBPath))
                {
                    // Create the tables if they don't exist
                    db.CreateTable<Budget>();
                    db.CreateTable<BudgetEnvelope>();
                    db.CreateTable<Account>();
                    db.CreateTable<Transaction>();

                    db.DeleteAll<Budget>();

                    db.Insert(new Budget()
                    {
                        Id = 1,
                        PaycheckAmount = 1000.0f,
                        Frequency = PaycheckFrequency.SemiMonthly,
                        Name = "My New Budget"
                    });

                    Budget b = db.Table<Budget>().First();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
示例#15
0
        public static async Task <bool> AgregarCatalogos(int CompanyId)
        {
            bool resultado = false;

            using (SQLite.SQLiteConnection con = new SQLite.SQLiteConnection(App.RutaDB))
            {
                var itemResult = await Controller.EmployeeController.EmployeeList(CompanyId);

                var itemResult2 = await Controller.EmployeeProductController.GetListEmployeeProduct_Day(CompanyId);

                if (itemResult.Result)
                {
                    var employeeList = JsonConvert.DeserializeObject <List <Models.Employee> >(itemResult.Data["Result"].ToString());
                    if (employeeList.Count > 0)
                    {
                        con.DeleteAll <Models.Employee>();
                        employeeList.ForEach(f => con.Insert(f));
                    }
                    resultado = true;
                }
                if (itemResult2.Result)
                {
                    var employeeProductList = JsonConvert.DeserializeObject <List <Models.EmployeeProduct> >(itemResult2.Data["Result"].ToString());
                    if (employeeProductList.Count > 0)
                    {
                        con.DeleteAll <Models.EmployeeProduct>();
                        employeeProductList.ForEach(f => con.Insert(new Models.EmployeeProduct()
                        {
                            CompanyId          = f.CompanyId,
                            EmployeeId         = f.EmployeeId,
                            EmployeeNumber     = f.EmployeeNumber,
                            AddedToService     = true,
                            CompanyDescription = f.CompanyDescription,
                            EmployeeName       = f.EmployeeName,
                            EmployeeProductId  = f.EmployeeProductId,
                            ProductDescription = f.ProductDescription,
                            ProductId          = f.ProductId,
                            RegistrationDate   = f.RegistrationDate,
                            Status             = f.Status,
                            StatusDescription  = f.StatusDescription
                        }));
                    }
                }
            }
            return(resultado);
        }
示例#16
0
        public ActionResultVM ResetAll(string password = "******")
        {
            var vm = new ActionResultVM();

            try
            {
                if (GlobalTo.GetValue <bool>("Safe:IsDev"))
                {
                    if (!string.IsNullOrWhiteSpace(password) && password == GlobalTo.GetValue("Safe:CreateAppPassword"))
                    {
                        //清空数据库
                        using var db = new SQLite.SQLiteConnection(FileServerService.SQLiteConn);
                        db.DeleteAll <SysKey>();
                        db.DeleteAll <FileRecord>();

                        //删除上传文件
                        var rootdir = GlobalTo.WebRootPath + GlobalTo.GetValue("StaticResource:RootDir");
                        if (Directory.Exists(rootdir))
                        {
                            Directory.Delete(rootdir, true);
                        }

                        vm.Set(ARTag.success);
                    }
                    else
                    {
                        vm.Set(ARTag.unauthorized);
                        vm.Msg = "密码错误";
                    }
                }
                else
                {
                    vm.Set(ARTag.refuse);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
示例#17
0
 public static void InsertUser(User u)
 {
     using (var conn = new SQLite.SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "database.sqlite")))
     {
         conn.CreateTable <User>();
         conn.DeleteAll <User>();
         conn.Insert(u);
         conn.Commit();
         conn.Close();
     }
 }
示例#18
0
 public static void InsertUser(Context c, User u)
 {
     using (var conn = new SQLite.SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "database.sqlite")))
     {
         conn.CreateTable <User>();
         conn.DeleteAll <User>();
         DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/User/" + u.Photo), u.Photo);
         conn.Insert(u);
         conn.Commit();
         conn.Close();
     }
 }
示例#19
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                connection.CreateTable <Result>();
                connection.DeleteAll <Result>();
                connection.Insert(new Result());
            }

            IgraDo();

            Navigation.PushAsync(new NewGamePage());
        }
        async void ConnectBridgeClicked(object sender, EventArgs e)
        {
            IBridgeLocator       locator   = new HttpBridgeLocator();
            IEnumerable <string> bridgeIPs = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));

            IpAddress = bridgeIPs.FirstOrDefault();

            client = new LocalHueClient(IpAddress);

            var appKey = new HueAppKey {
                AppId = await client.RegisterAsync("pooberry", "iphone")
            };
            var bridgeIp = new HueBridge {
                HueBridgeIpAddress = IpAddress
            };

            var conn = new SQLite.SQLiteConnection(_pathToDatabase);

            //set up bridge table
            conn.CreateTable <HueBridge> ();
            conn.DeleteAll <HueBridge> ();

            //set up app key table
            conn.CreateTable <HueAppKey> ();
            conn.DeleteAll <HueAppKey> ();

            //insert app key and bridge ip into database
            var db = new SQLite.SQLiteConnection(_pathToDatabase);

            db.Insert(bridgeIp);
            db.Insert(appKey);

            var alert = new UIAlertView("Success!", "Feel free to play with your lights!", null, "OK");

            alert.Show();
        }
示例#21
0
        public ActionResultVM ResetAll(string password)
        {
            var vm = new ActionResultVM();

            try
            {
                if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:AdminPassword"))
                {
                    vm.Set(ARTag.unauthorized);
                    vm.Msg = "密码错误或已关闭管理接口";
                }
                else
                {
                    //清空数据库
                    using var db = new SQLite.SQLiteConnection(FileServerService.SQLiteConn);
                    db.DeleteAll <SysApp>();
                    db.DeleteAll <FileRecord>();

                    //删除上传文件
                    var rootdir = Fast.PathTo.Combine(GlobalTo.WebRootPath, GlobalTo.GetValue("StaticResource:RootDir"));
                    if (Directory.Exists(rootdir))
                    {
                        Directory.Delete(rootdir, true);
                    }

                    vm.Set(ARTag.success);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
示例#22
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            var page2 = new infopage();

            SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.settingpath);
            conn.CreateTable <settingsdata>();
            try { conn.DeleteAll <settingsdata>(); } catch (Exception) { }
            conn.Insert(new settingsdata()
            {
                language = (Language)lang.SelectedIndex
            });
            Navigation.PopModalAsync();
            Navigation.PushModalAsync(new Configs(true));
            Navigation.PushModalAsync(new infopage());
        }
示例#23
0
        void Select_Activated(object sender, System.EventArgs e)
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH)) //create and open connection
            {
                var NumRows = conn.DeleteAll <Book>();                                      //insert the object into the table


                if (NumRows > 0)
                {
                    DisplayAlert("Success", "Books deleted sucessfully", "Done");
                }
                else
                {
                    DisplayAlert("Failure", "Book deleted Unsucessful", "Done");
                }
                OnAppearing();
            }
        }
示例#24
0
        private void Navigate()
        {
            App.Master.IsPresented = false;
            var mainViewModal = MainViewModel.GetInstance();

            if (this.PageName == "LoginPage")
            {
                Settings.IsRemembered = "false";
                mainViewModal.Token   = null;
                mainViewModal.User    = null;
                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.DeleteAll <UserLocal>();
                }
                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.DeleteAll <TokenResponse>();
                }
                Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
            else if (this.PageName == "MyProfilePage")
            {
                //var user = MainViewModel.GetInstance().User;
                //if (user.UserTypeId == 1)
                //{
                MainViewModel.GetInstance().MyProfile = new MyProfileViewModel();
                App.Navigator.PushAsync(new MyProfilePage());
                //}
                //else
                //{
                //    MainViewModel.GetInstance().MyExternalProfile = new MyExternalProfileViewModel();
                //    App.Navigator.PushAsync(new MyExternalProfilePage());
                //}
            }

            else if (this.PageName == "ProfilesPage")
            {
                MainViewModel.GetInstance().Profiles = new ProfilesViewModel();
                Application.Current.MainPage = new NavigationPage(new ProfilesPage());
            }
        }
示例#25
0
        public static async Task RefreshEmployeeProduct(int CompanyId)
        {
            #region RefreshEmployeeProduct
            try
            {
                var itemResult = await Controller.EmployeeProductController.GetListEmployeeProduct_Day(CompanyId);

                if (itemResult.Result)
                {
                    using (SQLite.SQLiteConnection con = new SQLite.SQLiteConnection(App.RutaDB))
                    {
                        var employeeProductList = JsonConvert.DeserializeObject <List <Models.EmployeeProduct> >(itemResult.Data["Result"].ToString());
                        if (employeeProductList.Count > 0)
                        {
                            con.DeleteAll <Models.EmployeeProduct>();
                            employeeProductList.ForEach(f => con.Insert(new Models.EmployeeProduct()
                            {
                                CompanyId          = f.CompanyId,
                                EmployeeId         = f.EmployeeId,
                                EmployeeNumber     = f.EmployeeNumber,
                                AddedToService     = true,
                                CompanyDescription = f.CompanyDescription,
                                EmployeeName       = f.EmployeeName,
                                EmployeeProductId  = f.EmployeeProductId,
                                ProductDescription = f.ProductDescription,
                                ProductId          = f.ProductId,
                                RegistrationDate   = f.RegistrationDate,
                                Status             = f.Status,
                                StatusDescription  = f.StatusDescription
                            }));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            #endregion
        }
示例#26
0
 public static void InsertCompany(Context c, Company com)
 {
     using (var conn = new SQLite.SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "database.sqlite")))
     {
         conn.CreateTable <Company>();
         conn.DeleteAll <Company>();
         if (com.CompanyLogo != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.CompanyLogo), com.CompanyLogo);
         }
         if (com.Photo1 != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.Photo1), com.Photo1);
         }
         if (com.Photo2 != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.Photo2), com.Photo2);
         }
         if (com.Photo3 != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.Photo3), com.Photo3);
         }
         if (com.Photo4 != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.Photo4), com.Photo4);
         }
         if (com.Photo5 != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.Photo5), com.Photo5);
         }
         if (com.StandPhoto != null)
         {
             DbConnection.GetImageBitmapFromUrlAndSave(c, ("http://expotest.somee.com/Images/Company/" + com.StandPhoto), com.StandPhoto);
         }
         conn.Insert(com);
         conn.Commit();
         conn.Close();
     }
 }
示例#27
0
        public static void InsertPoints()
        {
            SQLitePCL.Batteries.Init();

            using var sqlite = new SQLite.SQLiteConnection("../../../Data/Main.sqlite");
            sqlite.CreateTable <XYZPoint>();

            var profit = from odd in sqlite.Table <TwoWayOdd>().ToArray().Take(10000).Select(Convert)
                         join result in sqlite.Table <Result>().ToArray()
                         on odd.MarketId equals result.MarketId
                         let xy = (GetRatio(odd), GetProfit(odd, result))
                                  group xy by xy.Item1
                                  into temp
                                  orderby temp.Key
                                  select(temp.Key, profit : temp.Average(a => (double)a.Item2), count : temp.Count());


            var arr = profit.Select(p3 => new XYZPoint((int)(p3.Key), (int)(p3.profit * XYZPoint.Factor), (int)(p3.count))).AsParallel().ToArray();

            sqlite.DeleteAll <XYZPoint>();
            int inserts = sqlite.InsertAll(arr);
        }
示例#28
0
        public static void ResetDBData()
        {
            var app = (Application.Current as App);
            using (var db = new SQLite.SQLiteConnection(app.DBPath))
            {
                db.DeleteAll<JournalEntry>();

                //db.Insert(new JournalEntry()
                //{
                //    Id = 1,
                //    Title = "Journal Entry 1",
                //    Content = "A journal entry content string blah blah",
                //    date = DateTime.Now
                //});

                //db.Insert(new JournalEntry()
                //{
                //    Id = 2,
                //    Title = "Journal Entry 2",
                //    Content = "A journal entry content string 2 blah blah",
                //    date = DateTime.UtcNow
                //});
            }
        }
示例#29
0
        //private async System.Threading.Tasks.Task obtenerDireccionesAsync()
        //{
        //    using (var client = new HttpClient())
        //    {
        //        try
        //        {
        //            var domNuevos = db.Table<MDomicilio>().Where(x => x.Nuevo).ToList();
        //            string contenidoNuevos = JsonConvert.SerializeObject(domNuevos);

        //            string newUrl = baseURL + "Clientes/Domicilios";

        //            var p = new Dictionary<string, string>
        //            {
        //                { "nuevos", contenidoNuevos }
        //            };
        //            var content = new FormUrlEncodedContent(p);
        //            var response = await client.PostAsync(newUrl, content);

        //            var responseString = await response.Content.ReadAsStringAsync();

        //            List<MDomicilio> domicilios = JsonConvert.DeserializeObject<List<MDomicilio>>(responseString);
        //            db.DeleteAll<MDomicilio>();
        //            if (domicilios != null && domicilios.Count > 0)
        //                db.InsertAll(domicilios);
        //            sincronizarReservas();
        //        }
        //        catch (System.Exception ex)
        //        {
        //            RunOnUiThread(() => Toast.MakeText(this.BaseContext, "Ocurrió el siguiente error al sincronizar domicilios: " + ex.Message, ToastLength.Long).Show());
        //        }
        //    }
        //}

        private async System.Threading.Tasks.Task obtenerPaisesAsync()
        {
            using (var client = new HttpClient())
            {
                try
                {
                    string url    = baseURL + "Config/Paises";
                    var    result = await client.GetStringAsync(url);

                    List <MPais> paises = JsonConvert.DeserializeObject <List <MPais> >(result);
                    db.DeleteAll <MPais>();
                    if (paises != null && paises.Count > 0)
                    {
                        db.InsertAll(paises);
                    }
                    syncPaises = true;
                    sincronizarReservas();
                }
                catch (System.Exception ex)
                {
                    RunOnUiThread(() => Toast.MakeText(this.BaseContext, "Ocurrió el siguiente error al sincronizar paises: " + ex.Message, ToastLength.Long).Show());
                }
            }
        }
        private void ResetData()
        {
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Empty the Customer and Project tables
                db.DeleteAll <Customer>();
                db.DeleteAll <Project>();

                // Add seed customers and projects
                var newCustomer = new Customer()
                {
                    Name    = "Adventure Works",
                    City    = "Bellevue",
                    Contact = "Mu Han"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Expense Reports",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(4)
                });
                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Time Reporting",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(14)
                });
                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Project Management",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(24)
                });


                newCustomer = new Customer()
                {
                    Name    = "Contoso",
                    City    = "Seattle",
                    Contact = "David Hamilton"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Soccer Scheduling",
                    Description = "Windows Phone app",
                    DueDate     = DateTime.Today.AddDays(6)
                });

                newCustomer = new Customer()
                {
                    Name    = "Fabrikam",
                    City    = "Redmond",
                    Contact = "Guido Pica"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Product Catalog",
                    Description = "MVC4 app",
                    DueDate     = DateTime.Today.AddDays(30)
                });

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Expense Reports",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(-3)
                });

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Expense Reports",
                    Description = "Windows Phone app",
                    DueDate     = DateTime.Today.AddDays(45)
                });

                newCustomer = new Customer()
                {
                    Name    = "Tailspin Toys",
                    City    = "Kent",
                    Contact = "Michelle Alexander"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Kids Game",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(60)
                });
            }
        }
示例#31
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                connection.CreateTable <Result>();
                var results = connection.Table <Result>().ToList();

                App.MI = results[0].MiResult;
                App.VI = results[0].ViResult;
                results.RemoveAt(0);

                List <Par> pairs = parovi(results);

                int mi = 0, vi = 0;
                foreach (var pair in pairs)
                {
                    mi += pair.first;
                    vi += pair.second;
                }

                if (mi > vi)
                {
                    if (mi >= App.LIMIT[App.LIMIT_ID])
                    {
                        App.MI++;
                        connection.CreateTable <Result>();
                        connection.DeleteAll <Result>();
                        Result temp = new Result
                        {
                            MiResult = App.MI,
                            ViResult = App.VI
                        };
                        connection.Insert(temp);
                    }
                }
                else if (vi > mi)
                {
                    if (vi >= App.LIMIT[App.LIMIT_ID])
                    {
                        App.VI++;
                        connection.CreateTable <Result>();
                        connection.DeleteAll <Result>();
                        Result temp = new Result
                        {
                            MiResult = App.MI,
                            ViResult = App.VI
                        };
                        connection.Insert(temp);
                    }
                }


                results = connection.Table <Result>().ToList();

                App.MI = results[0].MiResult;
                App.VI = results[0].ViResult;
                results.RemoveAt(0);

                pairs = parovi(results);

                rezultati.ItemsSource = pairs;

                mi = 0; vi = 0;
                foreach (var pair in pairs)
                {
                    mi += pair.first;
                    vi += pair.second;
                }
                miUkupno.Text = mi.ToString();
                viUkupno.Text = vi.ToString();

                miPartije.Text = "MI " + App.MI.ToString();
                viPartije.Text = "VI " + App.VI.ToString();
            }
        }
示例#32
0
        private void CheckLocalBox()
        {
            BoxLocal boxLocal        = new BoxLocal();
            bool     valBoxLocal     = false;
            bool     valProfileLocal = false;

            using (var conn = new SQLite.SQLiteConnection(App.root_db))
            {
                string cadenaConexion = @"data source=serverappmynfo.database.windows.net;initial catalog=mynfo;user id=adminmynfo;password=4dmiNFC*Atx2020;Connect Timeout=60";
                //string cadenaConexion = @"data source=serverappmynfo.database.windows.net;initial catalog=mynfo;user id=adminmynfo;password=4dmiNFC*Atx2020;Connect Timeout=60";
                string queryToGetBoxDefault = "select * from dbo.Boxes where dbo.boxes.UserId = "
                                              + MainViewModel.GetInstance().User.UserId
                                              + " and dbo.Boxes.BoxDefault = 1";
                StringBuilder sb;
                var           resultBoxLocal        = conn.GetTableInfo("BoxLocal");
                var           resulForeingBox       = conn.GetTableInfo("ForeingBox");
                var           resultForeingProfiles = conn.GetTableInfo("ForeingProfile");

                if (resulForeingBox.Count == 0)
                {
                    conn.CreateTable <ForeingBox>();

                    if (resultForeingProfiles.Count == 0)
                    {
                        conn.CreateTable <ForeingProfile>();
                    }
                }

                //Si no existe la tabla de las boxes locales...
                if (resultBoxLocal.Count == 0)
                {
                    //Validamos si existe la tabla de perfiles locales
                    var resultProfileLocal = conn.GetTableInfo("ProfileLocal");

                    //Crear tabla de box local
                    conn.CreateTable <BoxLocal>();

                    //Si no existe la tabla de perfiles...
                    if (resultProfileLocal.Count == 0)
                    {
                        //Creamos la tabla de perfiles local
                        conn.CreateTable <ProfileLocal>();
                    }
                    else
                    {
                        //Eliminamos los datos de la tabla de perfiles locales
                        conn.DeleteAll <ProfileLocal>();
                    }
                    //Buscar registros, y si existen, replicarlos a la box local
                    using (SqlConnection connection = new SqlConnection(cadenaConexion))
                    {
                        sb = new System.Text.StringBuilder();
                        sb.Append(queryToGetBoxDefault);
                        string sql = sb.ToString();

                        using (SqlCommand command = new SqlCommand(sql, connection))
                        {
                            connection.Open();
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    boxLocal = new BoxLocal
                                    {
                                        BoxId      = (int)reader["BoxId"],
                                        BoxDefault = true,
                                        Name       = (string)reader["Name"],
                                        UserId     = MainViewModel.GetInstance().User.UserId,
                                        Time       = (DateTime)reader["Time"],
                                        FirstName  = MainViewModel.GetInstance().User.FirstName,
                                        LastName   = MainViewModel.GetInstance().User.LastName,
                                        ImagePath  = MainViewModel.GetInstance().User.ImagePath,
                                        UserTypeId = MainViewModel.GetInstance().User.UserTypeId
                                    };

                                    conn.Insert(boxLocal);
                                    valBoxLocal = true;
                                }
                            }
                            connection.Close();
                        }
                    }
                    //Si existe la box en la nube
                    if (boxLocal.BoxId != 0)
                    {
                        //Creación de perfiles locales de box local
                        string queryGetBoxEmail = "select * from dbo.ProfileEmails " +
                                                  "join dbo.Box_ProfileEmail on" +
                                                  "(dbo.ProfileEmails.ProfileEmailId = dbo.Box_ProfileEmail.ProfileEmailId) " +
                                                  "where dbo.Box_ProfileEmail.BoxId = " + boxLocal.BoxId;
                        string queryGetBoxPhone = "select * from dbo.ProfilePhones " +
                                                  "join dbo.Box_ProfilePhone on" +
                                                  "(dbo.ProfilePhones.ProfilePhoneId = dbo.Box_ProfilePhone.ProfilePhoneId) " +
                                                  "where dbo.Box_ProfilePhone.BoxId = " + boxLocal.BoxId;
                        string queryGetBoxSMProfiles = "select * from dbo.ProfileSMs " +
                                                       "join dbo.Box_ProfileSM on" +
                                                       "(dbo.ProfileSMs.ProfileMSId = dbo.Box_ProfileSM.ProfileMSId) " +
                                                       "join dbo.RedSocials on(dbo.ProfileSMs.RedSocialId = dbo.RedSocials.RedSocialId) " +
                                                       "where dbo.Box_ProfileSM.BoxId = " + boxLocal.BoxId;

                        //Consulta para obtener perfiles email
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxEmail);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal emailProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["Name"],
                                            value       = (string)reader["Email"],
                                            ProfileType = "Email"
                                        };
                                        //Crear perfil de correo de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(emailProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Consulta para obtener perfiles teléfono
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxPhone);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal phoneProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["Name"],
                                            value       = (string)reader["Number"],
                                            ProfileType = "Phone"
                                        };
                                        //Crear perfil de teléfono de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(phoneProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Consulta para obtener perfiles de redes sociales
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxSMProfiles);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal smProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["ProfileName"],
                                            value       = (string)reader["link"],
                                            ProfileType = (string)reader["Name"]
                                        };
                                        //Crear perfil de teléfono de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(smProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Validamos que se haya insertado al menos un perfil
                        if (conn.Table <ProfileLocal>().Count() > 0)
                        {
                            valProfileLocal = true;
                        }
                    }

                    if (valBoxLocal == true && valProfileLocal == true)
                    {
                        //this.get_box();
                    }
                }
                else
                {
                    //*********************************************
                    //Si la tabla de box local si existe
                    //La vacíamos para colocar los nuevos valores
                    conn.DeleteAll <BoxLocal>();

                    conn.DeleteAll <ProfileLocal>();

                    //Validamos que esté vacía
                    int a = conn.Table <BoxLocal>().Count();

                    //Buscar registros, y si existen, replicarlos a la box local
                    using (SqlConnection connection = new SqlConnection(cadenaConexion))
                    {
                        sb = new System.Text.StringBuilder();
                        sb.Append(queryToGetBoxDefault);
                        string sql = sb.ToString();

                        using (SqlCommand command = new SqlCommand(sql, connection))
                        {
                            connection.Open();
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    boxLocal = new BoxLocal
                                    {
                                        BoxId      = (int)reader["BoxId"],
                                        BoxDefault = true,
                                        Name       = (string)reader["Name"],
                                        UserId     = MainViewModel.GetInstance().User.UserId,
                                        Time       = (DateTime)reader["Time"],
                                        FirstName  = MainViewModel.GetInstance().User.FirstName,
                                        LastName   = MainViewModel.GetInstance().User.LastName,
                                        ImagePath  = MainViewModel.GetInstance().User.ImagePath,
                                        UserTypeId = MainViewModel.GetInstance().User.UserTypeId
                                    };

                                    conn.Insert(boxLocal);
                                    valBoxLocal = true;
                                }
                            }
                            connection.Close();
                        }
                    }

                    a = conn.Table <BoxLocal>().Count();

                    //Validamos que exista una box
                    if (boxLocal.BoxId != 0)
                    {
                        //Creación de perfiles locales de box local
                        string queryGetBoxEmail = "select * from dbo.ProfileEmails " +
                                                  "join dbo.Box_ProfileEmail on" +
                                                  "(dbo.ProfileEmails.ProfileEmailId = dbo.Box_ProfileEmail.ProfileEmailId) " +
                                                  "where dbo.Box_ProfileEmail.BoxId = " + boxLocal.BoxId;
                        string queryGetBoxPhone = "select * from dbo.ProfilePhones " +
                                                  "join dbo.Box_ProfilePhone on" +
                                                  "(dbo.ProfilePhones.ProfilePhoneId = dbo.Box_ProfilePhone.ProfilePhoneId) " +
                                                  "where dbo.Box_ProfilePhone.BoxId = " + boxLocal.BoxId;
                        string queryGetBoxSMProfiles = "select * from dbo.ProfileSMs " +
                                                       "join dbo.Box_ProfileSM on" +
                                                       "(dbo.ProfileSMs.ProfileMSId = dbo.Box_ProfileSM.ProfileMSId) " +
                                                       "join dbo.RedSocials on(dbo.ProfileSMs.RedSocialId = dbo.RedSocials.RedSocialId) " +
                                                       "where dbo.Box_ProfileSM.BoxId = " + boxLocal.BoxId;

                        //Consulta para obtener perfiles email
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxEmail);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal emailProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["Name"],
                                            value       = (string)reader["Email"],
                                            ProfileType = "Email"
                                        };
                                        //Crear perfil de correo de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(emailProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Consulta para obtener perfiles teléfono
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxPhone);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal phoneProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["Name"],
                                            value       = (string)reader["Number"],
                                            ProfileType = "Phone"
                                        };
                                        //Crear perfil de teléfono de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(phoneProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Consulta para obtener perfiles de redes sociales
                        using (SqlConnection conn1 = new SqlConnection(cadenaConexion))
                        {
                            sb = new System.Text.StringBuilder();
                            sb.Append(queryGetBoxSMProfiles);

                            string sql = sb.ToString();

                            using (SqlCommand command = new SqlCommand(sql, conn1))
                            {
                                conn1.Open();
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        ProfileLocal smProfile = new ProfileLocal
                                        {
                                            IdBox       = boxLocal.BoxId,
                                            UserId      = (int)reader["UserId"],
                                            ProfileName = (string)reader["ProfileName"],
                                            value       = (string)reader["link"],
                                            ProfileType = (string)reader["Name"]
                                        };
                                        //Crear perfil de teléfono de box local predeterminada
                                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                        {
                                            connSQLite.Insert(smProfile);
                                        }
                                    }
                                }

                                conn1.Close();
                            }
                        }

                        //Validamos que se haya insertado al menos un perfil
                        if (conn.Table <ProfileLocal>().Count() > 0)
                        {
                            valProfileLocal = true;
                        }


                        if (valBoxLocal == true && valProfileLocal == true)
                        {
                            //this.get_box();
                        }
                    }
                }
            }
        }
示例#33
0
        async void deleteBox(object sender, EventArgs e, int _BoxId, int _UserId, bool _BoxDefault)
        {
            string sqlDeleteEmails           = "delete from dbo.Box_ProfileEmail where dbo.Box_ProfileEmail.BoxId = " + _BoxId,
                   sqlDeletePhones           = "delete from dbo.Box_ProfilePhone where dbo.Box_ProfilePhone.BoxId = " + _BoxId,
                   sqlDeleteSMProfiles       = "delete from dbo.Box_ProfileSM where dbo.Box_ProfileSM.BoxId = " + _BoxId,
                   sqlDeleteWhatsappProfiles = "delete from dbo.Box_ProfileWhatsapp where dbo.Box_ProfileWhatsapp.BoxId = " + _BoxId,
                   sqlDeleteBox   = "delete from dbo.Boxes where dbo.boxes.BoxId = " + _BoxId;
            string cadenaConexion = @"data source=serverappmynfo.database.windows.net;initial catalog=mynfo;user id=adminmynfo;password=4dmiNFC*Atx2020;Connect Timeout=60";
            //string cadenaConexion = @"data source=serverappmynfo.database.windows.net;initial catalog=mynfo;user id=adminmynfo;password=4dmiNFC*Atx2020;Connect Timeout=60";
            StringBuilder sb;
            string        sql;

            bool answer = await DisplayAlert(Resource.Warning, Resource.DeleteBoxNotification, Resource.Yes, Resource.No);

            #region If
            if (answer == true)
            {
                using (SqlConnection connection = new SqlConnection(cadenaConexion))
                {
                    //Borrar emails de la box
                    sb = new System.Text.StringBuilder();
                    sb.Append(sqlDeleteEmails);
                    sql = sb.ToString();

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }

                    //Borrar teléfonos de la box
                    sb = new System.Text.StringBuilder();
                    sb.Append(sqlDeletePhones);
                    sql = sb.ToString();

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }

                    //Borrar perfiles de redes sociales de la box
                    sb = new System.Text.StringBuilder();
                    sb.Append(sqlDeleteSMProfiles);
                    sql = sb.ToString();

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }

                    //Borrar perfiles de whatsapp de la box
                    sb = new System.Text.StringBuilder();
                    sb.Append(sqlDeleteWhatsappProfiles);
                    sql = sb.ToString();

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }

                    //Borrar box
                    sb = new System.Text.StringBuilder();
                    sb.Append(sqlDeleteBox);
                    sql = sb.ToString();

                    var apiSecurity = Application.Current.Resources["APISecurity"].ToString();

                    var Box = await this.apiService.GetBox(
                        apiSecurity,
                        "/api",
                        "/Boxes",
                        _BoxId);

                    MainViewModel.GetInstance().Home.RemoveList(Box);

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }

                    //Si la box era predeterminada
                    if (_BoxDefault == true)
                    {
                        //Borrar box predeterminada anterior
                        using (var conn = new SQLite.SQLiteConnection(App.root_db))
                        {
                            conn.DeleteAll <BoxLocal>();
                        }
                        //Borrar perfiles de box predeterminada anteriores
                        using (var conn = new SQLite.SQLiteConnection(App.root_db))
                        {
                            conn.DeleteAll <ProfileLocal>();
                        }

                        string   sqlUpdateBoxDefault = "update top (1) dbo.Boxes set BoxDefault = 1 where dbo.Boxes.UserId = " + _UserId;
                        BoxLocal boxLocal;
                        bool     boxLocalExists = false;
                        int      boxIdLocal     = 0;

                        //Definir nueva box default
                        sb = new System.Text.StringBuilder();
                        sb.Append(sqlUpdateBoxDefault);
                        sql = sb.ToString();

                        using (SqlCommand command = new SqlCommand(sql, connection))
                        {
                            connection.Open();
                            command.ExecuteNonQuery();
                            connection.Close();
                        }


                        string sqlGetNewDefault = "select * from dbo.Boxes " +
                                                  "where dbo.Boxes.UserId = " + _UserId +
                                                  "and dbo.Boxes.BoxDefault = 1";

                        //Definir nueva box default
                        sb = new System.Text.StringBuilder();
                        sb.Append(sqlGetNewDefault);
                        sql = sb.ToString();
                        //Creación de nueva box local
                        using (SqlCommand command = new SqlCommand(sql, connection))
                        {
                            connection.Open();
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    boxLocal = new BoxLocal
                                    {
                                        BoxId      = (int)reader["BoxId"],
                                        BoxDefault = true,
                                        Name       = (String)reader["Name"],
                                        UserId     = MainViewModel.GetInstance().User.UserId,
                                        Time       = (DateTime)reader["Time"],
                                        FirstName  = MainViewModel.GetInstance().User.FirstName,
                                        LastName   = MainViewModel.GetInstance().User.LastName,
                                        ImagePath  = MainViewModel.GetInstance().User.ImagePath,
                                        UserTypeId = MainViewModel.GetInstance().User.UserTypeId
                                    };
                                    //Crear box local predeterminada
                                    using (var conn = new SQLite.SQLiteConnection(App.root_db))
                                    {
                                        conn.CreateTable <BoxLocal>();
                                        conn.Insert(boxLocal);
                                    }
                                    //Crear tabla de perfiles de box local predeterminada
                                    using (var conn = new SQLite.SQLiteConnection(App.root_db))
                                    {
                                        conn.CreateTable <ProfileLocal>();
                                    }
                                    boxLocalExists = true;
                                    boxIdLocal     = (int)reader["BoxId"];
                                }
                            }

                            connection.Close();
                        }

                        //Si se creo la box local, procedo a crear los perfiles locales
                        if (boxLocalExists == true)
                        {
                            //Creación de perfiles locales de box local
                            string queryGetBoxEmail = "select * from dbo.ProfileEmails " +
                                                      "join dbo.Box_ProfileEmail on" +
                                                      "(dbo.ProfileEmails.ProfileEmailId = dbo.Box_ProfileEmail.ProfileEmailId) " +
                                                      "where dbo.Box_ProfileEmail.BoxId = " + boxIdLocal;
                            string queryGetBoxPhone = "select * from dbo.ProfilePhones " +
                                                      "join dbo.Box_ProfilePhone on" +
                                                      "(dbo.ProfilePhones.ProfilePhoneId = dbo.Box_ProfilePhone.ProfilePhoneId) " +
                                                      "where dbo.Box_ProfilePhone.BoxId = " + boxIdLocal;
                            string queryGetBoxSMProfiles = "select * from dbo.ProfileSMs " +
                                                           "join dbo.Box_ProfileSM on" +
                                                           "(dbo.ProfileSMs.ProfileMSId = dbo.Box_ProfileSM.ProfileMSId) " +
                                                           "join dbo.RedSocials on(dbo.ProfileSMs.RedSocialId = dbo.RedSocials.RedSocialId) " +
                                                           "where dbo.Box_ProfileSM.BoxId = " + boxIdLocal;
                            string queryGetBoxWhatsappProfiles = "select * from dbo.ProfileWhatsapps join dbo.Box_ProfileWhatsapp on " +
                                                                 "(dbo.ProfileWhatsapps.ProfileWhatsappId = dbo.Box_ProfileWhatsapp.ProfileWhatsappId) " +
                                                                 "where dbo.Box_ProfileWhatsapp.BoxId = " + boxIdLocal;

                            //Consulta para obtener perfiles email
                            using (SqlConnection conn = new SqlConnection(cadenaConexion))
                            {
                                sb = new System.Text.StringBuilder();
                                sb.Append(queryGetBoxEmail);

                                sql = sb.ToString();

                                using (SqlCommand command = new SqlCommand(sql, conn))
                                {
                                    conn.Open();
                                    using (SqlDataReader reader = command.ExecuteReader())
                                    {
                                        while (reader.Read())
                                        {
                                            ProfileLocal emailProfile = new ProfileLocal
                                            {
                                                IdBox       = boxIdLocal,
                                                UserId      = (int)reader["UserId"],
                                                ProfileName = (string)reader["Name"],
                                                value       = (string)reader["Email"],
                                                ProfileType = "Email"
                                            };
                                            //Crear perfil de correo de box local predeterminada
                                            using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                            {
                                                connSQLite.Insert(emailProfile);
                                            }
                                        }
                                    }

                                    conn.Close();
                                }
                            }

                            //Consulta para obtener perfiles teléfono
                            using (SqlConnection conn = new SqlConnection(cadenaConexion))
                            {
                                sb = new System.Text.StringBuilder();
                                sb.Append(queryGetBoxPhone);

                                sql = sb.ToString();

                                using (SqlCommand command = new SqlCommand(sql, conn))
                                {
                                    conn.Open();
                                    using (SqlDataReader reader = command.ExecuteReader())
                                    {
                                        while (reader.Read())
                                        {
                                            ProfileLocal phoneProfile = new ProfileLocal
                                            {
                                                IdBox       = boxIdLocal,
                                                UserId      = (int)reader["UserId"],
                                                ProfileName = (string)reader["Name"],
                                                value       = (string)reader["Number"],
                                                ProfileType = "Phone"
                                            };
                                            //Crear perfil de teléfono de box local predeterminada
                                            using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                            {
                                                connSQLite.Insert(phoneProfile);
                                            }
                                        }
                                    }

                                    conn.Close();
                                }
                            }

                            //Consulta para obtener perfiles de redes sociales
                            using (SqlConnection conn = new SqlConnection(cadenaConexion))
                            {
                                sb = new System.Text.StringBuilder();
                                sb.Append(queryGetBoxSMProfiles);

                                sql = sb.ToString();

                                using (SqlCommand command = new SqlCommand(sql, conn))
                                {
                                    conn.Open();
                                    using (SqlDataReader reader = command.ExecuteReader())
                                    {
                                        while (reader.Read())
                                        {
                                            ProfileLocal smProfile = new ProfileLocal
                                            {
                                                IdBox       = boxIdLocal,
                                                UserId      = (int)reader["UserId"],
                                                ProfileName = (string)reader["ProfileName"],
                                                value       = (string)reader["link"],
                                                ProfileType = (string)reader["Name"]
                                            };
                                            //Crear perfil de teléfono de box local predeterminada
                                            using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                            {
                                                connSQLite.Insert(smProfile);
                                            }
                                        }
                                    }

                                    conn.Close();
                                }
                            }

                            //Consulta para obtener perfiles whatsapp
                            using (SqlConnection conn = new SqlConnection(cadenaConexion))
                            {
                                sb = new System.Text.StringBuilder();
                                sb.Append(queryGetBoxWhatsappProfiles);

                                sql = sb.ToString();

                                using (SqlCommand command = new SqlCommand(sql, conn))
                                {
                                    conn.Open();
                                    using (SqlDataReader reader = command.ExecuteReader())
                                    {
                                        while (reader.Read())
                                        {
                                            ProfileLocal whatsappProfile = new ProfileLocal
                                            {
                                                IdBox       = boxIdLocal,
                                                UserId      = (int)reader["UserId"],
                                                ProfileName = (string)reader["Name"],
                                                value       = (string)reader["Number"],
                                                ProfileType = "Whatsapp"
                                            };
                                            //Crear perfil de whatsapp de box local predeterminada
                                            using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                                            {
                                                connSQLite.Insert(whatsappProfile);
                                            }
                                        }
                                    }

                                    conn.Close();
                                }
                            }
                        }
                    }
                }

                //Regresar a home

                MainViewModel.GetInstance().Home = new HomeViewModel();
                Application.Current.MainPage = new MasterPage();
                await PopupNavigation.Instance.PopAllAsync();
            }
            #endregion
            //if(answer == true)
            //{
            //    MainViewModel.GetInstance().DetailsBoxEdith.DeleteBox(_BoxId);
            //}
            //else
            //{
            //    return;
            //}
        }
示例#34
0
        private static void PerformSuspenedAction(string pathToDatabase)
        {
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {

                db.DeleteAll<Item> ();
                db.DeleteAll<Trader> ();
                db.DeleteAll<AdUser> ();
            }
        }
		async void ConnectBridgeClicked (object sender, EventArgs e)
		{
			IBridgeLocator locator = new HttpBridgeLocator ();
			IEnumerable<string> bridgeIPs = await locator.LocateBridgesAsync (TimeSpan.FromSeconds (5));

			IpAddress = bridgeIPs.FirstOrDefault ();

			client = new LocalHueClient (IpAddress);

			var appKey = new HueAppKey{ AppId = await client.RegisterAsync ("pooberry", "iphone") };
			var bridgeIp = new HueBridge { HueBridgeIpAddress = IpAddress };

			var conn = new SQLite.SQLiteConnection (_pathToDatabase);
			//set up bridge table
			conn.CreateTable<HueBridge> ();
			conn.DeleteAll<HueBridge> ();

			//set up app key table
			conn.CreateTable<HueAppKey> ();
			conn.DeleteAll<HueAppKey> ();

			//insert app key and bridge ip into database
			var db = new SQLite.SQLiteConnection (_pathToDatabase);
			db.Insert (bridgeIp);
			db.Insert (appKey);

			var alert = new UIAlertView ("Success!", "Feel free to play with your lights!", null, "OK");		
			alert.Show ();	
		}
        private void ResetData()
        {
            GenericListToByteArray converter = new GenericListToByteArray();
            GenericDictionaryToByteArray dictionaryConverter = new GenericDictionaryToByteArray();

            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Empty the Customer and Project tables
                //db.DeleteAll<Meal>();
                db.DeleteAll<MealItem>();

                var newMealItem = new MealItem()
                {
                    Name = "Schweinerückenbraten in Rahmsauce",
                    Category = "Pork",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { {1,15}, {2,20}, {3,30}, {4, 40} })
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "Rinderrouladen in herzhafter Sauce",
                    Category = "Beef",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "kleine Röstkartoffeln(mit geschmorten Speck und Zwiebeln)",
                    Category = "SideDish",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "Rahmkohlrabi",
                    Category = "Vegetables",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "Blumenkohl (mit Sauce Hollandaise)",
                    Category = "Vegetables",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "Rote Grütze mit Vanillesauce",
                    Category = "Desserts",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                newMealItem = null;
                newMealItem = new MealItem()
                {
                    Name = "Herrencreme",
                    Category = "Desserts",
                    IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
                };
                db.Insert(newMealItem);

                // Add seed customers and projects
                /*
                var newMeal = new Meal()
                {
                    Name = "Jutta Althues",
                    DeliveryDate = DateTime.Now,
                    NumberOfGuests = 120,
                    MealItemIDs = (byte[])converter.Convert(new List<int>() {1,2,3,4,5,6,7,8}, null, null, ""),
                    Contact = "Contact1"
                };
                db.Insert(newMeal);

                newMeal = null;
                newMeal = new Meal()
                {
                    Name = "Heinz Benter",
                    DeliveryDate = DateTime.Now,
                    NumberOfGuests = 83,
                    MealItemIDs = (byte[])converter.Convert(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }, null, null, ""),
                    Contact = "Contact2"
                };
                db.Insert(newMeal);

                newMeal = null;
                newMeal = new Meal()
                {
                    Name = "MGV",
                    DeliveryDate = DateTime.Now,
                    NumberOfGuests = 83,
                    MealItemIDs = (byte[])converter.Convert(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }, null, null, ""),
                    Contact = "Contact3"
                };
                db.Insert(newMeal);

                newMeal = null;
                newMeal = new Meal()
                {
                    Name = "Möllers",
                    DeliveryDate = DateTime.Now,
                    NumberOfGuests = 5,
                    MealItemIDs = (byte[])converter.Convert(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }, null, null, "")
                };
                db.Insert(newMeal);

                newMeal = null;
                newMeal = new Meal()
                {
                    Name = "Wiedenbrück Schützenfest 2015",
                    DeliveryDate = DateTime.Now,
                    NumberOfGuests = 2434,
                    MealItemIDs = (byte[])converter.Convert(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }, null, null, "")
                };
                db.Insert(newMeal);*/
            }
        }
示例#37
0
        private void LoadData()
        {
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Empty the Customer table
                db.DeleteAll<Customer>();

                // Add seed customers
                var newCustomer = new Customer()
                {
                    Name = "Adventure Works",
                    City = "Bellevue",
                    Contact = "Mu Han"
                };
                db.Insert(newCustomer);

                newCustomer = new Customer()
                {
                    Name = "Contoso",
                    City = "Seattle",
                    Contact = "David Hamilton"
                };
                db.Insert(newCustomer);

                newCustomer = new Customer()
                {
                    Name = "Fabrikam",
                    City = "Redmond",
                    Contact = "Guido Pica"
                };
                db.Insert(newCustomer);

                newCustomer = new Customer()
                {
                    Name = "Tailspin Toys",
                    City = "Kent",
                    Contact = "Michelle Alexander"
                };
                db.Insert(newCustomer);
            }
        }