public static Dictionary <string, IEnumerable <StrandsWebTemplateData> > LoadAllWebTemplates()
    {
        try
        {
            StrandsApiClient strandsApiClient = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));

            var groups = from webTemplate in strandsApiClient.GetAvailableWebTemplates()
                         group webTemplate by webTemplate.Type
                         into webTemplateGroups
                         orderby webTemplateGroups.Key
                         select webTemplateGroups;

            return(groups.ToDictionary(
                       g => g.Key.ToStringRepresentation(),
                       g => g.OrderBy(GetTemplateOrder).Select(EncodeWebTemplate)));
        }
        catch (StrandsException ex)
        {
            EventLogProvider.LogException("Strands Recommender", "LOADALLWEBTEMPLATES", ex);

            // Since it is not possible to send exception with custom properties via AJAX when request failed,
            // throw regular exception and provide nice UI message as its base message
            throw new Exception(ex.UIMessage, ex);
        }
    }
    public static Dictionary<string, IEnumerable<StrandsWebTemplateData>> LoadAllWebTemplates()
    {
        try
        {
            StrandsApiClient strandsApiClient = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));

            var groups = from webTemplate in strandsApiClient.GetAvailableWebTemplates()
                         group webTemplate by webTemplate.Type
                         into webTemplateGroups
                         orderby webTemplateGroups.Key
                         select webTemplateGroups;

            return groups.ToDictionary(
                g => g.Key.ToStringRepresentation(),
                g => g.OrderBy(GetTemplateOrder).Select(EncodeWebTemplate));
        }
        catch (StrandsException ex)
        {
            EventLogProvider.LogException("Strands Recommender", "LOADALLWEBTEMPLATES", ex);

            // Since it is not possible to send exception with custom properties via AJAX when request failed,
            // throw regular exception and provide nice UI message as its base message
            throw new Exception(ex.UIMessage, ex);
        }
    }
    /// <summary>
    /// Loads names of all available email templates from Strands API.
    /// </summary>
    /// <returns>Collection containing names of all available email templates</returns>
    private List<string> LoadEmailTemplateNames()
    {
        var provider = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));

        try
        {
            // Return collection if everything is alright
            return provider.GetAvailableEmailTemplates().Select(HTMLHelper.HTMLEncode).ToList();
        }
        catch (StrandsException ex)
        {
            ProcessErrorMessage(ex, ex.UIMessage ?? ex.Message);
            return null;
        }
        catch (Exception ex)
        {
            // Usually an exception thrown when there is a problem when communicating with Strands
            ProcessErrorMessage(ex, GetString("strands.exception"));
            return null;
        }
    }
示例#4
0
    /// <summary>
    /// Loads names of all available email templates from Strands API.
    /// </summary>
    /// <returns>Collection containing names of all available email templates</returns>
    private List <string> LoadEmailTemplateNames()
    {
        var provider = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));

        try
        {
            // Return collection if everything is alright
            return(provider.GetAvailableEmailTemplates().Select(HTMLHelper.HTMLEncode).ToList());
        }
        catch (StrandsException ex)
        {
            ProcessErrorMessage(ex, ex.UIMessage ?? ex.Message);
            return(null);
        }
        catch (Exception ex)
        {
            // Usually an exception thrown when there is a problem when communicating with Strands
            ProcessErrorMessage(ex, GetString("strands.exception"));
            return(null);
        }
    }
    public static string LoadSpecificEmailTemplate(string name)
    {
        try
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var    provider = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));
            string template = provider.GetEmailTemplate(name);

            template = AddTitleParameter(template);

            return(template);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Strands Recommender", "LOADSPECIFISEMAILTEMPLATE", ex);
            throw;
        }
    }
    public static string LoadSpecificEmailTemplate(string name)
    {
        try
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var provider = new StrandsApiClient(StrandsSettings.GetApiID(SiteContext.CurrentSiteName));
            string template = provider.GetEmailTemplate(name);

            template = AddTitleParameter(template);

            return template;
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Strands Recommender", "LOADSPECIFISEMAILTEMPLATE", ex);
            throw;
        }
    }