Ejemplo n.º 1
0
        public void InsertData()
        {
            // string path = await FileUtils.CreateDefaultFolder();//await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("PortoSchool", CreationCollisionOption.OpenIfExists);
            //path = Path.Combine(path, "settings.sqlite");


            // bool a1 = comboBoxNobetAlan.SelectedItem == null;
            // bool a3=comboBoxNobetGunu.sele
            //if (a1) return;

            bool a2 = string.IsNullOrWhiteSpace(textBoxNobOgrAdSoyad.Text.Trim());

            if (a2)
            {
                return;
            }

            SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), FileUtils.FullDataPath);

            SentryLocationDataset nobalan = new SentryLocationDataset
            {
                SentryLocation = (comboBoxNobetAlan.SelectedItem as SentryLocationDataset).SentryLocation ?? ""
            };

            string nobetGunu = (string)comboBoxNobetGunu.SelectedItem ?? "";

            conn.Insert(new Models.SentinelsDataset {
                SentryLocation = nobalan.SentryLocation, SentinelFullName = textBoxNobOgrAdSoyad.Text, SentryDate = nobetGunu
            });

            //listViewNobetAlanlari.ItemsSource = NobetAlanManager.GetNobetAlanlari();
        }
        private async Task UpdateNobAlanIfXLSExistsAsync()
        {
            var res_SentryLocationFN = LocalizationUtils.ResourceValueByKey("SENTRYLOCATION_xlsx");
            var res_SENTRYLOCATION_xlsx_SENTRYLOCATION_TITLE = LocalizationUtils.ResourceValueByKey("SENTRYLOCATION_xlsx_SENTRYLOCATION_TITLE");

            if (!File.Exists(Path.Combine(App.WorkingPath, $"{res_SentryLocationFN}.xlsx")))
            {
                return;
            }


            ExcelReader a = ExcelReader.SharedReader();

            List <string> NöbetAlanList = new List <string>();

            StorageFile f = await StorageFile.GetFileFromPathAsync(Path.Combine(App.WorkingPath, $"{res_SentryLocationFN}.xlsx"));

            List <SheetData> x = await a.ParseSpreadSheetFile(f);

            var conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), FileUtils.FullDataPath);

            conn.DropTable <SentryLocationDataset>();
            conn.CreateTable <SentryLocationDataset>();

            foreach (var xx in x)
            {
                var data = xx.data;

                foreach (var dd in data)
                {
                    foreach (var ddc in dd)
                    {
                        if (ddc.Key == res_SENTRYLOCATION_xlsx_SENTRYLOCATION_TITLE)
                        {
                            NöbetAlanList.Add(ddc.Value.ToUpper());
                        }
                    }
                }
            }

            for (int i = 0; i < NöbetAlanList.Count; i++)
            {
                SentryLocationDataset row = new SentryLocationDataset
                {
                    SentryLocation = NöbetAlanList[i],
                };
                conn.Insert(row);
            }

            File.Delete(Path.Combine(App.WorkingPath, $"{res_SentryLocationFN}_OLD.xlsx"));
            File.Move(Path.Combine(App.WorkingPath, $"{res_SentryLocationFN}.xlsx"), Path.Combine(App.WorkingPath, $"{res_SentryLocationFN}_OLD.xlsx"));
        }