Pimp Your IDE: Visual Studio 2010 Themes and Skins

by Ради Атанасов 16. May 2010 13:35

For those who know me, I have always been a HUGE fan of customizing my development environment. Well now with Visual Studio 2010 we can do more than what we could do with VS 2008… I’ve always known that, but now I found the right tool to help me do it.

Visual Studio Color Theme Editor lets you change the colors of VS 2010 and save a set as a “theme”. Here is my first VS 2010 dark theme:

Elite Dark

clip_image001

Just install the extension and open my theme and you are ready to go!

Download Visual Studio Color Theme Editor

Download my theme: Elite Dark

UPDATE: My initial version had dark shades on the grid, I made them a bit lighter. ZIP file updated.

Tags: , ,

English

Microsoft Days 2010 – код и PowerPoint Slides

by Ради Атанасов 17. April 2010 16:58

За мен това беше първият MS Days на който съм присъствал - бях супер доволен. Добра атмосфера, много партньори, добри лекции… дори имаше и бира ?!?!?

Лекцията, която изнесох беше най-техническата на тема SharePoint – искаше ми се да има повече SharePoint (:

Ето и кода, който обещах: PerformanceManagement.zip

Това, за което може да ви е полезен е:

  1. Добавяне на бутон в Ribbon на SharePoint 2010
  2. Link към custom javascript file за този бутон
  3. отваряне на диалогов прозорец с т.н. Dialog Framework
  4. SP2010 webpart, който генерира Office документи с Open XML и Word Automation Services – супер интересно (:
  5. Има и един web service в SP 2010

Ето и презентацията: MS Days Radi Atanassov

Аз лично бях доволен от лекцията, въпреки че забравих да покажа генерираните PDF и XPS files…

Ето го и рейтинга ми:

Ради Атанасов

Архитектура и изграждане на бизнес приложения с SharePoint 2010, Silverlight и Open XML SDK (Ниво: 300)

79

Oбща оценка на презентацията

7.85 / 9

Ради Атанасов

Архитектура и изграждане на бизнес приложения с SharePoint 2010, Silverlight и Open XML SDK (Ниво: 300)

79

Компетентност на лектора

8.08 / 9

Ради Атанасов

Архитектура и изграждане на бизнес приложения с SharePoint 2010, Silverlight и Open XML SDK (Ниво: 300)

79

Предоставената информация е полезна за моята работа

7.46 / 9

Ради Атанасов

Архитектура и изграждане на бизнес приложения с SharePoint 2010, Silverlight и Open XML SDK (Ниво: 300)

79

Презентационни умения на лектора

7.54 / 9

Поздрави!

Tags: , , , , ,

Bulgarian

Използване на LINQ to XML върху резултатите от SharePoint Web Services

by Ради Атанасов 18. March 2010 12:02

Когато работиме със Silverlight имаме възможност да използваме LINQ to XML за извличане на данни от резултатите от SharePoint Web Services. Тези дни разгледах LINQ to XML и никога повече не бих работил с XmlDocument обектите (:

Ето няколко примера:

GetListItems() – това е метод от Lists.asmx, и ето му отговора:

<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="13">
   <z:row ... ows_ContentType="Task" ows_Title="New Task 1" ... />
   ... more rows here
</rs:data>
</listitems>

За да извлечем заглавията на list items и да ги подредим в List<string> обект:

private List<string> ProcessListResults(SPListsWS.GetListItemsCompletedEventArgs e)
{
    string result = e.Result.ToString();
 
    XNamespace ns = "#RowsetSchema";
    XElement results = new XElement(e.Result);
 
    var listItems = from x in results.Descendants(ns + "row")
                    where x.Attribute("ows_Title") != null
                    select x;
 
    List<string> itemsList = new List<string>();
 
    foreach (var item in listItems)
    {
        string title = item.Attribute("ows_Title").Value;
        itemsList.Add(title);
    }
    return itemsList;
}

GetUserInfo() – Този метод е от usergroup.asmx и ни дава информация за user в текущия SPSite обект (взима го от скрития user list). Ето отговора:

<GetUserInfo xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
  <User ID="7" Sid="S-1-5-21-347908140-582334945-263120918-1111" Name="Radi"
    LoginName="DEV\radi" Email="" Notes="" IsSiteAdmin="False"
    IsDomainGroup="False" />
</GetUserInfo>

 

И как извлиам LoginName:

public static string GetLoginFromServiceResponse(XElement result)
{
    XNamespace ns = "http://schemas.microsoft.com/sharepoint/soap/directory/";
 
    XName xUser = XName.Get("User", ns.NamespaceName);
    XName xUserInfo = XName.Get("GetUserInfo", ns.NamespaceName);
 
    XElement user = result.Element(xUser);
 
    if (user != null) {  return user.Attribute("LoginName").Value; }
 
    return null;
}

Това което подавам на метода е “e.Result.ToString()” от отговора.

Очаквайте още!

Tags: , , , ,

Bulgarian

Using LINQ to XML to process SharePoint web service responses in Silverlight

by Ради Атанасов 18. March 2010 11:53

Since working with LINQ to XML, I’ve totally fallen in love with it and could never go back to working with the XmlDocument objects.

Here are a few code snippets that can help you out. It is so simple once you get a hang of it.

GetListItems() – this Lists.asmx method returns the following response:

<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="13">
   <z:row ... ows_ContentType="Task" ows_Title="New Task 1" ... />
   ... more rows here
</rs:data>
</listitems>

To get the value of the title into a List<string> object:

private List<string> ProcessListResults(SPListsWS.GetListItemsCompletedEventArgs e)
{
    string result = e.Result.ToString();
 
    XNamespace ns = "#RowsetSchema";
    XElement results = new XElement(e.Result);
 
    var listItems = from x in results.Descendants(ns + "row")
                    where x.Attribute("ows_Title") != null
                    select x;
 
    List<string> itemsList = new List<string>();
 
    foreach (var item in listItems)
    {
        string title = item.Attribute("ows_Title").Value;
        itemsList.Add(title);
    }
    return itemsList;
}

GetUserInfo() – this method is inside usergroup.asmx and gives us information regarding a user in an SPSite object. The response:

<GetUserInfo xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
  <User ID="7" Sid="S-1-5-21-347908140-582334945-263120918-1111" Name="Radi"
    LoginName="DEV\radi" Email="" Notes="" IsSiteAdmin="False"
    IsDomainGroup="False" />
</GetUserInfo>

 

To get the LoginName:

public static string GetLoginFromServiceResponse(XElement result)
{
    XNamespace ns = "http://schemas.microsoft.com/sharepoint/soap/directory/";
 
    XName xUser = XName.Get("User", ns.NamespaceName);
    XName xUserInfo = XName.Get("GetUserInfo", ns.NamespaceName);
 
    XElement user = result.Element(xUser);
 
    if (user != null) {  return user.Attribute("LoginName").Value; }
 
    return null;
}

The passed in “result” is derived from e.Result.ToString().

Hope this helps!

Tags: , , , ,

English

SharePoint meets LINQ to XML: CAML заявки за работа с Lists.asmx

by Ради Атанасов 18. March 2010 10:28

Напоследък ми се налага да работя с LINQ to XML за интеграционни сценарии включващи Silverlight и SharePoint. LINQ to XML е страхотно – сравнително по-добре от създаване на XML чрез обекти като XmlDocument.

Ето пример – повиквам GetListItems() метода на Lists.asmx. Със следният код извличам list items от Task списъка създадени от специфичен user. Този пример би трябвало да работи както за WSS v3, така и за MSF v4.

XElement query = new XElement("Query",
        new XElement("Where",
            new XElement("Eq",
                new XElement("FieldRef", new XAttribute("Name", "Author"), new XAttribute("LookupId", "True")),
                new XElement("Value", new XAttribute("Type", "User"), userID)
)));


XElement queryOptions = new XElement("QueryOptions");
XElement viewFields = new XElement("ViewFields");

_listService.GetListItemsAsync("Tasks", null,
    query, viewFields, "100", queryOptions, null, null);

userID e SharePoint ID-то на потребителя, за който искам да видя резултатите. Можете да получите тази информация от usergroup.asmx.

Успех!

Tags: , , , ,

Bulgarian

SharePoint meets LINQ to XML: Building a CAML Query and calling Lists.asmx

by Ради Атанасов 18. March 2010 10:20

I’ve been playing around with LINQ to XML and Silverlight recently, and it is absolutely awesome! The amount of code you have to write compared to working with XML DOM objects like XmlDocument is extremely minimised.

Here is an example on calling the GetListItems() method of Lists.asmx. I am returning the top 100 items in a Task list that are created by a particular user. This code example should be compatible for both WSS v3 and MSF v4.

XElement query = new XElement("Query",
        new XElement("Where",
            new XElement("Eq",
                new XElement("FieldRef", new XAttribute("Name", "Author"), new XAttribute("LookupId", "True")),
                new XElement("Value", new XAttribute("Type", "User"), userID)
)));


XElement queryOptions = new XElement("QueryOptions");
XElement viewFields = new XElement("ViewFields");

_listService.GetListItemsAsync("Tasks", null,
    query, viewFields, "100", queryOptions, null, null);

userID is the SharePoint user value within the current SPSite. You can get this with the usergroup.asmx service.

Hope this helps!

Tags: , , , ,

English

Forcing the DIP to load when a Word Document loads from SharePoint

by Ради Атанасов 21. February 2010 07:47

I was working on a project and I had custom content types defined in a feature. These content types had document templates, and I wanted to control the Document Information Panel (DIP) when a document is opened in Word.

The following code snippet takes an SPContentType object and adds a custom XSN element to the content types XmlDocuments collection. Setting the openByDefault value to “True” will force the DIP to open when the document loads. I use a FeatureReceiver to run this code against a newly provisioned Content Type.

public static void ConfigureContentTypes(SPContentType ct)
{
    XmlDocument doc = GetCustomXsnDocument();
 
    ct.XmlDocuments.Add(doc);
    ct.Update(true);
}
 
private static XmlDocument GetCustomXsnDocument()
{
    XmlDocument doc = new XmlDocument();
    
    string xml = "<customXsn xmlns=\"http://schemas.microsoft.com/office/2006/metadata/customXsn\"><xsnLocation></xsnLocation><cached>True</cached><openByDefault>True</openByDefault><xsnScope></xsnScope></customXsn>";
 
    doc.LoadXml(xml);
    return doc;
}

You can find information about the child CustomXsn elements on this MSDN link: Content Type Document Information Panel Schema

Hope this helps.

Tags: , , ,

English

Автоматично показване на DIP когато се отваря Word документ

by Ради Атанасов 21. February 2010 07:45

Работя по един проект, в който имам дефинирани Content Types в Feature. Тези Content Types имат различни document templates, и ми се наложи да конфигурирам Document Information Panel (DIP) да се отваря автоматично. Това става лесно чрез интерфейса, но трябваше да е част от автоматизиран деплоймент.

В следващия код показвам как става това. Подаваме SPContentType обект, на който му се дефинира нов CustomXsn елемент в своята XmlDocuments колекция. Ако под-елемента openByDefault е “True”, DIP ще се покаже при отварянето на документа. Използвам FeatureReceiver за прекарам мойте Content Types през този статичен метод:

public static void ConfigureContentTypes(SPContentType ct)
{
    XmlDocument doc = GetCustomXsnDocument();
 
    ct.XmlDocuments.Add(doc);
    ct.Update(true);
}
 
private static XmlDocument GetCustomXsnDocument()
{
    XmlDocument doc = new XmlDocument();
    
    string xml = "<customXsn xmlns=\"http://schemas.microsoft.com/office/2006/metadata/customXsn\"><xsnLocation></xsnLocation><cached>True</cached><openByDefault>True</openByDefault><xsnScope></xsnScope></customXsn>";
 
    doc.LoadXml(xml);
    return doc;
}

Можете да намерите повече информация за CustomXsn елемента на този MSDN линк: Content Type Document Information Panel Schema

Дано това помогне на някой.

Tags: , , ,

Bulgarian

Формите на списъци в SharePoint 2007 - как работят те – Втора Част

by Ради Атанасов 20. February 2010 13:55

Този пост е продължение на предишния, в който разглеждам как можем да заменим “NewFormUrl”, “EditFormUrl” и “DisplayFormUrl” притежанията на Content Type обекти, с цел да се заменят формите, с които SharePoint показва данни за определен list item. Тука ще опиша как SharePoint използва Rendering Templates по време на зареждането на тези форми, и как можем да ги заменим с произволни, така че да добавиме функционалност.

Ето как работят Rendering Templates:

Всеки list item в SharePoint списък е под формата на определен Content Type. В повечето случай това е или “Item”, или “Document” Content Type, в зависимост от списъка, в който този list item се намира. Като разработчици, ние създаваме нови Content Types, които имат смисъл за съответния бизнес: Invoice, Quote, Proposal и т.н.

Всеки Content Type има свой “New”, “Edit” и “Display” форми за събиране и показване на своите данни. Всяка една от тези форми е дефинирана чрез “Form Rendering Template”, който съдържа HTML markup, или ASCX контролки.

Тези Rendering Templates са дефинирани в ASCX файлове в _CONTROLTEMPLATES папката (...12\TEMPLATE\CONTROLTEMPLATES). На повечето обекти в SharePoint са им дефинирани Rendering Templates в DefaultTemplates.ascx, там ще намерите HTML на много обекти като Toolbar, ListFieldIterator и т.н. Ето как е дефиниран DocumentLibraryForm:

<SharePoint:RenderingTemplate ID="DocumentLibraryForm" runat="server">
    <Template>
        <SharePoint:InformationBar runat="server"/>
        <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" 
        RightButtonSeparator="" runat="server">
            <Template_RightButtons>
                <SharePoint:SaveButton runat="server"/>
                <SharePoint:GoBackButton runat="server"/>
            </Template_RightButtons>
        </wssuc:ToolBar>
        <SharePoint:FormToolBar runat="server"/>
        <SharePoint:FormComponent TemplateName="DocumentLibraryFormCore" 
        runat="server"/>
    </Template>
</SharePoint:RenderingTemplate>

Забележете, че този Rendering Template вика други “FormCompontent” обекти чрез “TemplateName” атрибута. Това е много сходно с PHP…

Нашата цел, е да заменим тези Rendering Templates, за да променим това, което крайните потребители виждат като работят с нашите Content Types.

Имаме 2 варианта:

Вариант 1: посочване на наши Rendering Templates в самата дефиниция на наш Content Type.

Дефиниции на Content Types ни дават тази възможност чрез XmlDocument елементи:

<!-- Document Content Type -->
<ContentType ID="0x0101006BD6DAD38F7947799A6F2EE72F5C3C24"
    Name="TemporaryContentType"
    Group="Custom Content Types"
    Description="">
    <FieldRefs>
        <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
    </FieldRefs>
    <XmlDocuments>
        <XmlDocument 
        NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
            <FormTemplates 
            xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
                <Display>MyCustomForm</Display>
                <Edit>MyCustomForm</Edit>
                <New>MyCustomForm</New>
            </FormTemplates>
        </XmlDocument>
    </XmlDocuments>
</ContentType>

 

С горният FormTemplates елемент (в XmlDocument) съм посочил на този Content Type да използва MyCustomForm за Display, New и Edit формите си.

За да създадем MyCustomForm като Rendering Template, трябва да си направим свой ASCX файл и да го сложим в CONTROLTEMPLATES папката. Това е хубаво да стане чрез Feature.

Ето примерен Rendering Template в свой ASCX файл. SharePoint ще разгледа и запомни всички RenderingTemplate обекти по време на зареждане на своя Application Pool, стига те да се намират в CONTROLTEMPLATES папката.

<SharePoint:RenderingTemplate ID="MyCustomForm" runat="server">
    <Template>
        Hello
    </Template>
</SharePoint:RenderingTemplate>

Можете да добавите HTML и свой ASCX контролки и напълно да промените това, което крайните потребители виждат и използват.

Ето какво всъщност става „зад сцената“:

В първата част описах как ListFormWebPart се добавя от платформата на ASPX страници, които по принцип SharePoint би използвал за да покаже свойте “New”, “Edit” и “Display” форми. Този Web Part върши цялата работа в намирането на точния Rendering Template за текущия Content Type, върху който крайният потребител иска да работи.

Ето малко код от Reflector… Това е TemplateName, притежанието на този ListFormWebPart, който проверява текущия Content Type и връща името на конфигурирания Rendering Template.

image

Това ни води до следващата опция:

Вариант 2: Да посочим името на Rendering Template чрез код.

Кода е много прост (: SPContentType обекта открива 3 притежания:

cType.NewFormTemplateName = “MyCustomForm”;
cType.EditFormTemplateName = “MyCustomForm”;;
cType.DisplayFormTemplateName = “MyCustomForm”;
cType.Update(true);

С това ще се постигне същото нещо като Опция 1, но няма нужда от декларативен CAML. Чрез cType.Update(true); изпращаме промените към дъщерни Content Types.

Успех.

Tags: , ,

Bulgarian

SharePoint 2007 list forms under the hood – Part 2

by Ради Атанасов 20. February 2010 13:49

In Part 1 of this series I looked at replacing the “NewFormUrl”, “EditFormUrl” and “DisplayFormUrl” properties of the Content Type object to change the forms that SharePoint uses to display list item information. In this second part I will discuss how we can replace the actual Rendering Templates to achieve the same goals.

This is how Rendering Templates work:

Each item in a SharePoint list is of a certain Content Type. In most cases items are either an “Item” Content Type or a “Document” Content Type depending on the Base Type of the list. Usually as developers and customisers we create additional Content Types that make sense to the business, for example Invoices, Quotes, Proposals, etc.

Each Content Type has “New”, “Edit” and “Display” forms for displaying and collecting data related to the content type item. Each one of these 3 forms has a “Form Rendering Template” that defines the HTML markup and controls that will render for the forms.

These Rendering Templates are defined in the _CONTROLTEMPLATES folder. Most other objects in SharePoint have Rendering Templates which are defined in DefaultTemplates.ascx, check out the Toolbar, ListFieldIterator, etc. The DocumentLibraryForm is defined in DefaultTemplates.ascx:

<SharePoint:RenderingTemplate ID="DocumentLibraryForm" runat="server">
    <Template>
        <SharePoint:InformationBar runat="server"/>
        <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" 
        RightButtonSeparator="" runat="server">
            <Template_RightButtons>
                <SharePoint:SaveButton runat="server"/>
                <SharePoint:GoBackButton runat="server"/>
            </Template_RightButtons>
        </wssuc:ToolBar>
        <SharePoint:FormToolBar runat="server"/>
        <SharePoint:FormComponent TemplateName="DocumentLibraryFormCore" 
        runat="server"/>
    </Template>
</SharePoint:RenderingTemplate>

 

This rendering template calls other “FormCompontent” objects and their Rendering Tempaltes – very similar to PHP…

Our goal is to replace these Rendering Templates with our own, so we modify what end users see in the New, Edit and Display scenarios.

We can “tell” Content Types to use our own Rendering Tempaltes by two ways: including XML in the Content Type Definition, or Using code.

Option 1:

Content Type definitions in features allow you to set XmlDocument elements:

<!-- Document Content Type -->
<ContentType ID="0x0101006BD6DAD38F7947799A6F2EE72F5C3C24"
    Name="TemporaryContentType"
    Group="Custom Content Types"
    Description="">
    <FieldRefs>
        <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
    </FieldRefs>
    <XmlDocuments>
        <XmlDocument 
        NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
            <FormTemplates 
            xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
                <Display>MyCustomForm</Display>
                <Edit>MyCustomForm</Edit>
                <New>MyCustomForm</New>
            </FormTemplates>
        </XmlDocument>
    </XmlDocuments>
</ContentType>

With the above FormTemplates element under XmlDocument I have specified that the custom content type should use the custom Rendering Template MyCustomForm for rendering the New, Edit and Display forms.

To create this Rendering Template, create your own ASCX file to store it, use a feature to deploy it to the CONTROLTEMPLATES folder, and then add the XmlDocuments element to your Content Type definition as demonstrated above. Here is a basic Rendering Template that should go in a custom ASCX file, you can name it however you wish, SharePoint will “crawl” the folder for all Rendering Templates during the Application Pool start-up sequence.

<SharePoint:RenderingTemplate ID="MyCustomForm" runat="server">
    <Template>
        Hello
    </Template>
</SharePoint:RenderingTemplate>

You can include your own custom ASCX controls in your rendering templates and completely change the SharePoint experience.

In part 1 I explained how the ListFormWebPart gets added to our form pages that get provisioned with the list. This web part is what actually does the work in both options. During load time it checks the Rendering Template name specified in the properties and builds its markup based on that template.

Here is a shot of the TemplateName property where the web part checks the current Content Type and gets its template names:

clip_image002

This leads us to our next option: changing the Template names in code.

Option 2: Using code to change a Content Types Rendering Template.

It’s quite simple - the SPContentType object exposes 3 properties so we can set the template names:

cType.NewFormTemplateName = “MyCustomForm”;
cType.EditFormTemplateName = “MyCustomForm”;;
cType.DisplayFormTemplateName = “MyCustomForm”;
cType.Update(true);

This essentially achieves the same as Option 1 above, but keep in mind that you should most likely push the changes down to child content types – call .Update(true); instead of .Update();

All the best.

Tags: , ,

English

About the author

Аз съм консултант, архитект и разработчик на SharePoint решения.

Feeds

Get RSS Feed (Bulgarian)
Get RSS Feed (English)    
Get RSS Feed  (Both)        


Abilitics