Our session don on the Swiss Techdays on November 6th is now available on Channel 9 website.
You can find the video of the session here, and the slides here.
happy coding!
In quite some projects, I had to localize some SharePoint 2010 pages or WebPart resources, which custom code can handle pretty well.
But when it comes to localize titles of WebPart, SharePoint does actually not provide anything but a single string for any language.
I then built an abstract class named LocalizableWebPart, which with a few helper classes helps you set the WebPart title by editing it and changing the current site display language.
Here is the content of this class so that you can have a look:
public abstract class LocalizableTitleWebPart : WebPart
{
[WebPartStorage(Storage = Storage.Shared)]
public string LocalizedTitle { get; set; }
private LangageContainer langContainer = null;
protected string GetLocalizedProperty(LangageContainer container, string content)
{
if (container != null)
{
return container.GetOrInsertLanguage().EncodedLanguageContent;
}
else
{
container = LocalizationHelper.GetLanguagesContent(content);
return container.GetOrInsertLanguage().EncodedLanguageContent;
}
}
protected string SetLocalizedProperty(LangageContainer container, string content, string value)
{
container = LocalizationHelper.GetLanguagesContent(content);
var lang = container.GetOrInsertLanguage();
if (this.Page != null && this.Page.IsPostBack)
{
container.UpdateLanguage(lang.LanguageCode, value);
return LangageContainer.Serialize(container);
}
return content;
}
public override string Title
{
get
{
return GetLocalizedProperty(langContainer, this.LocalizedTitle);
}
set
{
this.LocalizedTitle = SetLocalizedProperty(langContainer, this.LocalizedTitle, value);
}
}
}
What you can see in the code above is:
You can find the code of this class and all required classes as a GitHub repo here:
https://github.com/JaYmZ666/localizableTitleWebPart
Happy coding!
Hi dear visitor,
This year Microsoft Techdays will be held at Conrès Beaulieu in Lausanne, on the 6th and 7th of November.
Yves Peneveyre and myself will be presenting a topic around SharePoint 2013 (in French
)
As I will be available between sessions on the CTP booth, please feel free to come and visit us, and ask questions about our work and Windows Azure for example
See you there!
I have been facing a very interesting search issue in SharePoint, which could get pretty annoying to figure out.
I had a nice SharePoint Search looking into my User Profiles, but for some reasons when searching for partial names, I was sometimes getting results or no results at all…
I was trying to build a custom Timer Job hosted at Farm level, which looks like this from a Feature activation standpoint:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
foreach (var s in SPFarm.Local.Services)
{
if (s.DisplayName.Contains("WSS_Administration"))
{
DeleteJob(s.JobDefinitions);
CustomTimerJob job1 = new CustomTimerJob(s);
SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 1;
s.JobDefinitions.Add(job1);
job1.Schedule = schedule;
job1.Update(true);
}
}
}
When trying to deploy, here is the error I was getting:
“Cannot change a recurring schedule to a one-time schedule (and vice versa) for a job definition.”
During last week, I have been working around building and using custom Service Applications in SharePoint 2010.
So, what exactly is a Service Application??
For those of you you missed my Techdays presentations, Microsoft Switzerland just put them on Channel 9 a few hours ago.
Here are the links to see them :
These videos are also visible on my blog in the “More” part of this post, enjoy!
For my last session in Techdays in Geneva this year, I proposed a session on the integration between SharePoint 2010 and Azure.
I am giving away today a custom column for SharePoint 2010 to upload download content to Azure Blob Storage !
What this thing does :
Here is the link to the solution (all source code available) : http://sp2010azurefield.codeplex.com/
Happy download!
If you want to build some WCF service to be used in SharePoitn 2010 context, you came to right place
Here are steps to follow in order to create such services:
In Visual Studio 2010 create a blank SharePoint 2010 project, then add a “SharePoint mapped folder” to the SharePoint ISAPI folder:
Add these following assembly references to your project:
Create a specific folder in ISAPI folder that will hold your WCF “.svc” service files (for example, mine is “MyWebservice”).
Create you class file, that will hold your service interface and service implementation (I added 2 just to show creating a SOAP etand a REST service):
The important part in the file here are attributes used on service implementations:
Back in our ”ISAPI/MyWebservice” folder, let’s create 2 text files and then rename thier extensions as ”.svc”:
Edit those files and place the following code in it:
<%@ServiceHost Language=”C#” Factory=”Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Service=”SP2010WCFService.MyWebservice.MyWebserviceSOAP, $SharePoint.Project.AssemblyFullName$”%>Once you choose your factory , you should have see that our host definition contains a specific tag, $SharePoint.Project.AssemblyFullName$ ?
This annotation coming out from SharePoint “Replaceable parameters” will replace corresponding values to SharePoint context values (here our compiled assembly details) ; for this to work when we’ll compile our stuff, edit the .Csproj file of your solution to add this element ”<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions>” in relevant “<PropertyGroup>” element so that Visual Studio will also replace parameters in SVC files.
Now just need to compile and have fun
PS: Here is the SP2010WCFServices solution shown in my example.
When developing InfoPath forms on an existing website, we could think how reimporting those customizations would work on a re-deployed package…
Answer is: YES !
Stil there are a few rules to follow in order to make it work fine:
In hat case the export/import of the Template will work like a charm.
So here is a walkthrough for importing your saved site template:
First, once template is saved, open Visual Studio and select “Import SharePoint Solution Package”, and then the package you want to import :
Then, select important items (in our case the lists), unselect all with Crtl+A then Space then select revelant ones; Visual Studio will figure that out for you on next screen:
Once imported, we can see import done in Solution Explorer is using Modules to deploy XSN list templates.
Finally, we can clean up a bit default item names and add other stuff in it (Webpart…).
Happy coding