/// <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);
    }
示例#2
0
    /// <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);
    }