public void LoadDatabase()
        {
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLitePCL.SQLiteConnection(path);

            string createVideo = @"CREATE TABLE IF NOT EXISTS Video (
                            VideoID VARCHAR(30) PRIMARY KEY NOT NULL,
                            VideoImg VARCHAR(100),
                            VideoTitle VARCHAR(200),
                            IsLike INTEGER,
                            PlaylistID INTEGER,
                            FOREIGN KEY(PlaylistID) REFERENCES Playlist(PlaylistID)
                        );";

            string createPlaylist        = @"CREATE TABLE IF NOT EXISTS Playlist (
                            PlaylistID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                            PlaylistName VARCHAR(100) NOT NULL UNIQUE
                        );";
            string createDefaultPlaylist = @"INSERT INTO Playlist (PlaylistName) VALUES (?);";

            using (var statement = conn.Prepare("BEGIN TRANSACTION"))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createPlaylist))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createVideo))
            {
                statement.Step();
            }

            using (var statement = conn.Prepare(createDefaultPlaylist))
            {
                statement.Bind(1, "Default");
                statement.Step();
            }
            using (var statement = conn.Prepare("COMMIT TRANSACTION"))
            {
                statement.Step();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Вызывается при обычном запуске приложения пользователем.  Будут использоваться другие точки входа,
        /// если приложение запускается для открытия конкретного файла, отображения
        /// результатов поиска и т. д.
        /// </summary>
        /// <param name="e">Сведения о запросе и обработке запуска.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Arguments))
            {
                int noteId = Convert.ToInt32(e.Arguments.Substring(e.Arguments.IndexOf("=") + 1));
                ScheduledToast.DeleteScheduledToast(noteId);

                SimpleNotesModel model = new SimpleNotesModel();
                SNItem item = model.GetItemById(noteId);

                item.N_timer_timestamp = 0;

                model.EditNote(item);
            }

            //
            //GeographicRegion userRegion = new GeographicRegion();
            //System.Diagnostics.Debug.WriteLine("=>" + Windows.System.UserProfile.GlobalizationPreferences.Languages[0]);
            //

            AppConstants appConst = new AppConstants();

            // Инициализируем БД
            StorageFile dbFile = null;
            bool isExists = true;

            try
            {
                dbFile = await StorageFile.GetFileFromPathAsync(AppConstants.DataBasePath);
            }
            catch (FileNotFoundException)
            {
                isExists = false;
            }

            if (!isExists)
            {
                StorageFile input = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Database\simple-notes.db3");
                StorageFolder folder = ApplicationData.Current.LocalFolder;
                StorageFile output = await folder.CreateFileAsync("simple-notes.db3", CreationCollisionOption.ReplaceExisting);

                IBuffer buffer = await FileIO.ReadBufferAsync(input);
                await FileIO.WriteBufferAsync(output, buffer);

                string categoryName = AppConstants.AppMessages[AppConstants.UsedLanguage]["init_category"];

                using (var db = new SQLitePCL.SQLiteConnection(AppConstants.DataBasePath))
                {
                    using (var stmt = db.Prepare("insert into categories (c_caption) values (?)"))
                    {
                        stmt.Bind(1, categoryName);
                        stmt.Step();
                    }
                }
            }
            // **************
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Не повторяйте инициализацию приложения, если в окне уже имеется содержимое,
            // только обеспечьте активность окна
            if (rootFrame == null)
            {
                // Создание фрейма, который станет контекстом навигации, и переход к первой странице
                rootFrame = new Frame();

                // TODO: Измените это значение на размер кэша, подходящий для вашего приложения
                rootFrame.CacheSize = 1;

                // Задайте язык по умолчанию
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Загрузить состояние из ранее приостановленного приложения
                }

                // Размещение фрейма в текущем окне
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // Удаляет турникетную навигацию для запуска.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated += this.RootFrame_FirstNavigated;

                // Если стек навигации не восстанавливается для перехода к первой странице,
                // настройка новой страницы путем передачи необходимой информации в качестве параметра
                // навигации
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Обеспечение активности текущего окна
            Window.Current.Activate();
        }
Beispiel #3
0
        public void LoadDatabase()
        {
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLitePCL.SQLiteConnection(path);

            string createUser     = @"CREATE TABLE IF NOT EXISTS User (
                            UserID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                            Username VARCHAR(100) NOT NULL,
                            UserPassword VARCHAR(100) NOT NULL,
                            Fullname VARCHAR(100),
                            Email VARCHAR(100),
                            NumberPhone VARCHAR(20),
                            Address VARCHAR(200)
                        );";
            string createCategory = @"CREATE TABLE IF NOT EXISTS Category (
                            CategoryID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                            CategoryName VARCHAR(100) NOT NULL
                        );";

            string createSubCategory = @"CREATE TABLE IF NOT EXISTS SubCategory (
                            SubCategoryID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                            SubCategoryName  vARCHAR(100) NOT NULL,
                            CategoryID INTEGER,
                            FOREIGN KEY(CategoryID) REFERENCES Category(CategoryID)
                        );";

            string createProduct = @"CREATE TABLE IF NOT EXISTS Product(
                            ProductID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                            ProductName VARCHAR(100) NOT NULL,
                            ProductDesc VARCHAR(500),
                            ProductPrice DOUBLE NOT NULL,
                            ProductImage VARCHAR(500),
                            ProductTrailer VARCHAR(500),
                            CategoryID INTEGER,
                            SubCategoryID INTEGER,
                            FOREIGN KEY (CategoryID) REFERENCES Category(CategoryID),
                            FOREIGN KEY (SubCategoryID) REFERENCES SubCategory(SubCategoryID)
                        );";

            using (var statement = conn.Prepare("BEGIN TRANSACTION"))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createUser))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createCategory))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createSubCategory))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare(createProduct))
            {
                statement.Step();
            }
            using (var statement = conn.Prepare("COMMIT TRANSACTION"))
            {
                statement.Step();
            }
        }
Beispiel #4
0
 public void deleteEntry(SQLitePCL.SQLiteConnection conn, string name)
 {
     Helper.HelperMethods.removeData(conn, name);
 }
Beispiel #5
0
        //public Dictionary<string, string> downloadHistory
        //{
        //    get
        //    {
        //        return _downloadHistory;
        //    }
        //    set
        //    {
        //        _downloadHistory = value;
        //        NotifyPropertyChanged();
        //    }
        //}


        //public void FillAllDownloadsList()
        //{
        //    foreach (var value in AllDownloads.Values)
        //    {
        //        CreateCollection(value.Key, value.Value.ToString());
        //    }
        //}

        public void LoadData(SQLitePCL.SQLiteConnection conn)
        {
            DownloadList = Helper.HelperMethods.getData(conn);
        }
Beispiel #6
0
 public SettingDAO(SQLitePCL.SQLiteConnection conn) : base(conn)
 {
     SettingCache = this.SelectAll();
 }
Beispiel #7
0
 public SettingDAO(SQLitePCL.SQLiteConnection conn) : base(conn)
 {
 }
Beispiel #8
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="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;
#if WINDOWS_UWP
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(100, 100));

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
            {  // ver 2.0
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
                {
                    if (rootFrame?.BackStackDepth > 0)
                    {
                        a.Handled = true;
                        rootFrame.GoBack();
                    }
                };
                ProvideGuiBackButton = false;
            }
#endif

#if WINDOWS_APP
            
#endif

#if WINDOWS_PHONE_APP
            ProvideGuiBackButton = false;
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
            {
                if (rootFrame?.BackStackDepth > 0)
                {
                    a.Handled = true;
                    rootFrame.GoBack();
                }
            };
#endif

            DatabaseConnection = Archiver.GetConnection();

            // 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();
                rootFrame.ContentTransitions = new TransitionCollection() { new ContentThemeTransition() { HorizontalOffset = 100 } };

                Common.SuspensionManager.KnownTypes.Add(typeof(int[]));
                Common.SuspensionManager.RegisterFrame(rootFrame, "Session");

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    await Common.SuspensionManager.RestoreAsync();
                }

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

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated += this.RootFrame_FirstNavigated;
#endif

                // 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), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }