/// <summary> /// Gets and bulk updates media libraries. Called when the "Get and bulk update libraries" button is pressed. /// Expects the CreateMediaLibrary method to be run first. /// </summary> private bool GetAndBulkUpdateMediaLibraries() { // Prepare the parameters string where = "LibraryName LIKE 'MyNew%'"; // Get the data DataSet libraries = MediaLibraryInfoProvider.GetMediaLibraries(where, null); if (!DataHelper.DataSourceIsEmpty(libraries)) { // Loop through the individual items foreach (DataRow libraryDr in libraries.Tables[0].Rows) { // Create object from DataRow MediaLibraryInfo modifyLibrary = new MediaLibraryInfo(libraryDr); // Update the property modifyLibrary.LibraryDisplayName = modifyLibrary.LibraryDisplayName.ToUpper(); // Update the media library MediaLibraryInfoProvider.SetMediaLibraryInfo(modifyLibrary); } return(true); } return(false); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData(bool forceReload) { uniSelector.IsLiveSite = IsLiveSite; uniSelector.ReturnColumnName = (UseLibraryNameForSelection ? "LibraryName" : "LibraryID"); uniSelector.WhereCondition = GetCompleteWhereCondition(); uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged; uniSelector.DropDownSingleSelect.AutoPostBack = UseAutoPostBack; bool noLibrary = MediaLibraryInfoProvider.GetMediaLibraries() .Where(GetGroupsWhereCondition()) .Count == 0; // Empty value '(none)' is allowed when it is allowed from outside (property 'AllowEmpty') or no libraries was found and flag 'NoneWhenEmpty' is set uniSelector.AllowEmpty |= (noLibrary && NoneWhenEmpty); if (AddCurrentLibraryRecord) { uniSelector.SpecialFields.Add(new SpecialField { Text = GetString("media.current"), Value = MediaLibraryInfoProvider.CURRENT_LIBRARY }); } if (forceReload) { uniSelector.Reload(true); } }
string GetDirectImageUrlFromMediaLibrary(Guid imageGuid) { //get filenale string fileName = null; var libs = MediaLibraryInfoProvider.GetMediaLibraries().ToList(); foreach (var lib in libs) { var folder = lib.Children.FirstOrDefault(); foreach (var image in folder) { if (!string.IsNullOrEmpty(image.GetProperty("Guid").ToString())) { if (image.GetProperty("Guid").ToString() == imageGuid.ToString()) { fileName = image.GetProperty("FileName").ToString(); } } } } var siteName = SiteContext.CurrentSiteName; var urlMediaFileInfo = MediaFileInfoProvider.GetMediaFileInfo(imageGuid, siteName); string url = MediaLibraryHelper.GetDirectUrl(urlMediaFileInfo); return(url); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData(bool forceReload) { string where = GetWhereConditionInternal(); uniSelector.IsLiveSite = IsLiveSite; uniSelector.ReturnColumnName = (UseLibraryNameForSelection ? "LibraryName" : "LibraryID"); uniSelector.WhereCondition = where; uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged; uniSelector.DropDownSingleSelect.AutoPostBack = UseAutoPostBack; bool noLibrary = DataHelper.DataSourceIsEmpty(MediaLibraryInfoProvider.GetMediaLibraries(where, null, 1, "LibraryID")); // Insert '(none)' record if no library exists - only if '(none)' isn't inserted by default uniSelector.AllowEmpty = (noLibrary && NoneWhenEmpty); if (!uniSelector.AllowEmpty && AddCurrentLibraryRecord) { uniSelector.SpecialFields.Add(new SpecialField { Text = GetString("media.current"), Value = MediaLibraryInfoProvider.CURRENT_LIBRARY }); } else { uniSelector.SpecialFields = null; } if (forceReload) { uniSelector.Reload(true); } }
string GetImageUrlFromMediaLibrary(Guid imageGuid) { //get filenale string fileName = null; var libs = MediaLibraryInfoProvider.GetMediaLibraries().ToList(); foreach (var lib in libs) { var folder = lib.Children.FirstOrDefault(); foreach (var image in folder) { if (!string.IsNullOrEmpty(image.GetProperty("Guid").ToString())) { if (image.GetProperty("Guid").ToString() == imageGuid.ToString()) { fileName = image.GetProperty("FileName").ToString(); } } } } //get url string url = MediaFileURLProvider.GetMediaFileUrl(imageGuid, fileName); return(url); }
/// <summary> /// Returns a value indicating whether the specified media library root folder name is unique. /// </summary> /// <param name="folderName">A name of the media library root folder.</param> private bool IsFolderNameUnique(string folderName) { MediaLibraryInfo library = MediaLibraryInfoProvider.GetMediaLibraries() .TopN(1) .Column("LibraryID") .WhereEquals("LibraryFolder", folderName) .WhereEquals("LibrarySiteID", SiteContext.CurrentSiteID) .FirstOrDefault(); return((library == null) || (MediaLibraryID == library.LibraryID)); }
protected override IEnumerable <SelectListItem> GetItems() => MediaLibraryInfoProvider .GetMediaLibraries() .WhereEquals("LibrarySiteID", SiteContext.CurrentSiteID) .TypedResult .Items .Select(mediaLibraryInfo => new SelectListItem { Text = mediaLibraryInfo.LibraryDisplayName, Value = mediaLibraryInfo.LibraryID.ToString() });
/// <summary> /// Returns a value indicating whether the specified media library root folder name is unique. /// </summary> /// <param name="folderName">A name of the media library root folder.</param> private bool IsFolderNameUnique(string folderName) { DataSet ds = MediaLibraryInfoProvider.GetMediaLibraries("LibraryFolder = '" + folderName.Replace("'", "''") + "' AND LibrarySiteID = " + CMSContext.CurrentSiteID, null); if (!DataHelper.DataSourceIsEmpty(ds)) { int libraryId = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["LibraryID"], 0); if (MediaLibraryID != libraryId) { return(false); } } return(true); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData(bool forceReload) { string where = GetWhereConditionInternal(); uniSelector.IsLiveSite = IsLiveSite; uniSelector.AllowEmpty = false; uniSelector.AllowAll = false; uniSelector.ReturnColumnName = (UseLibraryNameForSelection ? "LibraryName" : "LibraryID"); uniSelector.WhereCondition = where; uniSelector.OnSelectionChanged += new EventHandler(uniSelector_OnSelectionChanged); uniSelector.DropDownSingleSelect.AutoPostBack = UseAutoPostBack; bool noLibrary = DataHelper.DataSourceIsEmpty(MediaLibraryInfoProvider.GetMediaLibraries(where, null, 1, "LibraryID")); // Insert '(none)' record if no library exists - only if '(none)' isn't inserted by default if (((noLibrary && NoneWhenEmpty) || AddNoneItemsRecord) && AddCurrentLibraryRecord) { uniSelector.SpecialFields = new string[2, 2] { { GetString("general.selectnone"), "" }, { GetString("media.current"), MediaLibraryInfoProvider.CURRENT_LIBRARY } }; } else { if ((noLibrary && NoneWhenEmpty) || AddNoneItemsRecord) { uniSelector.SpecialFields = new string[1, 2] { { GetString("general.selectnone"), "" } }; } else if (AddCurrentLibraryRecord) { uniSelector.SpecialFields = new string[1, 2] { { GetString("media.current"), MediaLibraryInfoProvider.CURRENT_LIBRARY } }; } else { uniSelector.SpecialFields = null; } } if (forceReload) { uniSelector.Reload(true); } }
public async Task SyncAllMediaLibraries(CancellationToken?cancellation) { SyncLog.Log("Synchronizing media libraries"); var mediaLibraries = MediaLibraryInfoProvider.GetMediaLibraries().OnSite(Settings.Sitename); var index = 0; foreach (var mediaLibrary in mediaLibraries) { if (cancellation?.IsCancellationRequested == true) { return; } index++; SyncLog.Log($"Media library {mediaLibrary.LibraryDisplayName} ({index}/{mediaLibraries.Count})"); await UpsertAllMediaFiles(mediaLibrary); } }
/// <summary> /// Returns a value indicating whether the specified media library root folder name is unique. /// </summary> /// <param name="folderName">A name of the media library root folder.</param> private bool IsFolderNameUnique(string folderName) { MediaLibraryInfo library = MediaLibraryInfoProvider.GetMediaLibraries("LibraryFolder = '" + SqlHelper.GetSafeQueryString(folderName) + "' AND LibrarySiteID = " + SiteContext.CurrentSiteID, null, 1, "LibraryID").FirstOrDefault(); return((library == null) || (MediaLibraryID == library.LibraryID)); }
private IEnumerable <KeyValuePair <string, string> > GetMetricData() { string stringData = null; IEnumerable <KeyValuePair <string, string> > tupleData = null; // Gather data for each row, return special message if data is null switch (MetricCodeName) { // Categories case MetricDataEnum.support_metrics: case MetricDataEnum.support_metrics_system: case MetricDataEnum.support_metrics_environment: case MetricDataEnum.support_metrics_counters: case MetricDataEnum.support_metrics_ecommerce: case MetricDataEnum.support_metrics_tasks: case MetricDataEnum.support_metrics_eventlog: return(null); #region System case MetricDataEnum.support_metrics_system_version: stringData = CMSVersion.GetVersion(true, true, true, true); break; case MetricDataEnum.support_metrics_system_appname: stringData = SettingsHelper.AppSettings["CMSApplicationName"]; break; case MetricDataEnum.support_metrics_system_instancename: stringData = SystemContext.InstanceName; break; case MetricDataEnum.support_metrics_system_physicalpath: stringData = SystemContext.WebApplicationPhysicalPath; break; case MetricDataEnum.support_metrics_system_apppath: stringData = SystemContext.ApplicationPath; break; case MetricDataEnum.support_metrics_system_uiculture: stringData = LocalizationContext.CurrentUICulture.CultureName; break; case MetricDataEnum.support_metrics_system_installtype: stringData = SystemContext.IsWebApplicationProject ? "Web App" : "Web site"; break; case MetricDataEnum.support_metrics_system_portaltemplatepage: stringData = URLHelper.PortalTemplatePage; break; case MetricDataEnum.support_metrics_system_timesinceapprestart: stringData = (DateTime.Now - CMSApplication.ApplicationStart).ToString(@"dd\:hh\:mm\:ss"); break; case MetricDataEnum.support_metrics_system_discoveredassemblies: tupleData = AssemblyDiscoveryHelper.GetAssemblies(true).Select((a, i) => GetKeyValuePair(i, a.FullName)); break; case MetricDataEnum.support_metrics_system_targetframework: HttpRuntimeSection httpRuntime = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; stringData = httpRuntime.TargetFramework; break; case MetricDataEnum.support_metrics_system_authmode: AuthenticationSection Authentication = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; stringData = Authentication?.Mode.ToString(); break; case MetricDataEnum.support_metrics_system_sessionmode: SessionStateSection SessionState = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection; stringData = SessionState?.Mode.ToString(); break; case MetricDataEnum.support_metrics_system_debugmode: CompilationSection Compilation = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection; stringData = Compilation?.Debug.ToString(); break; case MetricDataEnum.support_metrics_system_runallmanagedmodules: var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(URLHelper.GetPhysicalPath("~/Web.config")); stringData = xmlDoc.SelectSingleNode("/configuration/system.webServer/modules").Attributes["runAllManagedModulesForAllRequests"]?.Value; break; #endregion System #region Environment case MetricDataEnum.support_metrics_environment_trustlevel: AspNetHostingPermissionLevel trustLevel = AspNetHostingPermissionLevel.None; if (!SystemContext.IsWebSite) { trustLevel = AspNetHostingPermissionLevel.Unrestricted; } // Check the trust level by evaluation of levels foreach (AspNetHostingPermissionLevel permissionLevel in new[] { AspNetHostingPermissionLevel.Unrestricted, AspNetHostingPermissionLevel.High, AspNetHostingPermissionLevel.Medium, AspNetHostingPermissionLevel.Low, AspNetHostingPermissionLevel.Minimal }) { try { new AspNetHostingPermission(permissionLevel).Demand(); } catch (SecurityException) { continue; } trustLevel = permissionLevel; break; } stringData = trustLevel.ToString(); break; case MetricDataEnum.support_metrics_environment_iisversion: stringData = MetricServerVariables["SERVER_SOFTWARE"]; break; case MetricDataEnum.support_metrics_environment_https: stringData = MetricServerVariables["HTTPS"]; break; case MetricDataEnum.support_metrics_environment_windowsversion: using (RegistryKey versionKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion")) { var productName = versionKey?.GetValue("ProductName"); var currentBuild = versionKey?.GetValue("CurrentBuild"); var releaseId = versionKey?.GetValue("ReleaseId"); stringData = String.Format("{0}, build {1}, release {2}", productName.ToString(), currentBuild.ToString(), releaseId.ToString()); } break; case MetricDataEnum.support_metrics_environment_netversion: using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\")) { var keyValue = ndpKey?.GetValue("Release"); if (keyValue != null) { var releaseKey = (int)keyValue; if (releaseKey >= 461808) { stringData = "4.7.2 or later"; } else if (releaseKey >= 461308) { stringData = "4.7.1"; } else if (releaseKey >= 460798) { stringData = "4.7"; } else if (releaseKey >= 394802) { stringData = "4.6.2"; } else if (releaseKey >= 394254) { stringData = "4.6.1"; } else if (releaseKey >= 393295) { stringData = "4.6"; } else if (releaseKey >= 379893) { stringData = "4.5.2"; } else if (releaseKey >= 378675) { stringData = "4.5.1"; } else if (releaseKey >= 378389) { stringData = "4.5"; } } } break; case MetricDataEnum.support_metrics_environment_sqlserverversion: var dtm = new TableManager(null); stringData = dtm.DatabaseServerVersion; break; case MetricDataEnum.support_metrics_environment_azure: var azureStats = new Dictionary <string, string>(4) { { "Is a Cloud Service", (SettingsHelper.AppSettings["CMSAzureProject"] == "true").ToString("false") }, { "Is file system on Azure", (SettingsHelper.AppSettings["CMSExternalStorageName"] == "azure").ToString("false") }, { "Azure storage account", SettingsHelper.AppSettings["CMSAzureAccountName"] ?? String.Empty }, { "Azure CDN endpoint", SettingsHelper.AppSettings["CMSAzureCDNEndpoint"] ?? String.Empty } }; tupleData = azureStats.Select(s => GetKeyValuePair(s.Key, s.Value)); break; case MetricDataEnum.support_metrics_environment_amazon: var amazonStats = new Dictionary <string, string>(3) { { "Is file system on Amazon", (SettingsHelper.AppSettings["CMSExternalStorageName"] == "amazon").ToString() }, { "Amazon bucket name", SettingsHelper.AppSettings["CMSAmazonBucketName"] ?? String.Empty }, { "Amazon public access", SettingsHelper.AppSettings["CMSAmazonPublicAccess"] ?? String.Empty }, }; tupleData = amazonStats.Select(s => GetKeyValuePair(s.Key, s.Value)); break; case MetricDataEnum.support_metrics_environment_services: tupleData = ServiceManager.GetServices().Select(s => GetKeyValuePair(s.ServiceName, s.Status)); break; #endregion Environment #region Counters case MetricDataEnum.support_metrics_counters_webfarmservers: stringData = CoreServices.WebFarm.GetEnabledServerNames().Count().ToString(); break; case MetricDataEnum.support_metrics_counters_stagingservers: stringData = ServerInfoProvider.GetServers().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_pagemostchildren: CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider(); var pageWithMostChildren = tree.SelectNodes().OnCurrentSite().Published() .ToDictionary(n => n, n => n.Children.Count) .Aggregate((l, r) => l.Value > r.Value ? l : r); tupleData = new[] { GetKeyValuePair(URLHelper.GetAbsoluteUrl("~" + pageWithMostChildren.Key.NodeAliasPath), pageWithMostChildren.Value) }; break; case MetricDataEnum.support_metrics_counters_modules: stringData = ResourceInfoProvider.GetResources().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_medialibraries: stringData = MediaLibraryInfoProvider.GetMediaLibraries().WhereNull("LibraryGroupID").GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_activities: stringData = ActivityInfoProvider.GetActivities().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_contacts: stringData = ContactInfoProvider.GetContacts().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_contactgroups: stringData = ContactGroupInfoProvider.GetContactGroups().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_omrules: stringData = RuleInfoProvider.GetRules().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_products: stringData = SKUInfoProvider.GetSKUs(SiteContext.CurrentSiteID).WhereNull("SKUOptionCategoryID").GetCount().ToString(); break; #endregion Counters #region Tasks case MetricDataEnum.support_metrics_tasks_webfarm: stringData = WebFarmTaskInfoProvider.GetWebFarmTasks() .WhereLessThan("TaskCreated", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_staging: stringData = StagingTaskInfoProvider.GetTasks() .WhereLessThan("TaskTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_integration: stringData = IntegrationTaskInfoProvider.GetIntegrationTasks() .WhereLessThan("TaskTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_scheduled: stringData = TaskInfoProvider.GetTasks() .WhereTrue("TaskDeleteAfterLastRun") .WhereLessThan("TaskNextRunTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_search: stringData = SearchTaskInfoProvider.GetSearchTasks() .WhereLessThan("SearchTaskCreated", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_email: stringData = EmailInfoProvider.GetEmailCount("EmailStatus = 1 AND EmailLastSendResult IS NOT NULL").ToString(); break; #endregion Tasks #region Event log case MetricDataEnum.support_metrics_eventlog_macroerrors: var macroErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "MacroResolver") .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = macroErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_stagingerrors: var stagingErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "staging") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = stagingErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_searcherrors: var searchErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "search") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = searchErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_contenterrors: var contentErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "content") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = contentErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_exceptions: var exceptions = EventLogProvider.GetEvents() .WhereEquals("EventCode", "exception") .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = exceptions.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_upgrade: EventLogInfo upgrade = EventLogProvider.GetEvents().WhereLike("Source", "upgrade%").FirstOrDefault(); var version = upgrade?.Source.Split(' ')[2]; if (!String.IsNullOrEmpty(version)) { var parameters = new QueryDataParameters { { "@versionnumber", version } }; var events = ConnectionHelper.ExecuteQuery("SupportHelper.CustomMetric.checkupgrade", parameters); tupleData = (from DataRow row in events.Tables[0]?.Rows select row) .Select(r => new EventLogInfo(r)).Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); } break; #endregion Event log } if (tupleData?.Count() > 0) { return(tupleData); } if (stringData != null) { return(new[] { GetKeyValuePair(0, stringData) }); } return(new[] { GetKeyValuePair(0, ResHelper.GetStringFormat("support.metrics.invalid", MetricDisplayName, MetricCodeName)) }); }
/// <summary> /// Validates input data and returns true if input is valid. /// </summary> /// <param name="codeName">Code name</param> protected bool ValidateForm(string codeName) { txtDisplayName.Text = txtDisplayName.Text.Trim(); txtDescription.Text = txtDescription.Text.Trim(); txtFolder.Text = URLHelper.GetSafeFileName(txtFolder.Text.Trim(), CMSContext.CurrentSiteName); string result = new Validator().NotEmpty(txtDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtDisplayName.Text, rfvCodeName.ErrorMessage) .IsCodeName(codeName, GetString("general.invalidcodename")).Result; // Folder name is enabled check it if ((String.IsNullOrEmpty(result)) && (this.txtFolder.Enabled)) { result = new Validator().NotEmpty(txtFolder.Text, rfvFolder.ErrorMessage) .IsFolderName(txtFolder.Text, GetString("media.invalidfoldername")).Result; if (String.IsNullOrEmpty(result)) { // Check special folder names if ((this.txtFolder.Text == ".") || (this.txtFolder.Text == "..")) { result = GetString("media.folder.foldernameerror"); } } } // Check for duplicit records within current site MediaLibraryInfo mli = null; if (this.MediaLibraryGroupID > 0) { mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(codeName, CMSContext.CurrentSiteID, this.MediaLibraryGroupID); } else { mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(codeName, CMSContext.CurrentSiteName); } if ((mli != null) && (mli.LibraryID != this.MediaLibraryID)) { result = GetString("general.codenameexists"); } // Check for duplicit library root folder DataSet ds = MediaLibraryInfoProvider.GetMediaLibraries("LibraryFolder = '" + txtFolder.Text.Trim().Replace("'", "''") + "' AND LibrarySiteID = " + CMSContext.CurrentSiteID, null); if (!DataHelper.DataSourceIsEmpty(ds)) { int libraryId = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["LibraryID"], 0); if (this.MediaLibraryID != libraryId) { result = GetString("media.folderexists"); } } // If meta files should be stored in filesystem for given site if ((ucMetaFile.PostedFile != null) && MetaFileInfoProvider.StoreFilesInFileSystem(CMSContext.CurrentSiteName)) { // Get image path for site string path = MetaFileInfoProvider.GetFilesFolderPath(CMSContext.CurrentSiteName); // Ensure meta files folder if (!Directory.Exists(path)) { DirectoryHelper.EnsureDiskPath(path, SettingsKeyProvider.WebApplicationPhysicalPath); } // Check permission for image folder if (!DirectoryHelper.CheckPermissions(path)) { result = String.Format(GetString("media.AccessDeniedToPath"), path); } } if (result != String.Empty) { lblError.Visible = true; lblError.Text = HTMLHelper.HTMLEncode(result); return(false); } return(true); }