/// <summary> /// Updates uni selector where condition based on current properties values. /// </summary> public void UpdateWhereCondition() { // Running sites where condition if (OnlyRunningSites) { // Running status where condition string where = "SiteStatus = '" + SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running) + "'"; // Combine where conditions uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(uniSelector.WhereCondition, where); } // Only sites assigned to user if (this.UserId != 0) { // User's site where condition string where = "SiteID IN (SELECT SiteID FROM CMS_UserSite WHERE UserID = " + this.UserId + ")"; // Combine where conditions uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(uniSelector.WhereCondition, where); } }
/// <summary> /// External data binding handler. /// </summary> private object Control_OnExternalDataBound(object sender, string sourceName, object parameter) { bool running; switch (sourceName.ToLowerCSafe()) { case "openlivesite": // Open live site action running = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["sitestatus"], "").ToUpperCSafe() == SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running); if (!running) { var button = ((CMSGridActionButton)sender); button.Enabled = false; } break; case "sitestatus": // Colorize site status { DataRowView drv = (DataRowView)parameter; running = SiteInfoProvider.SiteStatusToEnum(ValidationHelper.GetString(drv["SiteStatus"], "")) == SiteStatusEnum.Running; bool offline = ValidationHelper.GetBoolean(drv["SiteIsOffline"], false); if (running) { if (offline) { return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Offline"), "SiteStatusOffline")); } else { return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Running"), "SiteStatusRunning")); } } else { return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Stopped"), "SiteStatusStopped")); } } case "culture": // Culture with flag { DataRowView drv = (DataRowView)parameter; string siteName = ValidationHelper.GetString(drv["SiteName"], ""); string cultureCode = CultureHelper.GetDefaultCultureCode(siteName); return(UniGridFunctions.DocumentCultureFlag(cultureCode, null, Control.Page)); } case "start": // start action running = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["sitestatus"], "").ToUpperCSafe() == SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running); ((CMSGridActionButton)sender).Visible = !running; break; case "stop": // stop action running = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["sitestatus"], "").ToUpperCSafe() == SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running); ((CMSGridActionButton)sender).Visible = running; break; } return(parameter); }
/// <summary> /// External data binding handler. /// </summary> object UniGridSites_OnExternalDataBound(object sender, string sourceName, object parameter) { bool running = true; switch (sourceName.ToLower()) { case "editcontent": // Edit content action running = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["sitestatus"], "").ToUpper() == SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running); if (!running) { ImageButton button = ((ImageButton)sender); button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Editcontentdisabled.png"); button.Enabled = false; } break; case "openlivesite": // Open live site action running = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["sitestatus"], "").ToUpper() == SiteInfoProvider.SiteStatusToString(SiteStatusEnum.Running); if (!running) { ImageButton button = ((ImageButton)sender); button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Livesitedisabled.png"); button.Enabled = false; } break; case "sitestatus": // Status { DataRowView drv = (DataRowView)parameter; running = SiteInfoProvider.SiteStatusToEnum(ValidationHelper.GetString(drv["SiteStatus"], "")) == SiteStatusEnum.Running; bool offline = ValidationHelper.GetBoolean(drv["SiteIsOffline"], false); if (running) { if (offline) { return(UniGridFunctions.SpanMsg(GetString("Site_List.Offline"), "SiteStatusOffline")); } else { return(UniGridFunctions.SpanMsg(GetString("Site_List.Running"), "SiteStatusRunning")); } } else { return(UniGridFunctions.SpanMsg(GetString("Site_List.Stopped"), "SiteStatusStopped")); } } case "culture": // Culture { DataRowView drv = (DataRowView)parameter; string siteName = ValidationHelper.GetString(drv["SiteName"], ""); string cultureCode = CultureHelper.GetDefaultCulture(siteName); return(UniGridFunctions.DocumentCultureFlag(cultureCode, null, Page)); } } return(parameter); }