refatcor utilityplc
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AbstractBackgroundTasks.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>18.09.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the abstract background tasks class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// abstract class for BackGroundTask
|
||||
/// </summary>
|
||||
/// <summary> abstract class for BackGroundTask. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public abstract class AbstractBackgroundTasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the last running task
|
||||
/// </summary>
|
||||
/// <summary> Gets or sets the name of the last running task. </summary>
|
||||
/// <value> The name of the last added task. </value>
|
||||
protected static string LastAddedTaskName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AbstractFile.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>03.05.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the abstract file class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// File class.
|
||||
/// </summary>
|
||||
/// <summary> File class. </summary>
|
||||
/// <remarks> fiedlchr, 15.10.2013. </remarks>
|
||||
public abstract class AbstractFile
|
||||
{
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Delegation of the write callback function prototype.
|
||||
/// </summary>
|
||||
/// <summary> Delegation of the write callback function prototype. </summary>
|
||||
/// <remarks> fiedlchr, 15.10.2013. </remarks>
|
||||
public delegate void WriteCallbackFunc();
|
||||
|
||||
#endregion
|
||||
@@ -25,28 +24,25 @@ namespace CampusAppWPortalLib8.Utility
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary>Read data from file to a string.</summary>
|
||||
/// <remarks>Stubbfel, 03.09.2013.</remarks>
|
||||
/// <returns>data string.</returns>
|
||||
/// <summary> Read data from file to a string. </summary>
|
||||
/// <remarks> fiedlchr, 03.09.2013. </remarks>
|
||||
/// <returns> data string. </returns>
|
||||
public abstract byte[] ReadFile();
|
||||
|
||||
/// <summary>Write bytes to the file.</summary>
|
||||
/// <remarks>Stubbfel, 03.09.2013.</remarks>
|
||||
/// <param name="data"> data byte array.</param>
|
||||
/// <param name="onSavedCallback"> callback function, called after writing is done.</param>
|
||||
/// <param name="onFailedCallback">callback function, called when writing failed.</param>
|
||||
/// <summary> Write bytes to the file. </summary>
|
||||
/// <remarks> fiedlchr, 03.09.2013. </remarks>
|
||||
/// <param name="data"> data byte array. </param>
|
||||
/// <param name="onSavedCallback"> callback function, called after writing is done. </param>
|
||||
/// <param name="onFailedCallback"> callback function, called when writing failed. </param>
|
||||
public abstract void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a file is existing.
|
||||
/// </summary>
|
||||
/// <returns>true, if file exists, otherwise false</returns>
|
||||
/// <summary> Check if a file is existing. </summary>
|
||||
/// <remarks> fiedlchr, 15.10.2013. </remarks>
|
||||
/// <returns> true, if file exists, otherwise false. </returns>
|
||||
public abstract bool Exist();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,32 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AbstractHttpRequest.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>10.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the abstract HTTP request class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using CampusAppWPortalLib8.Model.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// abstract Class provides some methods and member for HttpRequest
|
||||
/// </summary>
|
||||
/// <summary> abstract Class provides some methods and member for HttpRequest. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public abstract class AbstractHttpRequest
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// BaseAddress of the webClient
|
||||
/// </summary>
|
||||
/// <summary> BaseAddress of the webClient. </summary>
|
||||
private string baseAddress;
|
||||
|
||||
#endregion
|
||||
|
||||
#region property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets BaseAddress of the webClient
|
||||
/// </summary>
|
||||
/// <summary> Gets or sets BaseAddress of the webClient. </summary>
|
||||
/// <value> The base address. </value>
|
||||
protected string BaseAddress
|
||||
{
|
||||
get
|
||||
@@ -50,11 +46,10 @@ namespace CampusAppWPortalLib8.Utility
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method create the Url for the http-get-method
|
||||
/// </summary>
|
||||
/// <param name="parameters"> list of parameters</param>
|
||||
/// <returns>absolute API-Url include GetParameter</returns>
|
||||
/// <summary> Method create the Url for the http-get-method. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="parameters"> list of parameters. </param>
|
||||
/// <returns> absolute API-Url include GetParameter. </returns>
|
||||
public Uri CreateGetUrl(List<UrlParamModel> parameters)
|
||||
{
|
||||
string paramterStr = string.Empty;
|
||||
|
||||
@@ -1,68 +1,64 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="DefaultStringManager.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>06.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the default string manager class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using CampusAppWPortalLib8.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// Class provides some special StringMethods
|
||||
/// </summary>
|
||||
/// <summary> Class provides some special StringMethods. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public class DefaultStringManager
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>
|
||||
/// Patter for Html-Tags
|
||||
/// </summary>
|
||||
/// <summary> Patter for Html-Tags. </summary>
|
||||
private static readonly string HtmlTagPattern = "<.*?>";
|
||||
|
||||
/// <summary>The mail valid regular expression.</summary>
|
||||
/// <summary> The mail valid regular expression. </summary>
|
||||
private static readonly string EMailValidRegex = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method removes Html-Tag of a String
|
||||
/// </summary>
|
||||
/// <param name="inputString">String with Html-Tags</param>
|
||||
/// <returns>String without Html-Tags</returns>
|
||||
/// <summary> Method removes Html-Tag of a String. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="inputString"> String with Html-Tags. </param>
|
||||
/// <returns> String without Html-Tags. </returns>
|
||||
public static string StripHTML(string inputString)
|
||||
{
|
||||
return Regex.Replace(inputString, DefaultStringManager.HtmlTagPattern, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method add an Newline to a string
|
||||
/// </summary>
|
||||
/// <param name="str">input string</param>
|
||||
/// <returns>input string + newline</returns>
|
||||
/// <summary> Method add an Newline to a string. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="str"> input string. </param>
|
||||
/// <returns> input string + newline. </returns>
|
||||
public static string AddNewLine(string str)
|
||||
{
|
||||
return str.ToString() + "\n";
|
||||
}
|
||||
|
||||
/// <summary>Method remove(TrimEND!) an Newline to a string.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="str">input string.</param>
|
||||
/// <returns>input string - newline.</returns>
|
||||
/// <summary> Method remove(TrimEND!) an Newline to a string. </summary>
|
||||
/// <remarks> Stubbfel, 12.09.2013. </remarks>
|
||||
/// <param name="str"> input string. </param>
|
||||
/// <returns> input string - newline. </returns>
|
||||
public static string RemoveNewLine(string str)
|
||||
{
|
||||
return str.TrimEnd('\n');
|
||||
}
|
||||
|
||||
/// <summary>Query if 'strIn' is valid email.</summary>
|
||||
/// <remarks>Stubbfel, 04.09.2013.</remarks>
|
||||
/// <param name="strIn">The in.</param>
|
||||
/// <returns>true if valid email, false if not.</returns>
|
||||
/// <summary> Query if 'strIn' is valid email. </summary>
|
||||
/// <remarks> Stubbfel, 04.09.2013. </remarks>
|
||||
/// <param name="strIn"> The in. </param>
|
||||
/// <returns> true if valid email, false if not. </returns>
|
||||
public static bool IsValidEmail(string strIn)
|
||||
{
|
||||
// Return true if strIn is in valid e-mail format.
|
||||
@@ -79,10 +75,10 @@ namespace CampusAppWPortalLib8.Utility
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates uni telefon number.</summary>
|
||||
/// <remarks>Stubbfel, 04.09.2013.</remarks>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns>The new uni telefon number.</returns>
|
||||
/// <summary> Creates uni telefon number. </summary>
|
||||
/// <remarks> Stubbfel, 04.09.2013. </remarks>
|
||||
/// <param name="input"> The input. </param>
|
||||
/// <returns> The new uni telefon number. </returns>
|
||||
public static string CreateUniTelefonNumber(string input)
|
||||
{
|
||||
string result = null;
|
||||
@@ -101,13 +97,14 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method create from a long string a short string
|
||||
/// </summary>
|
||||
/// <param name="longStr">the long input String</param>
|
||||
/// <param name="maxLenght">max length of the short string</param>
|
||||
/// <param name="suffix">(optional) suffix which added to the short string, when long string has to be cut</param>
|
||||
/// <returns>the shorted string</returns>
|
||||
/// <summary> Method create from a long string a short string. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="longStr"> the long input String. </param>
|
||||
/// <param name="maxLenght"> max length of the short string. </param>
|
||||
/// <param name="suffix">
|
||||
/// (optional) suffix which added to the short string, when long string has to be cut.
|
||||
/// </param>
|
||||
/// <returns> the shorted string. </returns>
|
||||
public static string ToShortString(string longStr, int maxLenght, string suffix = "")
|
||||
{
|
||||
string shortStr = longStr;
|
||||
@@ -124,17 +121,15 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return shortStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method gets the placeId of the result string for an qrCode string
|
||||
/// </summary>
|
||||
/// <param name="qrcodeResult">input qrCode string</param>
|
||||
/// <returns>the id if it was found it in the string otherwise null</returns>
|
||||
/// <summary> Method gets the placeId of the result string for an qrCode string. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="qrcodeResult"> input qrCode string. </param>
|
||||
/// <returns> the id if it was found it in the string otherwise null. </returns>
|
||||
public static string FilterPlaceIdinQRResultString(string qrcodeResult)
|
||||
{
|
||||
if (qrcodeResult == null)
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
string[] lines = qrcodeResult.Split('\n');
|
||||
@@ -152,11 +147,10 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method check if the string contains only digit
|
||||
/// </summary>
|
||||
/// <param name="str">input string</param>
|
||||
/// <returns>true if the string contains only digit, otherwise false</returns>
|
||||
/// <summary> Method check if the string contains only digit. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="str"> input string. </param>
|
||||
/// <returns> true if the string contains only digit, otherwise false. </returns>
|
||||
public static bool IsDigitsOnly(string str)
|
||||
{
|
||||
if (str == null || str.Length < 1)
|
||||
@@ -175,11 +169,10 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method gets the placeId of the result string for an nfc string
|
||||
/// </summary>
|
||||
/// <param name="nfcResult">input nfc string</param>
|
||||
/// <returns>the id if it was found it in the string otherwise null</returns>
|
||||
/// <summary> Method gets the placeId of the result string for an nfc string. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="nfcResult"> input nfc string. </param>
|
||||
/// <returns> the id if it was found it in the string otherwise null. </returns>
|
||||
public static string FilterPlaceIdinNFCResultString(string nfcResult)
|
||||
{
|
||||
string nfcResultTrim = nfcResult.Trim('{');
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
//--------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="Logger.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>03.05.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the logger class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// This Class creates logs for the app
|
||||
/// </summary>
|
||||
/// <summary> This Class creates logs for the app. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public class Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Method log a Exception
|
||||
/// </summary>
|
||||
/// <param name="exception">exception which has to log</param>
|
||||
/// <summary> Method log a Exception. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="exception"> exception which has to log. </param>
|
||||
public static void LogException(Exception exception)
|
||||
{
|
||||
// Console.WriteLine(exception);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log a message.
|
||||
/// </summary>
|
||||
/// <param name="msg">to be logged message</param>
|
||||
/// <summary> Log a message. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="msg"> to be logged message. </param>
|
||||
public static void LogMsg(string msg)
|
||||
{
|
||||
// Console.WriteLine(msg);
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="XmlManager.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>18.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the XML manager class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Class provides some Xml-methods
|
||||
/// </summary>
|
||||
/// <summary> Class provides some Xml-methods. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public class XmlManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Method deserialization a string to a Model
|
||||
/// </summary>
|
||||
/// <typeparam name="T">the model</typeparam>
|
||||
/// <param name="xmlString">the XmlString</param>
|
||||
/// <param name="validRootName">name of the RootTag</param>
|
||||
/// <returns>return the deserialization of the model</returns>
|
||||
/// <summary> Method deserialization a string to a Model. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <typeparam name="T"> the model. </typeparam>
|
||||
/// <param name="xmlString"> the XmlString. </param>
|
||||
/// <param name="validRootName"> name of the RootTag. </param>
|
||||
/// <returns> return the deserialization of the model. </returns>
|
||||
public static T DeserializationToModel<T>(string xmlString, string validRootName)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
@@ -38,11 +37,11 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>Deserialization a xml file to a model.</summary>
|
||||
/// <remarks>Stubbfel, 20.08.2013.</remarks>
|
||||
/// <typeparam name="T">Generic type parameter.</typeparam>
|
||||
/// <param name="xmlFilePath">Path to the a XmlFile.</param>
|
||||
/// <returns>model of the XmlFile.</returns>
|
||||
/// <summary> Deserialization a xml file to a model. </summary>
|
||||
/// <remarks> Stubbfel, 20.08.2013. </remarks>
|
||||
/// <typeparam name="T"> Generic type parameter. </typeparam>
|
||||
/// <param name="xmlFilePath"> Path to the a XmlFile. </param>
|
||||
/// <returns> model of the XmlFile. </returns>
|
||||
public static T DeserializationFileToModel<T>(string xmlFilePath)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
@@ -51,12 +50,11 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method serializes a model to a string.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">type of the model</typeparam>
|
||||
/// <param name="model">model object</param>
|
||||
/// <returns>serialized string</returns>
|
||||
/// <summary> Method serializes a model to a string. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <typeparam name="T"> type of the model. </typeparam>
|
||||
/// <param name="model"> model object. </param>
|
||||
/// <returns> serialized string. </returns>
|
||||
public static string SerializationToString<T>(T model)
|
||||
{
|
||||
string retValue = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user