From 2f5c10486042c9611b665ba92d8446d0a2f11be7 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Wed, 18 Sep 2013 14:50:32 +0200 Subject: [PATCH] add docs --- .gitattributes | 1 + CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 4 +- .../CampusAppWP8/File/Places/PlacesFile.cs | 2 +- .../CampusAppWP8/Model/Exams/ExamModel.cs | 2 +- .../CampusAppWP8/Model/GeoDb/PlaceModel.cs | 2 +- .../Model/Lecture/LectureActivity.cs | 10 +- .../Model/Person/PersonFunctionModel.cs | 14 +- .../CampusAppWP8/Model/Person/PersonModel.cs | 6 +- .../Utility/CourseListPickerItemListModel.cs | 3 +- CampusAppWP8/CampusAppWP8/Model/XmlModel.cs | 5 +- .../Pages/Campusmap/CampusMapPage.xaml.cs | 4 +- .../Pages/Setting/UserProfil.xaml.cs | 2 +- CampusAppWP8/CampusAppWP8/Settings.StyleCop | 51 +++-- .../CampusAppWP8/Utility/BackgroundTasks.cs | 58 ++++- CampusAppWP8/CampusAppWP8/Utility/File.cs | 1 + CampusAppWP8/CampusAppWP8/Utility/Logger.cs | 39 ---- .../Utility/Lui/Tiles/TileCreator.cs | 103 +++++++-- .../CampusAppWP8/Utility/Utilities.cs | 1 + .../CampusAppWP8/Utility/Wp8StringManager.cs | 29 +++ .../CampusAppWP8/Utility/XmlManager.cs | 91 -------- .../ScheduledAgent.cs | 214 +++++++++++++----- .../Utility/BackgroundTasks.cs | 21 +- .../Utility/HttpRequest.cs | 6 +- .../CampusAppWPortalLib8.csproj | 2 +- .../Model/Mensa/MealModel.cs | 18 +- .../Model/Mensa/MenuWeekModel.cs | 1 - .../Resources/Constants.resx | 6 + .../Resources/Constants1.Designer.cs | 18 ++ .../Utility/AbstractBackgroundTasks.cs | 18 +- .../Utility/AbstractHttpRequest.cs | 7 +- .../Utility/DefaultStringManager.cs} | 33 ++- .../CampusAppWPortalLib8/Utility/Logger.cs | 4 +- .../Utility/StringManager.cs | 69 ------ 33 files changed, 466 insertions(+), 379 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8/Utility/Logger.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs rename CampusAppWP8/{CampusAppWP8/Utility/StringManager.cs => CampusAppWPortalLib8/Utility/DefaultStringManager.cs} (75%) delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs diff --git a/.gitattributes b/.gitattributes index ad3aeb41..83a97a87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,7 @@ *.csproj -text merge=union *.sln -text merge=union *.resx -text merge=union +*.StyleCop -text merge=union #*.vbproj merge=binary #*.vcxproj merge=binary #*.vcproj merge=binary diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index d218c078..5494815e 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -269,7 +269,6 @@ - @@ -281,11 +280,10 @@ QRScanner.xaml - + Code - diff --git a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs index df16df60..382547bb 100644 --- a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs +++ b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs @@ -11,7 +11,7 @@ namespace CampusAppWP8.File.Places using CampusAppWP8.Model; using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// Places file. /// Stubbfel, 09.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs index 58c58ce6..e668fe35 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs @@ -62,7 +62,7 @@ namespace CampusAppWP8.Model.Exams { get { - return StringManager.StripHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); + return Wp8StringManager.StripAndDecodeHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); } } diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs index 758b2ef1..799b0757 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs @@ -16,7 +16,7 @@ namespace CampusAppWP8.Model.GeoDb using System.Text.RegularExpressions; using System.Xml.Serialization; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// /// Model for a place of the SPSService diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs index 8d87520b..db0feb15 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs @@ -199,7 +199,7 @@ namespace CampusAppWP8.Model.Lecture { if (value != this.topic) { - this.topic = StringManager.StripHTML(value); + this.topic = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -228,10 +228,10 @@ namespace CampusAppWP8.Model.Lecture string result = string.Empty; foreach (LectureLecturer tmpLecturer in this.Lecturer) { - result += StringManager.AddNewLine(tmpLecturer.ToString()); + result += Wp8StringManager.AddNewLine(tmpLecturer.ToString()); } - this.LecturerString = StringManager.RemoveNewLine(result); + this.LecturerString = Wp8StringManager.RemoveNewLine(result); } /// @@ -242,10 +242,10 @@ namespace CampusAppWP8.Model.Lecture string result = string.Empty; foreach (LectureCourse course in this.Course) { - result += StringManager.AddNewLine(course.Title); + result += Wp8StringManager.AddNewLine(course.Title); } - this.CourseString = StringManager.RemoveNewLine(result); + this.CourseString = Wp8StringManager.RemoveNewLine(result); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs b/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs index 5b68531c..0a0ddc9f 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs @@ -55,7 +55,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.tel1) { - this.tel1 = StringManager.CreateUniTelefonNumber(value); + this.tel1 = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -74,7 +74,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.tel2) { - this.tel2 = StringManager.CreateUniTelefonNumber(value); + this.tel2 = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -93,7 +93,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.fax) { - this.fax = StringManager.CreateUniTelefonNumber(value); + this.fax = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -112,7 +112,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.function) { - this.function = StringManager.StripHTML(value); + this.function = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -131,7 +131,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.appointment) { - this.appointment = StringManager.StripHTML(value); + this.appointment = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -150,7 +150,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.building) { - this.building = StringManager.StripHTML(value); + this.building = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -167,7 +167,7 @@ namespace CampusAppWP8.Model.Person set { - if (value != null && value != this.mail && StringManager.IsValidEmail(value)) + if (value != null && value != this.mail && Wp8StringManager.IsValidEmail(value)) { this.mail = value; } diff --git a/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs b/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs index af48f050..d4acbbcd 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs @@ -70,7 +70,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.akadgrad) { - this.akadgrad = StringManager.StripHTML(value); + this.akadgrad = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -89,7 +89,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.surName) { - this.surName = StringManager.StripHTML(value); + this.surName = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -108,7 +108,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.firstName) { - this.firstName = StringManager.StripHTML(value); + this.firstName = Wp8StringManager.StripAndDecodeHTML(value); } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs index 1015879a..fb606444 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs @@ -8,7 +8,6 @@ namespace CampusAppWP8.Model.Utility { using System.Collections.Generic; using System.Linq; - using CampusAppWP8.Feed.Exams; using CampusAppWP8.Feed.Utility; using CampusAppWP8.Utility; @@ -147,7 +146,7 @@ namespace CampusAppWP8.Model.Utility { foreach (CourseModel course in courseList) { - this.AddItem(new ListPickerItemModel(course.CourseNumber, StringManager.StripHTML(course.CourseText))); + this.AddItem(new ListPickerItemModel(course.CourseNumber, Wp8StringManager.StripAndDecodeHTML(course.CourseText))); } this.List = this.List.OrderBy(o => o.Text).ToList(); diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs index 71983884..27d6108a 100644 --- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs @@ -6,10 +6,9 @@ // 05.07.2013 //----------------------------------------------------------------------------- namespace CampusAppWP8.Model -{ +{ using System.Text; - using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// /// Xml model io handler class. diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 6062f5e8..2b0dc3e4 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -273,10 +273,10 @@ namespace CampusAppWP8.Pages.Campusmap { msgText += AppResources.PlaceLabel_Name + ": "; msgText += place.GetInformationsValue(Constants.PisInformationName_Name); - msgText = StringManager.AddNewLine(msgText); + msgText = Wp8StringManager.AddNewLine(msgText); msgText += AppResources.PlaceLabel_ShortDesc + ": "; msgText += place.GetInformationsValue(Constants.PisInformationName_ShortDesc); - msgText = StringManager.AddNewLine(msgText); + msgText = Wp8StringManager.AddNewLine(msgText); } MessageBoxes.ShowMainModelInfoMessageBox(msgText); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs index 2a5f9a81..a868f4c1 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs @@ -12,7 +12,7 @@ namespace CampusAppWP8.Pages.Setting using System.Windows.Navigation; using CampusAppWP8.Model.Setting; using CampusAppWP8.Model.Utility; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; using Microsoft.Phone.Controls; /// diff --git a/CampusAppWP8/CampusAppWP8/Settings.StyleCop b/CampusAppWP8/CampusAppWP8/Settings.StyleCop index cf756198..a049e944 100644 --- a/CampusAppWP8/CampusAppWP8/Settings.StyleCop +++ b/CampusAppWP8/CampusAppWP8/Settings.StyleCop @@ -1,26 +1,27 @@ - - - - akadgrad - api - apis - enum - initialise - initialises - ndef - ndefs - nfc - param - pid - pids - pis - prev - pss - Senftenberg - sps - Stubbfel - uni - wifi - - + + + + akadgrad + api + apis + enum + initialise + initialises + ndef + ndefs + nfc + param + perodic + pid + pids + pis + prev + pss + Senftenberg + sps + Stubbfel + uni + wifi + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs index 59682d23..76acf9d1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs @@ -1,28 +1,43 @@ -using CampusAppWP8ScheduledTaskAgent.Resources; -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility { + using System; + using CampusAppWP8ScheduledTaskAgent.Resources; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + + /// + /// Class provide some static methods for background tasks + /// public class BackgroundTasks : AbstractBackgroundTasks { - public static void StartPerodicTask(string taskName, string taskDesc) { + /// + /// Method start a certain PerodicTask + /// + /// name of the task + /// description of the task + public static void StartPerodicTask(string taskName, string taskDesc) + { BackgroundTasks.StopPerodicTask(BackgroundTasks.LastAddedTaskName); BackgroundTasks.StopPerodicTask(taskName); PeriodicTask periodicTask = new PeriodicTask(taskName); + // load description from localized strings periodicTask.Description = taskDesc; try { ScheduledActionService.Add(periodicTask); - ScheduledActionService.LaunchForTest(taskName, new TimeSpan(10)); + + // ScheduledActionService.LaunchForTest(taskName, new TimeSpan(10)); } catch (Exception e) { @@ -33,6 +48,10 @@ namespace CampusAppWP8.Utility BackgroundTasks.LastAddedTaskName = taskName; } + /// + /// Method stop a certain PerodicTask + /// + /// name of the task public static void StopPerodicTask(string taskName) { if (taskName == null) @@ -54,33 +73,50 @@ namespace CampusAppWP8.Utility } } + /// + /// Method start MensaBackgroundTask + /// public static void StartMensaTask() { int campusId = (int)Settings.UserProfil.DefaultCampus; BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Mensa, AppResources.BackGroundTaskDesc_Mensa + " - Feed " + campusId); } + /// + /// Method stop MensaBackgroundTask + /// public static void StopMensaTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); } + /// + /// Method start EventBackgroundTask + /// public static void StartEventTask() { BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Event, AppResources.BackGroundTaskDesc_Event); } + /// + /// Method stop EventBackgroundTask + /// public static void StopEventTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); } - + /// + /// Method start NewsBackgroundTask + /// public static void StartNewsTask() { BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_News, AppResources.BackGroundTaskDesc_News); } + /// + /// Method stop NewsBackgroundTask + /// public static void StopNewsTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs index 7905b1d9..d49ee632 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/File.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs @@ -11,6 +11,7 @@ namespace CampusAppWP8.Utility using System.IO; using System.Threading; using System.Threading.Tasks; + using CampusAppWPortalLib8.Utility; using Windows.Storage; /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/Logger.cs b/CampusAppWP8/CampusAppWP8/Utility/Logger.cs deleted file mode 100644 index 4416a3b4..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/Logger.cs +++ /dev/null @@ -1,39 +0,0 @@ -//-------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 03.05.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System; - - /// - /// This Class creates logs for the app - /// - public class Logger - { - #region Method - - /// - /// Method log a Exception - /// - /// exception which has to log - public static void LogException(Exception exception) - { - Console.WriteLine(exception); - } - - /// - /// Log a message. - /// - /// to be logged message - public static void LogMsg(string msg) - { - Console.WriteLine(msg); - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs index 52406b28..f393a002 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs @@ -1,104 +1,163 @@ -using CampusAppWP8.Resources; -using Microsoft.Phone.Scheduler; -using Microsoft.Phone.Shell; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility.Lui.Tiles { + using System; + using System.Linq; + using CampusAppWP8.Resources; + using Microsoft.Phone.Shell; + + /// + /// Class creates different live tiles + /// public class TileCreator { - public static void CreateIconicTile(string title, string path, string iconUrl, string smallIcon, string wContent1 = null, string wContent2 = null, string wContent3 = null) + /// + /// Method creates an IconicTile + /// + /// title of the tile + /// path the the page + /// icon url of the main icon + /// icon url of the small icon + /// string for the wide content 1 + /// string for the wide content 2 + /// string for the wide content 3 + public static void CreateIconicTile(string title, string path, string iconUrl, string smallIcon, string wideContent1 = null, string wideContent2 = null, string wideContent3 = null) { + IconicTileData iconTile = new IconicTileData(); + iconTile.Title = title; + iconTile.WideContent1 = wideContent1; + iconTile.WideContent2 = wideContent2; + iconTile.WideContent3 = wideContent3; - IconicTileData oIcontile = new IconicTileData(); - oIcontile.Title = title; - oIcontile.WideContent1 = wContent1; - oIcontile.WideContent2 = wContent2; - oIcontile.WideContent3 = wContent3; - - oIcontile.IconImage = new Uri(iconUrl, UriKind.Relative); - oIcontile.SmallIconImage = new Uri(smallIcon, UriKind.Relative); + iconTile.IconImage = new Uri(iconUrl, UriKind.Relative); + iconTile.SmallIconImage = new Uri(smallIcon, UriKind.Relative); // find the tile object for the application tile that using "Iconic" contains string in it. - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(path)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(path)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(path)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(path)) { - TileToFind.Delete(); + tileToFind.Delete(); } - ShellTile.Create(new Uri(path, UriKind.Relative), oIcontile, true); + ShellTile.Create(new Uri(path, UriKind.Relative), iconTile, true); } + /// + /// Method creates the MensaTile + /// public static void CreateMensaTile() { TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); - + // create a new task BackgroundTasks.StartMensaTask(); } + /// + /// Method creates the MailTile + /// public static void CreateWebMailTile() { TileCreator.CreateIconicTile(AppResources.MailApp_Title, Constants.PathMail_WebMailPage, Icons.WebMail, Icons.WebMail); } + /// + /// Method creates the NewsTile + /// public static void CreateNewsTile() { TileCreator.CreateIconicTile(AppResources.NewsApp_Title, Constants.PathNews_NewsIndexPage, Icons.News, Icons.News); + + // create a new Task BackgroundTasks.StartNewsTask(); } + /// + /// Method creates the LectureTile + /// public static void CreateLectureTile() { TileCreator.CreateIconicTile(AppResources.LectureApp_Title, Constants.PathLecture_LecturePage, Icons.Lectures, Icons.Lectures); } + /// + /// Method creates the EventTile + /// public static void CreateEventTile() { TileCreator.CreateIconicTile(AppResources.EventApp_Title, Constants.PathEvents_EventsIndexPage, Icons.News, Icons.News); + + // create a new taskk BackgroundTasks.StartEventTask(); } + /// + /// Method creates the DepartmentTile + /// public static void CreateDepartmentTile() { TileCreator.CreateIconicTile(AppResources.DepartmentApp_Title, Constants.PathDepartment_DepartmentIndexPage, Icons.Departments, Icons.Departments); } + /// + /// Method creates the OpeningHoursTile + /// public static void CreateOpeningHoursTile() { TileCreator.CreateIconicTile(AppResources.OpenHoursApp_Title, Constants.PathOpeninghours_OpeninghoursPage, Icons.Openhours, Icons.Openhours); } + /// + /// Method creates the linkTile + /// public static void CreateLinkTile() { TileCreator.CreateIconicTile(AppResources.LinkApp_Title, Constants.PathLinks_LinkPage, Icons.Link, Icons.Link); } + /// + /// Method creates the StudentCouncilTile + /// public static void CreateStudentCouncilTile() { TileCreator.CreateIconicTile(AppResources.OSAApp_Title, Constants.PathStudentCouncil_StudentCouncilPage, Icons.StudentCouncil, Icons.StudentCouncil); } + /// + /// Method creates the ExamsTile + /// public static void CreateExamsTile() { TileCreator.CreateIconicTile(AppResources.ExaminationApp_Header, Constants.PathExams_ExamsPage, Icons.Exams, Icons.Exams); } + /// + /// Method creates the PersonTile + /// public static void CreatePersonTile() { TileCreator.CreateIconicTile(AppResources.PersonApp_Title, Constants.PathPerson_Person, Icons.Person, Icons.Person); } + /// + /// Method creates the PlaceNewsTile + /// public static void CreatePlaceNewsTile() { TileCreator.CreateIconicTile(AppResources.PlaceNewsApp_Title, Constants.PathPlaceNews_PlaceNewsPage, Icons.News, Icons.News); } + /// + /// Method creates the CampusMapTile + /// public static void CreateCampusMapTile() { TileCreator.CreateIconicTile(AppResources.CampusMapApp_Title, Constants.PathCampusmap_Campusmap, Icons.Campus, Icons.Campus); diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index cbc4c010..d62a2786 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -17,6 +17,7 @@ namespace CampusAppWP8.Utility using System.Windows.Media; using CampusAppWP8.Resources; using Microsoft.Phone.Net.NetworkInformation; + using CampusAppWPortalLib8.Utility; /// /// Collection of utility functions. diff --git a/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs b/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs new file mode 100644 index 00000000..f8c57b83 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 06.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System; + using System.Text.RegularExpressions; + using CampusAppWP8.Resources; + + /// + /// Class provides some special StringMethods + /// + public class Wp8StringManager : CampusAppWPortalLib8.Utility.DefaultStringManager + { + /// + /// Method removes Html-Tag of a String + /// + /// String with Html-Tags + /// String without Html-Tags + public static string StripAndDecodeHTML(string inputString) + { + return System.Net.HttpUtility.HtmlDecode(Wp8StringManager.StripHTML(inputString)); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs b/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs deleted file mode 100644 index 118e8a11..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 18.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System.IO; - using System.Xml.Linq; - using System.Xml.Serialization; - - /// - /// Class provides some Xml-methods - /// - public class XmlManager - { - #region Method - - /// - /// Method deserialization a string to a Model - /// - /// the model - /// the XmlString - /// name of the RootTag - /// return the deserialization of the model - public static T DeserializationToModel(string xmlString, string validRootName) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Parse(xmlString); - if (!document.Root.Name.ToString().Equals(validRootName)) - { - XElement content = document.Root; - document = new XDocument(); - document.Add(new XElement(validRootName, content)); - } - - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// Deserialization a xml file to a model. - /// Stubbfel, 20.08.2013. - /// Generic type parameter. - /// Path to the a XmlFile. - /// model of the XmlFile. - public static T DeserializationFileToModel(string xmlFilePath) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Load(xmlFilePath); - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// Method serializes a model to a string. - /// Stubbfel, 12.09.2013. - /// type of the model. - /// model object. - /// serialized string. - public static string SerializationToString(T model) - { - string retValue = string.Empty; - - XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); - ns.Add(string.Empty, string.Empty); - - XmlSerializer serializer = new XmlSerializer(typeof(T)); - TextWriter writer = new StringWriter(); - - serializer.Serialize(writer, model, ns); - - retValue = writer.ToString(); - - if (retValue.StartsWith(""); - retValue = retValue.Substring(endTag + 2); - - if (retValue.StartsWith("\r\n") == true) - { - retValue = retValue.Substring(2); - } - } - - return retValue; - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index a8d2c0dc..597e72cb 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -1,27 +1,55 @@ -using CampusAppWP8ScheduledTaskAgent.Resources; -using CampusAppWP8ScheduledTaskAgent.Utility; -using CampusAppWPortalLib8.Model.Mensa; -using CampusAppWPortalLib8.Model.RSS; -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using Microsoft.Phone.Shell; -using System; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Windows; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent { + using System; + using System.Diagnostics; + using System.Globalization; + using System.Linq; + using System.Windows; + using CampusAppWP8ScheduledTaskAgent.Resources; + using CampusAppWP8ScheduledTaskAgent.Utility; + using CampusAppWPortalLib8.Model.Mensa; + using CampusAppWPortalLib8.Model.RSS; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + using Microsoft.Phone.Shell; + + /// + /// Class for agent of the BackgroundTask + /// public class ScheduledAgent : ScheduledTaskAgent { + #region Member + /// + /// Model for the mensa feed + /// private MenuWeekModel mensaModel; + /// + /// Model for the event feed + /// private RSSViewModel eventModel; + /// + /// Model for the news feed + /// private RSSViewModel newsModel; + #endregion + + #region Constructor + + /// + /// Initializes static members of the class. + /// static ScheduledAgent() { Deployment.Current.Dispatcher.BeginInvoke(delegate @@ -30,14 +58,16 @@ namespace CampusAppWP8ScheduledTaskAgent }); } - private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - if (Debugger.IsAttached) - { - Debugger.Break(); - } - } + #endregion + #region Method + + #region protected + + /// + /// override OnInvoke + /// + /// the background Task protected override void OnInvoke(ScheduledTask task) { switch (task.Name) @@ -53,10 +83,30 @@ namespace CampusAppWP8ScheduledTaskAgent case "NewsTask": this.HandleNewsTask(task); break; - } } + #endregion + + #region private + + /// + /// Method handle UnhandledException + /// + /// sender of Exception + /// Exception Args + private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (Debugger.IsAttached) + { + Debugger.Break(); + } + } + + /// + /// Method handle the EventBackgroundTask + /// + /// the eventTask private void HandleEventTask(ScheduledTask task) { if (this.eventModel == null || !this.CheckRssIsUpToDate(this.eventModel.CreateTime)) @@ -67,10 +117,14 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateEventTile(); + this.UpdateEventTile(); } } + /// + /// Method handle the NewsBackgroundTask + /// + /// the newsTask private void HandleNewsTask(ScheduledTask task) { if (this.newsModel == null || !this.CheckRssIsUpToDate(this.newsModel.CreateTime)) @@ -81,75 +135,97 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateNewsTile(); + this.UpdateNewsTile(); } } - private void GetEventIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the EventFeed + /// + /// sender of the Event + /// Event Args + private void GetEventIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.eventModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateEventTile(); + this.eventModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateEventTile(); } } - private void GetNewsIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the NewsFeed + /// + /// sender of the Event + /// Event Args + private void GetNewsIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.newsModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateNewsTile(); + this.newsModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateNewsTile(); } } - - private void updateNewsTile() + /// + /// Method update the NewsTile + /// + private void UpdateNewsTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); int randomNumber = random.Next(0, this.newsModel.Channel[0].Item.Count); RSSModel item = this.newsModel.Channel[0].Item[randomNumber]; data.WideContent1 = item.Date; - data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; - data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.WideContent2 = DefaultStringManager.ToShortString(item.Title, 40, "..."); + data.WideContent3 = DefaultStringManager.ToShortString(item.Text, 40, "..."); data.Count = this.newsModel.Channel[0].Item.Count; - TileToFind.Update(data); + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); } + this.NotifyComplete(); } - private void updateEventTile() + /// + /// Method update the EventTile + /// + private void UpdateEventTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count); RSSModel item = this.eventModel.Channel[0].Item[randomNumber]; data.WideContent1 = item.Date; - data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; - data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.WideContent2 = DefaultStringManager.ToShortString(item.Title, 40, "..."); + data.WideContent3 = DefaultStringManager.ToShortString(item.Text, 40, "..."); data.Count = this.eventModel.Channel[0].Item.Count; - TileToFind.Update(data); + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); } + this.NotifyComplete(); } + /// + /// Determine the correct MensaFeed/Url + /// + /// the Description of the MensaTask + /// Url of a mensa, which is set is in the UserProfile private Uri CalcMensaUrl(string mensaTaskDesc) { Uri url; @@ -176,6 +252,11 @@ namespace CampusAppWP8ScheduledTaskAgent return url; } + + /// + /// Method handle the MensaBackgroundTask + /// + /// the newsTask private void HandleMensaTask(ScheduledTask task) { if (this.mensaModel == null || !this.CheckMensaIsUpToDate(this.mensaModel.CreateTime)) @@ -186,25 +267,32 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateMensaTile(); + this.UpdateMensaTile(); } } - private void GetMensaIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the MensaFeed + /// + /// sender of the Event + /// Event Args + private void GetMensaIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.mensaModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateMensaTile(); + this.mensaModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateMensaTile(); } - } - private void updateMensaTile() + /// + /// Method update the NewsTile + /// + private void UpdateMensaTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)) { IconicTileData data = new IconicTileData(); DateTime now = DateTime.Now; @@ -228,20 +316,27 @@ namespace CampusAppWP8ScheduledTaskAgent { Random random = new Random(); int randomNumber = random.Next(0, mealCount); - data.WideContent3 = this.mensaModel.Menus[dayIndex].Meals[randomNumber].MealToShortString(); + MealModel meal = this.mensaModel.Menus[dayIndex].Meals[randomNumber]; + data.WideContent3 = meal.MealName + ": " + DefaultStringManager.ToShortString(meal.MealDesc, 30, "..."); data.Count = this.mensaModel.Menus[dayIndex].Meals.Count; } } - TileToFind.Update(data); + + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); } + this.NotifyComplete(); } - + /// + /// Check if the model of the mensa is up-to-date + /// + /// Date of the last modification + /// true, if it is up-to-date, otherwise false private bool CheckMensaIsUpToDate(DateTime lastModified) { int diff = lastModified.CompareTo(MenuWeekModel.CalcFirstWeekDay()); @@ -254,6 +349,11 @@ namespace CampusAppWP8ScheduledTaskAgent return true; } + /// + /// Check if the model of the RSS feed is up-to-date + /// + /// Date of the last modification + /// true, if it is up-to-date, otherwise false private bool CheckRssIsUpToDate(DateTime lastModified) { int diff = lastModified.CompareTo(DateTime.Now.AddDays(1)); @@ -265,5 +365,9 @@ namespace CampusAppWP8ScheduledTaskAgent return true; } + + #endregion + + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs index a585873d..26963480 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs @@ -1,11 +1,26 @@ -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using System; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent.Utility { + using System; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + + /// + /// Class provide some static methods for background tasks + /// public class BackgroundTasks : AbstractBackgroundTasks { + /// + /// Method stop a certain PerodicTask + /// + /// name of the task public static void StopPerodicTask(string taskName) { PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs index 455fad0d..2c558936 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs @@ -4,12 +4,12 @@ // // stubbfel // 10.06.2013 -//----------------------------------------------------------------------using System; +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent.Utility -{ - using CampusAppWPortalLib8.Utility; +{ using System; using System.Net; + using CampusAppWPortalLib8.Utility; /// /// Class realize the access of restful HttpRequest diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 567280d1..409d1953 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -55,7 +55,7 @@ - + diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs index 9aeb8eb9..bb76fcf7 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs @@ -8,8 +8,8 @@ namespace CampusAppWPortalLib8.Model.Mensa { using System.Xml.Serialization; - using CampusAppWPortalLib8.Utility; using CampusAppWPortalLib8.Resources; + using CampusAppWPortalLib8.Utility; /// /// Model for a meal @@ -135,7 +135,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { if (value != this.mealDesc) { - this.mealDesc = StringManager.StripHTML(value); + this.mealDesc = DefaultStringManager.StripHTML(value); } } } @@ -144,20 +144,6 @@ namespace CampusAppWPortalLib8.Model.Mensa #region Methods - #region public - - public string MealToShortString() - { - string shortDesc = this.mealDesc; - if (shortDesc.Length > 30) - { - shortDesc = shortDesc.Substring(0, 30) + "..."; - - } - return this.MealName + ": " + shortDesc; - } - #endregion - /// /// Method create depends of the mealId the mealName /// diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs index b26fd398..0af57379 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs @@ -7,7 +7,6 @@ //---------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Mensa { - using CampusAppWPortalLib8.Utility; using System; using System.Collections.ObjectModel; using System.Xml.Serialization; diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx index 537a908c..5680b6f2 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + +49 + /Pages/Events/EventIndexPage.xaml @@ -126,6 +129,9 @@ /Pages/News/NewsIndexPage.xaml + + 035569 + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs index f36a7113..5420fda2 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs @@ -61,6 +61,15 @@ namespace CampusAppWPortalLib8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die +49 ähnelt. + /// + public static string DeTelPrefix { + get { + return ResourceManager.GetString("DeTelPrefix", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt. /// @@ -88,6 +97,15 @@ namespace CampusAppWPortalLib8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 035569 ähnelt. + /// + public static string UniCBTelPrefix { + get { + return ResourceManager.GetString("UniCBTelPrefix", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. /// diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs index 6456db33..434104b4 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs @@ -1,7 +1,21 @@ -namespace CampusAppWPortalLib8.Utility +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWPortalLib8.Utility { + /// + /// abstract class for BackGroundTask + /// public abstract class AbstractBackgroundTasks { - protected static string LastAddedTaskName {get; set;} + /// + /// Gets or sets the name of the last running task + /// + protected static string LastAddedTaskName { get; set; } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs index f931f530..e52f9b50 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel @@ -13,7 +13,7 @@ namespace CampusAppWPortalLib8.Utility using CampusAppWPortalLib8.Model.Utility; /// - /// Class realize the access of restful HttpRequest + /// abstract Class provides some methods and member for HttpRequest /// public abstract class AbstractHttpRequest { @@ -28,6 +28,9 @@ namespace CampusAppWPortalLib8.Utility #region property + /// + /// Gets or sets BaseAddress of the webClient + /// protected string BaseAddress { get diff --git a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs similarity index 75% rename from CampusAppWP8/CampusAppWP8/Utility/StringManager.cs rename to CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs index 8a87aeae..faf0b1b3 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs @@ -1,20 +1,20 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel // 06.06.2013 //---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ +namespace CampusAppWPortalLib8.Utility +{ using System; using System.Text.RegularExpressions; - using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Resources; /// /// Class provides some special StringMethods /// - public static class StringManager + public class DefaultStringManager { #region Members @@ -37,8 +37,7 @@ namespace CampusAppWP8.Utility /// String without Html-Tags public static string StripHTML(string inputString) { - string result = Regex.Replace(inputString, HtmlTagPattern, string.Empty); - return System.Net.HttpUtility.HtmlDecode(result); + return Regex.Replace(inputString, DefaultStringManager.HtmlTagPattern, string.Empty); } /// @@ -71,7 +70,7 @@ namespace CampusAppWP8.Utility { return Regex.IsMatch( strIn, - StringManager.EMailValidRegex, + DefaultStringManager.EMailValidRegex, RegexOptions.IgnoreCase); } catch (Exception) @@ -101,6 +100,24 @@ namespace CampusAppWP8.Utility result = Constants.DeTelPrefix + result; return result; } + + /// + /// Method create from a long string a short string + /// + /// the long input String + /// max length of the short string + /// (optional) suffix which added to the short string, when long string has to be cut + /// the shorted string + public static string ToShortString(string longStr, int maxLenght, string suffix = "") + { + string shortStr = longStr; + if (shortStr.Length > maxLenght) + { + shortStr = shortStr.Substring(0, maxLenght) + suffix; + } + + return shortStr; + } #endregion } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs index b5fe92cb..f12400bc 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs @@ -20,7 +20,7 @@ namespace CampusAppWPortalLib8.Utility /// exception which has to log public static void LogException(Exception exception) { - // Console.WriteLine(exception); + // Console.WriteLine(exception); } /// @@ -29,7 +29,7 @@ namespace CampusAppWPortalLib8.Utility /// to be logged message public static void LogMsg(string msg) { - // Console.WriteLine(msg); + // Console.WriteLine(msg); } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs deleted file mode 100644 index 29b2f707..00000000 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 06.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWPortalLib8.Utility -{ - using System.Text.RegularExpressions; - - /// - /// Class provides some special StringMethods - /// - public static class StringManager - { - #region Members - - /// - /// Patter for Html-Tags - /// - private static readonly string HtmlTagPattern = "<.*?>"; - - #endregion - - #region Methods - - /// - /// Method removes Html-Tag of a String - /// - /// String with Html-Tags - /// String without Html-Tags - public static string StripHTML(string inputString) - { - return Regex.Replace(inputString, HtmlTagPattern, string.Empty); - } - - /// - /// Method add an Newline to a string - /// - /// input string - /// input string + newline - public static string AddNewLine(string str) - { - return str.ToString() + "\n"; - } - - /// - /// Method remove(TrimEND!) an Newline to a string - /// - /// input string - /// input string - newline maxLenght) - { - shortStr = shortStr.Substring(0, maxLenght); - } - return shortStr; - } - #endregion - } -}