Class ManagementHelper
Inheritance
Inherited Members
Namespace: Mediachase.Web.Console.Common
Assembly: Mediachase.WebConsoleLib.dll
Version: 10.8.0Syntax
public class ManagementHelper
Constructors
ManagementHelper()
Declaration
public ManagementHelper()
Methods
ClearCookie(String, String)
Clears the cookie. When called with empty value
, removes all values from the cookie.
Declaration
public static void ClearCookie(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.String | value | The value. |
CollectControls<T>(Control)
Collect all the controls of type 'T'
Declaration
public static List<T> CollectControls<T>(Control parent)
where T : Control
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | parent | The parent. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> |
Type Parameters
Name | Description |
---|---|
T |
ConvertToTable(IDataReader)
Translates reader to the datatable
Declaration
public static DataTable ConvertToTable(IDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | reader | The reader. |
Returns
Type | Description |
---|---|
System.Data.DataTable |
FormatAgoDateTime(DateTime)
Declaration
public static string FormatAgoDateTime(DateTime date)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date |
Returns
Type | Description |
---|---|
System.String |
FormatDateTime(DateTime)
Declaration
public static string FormatDateTime(DateTime date)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date |
Returns
Type | Description |
---|---|
System.String |
FormatDateTime(DateTime, Boolean)
Returns formatted string back
Declaration
public static string FormatDateTime(DateTime date, bool useThisDate)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | |
System.Boolean | useThisDate | If true, |
Returns
Type | Description |
---|---|
System.String | An HTML string for displaying the specified value. |
GetAppIdFromQueryString()
Gets the app id from query string.
Declaration
public static string GetAppIdFromQueryString()
Returns
Type | Description |
---|---|
System.String |
GetBindGridFlag(String)
Gets the bind grid flag.
Declaration
public static bool GetBindGridFlag(string gridId)
Parameters
Type | Name | Description |
---|---|---|
System.String | gridId | The grid id. |
Returns
Type | Description |
---|---|
System.Boolean |
GetBooleanValue(Object, Boolean)
Gets the boolean value.
Declaration
public static bool GetBooleanValue(object obj, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The obj. |
System.Boolean | defaultValue | if set to |
Returns
Type | Description |
---|---|
System.Boolean |
GetConsoleResource(String)
Gets the console resource.
Declaration
public static string GetConsoleResource(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
Returns
Type | Description |
---|---|
System.String |
GetControlFromCollection<T>(ControlCollection, String)
Searches for the control with specified id and type in the given controls collection
Declaration
public static T GetControlFromCollection<T>(ControlCollection coll, string controlId)
where T : Control
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.ControlCollection | coll | The coll. |
System.String | controlId | The control id. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetCookie(String)
Gets the cookie.
Declaration
public static NameValueCollection GetCookie(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.Collections.Specialized.NameValueCollection |
GetCookieValue(String)
Gets the cookie.
Declaration
public static string GetCookieValue(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.String |
GetEntryUrl(Int32, String)
Gets the entry URL.
Declaration
public static string GetEntryUrl(int entryId, string classTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | entryId | The entry id. |
System.String | classTypeId | The class type id. |
Returns
Type | Description |
---|---|
System.String |
GetFlagIcon(CultureInfo)
Gets the flag icon.
Declaration
public static string GetFlagIcon(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The culture. |
Returns
Type | Description |
---|---|
System.String |
GetGuidFromQueryString(String)
Gets the GUID from query string.
Declaration
public static Guid GetGuidFromQueryString(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
Returns
Type | Description |
---|---|
System.Guid |
GetImportExportFolderPath(String)
Gets the import export folder path.
Declaration
public static string GetImportExportFolderPath(string appFolder)
Parameters
Type | Name | Description |
---|---|---|
System.String | appFolder | The app folder. |
Returns
Type | Description |
---|---|
System.String |
GetIntegerValue(Object, Int32)
Gets the integer value.
Declaration
public static int GetIntegerValue(object obj, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The obj. |
System.Int32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
System.Int32 |
GetIntFromQueryString(String)
Gets the int from query string.
Declaration
public static int GetIntFromQueryString(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
Returns
Type | Description |
---|---|
System.Int32 |
GetIntFromQueryString(String, Int32)
Gets the int from query string.
Declaration
public static int GetIntFromQueryString(string name, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.Int32 | defaultValue | The default value if parameter does not exist. |
Returns
Type | Description |
---|---|
System.Int32 |
GetParentControl<T>(Control)
Returns the parent control of specified type for the given control
Declaration
public static T GetParentControl<T>(Control control)
where T : Control
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetStartOfWeek(DateTime)
Declaration
public static DateTime GetStartOfWeek(DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt |
Returns
Type | Description |
---|---|
System.DateTime |
GetStringValue(Object, String)
Gets the string value.
Declaration
public static string GetStringValue(object obj, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The obj. |
System.String | defaultValue | The default value. |
Returns
Type | Description |
---|---|
System.String |
GetUserDateTime(DateTime)
Returns datetime value converted based on current user's settings.
Declaration
[Obsolete("This only calls DateTime.ToLocalTime() on the value. Call ToLocalTime() directly. Will remain at least until November 2016.")]
public static DateTime GetUserDateTime(DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | DateTime in UTC. |
Returns
Type | Description |
---|---|
System.DateTime |
GetUserDateTimeNow()
Returns current datetime value converted based on current user's settings.
Declaration
[Obsolete("This returns DateTime.Now. Use DateTime.Now directly. Will remain at least until November 2016.")]
public static DateTime GetUserDateTimeNow()
Returns
Type | Description |
---|---|
System.DateTime |
GetUserName(Guid)
Gets the name of the user which has contact id specified.
Declaration
public static string GetUserName(Guid contactId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | contactId | The contact id. |
Returns
Type | Description |
---|---|
System.String |
GetValueFromQueryString(String, String)
Gets the value from query string.
Declaration
public static string GetValueFromQueryString(string name, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.String | defaultValue | The default value. |
Returns
Type | Description |
---|---|
System.String |
GetViewIdFromQueryString()
Gets the view id from query string.
Declaration
public static string GetViewIdFromQueryString()
Returns
Type | Description |
---|---|
System.String |
MakeCurrentApplicationCookieName(String)
Creates app-specific cookie name.
Declaration
public static string MakeCurrentApplicationCookieName(string baseName)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseName |
Returns
Type | Description |
---|---|
System.String |
MakeSafeSearchFilter(String)
Makes the safe search filter (replaces single quotes with double, etc.) Intended for use with filter strings inside single quotes, like in ICatalogSystem's method FindItemsDto (in clauses like this: "[FieldName] like 'filter'").
Declaration
public static string MakeSafeSearchFilter(string filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | The filter. |
Returns
Type | Description |
---|---|
System.String |
RegisterBrowserStyles(Page)
Includes browser-specific css files.
Declaration
public static void RegisterBrowserStyles(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page |
RegisterCommandsForView(Page, String, String)
Registers commands from xml for the specified app and view. This is needed because when there are no items in a grid CommandManager doesn't register commands that are used by grid items.
Declaration
public static void RegisterCommandsForView(Page page, string appId, string viewId)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The ASP.NET page that will handle the commands. |
System.String | appId | |
System.String | viewId |
SelectListItem(DropDownList, Guid)
Selects an item in a System.Web.UI.WebControls.DropDownList by guid value.
Declaration
public static void SelectListItem(DropDownList list, Guid value)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The System.Web.UI.WebControls.DropDownList to modify the selection in. |
System.Guid | value | The value of the System.Web.UI.WebControls.ListItem to select. If no match is found, the selection
of |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | More than one matching System.Web.UI.WebControls.ListItem was found in |
SelectListItem(DropDownList, Int32)
Selects an item in a System.Web.UI.WebControls.DropDownList by integer value.
Declaration
public static void SelectListItem(DropDownList list, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The System.Web.UI.WebControls.DropDownList to modify the selection in. |
System.Int32 | value | The value of the System.Web.UI.WebControls.ListItem to select. If no match is found, the selection
of |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | More than one matching System.Web.UI.WebControls.ListItem was found in |
SelectListItem(DropDownList, Object)
Selects an item in the drop down list by value. The value must match
val
.ToString() by case-sensitive string comparison. If
val
is null or no match is found, the selection will be cleared.
Declaration
[Obsolete("The comparison between the parameter value and the list value is unclear. Use SelectListItem(DropDownList, string, IEqualityComparer<string>). Will remain at least until November 2016.")]
public static void SelectListItem(DropDownList list, object val)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The drop down list to modify the selection in. |
System.Object | val | An object matching the value of the System.Web.UI.WebControls.ListItem to select. |
SelectListItem(DropDownList, String, IEqualityComparer<String>)
Selects an item in a System.Web.UI.WebControls.DropDownList by value, using a specified string comparison.
Declaration
public static void SelectListItem(DropDownList list, string value, IEqualityComparer<string> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The System.Web.UI.WebControls.DropDownList to modify the selection in. |
System.String | value | The value of the System.Web.UI.WebControls.ListItem to select. If |
System.Collections.Generic.IEqualityComparer<System.String> | comparer | A comparison used to find the desired System.Web.UI.WebControls.ListItem. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | More than one matching System.Web.UI.WebControls.ListItem was found in |
SelectListItem(ListBox, Object, Boolean)
Selects item in the listbox
Declaration
public static void SelectListItem(ListBox list, object val, bool clearSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.ListBox | list | The list. |
System.Object | val | The val. |
System.Boolean | clearSelection | if set to |
SelectListItem2(DropDownList, Object)
Selects an item in the drop down list by value. The value must match
val
.ToString() by case-insensitive string comparison. If
val
is null or no match is found, the selection will be cleared.
Declaration
[Obsolete("The comparison between the parameter value and the list value is unclear. Use SelectListItem(DropDownList, string, IEqualityComparer<string>). Will remain at least until November 2016.")]
public static void SelectListItem2(DropDownList list, object val)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The drop down list to modify the selection in. |
System.Object | val | An object matching the value of the System.Web.UI.WebControls.ListItem to select. |
SelectListItemIgnoreCase(DropDownList, String)
The same as SelectListItem, but ignores items' values case. Used for string values only.
Declaration
[Obsolete("This method is redundant. Use SelectListItem(DropDownList, string, IEqualityComparer<string>). Will remain at least until November 2016.")]
public static void SelectListItemIgnoreCase(DropDownList list, string val)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.DropDownList | list | The list. |
System.String | val | The val. |
SelectListItemIgnoreCase(ListBox, String, Boolean)
The same as SelectListItem, but ignores items' values case. Used for string values only.
Declaration
public static void SelectListItemIgnoreCase(ListBox list, string val, bool clearSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.ListBox | list | The list. |
System.String | val | String value. |
System.Boolean | clearSelection | if set to |
SelectRadioListItem(RadioButtonList, Object)
Selects item in the radio list
Declaration
public static void SelectRadioListItem(RadioButtonList list, object val)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.RadioButtonList | list | The list. |
System.Object | val | The val. |
SetBindGridFlag(String)
Sets the bind grid flag.
Declaration
public static void SetBindGridFlag(string gridId)
Parameters
Type | Name | Description |
---|---|---|
System.String | gridId | The grid id. |
SetBindGridFlag(String, Boolean)
Sets the bind grid flag.
Declaration
public static void SetBindGridFlag(string gridId, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.String | gridId | The grid id. |
System.Boolean | value | if set to |
SetCookie(String, NameValueCollection, DateTime)
Sets the cookie.
Declaration
public static void SetCookie(string key, NameValueCollection values, DateTime expires)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.Collections.Specialized.NameValueCollection | values | The values. |
System.DateTime | expires | The expires. |
SetCookie(String, String, DateTime)
Sets the cookie.
Declaration
public static void SetCookie(string key, string val, DateTime expires)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
System.String | val | The val. |
System.DateTime | expires | The expiration time for the cookie. |