Trikks

The digital adventures of Eric Herlitz

The undocumented MediaSettings class from Microsoft.Rtc

Posted by trikks on December 16, 2012

This is a media settings object used by Lync servers among others to handle settings for real time clients (rtc).

Namespace

Microsoft.Rtc.Management.WritableConfig.Settings.Media

The MediaSettings object

using Microsoft.Rtc.Management.WritableConfig;
using System;
using System.Xml.Linq;
 
namespace Microsoft.Rtc.Management.WritableConfig.Settings.Media
{
    public sealed class MediaSettings : WritableConfigDocument, ICloneable
    {
        public MediaSettings();
 
        public bool EnableQoS { get; set; }
        public bool EnableSiren { get; set; }
        public EncryptionLevel EncryptionLevel { get; set; }
        public MaxVideoRateAllowed MaxVideoRateAllowed { get; set; }
        public static Microsoft.Rtc.Management.Core.SchemaId StaticSchemaId { get; }
 
        public static MediaSettings Create(XElement element);
    }
}

EncryptionLevel property class

using System;
 
namespace Microsoft.Rtc.Management.WritableConfig.Settings.Media
{
    public enum EncryptionLevel
    {
        SupportEncryption =  0,
        RequireEncryption = 1,
        DoNotSupportEncryption = 2,
    }
}

MaxVideoRateAllowed property class

using System;
 
namespace Microsoft.Rtc.Management.WritableConfig.Settings.Media
{
    public enum MaxVideoRateAllowed
    {
        CIF250K =  0,
        VGA600K = 1,
        Hd720p15M = 2,
    }
}

Posted in C#, Lync | Tagged: , | Leave a Comment »

Get a typed object from the uComponents Url Picker

Posted by trikks on October 12, 2012

This snippet is based on Umbraco 4.9 and uComponents 5 but should work almost any verison.

uComponents for Umbraco is possibly one of the best extensions out there for any CMS and the Url Picker is one of my favorites. The data returned to the

As the documentation states (UrlPicker documentation) you get the data as xml or json.

<url-picker mode="Content">
        <new-window>False</new-window>
        <node-id>1061</node-id>
        <url>/homeorawaytest4.aspx</url>
        <link-title>Home Or Away Quiz</link-title>
</url-picker>

Snippet

I created an object that will help those of who uses c# or vb.net. Use it like this

Node CurrentNode = Node.GetCurrent();
var buyOnlineProperty = CurrentNode.GetProperty("buyOnline");
var buyOnline = new Trikks.Umbraco.UrlPicker(buyOnlineProperty);

And include this object

using System;
using System.Xml;
using umbraco.interfaces;

namespace Trikks.Umbraco
{
    public class UrlPicker
    {
        public string Url { get; set; }
        public int NodeId { get; set; }
        public string LinkTitle { get; set; }
        public bool NewWindow { get; set; }

        public UrlPicker() { }

        public UrlPicker(object property)
        {
            string propertyValue = string.Empty;

            // If IProperty
            if (property is IProperty)
            {
                propertyValue = ((IProperty) property).Value;
            }

            // If string
            if (property is string)
            {
                propertyValue = property.ToString();
            }

            if (!string.IsNullOrEmpty(propertyValue))
            {
                // Get url from xml
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(propertyValue);

                var url = doc.SelectSingleNode("//url");
                if (url != null)
                    Url = url.InnerText;

                var newWindow = doc.SelectSingleNode("//new-window");
                if (newWindow != null)
                    NewWindow = Convert.ToBoolean(newWindow.InnerText);

                var nodeId = doc.SelectSingleNode("//node-id");
                if (nodeId != null && !string.IsNullOrEmpty(nodeId.InnerText))
                    NodeId = Convert.ToInt32(nodeId.InnerText);

                var linkTitle = doc.SelectSingleNode("//link-title");
                if (linkTitle != null)
                    LinkTitle = linkTitle.InnerText;
            }

        }
    }
}

Some results

Using static url

Using Content node picker

Posted in uComponents, Umbraco | 1 Comment »

Problems with uComponents Sub Tabs and getting error on GUID 2c787731-cd81-48cd-a94f-4930185bdb58?

Posted by trikks on October 11, 2012

Using uComponents in Umbraco can sometimes misbehave, this error was given to me in Umbraco 4.9 using uComponents 5.0

The full error is as follows

Could not find a IDataType control matching DataEditorId 2c787731-cd81-48cd-a94f-4930185bdb58 in the controls collection. To correct this, check the data type definition in the developer section or ensure that the package/control is installed correctly.

This means you are missing a data type from uComponents, in this case the Sub Tabs. This is since Sub Tabs wasn’t implemented in 5.0. I use it anyway but that means that I have to do the build myself and put the binaries into the bin folder of umbraco.

Problem solved!

Posted in Umbraco | Leave a Comment »

Clean up your Umbraco Templates and Document Types

Posted by trikks on October 6, 2012

I run a couple of Umbraco sites and as usual after a couple of years some sites tend to become a bit dirty. The cleaning could be 100 % automated but thats to risky business for me but having some visual help in Template and Document Type usage was welcome. So by the help of uComponents uQuery I made some outputs.

Where you put the code is up to you, I did put it in an ascx file and run it as a macro.

Usings

using System;
using System.Collections.Generic;
using System.Linq;
using uComponents.Core;
using umbraco.cms.businesslogic.template;
using umbraco.cms.businesslogic.web;
using umbraco.interfaces;
using umbraco.NodeFactory;

The Code

/// <summary>
/// Invoke this method...
/// </summary>
private void WhatsUp()
{
    // Start at root level (-1) and populate the AllNodes property
    GetAllNodesAsFlatList(new Node(-1));
    PrintResultInfo("Templates", GetTemplateResult());
    PrintResultInfo("Document Types", GetDocTypeInfo());
}
 
/// <summary>
/// Return alias and occurences of all templates
/// </summary>
/// <returns></returns>
private List<Result> GetTemplateResult()
{
    return
        Template.GetAllAsList().Select(
            template =>
            new Result {Alias = template.Alias, Count = AllNodes.Count(x => x.template.Equals(template.Id))}).
            ToList();
}
 
/// <summary>
/// Return alias and occurences of all document types
/// </summary>
/// <returns></returns>
private List<Result> GetDocTypeInfo()
{
    return
        DocumentType.GetAllAsList().Select(
            documentType =>
            new Result() { Count = GetNodesByNodeType(documentType.Id), Alias = documentType.Alias }).ToList();
}
 
private int GetNodesByNodeType(int documentType)
{
    var nodes = uQuery.GetNodesByType(documentType);
    if (nodes == null)
        return 0;
 
    return nodes.Count;
}
 
/// <summary>
/// Print the result info
/// </summary>
/// <param name="header"></param>
/// <param name="results"></param>
private void PrintResultInfo(string header, List<Result> results)
{
    Response.Write(string.Format("<h1>{0}</h1>", header));
    Response.Write("<h2>Empty</h2>");
    foreach (Result result in results.Where(x => x.Count.Equals(0)))
    {
        Response.Write(string.Format("{0} [{1}]<br />", result.Alias, result.Count));
    }
 
    Response.Write("<h2>Used</h2>");
    foreach (Result result in results.Where(x => !x.Count.Equals(0)))
    {
        Response.Write(string.Format("{0} [{1}]<br />", result.Alias, result.Count));
    }
}
 
/// <summary>
/// Storage for GetAllNodesAsFlatList
/// </summary>
private readonly List<INode> AllNodes = new List<INode>();
 
/// <summary>
/// Get all child nodes from a certain node
/// </summary>
/// <param name="startNode"></param>
private void GetAllNodesAsFlatList(INode startNode)
{
    AllNodes.Add(startNode);
 
    // Traverse the above throug the node
    List<INode> children = startNode.ChildrenAsList;
    if (!children.Any())
        return;
 
    foreach (INode child in children)
    {
        GetAllNodesAsFlatList(child);
    }
}
 
/// <summary>
/// Result object
/// </summary>
private class Result
{
    public int Count { get; set; }
    public string Alias { get; set; }
}

The result

I did truncate the result to max 5 posts, the actual result was hundreds of lines :)
The result shows empty and used as groups with the alias and number of nodes that are using the Document Type or Template.

Thats it!
Cheers

Posted in Uncategorized | Leave a Comment »

Howto fix the ‘/GetSecondsBeforeUserLogout’ error in Umbraco

Posted by trikks on October 1, 2012

In some Umbraco installations there are very frequent calls to the service

/umbraco/webservices/legacyajaxcalls.asmx/GetSecondsBeforeUserLogout

This may leave errors like this

Request format is unrecognized for URL unexpectedly ending in '/GetSecondsBeforeUserLogout'.

Here is how to fix it

Insert this in the <system.web> section of your web.config

<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>

A bit more detailed

<configuration>
    <system.web>
        <webServices>
            <protocols>
                <add name="HttpGet"/>
                <add name="HttpPost"/>
            </protocols>
        </webServices>
    </system.web>
</configuration>

There, it works

You may get other errors from here on, but the webservice(s) should at least be accessible

Cheers!

Posted in Umbraco | Tagged: , | Leave a Comment »

Deleting a Contact (Customer) from Mediachase / EPiCommerce programmatically

Posted by trikks on September 30, 2012

This is a somewhat undocumented function but if you are familiar with the class BusinessManager in the Mediachase.BusinessFoundation.Data.Business namespace things become quite easy.

To demonstrate this I created a customer called Test Testson

Snippet

To remove this customer contact programmatically with c# the following code is required

// Fetch the user
Mediachase.Commerce.Customers.CustomerContext customerContext = new Mediachase.Commerce.Customers.CustomerContext();
Mediachase.Commerce.Customers.CustomerContact testTestson = customerContext.GetContactById(new Guid("1c8279d8-85bd-4063-a018-a627f98c99cb"));

// Delete
Mediachase.BusinessFoundation.Data.Business.BusinessManager.Delete(testTestson);

That’s it.

Posted in EPiServer, EpiServer Commerce, Mediachase | Tagged: , , , | Leave a Comment »

How to handle the error “Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list”

Posted by trikks on September 8, 2012

I did port some of my development environments to a new virtual machine with a brand new 2008 R2 Server and a Visual Studio 2012. Everything seemed fine until I tried to load one of my Umbraco labs.

The error “Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list” showed up.

This is quite simple to resolve for Umbraco,

  • ensure your application pool runs in .net 4 classic mode in IIS
  • run the aspnet_regiis.exe -i command, to run the aspnet_regiis command
    • navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 (or whatever .net 4 framework version you have)
    • type aspnet_regiis.exe -i and press enter

Thats it

 

 

Posted in IIS, Umbraco | Tagged: , , | Leave a Comment »

EPiServer Commerce error message “Failed to check the license.”

Posted by trikks on August 17, 2012

Usually I develop most of my EPiServer Commerce stuff in console applications and then deploy them in a proper .net manner. Occasionally this error shows up when invoking a method that has license check involved.

License section

Verify that everything in this section in the app (or web) config is correct

<mediachase.license>
    <licenseProvider defaultProvider="sqlProvider" allowUpload="True" licenseServerUri="http://licensing.mediachase.com/2.0/License.aspx">
        <providers>
            <add name="fileProvider" type="Mediachase.Licensing.FileStorageProvider, Mediachase.Licensing" storagePath="C:\EPiServer\eCommerceFramework\5.2\EPiServerCommerceManager\Licensing"/>
            <add name="sqlProvider" type="Mediachase.Licensing.SqlStorageProvider, Mediachase.Licensing" connectionStringName="EcfSqlConnection" tableName="" createTable="True"/>
        </providers>
    </licenseProvider>
</mediachase.license>

and this section

These settings may not even be present in your app/web.config. Please ensure that they are and setup according to your preferences.

<appSettings>
    <add key="BaseCatalog" value="Everything"/>
    <add key="BaseAddress" value="http://localhost:17000"/>
</appSettings>

Posted in EpiServer Commerce, Mediachase | Leave a Comment »

Programmatically register a display template in EPiServer Commerce [Snippet]

Posted by trikks on August 15, 2012

This is quite simple and follow the general behind the scenes pattern Mediachase use.

Expected result

To programmatically register template references in the commerce manager

Code

// Get all templates
Mediachase.Cms.Dto.TemplateDto templateDto = Mediachase.Cms.Managers.DictionaryManager.GetTemplateDto();

string newTemplateName = "PromotionTemplate";
string newTemplateFriendlyName = "Promotion Template";

// Check if the template exist
if (!templateDto.main_Templates.Any(x => x.Name.Equals(newTemplateName, StringComparison.InvariantCultureIgnoreCase)))
{
    // Create empty template dto
    templateDto = new Mediachase.Cms.Dto.TemplateDto();
    Mediachase.Cms.Dto.TemplateDto.main_TemplatesRow row = null;

    row = templateDto.main_Templates.Newmain_TemplatesRow();
    row.ApplicationId = Mediachase.Cms.CmsConfiguration.Instance.ApplicationId;

    row.Name = newTemplateName;
    row.FriendlyName = newTemplateFriendlyName;
    row.Path = string.Format("~/Templates/DisplayTemplates/{0}.ascx", newTemplateName);
    row.TemplateType = "Entry";
    row.LanguageCode = "en-us";

    if (row.RowState == DataRowState.Detached)
        templateDto.main_Templates.Rows.Add(row);

    // Save any changes
    if (templateDto.HasChanges())
        Mediachase.Cms.Managers.DictionaryManager.SaveTemplateDto(templateDto);
}

Posted in EpiServer Commerce, Mediachase | Tagged: , | Leave a Comment »

Exchange error of death, The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer.

Posted by trikks on August 13, 2012

The full error looks something like this

The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid . For more information, seethe aboout_remote_troubleshooting Help topic . It was running the command ‘Discover-ExchangeServer -UserWIA $true -SuppressError $true -CurrentVersion ‘version 14.2 (Build 247.5)”

This error seem to have a number of sources, this blog will describe how I solved it.

The error you see depends on the fact that a service isn’t running and when checking the Event Viewer I found this error

The Microsoft Exchange Information Store service terminated with service-specific error %%-2147221213.

This error depend on the fact that there is a key missing in your Windows Registry

  1. Open regedit.exe
  2. Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\
  3. Create a key and name it “Setup”, if the key already exist skip this step
  4. Create a new string value inside the “Setup” key and name it “Services”
  5. Modify the value in “Services” and set the path to your Exchange directory, usually C:\Program Files\Microsoft\Exchange Server\V14
  6. Close and restart your computer

Other solutions

This blog post, http://blogs.technet.com/b/exchange/archive/2010/02/04/3409289.aspx, sais

  1. The ExchangeInstallPath variable may be missing. To check this, go to the System Properties, Environment variables, and look under the System variables. You should see a variable ofExchangeInstallPath with a value pointing to C:\Program Files\Microsoft\Exchange Server\V14\.
  2. The Path of the Powershell virtual directory has been modified. The PowerShell virtual directory must point to the \Program Files\Microsoft\Exchange Server\v14\ClientAccess\PowerShell directory or you will encounter problems.

This blog post, http://social.technet.microsoft.com/Forums/en-US/exchangesoftwareupdate/thread/d8f7b284-650c-471f-807e-aaddb254474f/, suggests this

  1. Please check the “Log On” tab of the information store service, only “Local System account” should be selected
  2. Please compare the time between the problematic server and the DC. If the problematic server is a virtual machine, please also check the time on the host machine

 

Posted in Exchange | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.