diff --git a/myRoRo.sln b/myRoRo.sln new file mode 100644 index 0000000..1d66409 --- /dev/null +++ b/myRoRo.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2002 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "myRoRo", "myRoRo\myRoRo.csproj", "{69838279-964F-45BF-B6CE-85B782710430}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69838279-964F-45BF-B6CE-85B782710430}.Debug|ARM.ActiveCfg = Debug|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Debug|ARM.Build.0 = Debug|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Debug|ARM.Deploy.0 = Debug|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x64.ActiveCfg = Debug|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x64.Build.0 = Debug|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x64.Deploy.0 = Debug|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x86.ActiveCfg = Debug|x86 + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x86.Build.0 = Debug|x86 + {69838279-964F-45BF-B6CE-85B782710430}.Debug|x86.Deploy.0 = Debug|x86 + {69838279-964F-45BF-B6CE-85B782710430}.Release|ARM.ActiveCfg = Release|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Release|ARM.Build.0 = Release|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Release|ARM.Deploy.0 = Release|ARM + {69838279-964F-45BF-B6CE-85B782710430}.Release|x64.ActiveCfg = Release|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Release|x64.Build.0 = Release|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Release|x64.Deploy.0 = Release|x64 + {69838279-964F-45BF-B6CE-85B782710430}.Release|x86.ActiveCfg = Release|x86 + {69838279-964F-45BF-B6CE-85B782710430}.Release|x86.Build.0 = Release|x86 + {69838279-964F-45BF-B6CE-85B782710430}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {468B6ACF-3977-4DC6-8BEE-A0EDD9BFFE90} + EndGlobalSection +EndGlobal diff --git a/myRoRo/App.xaml b/myRoRo/App.xaml new file mode 100644 index 0000000..724232b --- /dev/null +++ b/myRoRo/App.xaml @@ -0,0 +1,7 @@ + + + diff --git a/myRoRo/App.xaml.cs b/myRoRo/App.xaml.cs new file mode 100644 index 0000000..70221c2 --- /dev/null +++ b/myRoRo/App.xaml.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace myRoRo +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// 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. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { + 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(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (e.PrelaunchActivated == false) + { + 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 + rootFrame.Navigate(typeof(MainPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); + } + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/myRoRo/Assets/LargeTile.scale-100.png b/myRoRo/Assets/LargeTile.scale-100.png new file mode 100644 index 0000000..e8b3a99 Binary files /dev/null and b/myRoRo/Assets/LargeTile.scale-100.png differ diff --git a/myRoRo/Assets/LargeTile.scale-125.png b/myRoRo/Assets/LargeTile.scale-125.png new file mode 100644 index 0000000..74abb19 Binary files /dev/null and b/myRoRo/Assets/LargeTile.scale-125.png differ diff --git a/myRoRo/Assets/LargeTile.scale-150.png b/myRoRo/Assets/LargeTile.scale-150.png new file mode 100644 index 0000000..9fb41c6 Binary files /dev/null and b/myRoRo/Assets/LargeTile.scale-150.png differ diff --git a/myRoRo/Assets/LargeTile.scale-200.png b/myRoRo/Assets/LargeTile.scale-200.png new file mode 100644 index 0000000..03e40c5 Binary files /dev/null and b/myRoRo/Assets/LargeTile.scale-200.png differ diff --git a/myRoRo/Assets/LargeTile.scale-400.png b/myRoRo/Assets/LargeTile.scale-400.png new file mode 100644 index 0000000..b559cd3 Binary files /dev/null and b/myRoRo/Assets/LargeTile.scale-400.png differ diff --git a/myRoRo/Assets/LockScreenLogo.scale-200.png b/myRoRo/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..735f57a Binary files /dev/null and b/myRoRo/Assets/LockScreenLogo.scale-200.png differ diff --git a/myRoRo/Assets/SmallTile.scale-100.png b/myRoRo/Assets/SmallTile.scale-100.png new file mode 100644 index 0000000..3e6fd06 Binary files /dev/null and b/myRoRo/Assets/SmallTile.scale-100.png differ diff --git a/myRoRo/Assets/SmallTile.scale-125.png b/myRoRo/Assets/SmallTile.scale-125.png new file mode 100644 index 0000000..632887d Binary files /dev/null and b/myRoRo/Assets/SmallTile.scale-125.png differ diff --git a/myRoRo/Assets/SmallTile.scale-150.png b/myRoRo/Assets/SmallTile.scale-150.png new file mode 100644 index 0000000..0e5b683 Binary files /dev/null and b/myRoRo/Assets/SmallTile.scale-150.png differ diff --git a/myRoRo/Assets/SmallTile.scale-200.png b/myRoRo/Assets/SmallTile.scale-200.png new file mode 100644 index 0000000..4418e1f Binary files /dev/null and b/myRoRo/Assets/SmallTile.scale-200.png differ diff --git a/myRoRo/Assets/SmallTile.scale-400.png b/myRoRo/Assets/SmallTile.scale-400.png new file mode 100644 index 0000000..f640a61 Binary files /dev/null and b/myRoRo/Assets/SmallTile.scale-400.png differ diff --git a/myRoRo/Assets/SplashScreen.scale-100.png b/myRoRo/Assets/SplashScreen.scale-100.png new file mode 100644 index 0000000..f7e1c3b Binary files /dev/null and b/myRoRo/Assets/SplashScreen.scale-100.png differ diff --git a/myRoRo/Assets/SplashScreen.scale-125.png b/myRoRo/Assets/SplashScreen.scale-125.png new file mode 100644 index 0000000..f0bde00 Binary files /dev/null and b/myRoRo/Assets/SplashScreen.scale-125.png differ diff --git a/myRoRo/Assets/SplashScreen.scale-150.png b/myRoRo/Assets/SplashScreen.scale-150.png new file mode 100644 index 0000000..4cf8a01 Binary files /dev/null and b/myRoRo/Assets/SplashScreen.scale-150.png differ diff --git a/myRoRo/Assets/SplashScreen.scale-200.png b/myRoRo/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000..1bd2d8e Binary files /dev/null and b/myRoRo/Assets/SplashScreen.scale-200.png differ diff --git a/myRoRo/Assets/SplashScreen.scale-400.png b/myRoRo/Assets/SplashScreen.scale-400.png new file mode 100644 index 0000000..574cf7d Binary files /dev/null and b/myRoRo/Assets/SplashScreen.scale-400.png differ diff --git a/myRoRo/Assets/Square150x150Logo.scale-100.png b/myRoRo/Assets/Square150x150Logo.scale-100.png new file mode 100644 index 0000000..0a325ac Binary files /dev/null and b/myRoRo/Assets/Square150x150Logo.scale-100.png differ diff --git a/myRoRo/Assets/Square150x150Logo.scale-125.png b/myRoRo/Assets/Square150x150Logo.scale-125.png new file mode 100644 index 0000000..66aa2c2 Binary files /dev/null and b/myRoRo/Assets/Square150x150Logo.scale-125.png differ diff --git a/myRoRo/Assets/Square150x150Logo.scale-150.png b/myRoRo/Assets/Square150x150Logo.scale-150.png new file mode 100644 index 0000000..b744ef4 Binary files /dev/null and b/myRoRo/Assets/Square150x150Logo.scale-150.png differ diff --git a/myRoRo/Assets/Square150x150Logo.scale-200.png b/myRoRo/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..3642b4b Binary files /dev/null and b/myRoRo/Assets/Square150x150Logo.scale-200.png differ diff --git a/myRoRo/Assets/Square150x150Logo.scale-400.png b/myRoRo/Assets/Square150x150Logo.scale-400.png new file mode 100644 index 0000000..b82508e Binary files /dev/null and b/myRoRo/Assets/Square150x150Logo.scale-400.png differ diff --git a/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-16.png b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-16.png new file mode 100644 index 0000000..103342e Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-16.png differ diff --git a/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-256.png b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-256.png new file mode 100644 index 0000000..d481a31 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-256.png differ diff --git a/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-32.png b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-32.png new file mode 100644 index 0000000..17e7e73 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-32.png differ diff --git a/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-48.png b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-48.png new file mode 100644 index 0000000..523be23 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.altform-unplated_targetsize-48.png differ diff --git a/myRoRo/Assets/Square44x44Logo.scale-100.png b/myRoRo/Assets/Square44x44Logo.scale-100.png new file mode 100644 index 0000000..c2fe073 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.scale-100.png differ diff --git a/myRoRo/Assets/Square44x44Logo.scale-125.png b/myRoRo/Assets/Square44x44Logo.scale-125.png new file mode 100644 index 0000000..c1f2aab Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.scale-125.png differ diff --git a/myRoRo/Assets/Square44x44Logo.scale-150.png b/myRoRo/Assets/Square44x44Logo.scale-150.png new file mode 100644 index 0000000..b853bb0 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.scale-150.png differ diff --git a/myRoRo/Assets/Square44x44Logo.scale-200.png b/myRoRo/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..ba851b7 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.scale-200.png differ diff --git a/myRoRo/Assets/Square44x44Logo.scale-400.png b/myRoRo/Assets/Square44x44Logo.scale-400.png new file mode 100644 index 0000000..a11eb5b Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.scale-400.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-16.png b/myRoRo/Assets/Square44x44Logo.targetsize-16.png new file mode 100644 index 0000000..60a88cb Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-16.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-24.png b/myRoRo/Assets/Square44x44Logo.targetsize-24.png new file mode 100644 index 0000000..2f9cd27 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-24.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/myRoRo/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..cf0e53b Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-256.png b/myRoRo/Assets/Square44x44Logo.targetsize-256.png new file mode 100644 index 0000000..9fe1476 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-256.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-32.png b/myRoRo/Assets/Square44x44Logo.targetsize-32.png new file mode 100644 index 0000000..3d4b2ae Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-32.png differ diff --git a/myRoRo/Assets/Square44x44Logo.targetsize-48.png b/myRoRo/Assets/Square44x44Logo.targetsize-48.png new file mode 100644 index 0000000..3a28431 Binary files /dev/null and b/myRoRo/Assets/Square44x44Logo.targetsize-48.png differ diff --git a/myRoRo/Assets/StoreLogo.backup.png b/myRoRo/Assets/StoreLogo.backup.png new file mode 100644 index 0000000..7385b56 Binary files /dev/null and b/myRoRo/Assets/StoreLogo.backup.png differ diff --git a/myRoRo/Assets/StoreLogo.scale-100.png b/myRoRo/Assets/StoreLogo.scale-100.png new file mode 100644 index 0000000..e574fba Binary files /dev/null and b/myRoRo/Assets/StoreLogo.scale-100.png differ diff --git a/myRoRo/Assets/StoreLogo.scale-125.png b/myRoRo/Assets/StoreLogo.scale-125.png new file mode 100644 index 0000000..7580b03 Binary files /dev/null and b/myRoRo/Assets/StoreLogo.scale-125.png differ diff --git a/myRoRo/Assets/StoreLogo.scale-150.png b/myRoRo/Assets/StoreLogo.scale-150.png new file mode 100644 index 0000000..0e8105b Binary files /dev/null and b/myRoRo/Assets/StoreLogo.scale-150.png differ diff --git a/myRoRo/Assets/StoreLogo.scale-200.png b/myRoRo/Assets/StoreLogo.scale-200.png new file mode 100644 index 0000000..3ebaf95 Binary files /dev/null and b/myRoRo/Assets/StoreLogo.scale-200.png differ diff --git a/myRoRo/Assets/StoreLogo.scale-400.png b/myRoRo/Assets/StoreLogo.scale-400.png new file mode 100644 index 0000000..c3f93a9 Binary files /dev/null and b/myRoRo/Assets/StoreLogo.scale-400.png differ diff --git a/myRoRo/Assets/Wide310x150Logo.scale-100.png b/myRoRo/Assets/Wide310x150Logo.scale-100.png new file mode 100644 index 0000000..a56194f Binary files /dev/null and b/myRoRo/Assets/Wide310x150Logo.scale-100.png differ diff --git a/myRoRo/Assets/Wide310x150Logo.scale-125.png b/myRoRo/Assets/Wide310x150Logo.scale-125.png new file mode 100644 index 0000000..8635f17 Binary files /dev/null and b/myRoRo/Assets/Wide310x150Logo.scale-125.png differ diff --git a/myRoRo/Assets/Wide310x150Logo.scale-150.png b/myRoRo/Assets/Wide310x150Logo.scale-150.png new file mode 100644 index 0000000..4def011 Binary files /dev/null and b/myRoRo/Assets/Wide310x150Logo.scale-150.png differ diff --git a/myRoRo/Assets/Wide310x150Logo.scale-200.png b/myRoRo/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..f7e1c3b Binary files /dev/null and b/myRoRo/Assets/Wide310x150Logo.scale-200.png differ diff --git a/myRoRo/Assets/Wide310x150Logo.scale-400.png b/myRoRo/Assets/Wide310x150Logo.scale-400.png new file mode 100644 index 0000000..1bd2d8e Binary files /dev/null and b/myRoRo/Assets/Wide310x150Logo.scale-400.png differ diff --git a/myRoRo/DatabaseHelper.cs b/myRoRo/DatabaseHelper.cs new file mode 100644 index 0000000..d786cbb --- /dev/null +++ b/myRoRo/DatabaseHelper.cs @@ -0,0 +1,160 @@ +using Microsoft.Data.Sqlite; +using System; +using System.Collections.Generic; +#if DEBUG +using System.Diagnostics; +#endif +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Xaml.Controls; + +namespace myRoRo +{ + class DatabaseHelper + { + public static string DATABASE_NAME = "schedule.db"; + public static string TABLE_NAME = "day"; + public string COL_1 = "kl", + COL_2 = "std", + COL_3 = "fach", + COL_4 = "raum", + COL_5 = "vlehrer", + COL_6 = "vfach", + COL_7 = "vraum", + COL_8 = "info"; + + public DatabaseHelper() + { + using (SqliteConnection db = new SqliteConnection("Filename=" + DATABASE_NAME)) + { + db.Open(); + + try + { + EnsureTableExists(1, db).ExecuteReader(); + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + #endif + } + + db.Close(); + } + } + + public void DeleteTable(int index) + { + using (SqliteConnection db = new SqliteConnection("Filename=" + DATABASE_NAME)) + { + db.Open(); + + SqliteCommand insertCommand = new SqliteCommand + { + Connection = db, + CommandText = "DROP TABLE IF EXISTS " + TABLE_NAME + index + }; + + try + { + insertCommand.ExecuteReader(); + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + #endif + } + + db.Close(); + } + } + + private SqliteCommand EnsureTableExists(int index, SqliteConnection db) + { + return new SqliteCommand + { + Connection = db, + + CommandText = "create table if not exists " + TABLE_NAME + index + "(ID INTEGER PRIMARY KEY AUTOINCREMENT," + + COL_1 + " TEXT," + + COL_2 + " TEXT," + + COL_3 + " TEXT," + + COL_4 + " TEXT," + + COL_5 + " TEXT," + + COL_6 + " TEXT," + + COL_7 + " TEXT," + + COL_8 + " TEXT)" + }; + } + + public bool InsertData(int tableIndex, + string kl, + string std, + string fach, + string raum, + string vlehrer, + string vfach, + string vraum, + string info) + { + + using (SqliteConnection db = new SqliteConnection("Filename=" + DATABASE_NAME)) + { + db.Open(); + + SqliteCommand insertCommand = new SqliteCommand + { + Connection = db, + + CommandText = "INSERT INTO " + TABLE_NAME + tableIndex + " (" + + COL_1 + ", " + + COL_2 + ", " + + COL_3 + ", " + + COL_4 + ", " + + COL_5 + ", " + + COL_6 + ", " + + COL_7 + ", " + + COL_8 + + + ") VALUES (@0, @1 , @2, @3, @4, @5, @6, @7)" + }; + + insertCommand.Parameters.AddWithValue("@0", kl); + insertCommand.Parameters.AddWithValue("@1", std); + insertCommand.Parameters.AddWithValue("@2", fach); + insertCommand.Parameters.AddWithValue("@3", raum); + insertCommand.Parameters.AddWithValue("@4", vlehrer); + insertCommand.Parameters.AddWithValue("@5", vfach); + insertCommand.Parameters.AddWithValue("@6", vraum); + insertCommand.Parameters.AddWithValue("@7", info); + + try + { + EnsureTableExists(tableIndex, db).ExecuteReader(); + insertCommand.ExecuteNonQuery(); + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + /*ContentDialog noWifiDialog = new ContentDialog() + { + Title = "Verbindungsfehler", + Content = "Bitte Netzwerk überprüfen und erneut versuchen. Fehlermeldung:\n" + e.Message + e.StackTrace, + CloseButtonText = "Ok" + }; + + noWifiDialog.ShowAsync();*/ + #endif + return false; + } + db.Close(); + } + + return true; + } + } +} diff --git a/myRoRo/MainPage.xaml b/myRoRo/MainPage.xaml new file mode 100644 index 0000000..4744929 --- /dev/null +++ b/myRoRo/MainPage.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/myRoRo/MainPage.xaml.cs b/myRoRo/MainPage.xaml.cs new file mode 100644 index 0000000..95644bc --- /dev/null +++ b/myRoRo/MainPage.xaml.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +#if DEBUG +using System.Diagnostics; +#endif +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel.Background; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 + +namespace myRoRo +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainPage : Page + { + private ObservableCollection schedules; + + public MainPage() + { + #if DEBUG + Debug.WriteLine("Starting App..."); + #endif + InitializeComponent(); + + LoadingProcessProgressRing.IsActive = true; + LoadingProcessProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible; + + InitLoadSequence(); + #if DEBUG + Debug.WriteLine("Initialization Complete."); + #endif + + + //Setting up byckground sync + + /*TimeTrigger backgroundSync = new TimeTrigger(15, false); + BackgroundExecutionManager.RequestAccessAsync(); + + string entryPoint = "myRoRo.Sync"; + string taskName = "NotificationSync"; + + BackgroundTaskRegistration task = RegisterBackgroundTask(entryPoint, taskName, backgroundSync);*/ + } + + private async void InitLoadSequence() + { + #if DEBUG + Debug.WriteLine("Network Task created!"); + #endif + await ScheduleNetwork.Refresh(); + #if DEBUG + Debug.WriteLine("Loading Schedule Complete."); + #endif + + schedules = null; + schedules = ScheduleManager.GetSchedules(); + + //Updating Bindings (the data behind the Pivot) + Binding binding = new Binding(); + binding.Source = schedules; + binding.Mode = BindingMode.TwoWay; + binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; + BindingOperations.SetBinding(pivot1, Pivot.ItemsSourceProperty, binding); + + LoadingProcessProgressRing.IsActive = false; + LoadingProcessProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; + + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + pivot1.Title = (string)localSettings.Values["UpdateDate"]; + } + } +} diff --git a/myRoRo/NameShortcuts.cs b/myRoRo/NameShortcuts.cs new file mode 100644 index 0000000..89cadcd --- /dev/null +++ b/myRoRo/NameShortcuts.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace myRoRo +{ + class NameShortcuts + { + public static string GetRealName(string fakeName) + { + //Not sure if I am allowed to do this, so it will not make it into release... + #if DEBUG + switch (fakeName) { + case "Thei": + return "Frau Theiss"; + case "Mitt": + return "Herrn Mittag"; + case "Otti": + return "Herrn Ottink"; + case "MoßF": + return "Frau Moß"; + case "Conr": + return "Frau Conrad"; + case "Vökl": + return "Frau Völker-Klatte"; + case "Häne": + return "Herrn Hänel"; + case "vPar": + return "Herrn von Paris"; + case "Wala": + return "Frau Walachowitz"; + case "Beye": + return "Herrn Beyerle"; + case "Gres": + return "Frau Gresch"; + case "Gegu": + return "Herrn Gegusch"; + case "Kühn": + return "Frau Kühne"; + case "Jahn": + return "Frau Jahn"; + case "Drew": + return "Frau Drews"; + case "Siek": + return "Herrn Siek"; + case "Bett": + return "Herrn Bettencourt"; + case "Hüls": + return "Herrn Hülsmann"; + case "Pösc": + return "Herrn Pöschl"; + case "Toka": + return "Frau Tokarik"; + case "Krab": + return "Frau Krabbe"; + case "Fisc": + return "Frau Fischer"; + case "Pill": + return "Frau Pillin"; + case "Möbi": + return "Herrn Möbius"; + case "Jehl": + return "Herrn Jehle"; + case "Deut": + return "Frau Deutschmann"; + case "Rex": + return "Frau Rex"; + case "Wese": + return "Herrn Weser"; + case "Bern": + return "Frau Bernd"; + case "Kans": + return "Herrn Kanstinger"; + case "Köni": + return "Herrn König"; + case "MoßH": + return "Herrn Moß"; + case "Brem": + return "Herrn Bremert"; + case "Miko": + return "Frau Mikoleiwski"; + case "Rapp": + return "Herrn Rapp"; + case "Habe": + return "Frau Habermann-Lange"; + case "Bahr": + return "Frau Bahr"; + case "Lehn": + return "Frau Lehne"; + default: + return "[" + fakeName + "]"; + } +# endif + return fakeName; + } + + public static string GetRealClass(string fakeClass) + { + switch (fakeClass) + { + case "Ma": + return "Mathe"; + case "Mu": + return "Musik"; + case "NaWi": + return fakeClass; + case "Ku": + return "Kunst"; + case "Sp/m": + return "Sport Jungen"; + case "Sp/w": + return "Sport Mädchen"; + case "Eth": + return "Ethik"; + case "Ge": + return "Geschichte"; + case "Ev.R": + return "Religion (Ev)"; + case "De": + return "Deutsch"; + case "Ch": + return "Chemie"; + case "Ek": + return "Erdkunde"; + case "Ph": + return "Physik"; + case "Bi": + return "Bio"; + + default: + return /*"[" + */fakeClass/* + "]"*/; + } + } + } +} diff --git a/myRoRo/Package.appxmanifest b/myRoRo/Package.appxmanifest new file mode 100644 index 0000000..0c41713 --- /dev/null +++ b/myRoRo/Package.appxmanifest @@ -0,0 +1,33 @@ + + + + + + myRoRo + wulka + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/myRoRo/Properties/AssemblyInfo.cs b/myRoRo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8d08673 --- /dev/null +++ b/myRoRo/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("myRoRo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("myRoRo")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/myRoRo/Properties/Default.rd.xml b/myRoRo/Properties/Default.rd.xml new file mode 100644 index 0000000..af00722 --- /dev/null +++ b/myRoRo/Properties/Default.rd.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/myRoRo/Schedule.cs b/myRoRo/Schedule.cs new file mode 100644 index 0000000..d1400bf --- /dev/null +++ b/myRoRo/Schedule.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +#if DEBUG +using System.Diagnostics; +#endif +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace myRoRo +{ + public class ScheduleEntry + { + public string ClassName + { + get; + set; + } + + public string Entries + { + get; + set; + } + + public int Height + { + get; + set; + } + } + + public class Schedule + { + public string DayName + { + get; + set; + } + + public List ScheduleEntries + { + get; + set; + } + } + + public class ScheduleManager + { + public static ObservableCollection GetSchedules() + { + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + + #if DEBUG + Debug.WriteLine("Creating ScheduleManager"); + #endif + + ObservableCollection outList = new ObservableCollection(); + + int pagesCount = (int) localSettings.Values[ScheduleNetwork.PAGES_COUNT]; + + for (int i = 1; i <= pagesCount; i++) + { + List entries = new List(); + string date = ScheduleNetwork.GetDate(i); + + ScheduleHandler handler = new ScheduleHandler(i); + + List classes = handler.getClassList(); + + foreach (string classStr in classes) + { + entries.Add(new ScheduleEntry + { + ClassName = classStr, + Entries = handler.GetClassInfo(classStr) + }); + } + + outList.Add(new Schedule + { + DayName = date, + ScheduleEntries = entries + }); + } + + return outList; + } + } +} \ No newline at end of file diff --git a/myRoRo/ScheduleHandler.cs b/myRoRo/ScheduleHandler.cs new file mode 100644 index 0000000..36e787d --- /dev/null +++ b/myRoRo/ScheduleHandler.cs @@ -0,0 +1,437 @@ +using System; +using System.Collections.Generic; +#if DEBUG +using System.Diagnostics; +#endif +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Data.Sqlite; +using Microsoft.Data.Sqlite.Internal; + +namespace myRoRo +{ + class ScheduleHandler + { + private DatabaseHelper helper; + private string lineBreak = "\n"; + int index; + + public ScheduleHandler(int index) + { + this.index = index; + helper = new DatabaseHelper(); + } + + public List getClassList() + { + + List outputList = new List(); //this is the List which will be put out. at the end it will contain all Classes that are appearing in the schedule + + using (SqliteConnection db = new SqliteConnection("Filename=" + DatabaseHelper.DATABASE_NAME)) + { + db.Open(); + SqliteCommand selectCommand = new SqliteCommand("SELECT " + helper.COL_1 + " FROM " + DatabaseHelper.TABLE_NAME + index + " GROUP BY " + helper.COL_1, db); + SqliteDataReader query; + + + try + { + query = selectCommand.ExecuteReader(); + + + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + #endif + return null; + } + + while (query.Read()) + { + outputList.Add(query.GetString(0)); + } + + db.Close(); + } + return outputList; + } + + public List GetForSQL(string SQL) + { + List output = new List(); + using (SqliteConnection db = new SqliteConnection("Filename=" + DatabaseHelper.DATABASE_NAME)) + { + SqliteCommand command = new SqliteCommand(SQL, db); + SqliteDataReader query; + + try + { + query = command.ExecuteReader(); + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + #endif + return null; + } + + int i = 0; + while (query.Read()) + { + try + { + query.GetString(i); + } + catch (Exception e) + { + break; + } + i++; + } + + db.Close(); + } + + return output; + } + + /*public List GetClassListCustom() + { + + SQLiteDatabase db = databaseHelper.getWritableDatabase(); + Cursor res; + SharedPreferences pref = context.getSharedPreferences("Tralala", MODE_PRIVATE); + ArrayList outputList = new ArrayList<>(); + + res = db.rawQuery("SELECT kl FROM " + databaseHelper.TABLE_NAME + index + " WHERE " + pref.getString(SettingsActivity.CUSTOMSQL_NAME, "") + " GROUP BY " + databaseHelper.COL_1, null); + + while (res.moveToNext()) { + outputList.add(res.getString(0)); + } + res.close(); + + return outputList; + } + + public ArrayList getClassInfoCustom(String thisClass) throws Exception { + SharedPreferences pref = context.getSharedPreferences("Tralala", MODE_PRIVATE); + + return getClassInfoForSQL("SELECT * FROM " + databaseHelper.TABLE_NAME + index + " WHERE (" + pref.getString(SettingsActivity.CUSTOMSQL_NAME, "")+ ") and " + databaseHelper.COL_1 + " = '" + thisClass + "'"); + } + + public ArrayList getClassListPersonalized(int id) { + SQLiteDatabase db = databaseHelper.getWritableDatabase(); + Cursor res; + SharedPreferences pref = context.getSharedPreferences("Tralala", MODE_PRIVATE); + String coursesRaw = pref.getString(SettingsActivity.CLASSES_NAME, ""); + ArrayList outputList = new ArrayList<>(); + if (coursesRaw == "") + return outputList; + + ArrayList extraArguments = new ArrayList<>(); + String buffer = ""; + + for(int i = 0; i < coursesRaw.length(); i++) { + if ((coursesRaw.charAt(i) == ';') || (i == (coursesRaw.length() - 1))) { + if (i == (coursesRaw.length() - 1)) + buffer = buffer + coursesRaw.charAt(i); + extraArguments.add(databaseHelper.COL_1 + " = '" + buffer.trim() + "' COLLATE NOCASE"); + buffer = ""; + } else { + buffer = buffer + coursesRaw.charAt(i); + } + } + + String extraArgumentsSQL = ""; + if (extraArguments.size() != 0) + extraArgumentsSQL = " WHERE "; + + for(int i = 0; i < extraArguments.size(); i++) { + extraArgumentsSQL = extraArgumentsSQL + extraArguments.get(i) + " COLLATE NOCASE"; + if(i < (extraArguments.size() - 1)) + extraArgumentsSQL = extraArgumentsSQL + " or "; + } + + res = db.rawQuery("SELECT kl FROM " + databaseHelper.TABLE_NAME + index + extraArgumentsSQL + " GROUP BY " + databaseHelper.COL_1, null); + + try { + while (res.moveToNext()) { + outputList.add(res.getString(0)); + } + } finally { + res.close(); + } + + return outputList; + } + + /** + * The basic idea of this method is that you have go a String in SharedPreferences. It will look like this: "gen 1;gku 1;Fr 2" The ; seperates them from each other. So this method returns + * a ArrayList of Spannable Strings with the Class you want and in addition only the courses you want. When the user puts in all the Info, first he will be asked to put in all the classes + * which potentially could fit the rules + * @param thisClass + * @return + + public ArrayList getClassInfoPersonalized(String thisClass) + { + SQLiteDatabase db = databaseHelper.getWritableDatabase(); + Cursor res; + SharedPreferences pref = context.getSharedPreferences("Tralala", MODE_PRIVATE); + String coursesRaw = pref.getString("Courses", ""); + + /*if (coursesRaw == "") + return new ArrayList<>(); + + ArrayList extraArguments = new ArrayList<>(); + String buffer = ""; + + boolean moreThanZero = false; + + if (coursesRaw != "" && coursesRaw.length() > 0) + { + for (int i = 0; i < coursesRaw.length(); i++) + { + if ((coursesRaw.charAt(i) == ';') || (i == (coursesRaw.length() - 1))) + { + if (i == (coursesRaw.length() - 1)) + buffer = buffer + coursesRaw.charAt(i); + extraArguments.add(databaseHelper.COL_3 + " = '" + buffer.trim() + "' COLLATE NOCASE or " + databaseHelper.COL_6 + " = '" + buffer.trim() + "' COLLATE NOCASE"); + buffer = ""; + } + else + { + buffer = buffer + coursesRaw.charAt(i); + } + } + moreThanZero = true; + } + else + { + moreThanZero = false; + } + + String extraArgumentsSQL = ""; + + if (moreThanZero) + { + if (extraArguments.size() > 0) + if (extraArguments != null) + { + extraArgumentsSQL = " and ("; + moreThanZero = true; + } + else + moreThanZero = false; + else + moreThanZero = false; + } + + for (int i = 0; i < extraArguments.size(); i++) + { + extraArgumentsSQL = extraArgumentsSQL + extraArguments.get(i); + if (i < (extraArguments.size() - 1)) + extraArgumentsSQL = extraArgumentsSQL + " or "; + } + + if (moreThanZero) + { + return getClassInfoForSQL("SELECT * FROM " + databaseHelper.TABLE_NAME + index + " WHERE " + databaseHelper.COL_1 + " = '" + thisClass + "'" + extraArgumentsSQL + ")"); + } + else + { + return getClassInfoForSQL("SELECT * FROM " + databaseHelper.TABLE_NAME + index + " WHERE " + databaseHelper.COL_1 + " = '" + thisClass + "'"/* + extraArgumentsSQL); + } + } + + public ArrayList getClassInfo(String thisClass) + { + return getClassInfoForSQL("SELECT * FROM " + databaseHelper.TABLE_NAME + index + " WHERE " + databaseHelper.COL_1 + " = '" + thisClass + "'"); + }*/ + + public string GetClassInfo(string thisClass) + { + return GetClassInfoForSQL("SELECT * FROM " + DatabaseHelper.TABLE_NAME + index + " WHERE " + helper.COL_1 + " = '" + thisClass + "'"); + } + + + public string GetClassInfoForSQL(string sql) + { + bool forInfo = true; + List outList = new List(); + SqliteDataReader reader; + + using (SqliteConnection db = new SqliteConnection("Filename=" + DatabaseHelper.DATABASE_NAME)) + { + SqliteCommand command = new SqliteCommand(sql, db); + db.Open(); + + try + { + reader = command.ExecuteReader(); + } + catch (SqliteException e) + { + #if DEBUG + Debug.WriteLine("SQLite Exception: " + e.Message + e.StackTrace); + #endif + return null; + } + db.Close(); + } + + String currentLesson = "x"; + + #if DEBUG + int t = 0; + #endif + + while (reader.Read()) + { + #if DEBUG + t++; + #endif + forInfo = true; + StringBuilder line = new StringBuilder(); + + if (reader.GetString(2).Contains(currentLesson)) + line.Append(Spaces(5)); + else if (currentLesson.Contains("10")) + line.Append(RemLB(reader.GetString(2)) + "." + Spaces(1)); + else + line.Append(RemLB(reader.GetString(2)) + "." + Spaces(2)); + + if (reader.GetString(6).Contains("\u00A0")) + { + if (reader.GetString(3).Contains("\u00A0")) + line.Append("[Fach]"); + else + line.Append(NameShortcuts.GetRealClass(RemLB(reader.GetString(3)))); + } + else + { + line.Append(NameShortcuts.GetRealClass(RemLB(reader.GetString(6)))); + } + + if (reader.GetString(5).Contains("*Frei")) + { + line.Append(" entfällt"); + forInfo = false; + } + else if (reader.GetString(5).Contains("Raumänderung")) + { + line.Append(": Raumänderung in Raum " + RemLB(reader.GetString(7))); + forInfo = false; + } + else if (reader.GetString(5).Contains("*Stillarbeit")) + { + //if (myList.get(3) == "null") //TODO: Stillarbeit Teacher + if (reader.GetString(4).Contains("\u00A0")) + line.Append(": " + "Stillarbeit"); + else + line.Append(": " + "Stillarbeit in Raum " + RemLB(reader.GetString(4))); + forInfo = false; + } + + + if (forInfo) + { + line.Append(" bei "); + + if (reader.GetString(5).Contains("\u00A0")) + { + line.Append("[Lehrer]"); + } + else + { + line.Append(NameShortcuts.GetRealName(RemLB(reader.GetString(5)))); + } + + + if (reader.GetString(7).Contains("\u00A0")) + { + if (reader.GetString(4).Contains("\u00A0")) + line.Append(" in " + "[Raum]"); + else + { + line.Append(" in Raum " + RemLB(reader.GetString(4))); + } + } + else + { + line.Append(" in Raum "); + line.Append(RemLB(reader.GetString(7))); + } + } + + if (reader.GetString(8).Contains("verschoben")) + { + if (reader.GetString(2).Contains(currentLesson)) + line = new StringBuilder(Spaces(5) + NameShortcuts.GetRealClass(RemLB(reader.GetString(3))) + " wird " + RemLB(reader.GetString(8))); + else if (currentLesson.Contains("10")) + line = new StringBuilder(RemLB(reader.GetString(2)) + "." + Spaces(1) + NameShortcuts.GetRealClass(RemLB(reader.GetString(3))) + " wird " + RemLB(reader.GetString(8))); + else + line = new StringBuilder(RemLB(reader.GetString(2)) + "." + Spaces(2) + NameShortcuts.GetRealClass(RemLB(reader.GetString(3))) + " wird " + RemLB(reader.GetString(8))); //[Fach] wird [verschoben auf Datum] + } + else if (reader.GetString(8).Contains("anstatt")) + { + line.Append(" " + RemLB(reader.GetString(8))); + } + else if (reader.GetString(8).Contains("Aufg. erteilt")) + { + line.Append(lineBreak + Spaces(5) + "Aufgaben erteilt"); + } + else if (reader.GetString(8).Contains("Aufg. für zu Hause erteilt")) + { + line.Append(lineBreak + Spaces(5) + "Aufgaben für Zuhause erteilt"); + } + else if (reader.GetString(8).Contains("Aufg. für Stillarbeit erteilt")) + { + line.Append(lineBreak + Spaces(5) + "Aufgaben für Stillarbeit erteilt"); + //} else if (myList.get(six).contains("ganze Klasse")) { + } + else if (!reader.GetString(8).Contains("\u00A0")) + { + line.Append(lineBreak + Spaces(5) + RemLB(reader.GetString(8))); + } + + if (!reader.GetString(2).Contains(" ")) + currentLesson = RemLB(reader.GetString(2)); + + outList.Add(line.ToString()); + } + + string outStr = ""; + + foreach (string str in outList) + { + outStr = outStr + "\n" + str; + } + + #if DEBUG + Debug.WriteLine("Iterations | READ " + t); + #endif + return outStr.Replace(System.Environment.NewLine, ""); + } + + public static string RemLB(string removeLineBreaks) + { + return removeLineBreaks.Replace(System.Environment.NewLine, ""); + } + + private string Spaces(int count) + { + string outStr = ""; + + for (int i = 0; i < count; i++) + { + outStr = outStr + ' '; + } + + return outStr; + } + } +} \ No newline at end of file diff --git a/myRoRo/ScheduleNetwork.cs b/myRoRo/ScheduleNetwork.cs new file mode 100644 index 0000000..2e6f006 --- /dev/null +++ b/myRoRo/ScheduleNetwork.cs @@ -0,0 +1,234 @@ +using HtmlAgilityPack; +using Microsoft.Data.Sqlite; +using System; +using System.Collections.Generic; +#if DEBUG +using System.Diagnostics; +#endif +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Xaml.Controls; + +namespace myRoRo +{ + class ScheduleNetwork + { + public static string PAGES_COUNT = "pgs_count"; + + private static async Task> GetURLs(string url, string usrName, string pw) + { + try + { + #if DEBUG + Debug.WriteLine("Attempting to load initial page."); + #endif + HttpClient http = new HttpClient(); + + + string authInfo = usrName + ":" + pw; + authInfo = Convert.ToBase64String(Encoding.ASCII.GetBytes(authInfo)); + http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authInfo); + + var response = await http.GetByteArrayAsync(url); + String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1); + source = WebUtility.HtmlDecode(source); + HtmlDocument result = new HtmlDocument(); + result.LoadHtml(source); + + #if DEBUG + Debug.WriteLine("Complete."); + #endif + + List outList = new List(); + + foreach (HtmlNode link in result.DocumentNode.SelectNodes("//a[@href]")) + { + string hrefValue = link.GetAttributeValue("href", string.Empty); + outList.Add("http://www.romain-rolland-gymnasium.eu/schuelerbereich/svplaneinseitig/" + hrefValue); + #if DEBUG + Debug.WriteLine(hrefValue); + #endif + } + + outList.RemoveAt(outList.Count - 1); + + string date = ScheduleHandler.RemLB(result.DocumentNode.SelectSingleNode("//h1").InnerText); + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + localSettings.Values["UpdateDate"] = date; + + return outList; + } + catch (Exception e) + { + #if DEBUG + Debug.WriteLine("PAGE NOT LOADED: " + e.Message + e.StackTrace); + #endif + + + ContentDialog noWifiDialog = new ContentDialog() + { + Title = "Verbindungsfehler", + Content = "Bitte Netzwerk überprüfen und erneut versuchen.\n\n Fehlermeldung:\n" + e.Message + e.StackTrace, + CloseButtonText = "Ok" + }; + + await noWifiDialog.ShowAsync(); + return null; + } + } + + public static async Task Refresh() + { + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + + #if DEBUG + Debug.WriteLine("Refresh() called."); + #endif + DatabaseHelper helper = new DatabaseHelper(); + + string username = "wieland.schoebl"; + string password = "bawo2"; + string URL = "http://www.romain-rolland-gymnasium.eu/schuelerbereich/svplaneinseitig/Index.html"; + + List URLs = await GetURLs(URL, username, password); + + int pagesCount = 0; + + #if DEBUG + Debug.WriteLine("URL Count: " + URLs.Count); + #endif + + for (int i = 1; i <= URLs.Count; i++) + { + String url = URLs.ElementAt(i - 1); + + try + { + HttpClient http = new HttpClient(); + + string authInfo = username + ":" + password; + authInfo = Convert.ToBase64String(Encoding.ASCII.GetBytes(authInfo)); + http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authInfo); + + var response = await http.GetByteArrayAsync(url); + String source = Encoding.GetEncoding("ISO8859-1").GetString(response, 0, response.Length - 1); + source = WebUtility.HtmlDecode(source); + + + HtmlDocument result = new HtmlDocument(); + result.LoadHtml(source); + + helper.DeleteTable(i); + + //START SQL + String currentClass = "Aufsicht"; + String currentLesson = ""; + + #if DEBUG + Debug.WriteLine("One URL loaded."); + int t = 0; + #endif + + + foreach (HtmlNode table in result.DocumentNode.SelectNodes("//table")) + { + foreach (HtmlNode row in table.SelectNodes("tr")) + { + #if DEBUG + t++; + #endif + List rowText = new List(); + List rowHtml = new List(); + foreach (HtmlNode cell in row.SelectNodes("td")) + { + rowText.Add(cell.InnerText); + rowHtml.Add(cell.OuterHtml); + } + + #if DEBUG + //Debug.WriteLine(rowHtml.ElementAt(0)); + #endif + + if (!(rowText.ElementAt(0).Contains(" "))) + { //All rows will need a class name, otherwise it will be much more difficult to parse the data + if (!rowText.ElementAt(0).Contains("Kl")) + { //checking for irrelevant data (such as KL., which appears at the top.) + currentClass = rowText.ElementAt(0); + if (rowText.ElementAt(1).Contains(" ")) + helper.InsertData(i, rowText.ElementAt(0), currentLesson, rowText.ElementAt(2), rowText.ElementAt(3), rowText.ElementAt(4), rowText.ElementAt(5), rowText.ElementAt(6), rowText.ElementAt(7)); //inserting all the data into the SQL database + else + { + helper.InsertData(i, rowText.ElementAt(0), rowText.ElementAt(1), rowText.ElementAt(2), rowText.ElementAt(3), rowText.ElementAt(4), rowText.ElementAt(5), rowText.ElementAt(6), rowText.ElementAt(7)); + currentLesson = rowText.ElementAt(1); + } + } + } + else + { + if (rowText.ElementAt(1).Contains(" ")) + helper.InsertData(i, currentClass, currentLesson, rowText.ElementAt(2), rowText.ElementAt(3), rowText.ElementAt(4), rowText.ElementAt(5), rowText.ElementAt(6), rowText.ElementAt(7)); //inserting all the data into the SQL database + else + { + helper.InsertData(i, currentClass, rowText.ElementAt(1), rowText.ElementAt(2), rowText.ElementAt(3), rowText.ElementAt(4), rowText.ElementAt(5), rowText.ElementAt(6), rowText.ElementAt(7)); + currentLesson = rowText.ElementAt(1); + } + } + } + } + + #if DEBUG + Debug.WriteLine("Iterations: " + t); + #endif + //END SQL + string outStr = ScheduleHandler.RemLB(result.DocumentNode.SelectSingleNode("//h2").InnerText); + + if (!outStr.Contains("erscheint")) { + localSettings.Values["Day" + i + "_Date"] = outStr; + + outStr = ScheduleHandler.RemLB(result.DocumentNode.SelectSingleNode("//h1").InnerText); + localSettings.Values["Day" + i + "_UpdateDate"] = outStr; + //END SAVING DATES + + pagesCount = i; + } + } + catch (Exception e) + { + #if DEBUG + Debug.WriteLine("Error loading individual page: " + e.Message + e.StackTrace); + #endif + + //ContentDialog noWifiDialog = new ContentDialog() + //{ + // Title = "Merkwürdiger Fehler", + // Content = "Fehler beim laden einer einzelnen Seite.\n\n Fehlermeldung:\n" + e.Message + e.StackTrace, + // CloseButtonText = "Ok" + //}; + + //await noWifiDialog.ShowAsync(); + } + } + + localSettings.Values[PAGES_COUNT] = pagesCount; + } + + public static string GetDate(int index) + { + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + return (string) localSettings.Values["Day" + index + "_Date"]; + } + + public static string GetUpdateDate() + { + Windows.Storage.ApplicationDataContainer localSettings = + Windows.Storage.ApplicationData.Current.LocalSettings; + return (string) localSettings.Values["UpdateDate"]; + } + } +} diff --git a/myRoRo/Sync.cs b/myRoRo/Sync.cs new file mode 100644 index 0000000..9bc4e74 --- /dev/null +++ b/myRoRo/Sync.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace myRoRo +{ + class Sync + { + } +} diff --git a/myRoRo/myRoRo.csproj b/myRoRo/myRoRo.csproj new file mode 100644 index 0000000..e9b37a8 --- /dev/null +++ b/myRoRo/myRoRo.csproj @@ -0,0 +1,204 @@ + + + + + Debug + x86 + {69838279-964F-45BF-B6CE-85B782710430} + AppContainerExe + Properties + myRoRo + myRoRo + de-DE + UAP + 10.0.16299.0 + 10.0.14393.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + myRoRo_TemporaryKey.pfx + True + Always + arm + D:\wulka\Desktop\ + False + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + PackageReference + + + + App.xaml + + + + MainPage.xaml + + + + + + + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + 1.7.1 + + + 1.1.0 + + + + 14.0 + + + true + + + myRoRo_TemporaryKey.pfx + + + + \ No newline at end of file