Fixed issue with removing folders, users and groups in HeliconApe for a web site;
Added checks values conversion utility routines to avoid perf hits caused by exceptions being thrown;
This commit is contained in:
parent
0e9a2db8a4
commit
4a16ca9524
2 changed files with 422 additions and 419 deletions
|
@ -50,40 +50,40 @@ using WebsitePanel.WebPortal;
|
||||||
|
|
||||||
namespace WebsitePanel.Portal
|
namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
public class PortalUtils
|
public class PortalUtils
|
||||||
{
|
{
|
||||||
public const string SharedResourcesFile = "SharedResources.ascx.resx";
|
public const string SharedResourcesFile = "SharedResources.ascx.resx";
|
||||||
public const string CONFIG_FOLDER = "~/App_Data/";
|
public const string CONFIG_FOLDER = "~/App_Data/";
|
||||||
public const string SUPPORTED_THEMES_FILE = "SupportedThemes.config";
|
public const string SUPPORTED_THEMES_FILE = "SupportedThemes.config";
|
||||||
public const string SUPPORTED_LOCALES_FILE = "SupportedLocales.config";
|
public const string SUPPORTED_LOCALES_FILE = "SupportedLocales.config";
|
||||||
public const string USER_ID_PARAM = "UserID";
|
public const string USER_ID_PARAM = "UserID";
|
||||||
public const string SPACE_ID_PARAM = "SpaceID";
|
public const string SPACE_ID_PARAM = "SpaceID";
|
||||||
public const string SEARCH_QUERY_PARAM = "Query";
|
public const string SEARCH_QUERY_PARAM = "Query";
|
||||||
|
|
||||||
public static string CultureCookieName
|
public static string CultureCookieName
|
||||||
{
|
{
|
||||||
get { return PortalConfiguration.SiteSettings["CultureCookieName"]; }
|
get { return PortalConfiguration.SiteSettings["CultureCookieName"]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ThemeCookieName
|
public static string ThemeCookieName
|
||||||
{
|
{
|
||||||
get { return PortalConfiguration.SiteSettings["ThemeCookieName"]; }
|
get { return PortalConfiguration.SiteSettings["ThemeCookieName"]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static System.Globalization.CultureInfo CurrentCulture
|
public static System.Globalization.CultureInfo CurrentCulture
|
||||||
{
|
{
|
||||||
get { return GetCurrentCulture(); }
|
get { return GetCurrentCulture(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static System.Globalization.CultureInfo CurrentUICulture
|
public static System.Globalization.CultureInfo CurrentUICulture
|
||||||
{
|
{
|
||||||
get { return GetCurrentCulture(); }
|
get { return GetCurrentCulture(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CurrentTheme
|
public static string CurrentTheme
|
||||||
{
|
{
|
||||||
get { return GetCurrentTheme(); }
|
get { return GetCurrentTheme(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetCurrentTheme()
|
internal static string GetCurrentTheme()
|
||||||
{
|
{
|
||||||
|
@ -131,51 +131,51 @@ namespace WebsitePanel.Portal
|
||||||
return String.IsNullOrEmpty(theme) ? "Default" : theme;
|
return String.IsNullOrEmpty(theme) ? "Default" : theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetCurrentTheme(string theme)
|
public static void SetCurrentTheme(string theme)
|
||||||
{
|
{
|
||||||
// theme
|
// theme
|
||||||
if (!String.IsNullOrEmpty(theme))
|
if (!String.IsNullOrEmpty(theme))
|
||||||
{
|
{
|
||||||
HttpCookie cookieTheme = new HttpCookie(ThemeCookieName, theme);
|
HttpCookie cookieTheme = new HttpCookie(ThemeCookieName, theme);
|
||||||
cookieTheme.Expires = DateTime.Now.AddMonths(2);
|
cookieTheme.Expires = DateTime.Now.AddMonths(2);
|
||||||
HttpContext.Current.Response.Cookies.Add(cookieTheme);
|
HttpContext.Current.Response.Cookies.Add(cookieTheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static System.Globalization.CultureInfo GetCurrentCulture()
|
internal static System.Globalization.CultureInfo GetCurrentCulture()
|
||||||
{
|
{
|
||||||
System.Globalization.CultureInfo ci = (System.Globalization.CultureInfo)
|
System.Globalization.CultureInfo ci = (System.Globalization.CultureInfo)
|
||||||
HttpContext.Current.Items[CultureCookieName];
|
HttpContext.Current.Items[CultureCookieName];
|
||||||
|
|
||||||
if (ci == null)
|
if (ci == null)
|
||||||
{
|
{
|
||||||
HttpCookie localeCrumb = HttpContext.Current.Request.Cookies[CultureCookieName];
|
HttpCookie localeCrumb = HttpContext.Current.Request.Cookies[CultureCookieName];
|
||||||
if (localeCrumb != null)
|
if (localeCrumb != null)
|
||||||
{
|
{
|
||||||
ci = System.Globalization.CultureInfo.CreateSpecificCulture(localeCrumb.Value);
|
ci = System.Globalization.CultureInfo.CreateSpecificCulture(localeCrumb.Value);
|
||||||
|
|
||||||
if (ci != null)
|
if (ci != null)
|
||||||
{
|
{
|
||||||
HttpContext.Current.Items[CultureCookieName] = ci;
|
HttpContext.Current.Items[CultureCookieName] = ci;
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return ci;
|
return ci;
|
||||||
|
|
||||||
return System.Threading.Thread.CurrentThread.CurrentCulture;
|
return System.Threading.Thread.CurrentThread.CurrentCulture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AdminEmail
|
public static string AdminEmail
|
||||||
{
|
{
|
||||||
get { return PortalConfiguration.SiteSettings["AdminEmail"]; }
|
get { return PortalConfiguration.SiteSettings["AdminEmail"]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FromEmail
|
public static string FromEmail
|
||||||
{
|
{
|
||||||
get { return PortalConfiguration.SiteSettings["FromEmail"]; }
|
get { return PortalConfiguration.SiteSettings["FromEmail"]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendMail(string from, string to, string bcc, string subject, string body)
|
public static void SendMail(string from, string to, string bcc, string subject, string body)
|
||||||
{
|
{
|
||||||
|
@ -214,87 +214,87 @@ namespace WebsitePanel.Portal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UserSignOut()
|
public static void UserSignOut()
|
||||||
{
|
{
|
||||||
FormsAuthentication.SignOut();
|
FormsAuthentication.SignOut();
|
||||||
HttpContext.Current.Response.Redirect(LoginRedirectUrl);
|
HttpContext.Current.Response.Redirect(LoginRedirectUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MenuItem GetSpaceMenuItem(string menuItemKey)
|
public static MenuItem GetSpaceMenuItem(string menuItemKey)
|
||||||
{
|
{
|
||||||
MenuItem item = new MenuItem();
|
MenuItem item = new MenuItem();
|
||||||
item.Value = menuItemKey;
|
item.Value = menuItemKey;
|
||||||
|
|
||||||
menuItemKey = String.Concat("Space", menuItemKey);
|
menuItemKey = String.Concat("Space", menuItemKey);
|
||||||
|
|
||||||
PortalPage page = PortalConfiguration.Site.Pages[menuItemKey];
|
PortalPage page = PortalConfiguration.Site.Pages[menuItemKey];
|
||||||
|
|
||||||
if (page != null)
|
if (page != null)
|
||||||
item.NavigateUrl = DefaultPage.GetPageUrl(menuItemKey);
|
item.NavigateUrl = DefaultPage.GetPageUrl(menuItemKey);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FormsAuthenticationTicket AuthTicket
|
private static FormsAuthenticationTicket AuthTicket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
FormsAuthenticationTicket authTicket = (FormsAuthenticationTicket)HttpContext.Current.Items[FormsAuthentication.FormsCookieName];
|
FormsAuthenticationTicket authTicket = (FormsAuthenticationTicket)HttpContext.Current.Items[FormsAuthentication.FormsCookieName];
|
||||||
|
|
||||||
if (authTicket == null)
|
if (authTicket == null)
|
||||||
{
|
{
|
||||||
// original code
|
// original code
|
||||||
HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
|
HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
|
||||||
// workaround for cases when AuthTicket is required before round-trip
|
// workaround for cases when AuthTicket is required before round-trip
|
||||||
if (authCookie == null || String.IsNullOrEmpty(authCookie.Value))
|
if (authCookie == null || String.IsNullOrEmpty(authCookie.Value))
|
||||||
authCookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
|
authCookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
|
||||||
//
|
//
|
||||||
if (authCookie != null)
|
if (authCookie != null)
|
||||||
{
|
{
|
||||||
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
|
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
|
||||||
HttpContext.Current.Items[FormsAuthentication.FormsCookieName] = authTicket;
|
HttpContext.Current.Items[FormsAuthentication.FormsCookieName] = authTicket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return authTicket;
|
return authTicket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetAuthTicket(FormsAuthenticationTicket ticket, bool persistent)
|
private static void SetAuthTicket(FormsAuthenticationTicket ticket, bool persistent)
|
||||||
{
|
{
|
||||||
// issue authentication cookie
|
// issue authentication cookie
|
||||||
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
|
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
|
||||||
authCookie.Domain = FormsAuthentication.CookieDomain;
|
authCookie.Domain = FormsAuthentication.CookieDomain;
|
||||||
authCookie.Secure = FormsAuthentication.RequireSSL;
|
authCookie.Secure = FormsAuthentication.RequireSSL;
|
||||||
authCookie.Path = FormsAuthentication.FormsCookiePath;
|
authCookie.Path = FormsAuthentication.FormsCookiePath;
|
||||||
authCookie.Value = FormsAuthentication.Encrypt(ticket);
|
authCookie.Value = FormsAuthentication.Encrypt(ticket);
|
||||||
|
|
||||||
if (persistent)
|
if (persistent)
|
||||||
authCookie.Expires = DateTime.Now.AddMonths(1);
|
authCookie.Expires = DateTime.Now.AddMonths(1);
|
||||||
|
|
||||||
HttpContext.Current.Response.Cookies.Add(authCookie);
|
HttpContext.Current.Response.Cookies.Add(authCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ApplicationPath
|
public static string ApplicationPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (HttpContext.Current.Request.ApplicationPath == "/")
|
if (HttpContext.Current.Request.ApplicationPath == "/")
|
||||||
return "";
|
return "";
|
||||||
else
|
else
|
||||||
return HttpContext.Current.Request.ApplicationPath;
|
return HttpContext.Current.Request.ApplicationPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSharedLocalizedString(string moduleName, string resourceKey)
|
public static string GetSharedLocalizedString(string moduleName, string resourceKey)
|
||||||
{
|
{
|
||||||
string className = SharedResourcesFile.Replace(".resx", "");
|
string className = SharedResourcesFile.Replace(".resx", "");
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(moduleName))
|
if (!String.IsNullOrEmpty(moduleName))
|
||||||
className = String.Concat(moduleName, "_", className);
|
className = String.Concat(moduleName, "_", className);
|
||||||
|
|
||||||
return (string)HttpContext.GetGlobalResourceObject(className, resourceKey);
|
return (string)HttpContext.GetGlobalResourceObject(className, resourceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCurrentPageId()
|
public static string GetCurrentPageId()
|
||||||
{
|
{
|
||||||
|
@ -311,40 +311,40 @@ namespace WebsitePanel.Portal
|
||||||
return DefaultPage.GetLocalizedPageName(pageId);
|
return DefaultPage.GetLocalizedPageName(pageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int AuthenticateUser(string username, string password, string ipAddress,
|
public static int AuthenticateUser(string username, string password, string ipAddress,
|
||||||
bool rememberLogin, string preferredLocale, string theme)
|
bool rememberLogin, string preferredLocale, string theme)
|
||||||
{
|
{
|
||||||
esAuthentication authService = new esAuthentication();
|
esAuthentication authService = new esAuthentication();
|
||||||
ConfigureEnterpriseServerProxy(authService, false);
|
ConfigureEnterpriseServerProxy(authService, false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int authResult = authService.AuthenticateUser(username, password, ipAddress);
|
int authResult = authService.AuthenticateUser(username, password, ipAddress);
|
||||||
|
|
||||||
if (authResult < 0)
|
if (authResult < 0)
|
||||||
{
|
{
|
||||||
return authResult;
|
return authResult;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress);
|
UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
// issue authentication ticket
|
// issue authentication ticket
|
||||||
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin);
|
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin);
|
||||||
SetAuthTicket(ticket, rememberLogin);
|
SetAuthTicket(ticket, rememberLogin);
|
||||||
|
|
||||||
CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
|
CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetAuthenticationFormsTimeout()
|
private static int GetAuthenticationFormsTimeout()
|
||||||
{
|
{
|
||||||
|
@ -381,18 +381,18 @@ namespace WebsitePanel.Portal
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ChangeUserPassword(int userId, string newPassword)
|
public static int ChangeUserPassword(int userId, string newPassword)
|
||||||
{
|
{
|
||||||
// load user account
|
// load user account
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService, true);
|
ConfigureEnterpriseServerProxy(usersService, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UserInfo user = usersService.GetUserById(userId);
|
UserInfo user = usersService.GetUserById(userId);
|
||||||
|
|
||||||
// change WebsitePanel account password
|
// change WebsitePanel account password
|
||||||
int result = usersService.ChangeUserPassword(userId, newPassword);
|
int result = usersService.ChangeUserPassword(userId, newPassword);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -400,15 +400,15 @@ namespace WebsitePanel.Portal
|
||||||
if (String.Compare(user.Username, AuthTicket.Name, true) == 0)
|
if (String.Compare(user.Username, AuthTicket.Name, true) == 0)
|
||||||
{
|
{
|
||||||
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, newPassword, user.Role, AuthTicket.IsPersistent);
|
FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, newPassword, user.Role, AuthTicket.IsPersistent);
|
||||||
SetAuthTicket(ticket, AuthTicket.IsPersistent);
|
SetAuthTicket(ticket, AuthTicket.IsPersistent);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int UpdateUserAccount(UserInfo user)
|
public static int UpdateUserAccount(UserInfo user)
|
||||||
{
|
{
|
||||||
|
@ -416,138 +416,138 @@ namespace WebsitePanel.Portal
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int UpdateUserAccount(string taskId, UserInfo user)
|
public static int UpdateUserAccount(string taskId, UserInfo user)
|
||||||
{
|
{
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService, true);
|
ConfigureEnterpriseServerProxy(usersService, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update user in WebsitePanel
|
// update user in WebsitePanel
|
||||||
return usersService.UpdateUserTask(taskId, user);
|
return usersService.UpdateUserTask(taskId, user);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int AddUserAccount(List<string> log, UserInfo user, bool sendLetter)
|
public static int AddUserAccount(List<string> log, UserInfo user, bool sendLetter)
|
||||||
{
|
{
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService, true);
|
ConfigureEnterpriseServerProxy(usersService, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// add user to WebsitePanel server
|
// add user to WebsitePanel server
|
||||||
return usersService.AddUser(user, sendLetter);
|
return usersService.AddUser(user, sendLetter);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DeleteUserAccount(int userId)
|
public static int DeleteUserAccount(int userId)
|
||||||
{
|
{
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService, true);
|
ConfigureEnterpriseServerProxy(usersService, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// add user to WebsitePanel server
|
// add user to WebsitePanel server
|
||||||
return usersService.DeleteUser(userId);
|
return usersService.DeleteUser(userId);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ChangeUserStatus(int userId, UserStatus status)
|
public static int ChangeUserStatus(int userId, UserStatus status)
|
||||||
{
|
{
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService, true);
|
ConfigureEnterpriseServerProxy(usersService, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// add user to WebsitePanel server
|
// add user to WebsitePanel server
|
||||||
return usersService.ChangeUserStatus(userId, status);
|
return usersService.ChangeUserStatus(userId, status);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserInfo GetCurrentUser()
|
public static UserInfo GetCurrentUser()
|
||||||
{
|
{
|
||||||
UserInfo user = null;
|
UserInfo user = null;
|
||||||
|
|
||||||
if (AuthTicket != null)
|
if (AuthTicket != null)
|
||||||
{
|
{
|
||||||
esUsers usersService = new esUsers();
|
esUsers usersService = new esUsers();
|
||||||
ConfigureEnterpriseServerProxy(usersService);
|
ConfigureEnterpriseServerProxy(usersService);
|
||||||
|
|
||||||
user = usersService.GetUserByUsername(AuthTicket.Name);
|
user = usersService.GetUserByUsername(AuthTicket.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CompleteUserLogin(string username, bool rememberLogin,
|
private static void CompleteUserLogin(string username, bool rememberLogin,
|
||||||
string preferredLocale, string theme)
|
string preferredLocale, string theme)
|
||||||
{
|
{
|
||||||
// store last successful username in the cookie
|
// store last successful username in the cookie
|
||||||
HttpCookie cookie = new HttpCookie("WebsitePanelLogin", username);
|
HttpCookie cookie = new HttpCookie("WebsitePanelLogin", username);
|
||||||
cookie.Expires = DateTime.Now.AddDays(7);
|
cookie.Expires = DateTime.Now.AddDays(7);
|
||||||
HttpContext.Current.Response.Cookies.Add(cookie);
|
HttpContext.Current.Response.Cookies.Add(cookie);
|
||||||
|
|
||||||
// set language
|
// set language
|
||||||
SetCurrentLanguage(preferredLocale);
|
SetCurrentLanguage(preferredLocale);
|
||||||
|
|
||||||
// set theme
|
// set theme
|
||||||
SetCurrentTheme(theme);
|
SetCurrentTheme(theme);
|
||||||
|
|
||||||
// remember me
|
// remember me
|
||||||
if (rememberLogin)
|
if (rememberLogin)
|
||||||
HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(1);
|
HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetCurrentLanguage(string preferredLocale)
|
public static void SetCurrentLanguage(string preferredLocale)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(preferredLocale))
|
if (!String.IsNullOrEmpty(preferredLocale))
|
||||||
{
|
{
|
||||||
HttpCookie localeCrumb = new HttpCookie(CultureCookieName, preferredLocale);
|
HttpCookie localeCrumb = new HttpCookie(CultureCookieName, preferredLocale);
|
||||||
localeCrumb.Expires = DateTime.Now.AddMonths(2);
|
localeCrumb.Expires = DateTime.Now.AddMonths(2);
|
||||||
HttpContext.Current.Response.Cookies.Add(localeCrumb);
|
HttpContext.Current.Response.Cookies.Add(localeCrumb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy)
|
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy)
|
||||||
{
|
{
|
||||||
ConfigureEnterpriseServerProxy(proxy, true);
|
ConfigureEnterpriseServerProxy(proxy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
|
public static void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
|
||||||
{
|
{
|
||||||
// load ES properties
|
// load ES properties
|
||||||
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
|
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
|
||||||
|
|
||||||
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
|
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
|
||||||
cnfg.EnterpriseServerUrl = serverUrl;
|
cnfg.EnterpriseServerUrl = serverUrl;
|
||||||
|
|
||||||
// create assertion
|
// create assertion
|
||||||
if (applyPolicy)
|
if (applyPolicy)
|
||||||
{
|
{
|
||||||
if (AuthTicket != null)
|
if (AuthTicket != null)
|
||||||
{
|
{
|
||||||
cnfg.Username = AuthTicket.Name;
|
cnfg.Username = AuthTicket.Name;
|
||||||
cnfg.Password = AuthTicket.UserData.Substring(0, AuthTicket.UserData.IndexOf(Environment.NewLine));
|
cnfg.Password = AuthTicket.UserData.Substring(0, AuthTicket.UserData.IndexOf(Environment.NewLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cnfg.Configure(proxy);
|
cnfg.Configure(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlNode GetModuleContentNode(WebPortalControlBase module)
|
public static XmlNode GetModuleContentNode(WebPortalControlBase module)
|
||||||
{
|
{
|
||||||
|
@ -560,15 +560,15 @@ namespace WebsitePanel.Portal
|
||||||
return module.Module.SelectNodes("MenuItem");
|
return module.Module.SelectNodes("MenuItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatIconImageUrl(string url)
|
public static string FormatIconImageUrl(string url)
|
||||||
{
|
{
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatIconLinkUrl(object url)
|
public static string FormatIconLinkUrl(object url)
|
||||||
{
|
{
|
||||||
return DefaultPage.GetPageUrl(url.ToString());
|
return DefaultPage.GetPageUrl(url.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetThemedImage(string imageUrl)
|
public static string GetThemedImage(string imageUrl)
|
||||||
{
|
{
|
||||||
|
@ -582,76 +582,76 @@ namespace WebsitePanel.Portal
|
||||||
return page.ResolveUrl("~/App_Themes/" + page.Theme + "/" + iconUrl);
|
return page.ResolveUrl("~/App_Themes/" + page.Theme + "/" + iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadStatesDropDownList(DropDownList list, string countryCode)
|
public static void LoadStatesDropDownList(DropDownList list, string countryCode)
|
||||||
{
|
{
|
||||||
string xmlFilePath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "CountryStates.config");
|
string xmlFilePath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "CountryStates.config");
|
||||||
list.Items.Clear();
|
list.Items.Clear();
|
||||||
if (File.Exists(xmlFilePath))
|
if (File.Exists(xmlFilePath))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
xmlDoc.Load(xmlFilePath);
|
xmlDoc.Load(xmlFilePath);
|
||||||
|
|
||||||
List<ListItem> items = new List<ListItem>();
|
List<ListItem> items = new List<ListItem>();
|
||||||
|
|
||||||
XmlNodeList xmlNodes = xmlDoc.SelectNodes("//State[@countryCode='" + countryCode + "']");
|
XmlNodeList xmlNodes = xmlDoc.SelectNodes("//State[@countryCode='" + countryCode + "']");
|
||||||
foreach (XmlElement xmlNode in xmlNodes)
|
foreach (XmlElement xmlNode in xmlNodes)
|
||||||
{
|
{
|
||||||
string nodeName = xmlNode.GetAttribute("name");
|
string nodeName = xmlNode.GetAttribute("name");
|
||||||
string nodeKey = xmlNode.GetAttribute("key");
|
string nodeKey = xmlNode.GetAttribute("key");
|
||||||
|
|
||||||
items.Add(new ListItem(nodeName, nodeKey));
|
items.Add(new ListItem(nodeName, nodeKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Items.AddRange(items.ToArray());
|
list.Items.AddRange(items.ToArray());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadCountriesDropDownList(DropDownList list, string countryToSelect)
|
public static void LoadCountriesDropDownList(DropDownList list, string countryToSelect)
|
||||||
{
|
{
|
||||||
string countriesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "Countries.config");
|
string countriesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "Countries.config");
|
||||||
|
|
||||||
if (File.Exists(countriesPath))
|
if (File.Exists(countriesPath))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlDocument xmlCountriesDoc = new XmlDocument();
|
XmlDocument xmlCountriesDoc = new XmlDocument();
|
||||||
xmlCountriesDoc.Load(countriesPath);
|
xmlCountriesDoc.Load(countriesPath);
|
||||||
|
|
||||||
List<ListItem> items = new List<ListItem>();
|
List<ListItem> items = new List<ListItem>();
|
||||||
|
|
||||||
XmlNodeList xmlCountries = xmlCountriesDoc.SelectNodes("//Country");
|
XmlNodeList xmlCountries = xmlCountriesDoc.SelectNodes("//Country");
|
||||||
foreach (XmlElement xmlCountry in xmlCountries)
|
foreach (XmlElement xmlCountry in xmlCountries)
|
||||||
{
|
{
|
||||||
string countryName = xmlCountry.GetAttribute("name");
|
string countryName = xmlCountry.GetAttribute("name");
|
||||||
string countryKey = xmlCountry.GetAttribute("key");
|
string countryKey = xmlCountry.GetAttribute("key");
|
||||||
|
|
||||||
if (String.Compare(countryKey, countryToSelect) == 0)
|
if (String.Compare(countryKey, countryToSelect) == 0)
|
||||||
{
|
{
|
||||||
ListItem li = new ListItem(countryName, countryKey);
|
ListItem li = new ListItem(countryName, countryKey);
|
||||||
li.Selected = true;
|
li.Selected = true;
|
||||||
items.Add(li);
|
items.Add(li);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
items.Add(new ListItem(countryName, countryKey));
|
items.Add(new ListItem(countryName, countryKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Items.AddRange(items.ToArray());
|
list.Items.AddRange(items.ToArray());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void LoadCultureDropDownList(DropDownList list)
|
public static void LoadCultureDropDownList(DropDownList list)
|
||||||
{
|
{
|
||||||
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedLocales.config");
|
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedLocales.config");
|
||||||
|
|
||||||
if (File.Exists(localesPath))
|
if (File.Exists(localesPath))
|
||||||
|
@ -696,39 +696,39 @@ namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadThemesDropDownList(DropDownList list)
|
public static void LoadThemesDropDownList(DropDownList list)
|
||||||
{
|
{
|
||||||
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedThemes.config");
|
string localesPath = HttpContext.Current.Server.MapPath(CONFIG_FOLDER + "SupportedThemes.config");
|
||||||
|
|
||||||
if (File.Exists(localesPath))
|
if (File.Exists(localesPath))
|
||||||
{
|
{
|
||||||
string themeToSelect = CurrentTheme;
|
string themeToSelect = CurrentTheme;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(localesPath);
|
doc.Load(localesPath);
|
||||||
|
|
||||||
XmlNodeList xmlThemes = doc.SelectNodes("//Theme");
|
XmlNodeList xmlThemes = doc.SelectNodes("//Theme");
|
||||||
for (int i = 0; i < xmlThemes.Count; i++)
|
for (int i = 0; i < xmlThemes.Count; i++)
|
||||||
{
|
{
|
||||||
XmlElement xmlTheme = (XmlElement)xmlThemes[i];
|
XmlElement xmlTheme = (XmlElement)xmlThemes[i];
|
||||||
string themeName = xmlTheme.GetAttribute("name");
|
string themeName = xmlTheme.GetAttribute("name");
|
||||||
string themeTitle = xmlTheme.GetAttribute("title");
|
string themeTitle = xmlTheme.GetAttribute("title");
|
||||||
|
|
||||||
list.Items.Add(new ListItem(themeTitle, themeName));
|
list.Items.Add(new ListItem(themeTitle, themeName));
|
||||||
|
|
||||||
if (String.Compare(themeName, themeToSelect) == 0)
|
if (String.Compare(themeName, themeToSelect) == 0)
|
||||||
list.Items[i].Selected = true;
|
list.Items[i].Selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Navigation Routines
|
#region Navigation Routines
|
||||||
public static string LoginRedirectUrl
|
public static string LoginRedirectUrl
|
||||||
|
@ -805,23 +805,23 @@ namespace WebsitePanel.Portal
|
||||||
urlBuilder.Add(String.Concat(keyName, "=", keyValue));
|
urlBuilder.Add(String.Concat(keyName, "=", keyValue));
|
||||||
|
|
||||||
// load additional params
|
// load additional params
|
||||||
if (additionalParams != null)
|
if (additionalParams != null)
|
||||||
{
|
{
|
||||||
string controlId = null;
|
string controlId = null;
|
||||||
string moduleDefinitionId = null;
|
string moduleDefinitionId = null;
|
||||||
//
|
//
|
||||||
foreach (string paramStr in additionalParams)
|
foreach (string paramStr in additionalParams)
|
||||||
{
|
{
|
||||||
if (paramStr.StartsWith("ctl=", StringComparison.InvariantCultureIgnoreCase))
|
if (paramStr.StartsWith("ctl=", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
// ensure page exists and avoid unnecessary exceptions throw
|
// ensure page exists and avoid unnecessary exceptions throw
|
||||||
if (PortalConfiguration.Site.Pages.ContainsKey(pageId))
|
if (PortalConfiguration.Site.Pages.ContainsKey(pageId))
|
||||||
{
|
{
|
||||||
string[] pair = paramStr.Split('=');
|
string[] pair = paramStr.Split('=');
|
||||||
controlId = pair[1];
|
controlId = pair[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (paramStr.StartsWith("moduleDefId=", StringComparison.InvariantCultureIgnoreCase))
|
else if (paramStr.StartsWith("moduleDefId=", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
// ensure page exists and avoid unnecessary exceptions throw
|
// ensure page exists and avoid unnecessary exceptions throw
|
||||||
|
@ -832,8 +832,8 @@ namespace WebsitePanel.Portal
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
urlBuilder.Add(paramStr);
|
urlBuilder.Add(paramStr);
|
||||||
}
|
}
|
||||||
if (!String.IsNullOrEmpty(moduleDefinitionId) && !String.IsNullOrEmpty(controlId))
|
if (!String.IsNullOrEmpty(moduleDefinitionId) && !String.IsNullOrEmpty(controlId))
|
||||||
{
|
{
|
||||||
// 1. Read module controls first information first
|
// 1. Read module controls first information first
|
||||||
|
@ -864,7 +864,7 @@ namespace WebsitePanel.Portal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
End:
|
End:
|
||||||
if (urlBuilder.Count > 0)
|
if (urlBuilder.Count > 0)
|
||||||
|
|
|
@ -66,44 +66,47 @@ namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
if (IsHeliconApeInstalled)
|
if (IsHeliconApeInstalled)
|
||||||
{
|
{
|
||||||
WebSite site = null;
|
if (!IsPostBack)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
|
WebSite site = null;
|
||||||
}
|
try
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
|
||||||
HostModule.ShowErrorMessage("WEB_GET_SITE", ex);
|
}
|
||||||
return;
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
HostModule.ShowErrorMessage("WEB_GET_SITE", ex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (site == null)
|
if (site == null)
|
||||||
RedirectToBrowsePage();
|
RedirectToBrowsePage();
|
||||||
|
|
||||||
BindHeliconApe(site);
|
BindHeliconApe(site);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindHeliconApe(WebSite site)
|
public void BindHeliconApe(WebSite site)
|
||||||
{
|
{
|
||||||
// save initial state
|
// save initial state
|
||||||
IsHeliconApeInstalled = site.HeliconApeInstalled;
|
IsHeliconApeInstalled = site.HeliconApeInstalled;
|
||||||
IsHeliconApeEnabled = site.HeliconApeEnabled;
|
IsHeliconApeEnabled = site.HeliconApeEnabled;
|
||||||
IsSecuredFoldersInstalled = site.SecuredFoldersInstalled;
|
IsSecuredFoldersInstalled = site.SecuredFoldersInstalled;
|
||||||
|
|
||||||
// Render a warning message about the automatic site's settings change
|
// Render a warning message about the automatic site's settings change
|
||||||
if (!IsHeliconApeEnabled && site.IIs7)
|
if (!IsHeliconApeEnabled && site.IIs7)
|
||||||
{
|
{
|
||||||
// Ensure the message is displayed only when neccessary
|
// Ensure the message is displayed only when neccessary
|
||||||
if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled)
|
if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled)
|
||||||
{
|
{
|
||||||
// TODO: show warning, do not force to enable integrated pool
|
// TODO: show warning, do not force to enable integrated pool
|
||||||
string warningStr = GetLocalizedString("EnableFoldersIIs7Warning.Text");
|
string warningStr = GetLocalizedString("EnableFoldersIIs7Warning.Text");
|
||||||
// Render a warning only if specified
|
// Render a warning only if specified
|
||||||
if (!String.IsNullOrEmpty(warningStr))
|
if (!String.IsNullOrEmpty(warningStr))
|
||||||
btnToggleHeliconApe.OnClientClick = String.Format("return confirm('{0}')", warningStr);
|
btnToggleHeliconApe.OnClientClick = String.Format("return confirm('{0}')", warningStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// toggle
|
// toggle
|
||||||
ToggleControls();
|
ToggleControls();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +115,7 @@ namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
if (IsHeliconApeInstalled)
|
if (IsHeliconApeInstalled)
|
||||||
{
|
{
|
||||||
// toggle button
|
// toggle button
|
||||||
btnToggleHeliconApe.Text = GetLocalizedString(
|
btnToggleHeliconApe.Text = GetLocalizedString(
|
||||||
IsHeliconApeEnabled ? "DisableHeliconApe.Text" : "EnableHeliconApe.Text");
|
IsHeliconApeEnabled ? "DisableHeliconApe.Text" : "EnableHeliconApe.Text");
|
||||||
|
|
||||||
|
@ -130,9 +133,9 @@ namespace WebsitePanel.Portal
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Display the module not installed message for informational purposes.
|
// Display the module not installed message for informational purposes.
|
||||||
panelHeliconApeIsNotInstalledMessage.Visible = true;
|
panelHeliconApeIsNotInstalledMessage.Visible = true;
|
||||||
//
|
//
|
||||||
btnToggleHeliconApe.Visible = false;
|
btnToggleHeliconApe.Visible = false;
|
||||||
HeliconApeFoldersPanel.Visible = false;
|
HeliconApeFoldersPanel.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue