using System; using System.Collections.Generic; using System.Configuration; using System.Web; using System.Web.UI; using System.Globalization; using System.IO; using System.Linq; using TeamLab; using ASC.TeamlabSite.MultiRegionHelper; using log4net; using System.Text; /// /// Summary description for BasePage /// public class BasePage : Page { #region Teamlab UI Culture public CultureInfo TeamLabUICulture { get { return LanguageProvider.GetCurrentCulture(); } } #endregion private static Dictionary> m_contentExists = new Dictionary>(); private static object lockObj = new object(); private string GetContentFileNameByCulture(string contentName) { return GetContentFileNameByCulture(contentName, string.Empty); } private string GetContentFileNameByCulture(string contentName, string cultureKey) { string fileName = string.Empty; if (contentName.Contains("/")) { fileName = string.Format("~/{0}", contentName.Trim("~/".ToCharArray())); } if (!string.IsNullOrEmpty(cultureKey)) { fileName = string.Format("{0}.{2}.{1}", fileName.Remove(fileName.LastIndexOf('.')), fileName.Substring(fileName.LastIndexOf('.') + 1), cultureKey); } return fileName; } private bool IsContentExists(string contentName, string cultureKey) { string fileName = GetContentFileNameByCulture(contentName, cultureKey); return File.Exists(MapPath(fileName)) || Directory.EnumerateFiles(MapPath("~/Bin/"), Path.GetFileName(fileName) + ".*.compiled").Any(); } public string GetContentFileName(string contentName, bool isVirtualPath) { string cultureKey = TeamLabUICulture.TwoLetterISOLanguageName; string result; bool exists = (String.Compare( ConfigurationManager.AppSettings["cache-loc-content-filenames"], "true", true) == 0) ? GetContentExists(contentName, cultureKey) : IsContentExists(contentName, cultureKey); result = exists ? GetContentFileNameByCulture(contentName, cultureKey) : GetContentFileNameByCulture(contentName); if (!isVirtualPath) { result = MapPath(result); } return result; } public string GetContentFileName(string contentName) { return GetContentFileName(contentName, true); } private bool GetContentExists(string contentName, string cultureKey) { bool result; lock (lockObj) { if (!m_contentExists.ContainsKey(cultureKey)) { m_contentExists.Add(cultureKey, new Dictionary()); } if (!m_contentExists[cultureKey].ContainsKey(contentName)) { result = IsContentExists(contentName, cultureKey); m_contentExists[cultureKey].Add(contentName, result); } else { result = m_contentExists[cultureKey][contentName].Value; } } return result; } //Hide ViewSate public string PageCaption { get; set; } public string PageTitle { get; set; } public string MetaDescription { get; set; } public string MetaKeyWords { get; set; } public object Guides { get; set; } public object HelpCenter { get; set; } public string EditionVersion { get; set; } public string CommandName { get; set; } public string VersionName { get; set; } public string VersionLink { get; set; } public string link1 { get; set; } public string link2 { get; set; } }