Reza on blogging [MVP]

THIS BLOG HAS MOVED TO: http://blogs.devhorizon.com/reza

Subscriptions

<October 2008>
SuMoTuWeThFrSa
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

News



toronto.sharepoint.camp


Navigation

Post Categories

Other Bloggers

Personal Links

Sharepoint (RSS)

Installing Team Foundation Server in single Server Mode (WSS 2.0)

I have installed TFS couple of times, but it has been always in a dual-server mode which basically puts the Team Foundation data and the application tiers on separate computers. Last week, I was asked by a colleague of mine to give him a hand on installing TFS in a single server mode. Well, I am not a TFS expert, but when it comes to a technology that somehow relates to SharePoint somewhere, I step in and learn enough about that technology to protect myself for rainy days in future. As a result, I have been involved in many integration projects that SharePoint is the other end or it is used under the hood. Despite the fact that I am known for 100% SharePoint architecting and dev , I *really* enjoy this type of work a lot more.It is much more fun plus the exposure you can get to other complementary technologies around SharePoint. Obviously, the challenge is always to stay focused and indeed not to be derailed.

Okay, back to the issue. I agree wholeheartedly that
TFS documentation is really good , but I think it is a bit complicated for many users, definitely lacks some screenshots and a very important tip which is the fact that TFS expects SharePoint configuration database to be called STS_Config_TFS. One other thing that I have found very important (and not emphasized enough in the documentation) is to create and use right user accounts for various steps during the installation process.Having said this , I decided to create a document that describes the installation steps in a more summarized way along with many screenshots of the important steps. You can download this document here and please let me know what you think.


posted Sunday, November 04, 2007 2:02 AM by rezaa with 0 Comments

Calling all volunteers for Toronto SharePoint Camp 2007!!

Toronto SharePoint Camp 2007 is only 3 days away – and we need your help. 

If you have already registered to help us or if you are interested, then tonight is the right time to get more involved.Please join other volunteers at 6:00pm at the Toronto SharePoint User Group venue at 2 Bloor West, so that we can allocate job roles, functions, and responsibilities surrounding the event this Saturday.

Thank you in advance for donating your time to support the Toronto SharePoint Camp 2007.

See you tonight,


posted Wednesday, October 17, 2007 1:26 PM by rezaa with 0 Comments

Getting user login from the PeopleEditor via Code

Assuming you have a people editor control defined like below:

<wssawc:PeopleEditor AllowEmpty="false"  ID="myPeopleEditorControl" runat=server SelectionSet="User" MaximumEntities="1" MultiSelect="false" AllowTypeIn="false" Width='500px' />

The following code sample will get you the currently logged on user's login from the PeopleEditor control:

  ArrayList peEntities = myPeopleEditorControl.Entities;
  PickerEntity pickEn = (PickerEntity)peEntities[0];
  stringLogIn = pickEn.Key;

This comes handy when you want to create an SPUser context out of the entities kept in the PeopleEditor control. For example:

 private SPUser GetUser(string logIn)

        {
             SPUser user = this.workflowProperties.Web.SiteUsers[logIn];
             return user;
        }

Don't forget Required Field Validation on your people editor control if you want the code not to break on you.


posted Thursday, October 04, 2007 2:56 PM by rezaa with 0 Comments

Toronto SharePoint Camp 2007 Count down

The Toronto SharePoint Camp 2007 is just around the corner, 20th of October in Toronto. Register Today, Space is limited!

Remember, this is a *Free* event and no matter how expert you are in SharePoint, there should be something there for you to learn. For those of you who keep sending me emails asking for events and opportunities to learn MOSS 2007, there you are! Here is a great opportunity to meet a lot of SharePoint guys, learn for top-notch industry experts plus a lot of fun and PRIZES!!!

I have two demos prepared one targeting the advanced audience and the other one for beginners. I probably have to choose one of them if there are many speakers lined up.

Please keep an eye on my blog, Eli’s blog and SharePoint Buzz blog for updates and  announcements

 




posted Sunday, September 30, 2007 11:02 PM by rezaa with 1 Comments

Item Level Permission in workflow CreateTaskXXX activities

I wish there was an easier way of incorporating item-level security into "CreateTask" and "CreateTaskWithContetType" activities other than what SPWorkFlowTask offers.I think this is a serious requirement for many clients who asks for a process to be modeled by workflow and therefore there should be an easier way to accomplish it. sadly,workflows assume that users already have permission to access the task list and once the tasks are created by workflow, you are basically on your own to set up the required permissions. If you fail to properly set the required permissions on item level basis and aside from the issue described above, assignee might get an email regarding the new task , click on link and boom ...... ugly "Access Denied" will be thrown at his face. There is a sample activity here that you can check out , but for me it only worked in SharePoint designer and I was never able to get it to work as an activity in my custom workflows not written in SPD.

Here is the way I do it:

1) I create the Task using "CreateTaskWithContentType" activity from my workflow. Obviously, I already have a content type in place.

2) I have also attached an event handler to the content type I use above. Oops! I forgot to say that there is no way you can visually do that (except this one), so I use a programmatic approach to assign an event handler to my content type when the feature that contains my content type get activated.

3) So I have to create a Feature that contains the content type (MyTaskContentType.xml is content type definition which I will skip for the sake of code brevity)
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="5FED1202-C6B8-453e-9EC0-F328655ED4DC"
  Title="My Workflow Task Content Types"
  Description="...."
  Version="12.0.0.0"
  Scope="Site"
  xmlns="http://schemas.microsoft.com/sharepoint/"
  ReceiverAssembly="DevHorizon.SharePoint.Workflows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=207a12b7817b805c"
  ReceiverClass=" "DevHorizon.SharePoint.Workflows.AddConentTypesEventHanlders">

<ElementManifests>
  <ElementManifest Location="DivRepTask.xml" />
  <ElementManifest Location="HRAdminTask.xml" />
</ElementManifests>

</Feature>

4) I create a feature receiver class for this feature, I get a reference to the content type and attach the event handler to it programmatically:

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            using (SPSite siteCollection = (SPSite) properties.Feature.Parent)
            {
                using (SPWeb web = siteCollection.OpenWeb())
                {
            System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();                   
                    SPContentType ctMyTask = web.ContentTypes["My Conent Type"];
                    ctMyTask.EventReceivers.Add(SPEventReceiverType.ItemAdded, a.FullName,"MyTaskItemEventReceiver");
                    ctMyTask.Update();
                    web.Update();
           
                 }
              }
          }

5)  Now,I need to create an event handler class named "MyTaskItemEventReceiver" that inherits from SPItemEventReceiver.Make sure you decorate this class with the right attributes to target to the featureId that contains your content type and the content type Id that you are writing this event handler for. You also need a unique GUID for your event handler

           [TargetContentType("feature id goes here", "content type id goes here")]
           [Guid("and here is the unique id for your enevnt handler")]


6) In ItemAdded method of your event handler add the following code:

            DisableEventFiring();
            SPListItem listItem = properties.ListItem;
            try
            {
                listItem.BreakRoleInheritance(false);
                listItem.Update();
                listItem =SetItemLevelPermissions(listItem.Web, listItem, SPRoleType.Contributor, listItem["Assigned To"].ToString());
                listItem.Update();
            }
            catch (Exception ex)
            {
                try
                {
                   //Add error handling code here
                }
                catch { }
            }

            EnableEventFiring();

7) And finally add this helper method somewhere accessible from within your event handler

         public static SPListItem SetItemLevelPermissions(SPWeb setSPWeb, SPListItem setListItem, SPRoleType setRoleType, string assignedTo)
        {
            int index = assignedTo.IndexOf(';');
            int id = Int32.Parse(assignedTo.Substring(0, index));
            SPUser user = setSPWeb.SiteUsers.GetByID(id);
            SPRoleDefinition roleDefinition = setSPWeb.RoleDefinitions.GetByType(setRoleType);
            SPRoleAssignment roleAssignment = new SPRoleAssignment(user.LoginName, string.Empty, string.Empty, string.Empty);
            roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
            setListItem.RoleAssignments.Add(roleAssignment);
            return setListItem;
        }

Now when your workflow creates a task, its item level permission will be broken and set to "assigned to" field.Happy ending!


posted Thursday, September 27, 2007 2:00 AM by rezaa with 0 Comments

Programming under the influence

Let’s say you have a list (i.e.task list ) for which you need to capture ItemAdded event using an event handler and You have to do something unusual like the following:

        [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
        public override void ItemAdded(SPItemEventProperties properties)

        {
            SPListItem testtask = properties.ListItem.ParentList.Items.Add();
            testtask["Title"] = "You are fired!::" + DateTime.Now.ToString();
            testtask["Due Date"] = DateTime.Now;
            testtask["Priority"] = "(1) High";
            testtask.Update();
        }

 

Congradulations! You are trapped in a loop. How? Somebody adds  a task and your event handler fires and adds another task and  so on and so forths. I know this may sound stupid to do, by my point is something else here. Event handler OM is now smart enough not to let you get trapped in an infinite loop ,so recursion depth in such case is set to 10 (for itemAdded) and looping only occurs 10 times. It is really cool! Look at the picture below:

 If you really have to do such a thing then at least use DisableEventFiring() and EnableEventFiring(); to stop the event handler from firing 10 times. 

        [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
        public override void ItemAdded(SPItemEventProperties properties)

        {
            DisableEventFiring();
            SPListItem testtask = properties.ListItem.ParentList.Items.Add();
            testtask["Title"] = "You are fired!::" + + DateTime.Now.ToString();            
            testtask["Due Date"] = DateTime.Now;
            testtask["Priority"] = "(1) High";
            testtask.Update();
            EnableEventFiring();
        }


posted Wednesday, September 26, 2007 4:34 PM by rezaa with 1 Comments

Plan your three Must-Attend conferences in 2008

1) Microsoft Office System Developer Conference 2008 | San Jose, California | Feb 10-13 2008

I was just informed that the official site for this has gone live. I think this is the first time ever this conference is open to the public, so everyone is invited. This is a fantastic opportunity for architects, developers, industry experts, and Microsoft insiders to come together to discuss various developing solutions in Office System.

2) SharePoint 2008 conference | Seattle,WA | March 3-6,2008

Take advantage of  the "early bird" special discount. Register Today

3) Tech·Ed | Orlando, FL | June 9-13, 2008

Be among the first to get conference information, session agendas, and preregistration details by signing in the Tech·Ed 2008 Guestbook.

If you live in Greater Toronto Area, I'd highly recommend you to mark your calendar for 20th of October for Toronto SharePoint Camp. I can't wait to see you all there! 


posted Monday, September 17, 2007 7:32 PM by rezaa with 0 Comments

Toronto SharePoint Camp: Saturday, October 20, 2007

I've just come back from vacation and I am very pleased to announce The first ever SharePoint Camp being held in Toronto on Saturday, October 20, 2007. I duplicate what Eli has posted in his blog because no one in Greater Toronto Area(GTA) should miss this great opportunity. For most updated information on this event keep an eye on Eli's blog.

Mark your calendar! The first ever SharePoint Camp will be in Toronto, and registration will be absolutely free.

Toronto SharePoint Camp, Manulife Centre
200 Bloor Street East
Saturday, October 20

The event will be hosted by the Toronto SharePoint User Group with a supporting cast of many fantastic volunteers and guest speakers.

There are 3 tracks: Developer, Administrator, and Champion/Architect. There will be 15-18 presentations total in 3 to 5 theatres. The space should comfortably accomodate 200 to 300 attendees. We'll follow the CodeCamp manifesto: free, volunteer-run, brand-agnostic, less talk, more rock. 

Call for speakers: All submissions must be delivered by September 21, 2007. Presentations and demo code is due by October 12, 2007. Read more about how you can contribute and apply by downloading the Call For Speakers today!

Call for Volunteers:  If you'd like to help out, mark your calendar for October 17 and 20 today. Then, watch this blog for link to the sign-up sheet as soon as the site goes live. On Wednesday, October 17th at 6:pm we'll have a pizza meeting for about an hour at 2 Bloor Street West (Nexient) to get organized. Note that this is the regular time and location of the SharePoint User Group meeting which will be replaced in October by the Organizer's Meeting (note: in September TSPUG will have a great workflow presentation by K2).

Registration: The website will be up asap, watch Eli's blog for the announcement to be the first in line.


posted Thursday, September 13, 2007 3:49 PM by rezaa with 1 Comments

The latest MOSS and WSS SDK release

There has been a major update to the MOSS and WSS Software Development Kit (SDK) which makes this release an important one.Now there are more samples and articles included and a series of new tools and features are nicely packaged up in the download files.You can install them from the following loc