コード例 #1
0
        private async void btnCopyCouseTableToSharedFolder_Click(object sender, RoutedEventArgs e)
        {
            var COURSETABLE_xlsx = LocalizationUtils.ResourceValueByKey("COURSETABLE/xlsx");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/" + COURSETABLE_xlsx));

            StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(Settings.LocalDataFolder);

            await file.CopyAsync(storageFolder, COURSETABLE_xlsx);
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        private async Task UpdateNobOgrIfXLSExistsAsync()
        {
            string res_SentinelsFN = LocalizationUtils.ResourceValueByKey("SENTINELS_xlsx");//determine whether file is SENTINELS.xlsx or NOBETCILER.xlsx etc.

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

            string res_SentinelFullNameTitle = LocalizationUtils.ResourceValueByKey("SENTINELS_xlsx_SENTINELFULLNAME_TITLE");
            string res_SentryDateTitle       = LocalizationUtils.ResourceValueByKey("SENTINELS_xlsx_SENTRYDATE_TITLE");
            string res_SentryLocationTitle   = LocalizationUtils.ResourceValueByKey("SENTINELS_xlsx_SENTRYLOCATION_TITLE");

            ExcelReader   a = ExcelReader.SharedReader();
            List <string> ÖğretmenAdıSoyadıList = new List <string>();
            List <string> NöbetGünüList         = new List <string>();
            List <string> NöbetAlanList         = new List <string>();

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

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

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

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

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

                foreach (var dd in data)
                {
                    foreach (var ddc in dd)
                    {
                        if (ddc.Key == res_SentinelFullNameTitle)
                        {
                            ÖğretmenAdıSoyadıList.Add(ddc.Value.ToUpper());
                        }
                        else
                        if (ddc.Key == res_SentryDateTitle)
                        {
                            NöbetGünüList.Add(ddc.Value.ToUpper());
                        }
                        else
                        if (ddc.Key == res_SentryLocationTitle)
                        {
                            NöbetAlanList.Add(ddc.Value.ToUpper());
                        }
                    }
                }
            }

            for (int i = 0; i < ÖğretmenAdıSoyadıList.Count; i++)
            {
                SentinelsDataset row = new SentinelsDataset
                {
                    SentinelFullName = ÖğretmenAdıSoyadıList[i],
                    SentryDate       = NöbetGünüList[i],
                    SentryLocation   = NöbetAlanList[i]
                };
                conn.Insert(row);
            }

            File.Delete(Path.Combine(App.WorkingPath, $"{res_SentinelsFN}_OLD.xlsx"));
            File.Move(Path.Combine(App.WorkingPath, $"{res_SentinelsFN}.xlsx"), Path.Combine(App.WorkingPath, $"{res_SentinelsFN}_OLD.xlsx"));
        }
コード例 #4
0
        public static async void ImportDataFromCouseTableXlsx()
        {
            var COURSETABLE_xlsx = LocalizationUtils.ResourceValueByKey("COURSETABLE/xlsx");

            schoolTimeSpans.Clear();
            if (!File.Exists(Path.Combine(App.WorkingPath, COURSETABLE_xlsx)))
            {
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/" + COURSETABLE_xlsx));

                StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(Settings.LocalDataFolder);

                await file.CopyAsync(storageFolder, COURSETABLE_xlsx);
            }

            ExcelReader a = ExcelReader.SharedReader();
            StorageFile f = await StorageFile.GetFileFromPathAsync(Path.Combine(App.WorkingPath, COURSETABLE_xlsx));

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

            int            hours, mins;
            int            mod4 = 0;
            SchoolTimeSpan sts  = new SchoolTimeSpan();;

            var xx = sheetdatas[0];

            var data      = xx.data;
            var datacount = data.Count;

            //foreach (var dd in data)
            for (int j = 0; j < datacount; j = j + 1)
            {
                var dd      = data[j];
                int ddcount = dd.Count;

                for (int i = 0; i < ddcount; i = i + 1)
                {
                    KeyValuePair <string, string> ddc = dd.ElementAt(i);

                    var splt = ddc.Key.Split('-');

                    if (splt.Length == 2)
                    {
                        if (splt[1] == "TITLE")
                        {
                            sts.Day   = splt[0];
                            sts.Title = ddc.Value;
                        }

                        if ((splt[1] == "T1") && (!string.IsNullOrEmpty(ddc.Value)))
                        {
                            hours         = int.Parse(ddc.Value.Split(":")[0]);
                            mins          = int.Parse(ddc.Value.Split(":")[1]);
                            sts.TimeStart = new TimeSpan(hours, mins, 0);
                        }

                        if ((splt[1] == "T2") && (!string.IsNullOrEmpty(ddc.Value)))
                        {
                            hours       = int.Parse(ddc.Value.Split(":")[0]);
                            mins        = int.Parse(ddc.Value.Split(":")[1]);
                            sts.TimeEnd = new TimeSpan(hours, mins, 0);
                        }
                    }//end of if..

                    //listView1.Items.Add($"{ddc.Key},{ddc.Value}");
                    if ((mod4 == 3) && (!string.IsNullOrEmpty(ddc.Value)))
                    {
                        schoolTimeSpans.Add(sts);
                        sts = new SchoolTimeSpan();
                    }

                    mod4 = ((mod4 + 1) % 4);
                }//end of for..
            }

            //File.Delete(Path.Combine(App.WorkingPath, "COURSETABLE_OLD.xlsx"));
            //File.Move(Path.Combine(App.WorkingPath, "COURSETABLE.xlsx"), Path.Combine(App.WorkingPath, "COURSETABLE_OLD.xlsx"));
        }