2

Aim: I want whenever someone creates a new Task, validate it and cancel if needed.

Enviroment details: Currently I'm using Project Server 2013 and trying to make remote event handlers work. Remote event handlers are in WCF service which is in ASP.NET Web Application, hosted on IIS on Windows Server along with Project Server.

Currently I have 2 WCF services in my application:

  1. ProjectEventReceiver.svc :

    namespace EventHandlersTest
    {
        public class ProjectEventReceiverDemo : IProjectEventReceiverRemote
        {
            ...
            public ProjectPreEventArgs OnCreatingRemote(PSContextInfo contextInfo, Guid eventHandlerUid, ProjectPreEventArgs e) 
            {
                if (/*invalid project name for example*/)
                {
                    e.Cancel = true;
                }
                return e;
            }
            ...
        }
    }
    

    This one is binded in SharePoint Central Administation -> ... -> Server Side Event Handlers -> to the event Project - Creating like this:

    Class Name: EventHandlersTest.ProjectEventReceiverDemo

    Url: http://localhost:6569/EventHandlersTest/ProjectEventReceiver.svc

    The url is ok, I can access that .cvs file in browser. This handler works perfectly (for example when I create a new Enterprise Project with invalid name - the event is caught, creation canceled and I can see my custom logs show that class was constructed and method OnCreatingRemote was invoked).

Now the problem itself with second service:

  1. TaskEventReceiver.svc :

    namespace EventHandlersTest
    {
        public class TaskEventReceiverDemo : IStatusingEventReceiverRemote
        {
            ...
            public StatusCreateTaskPreEventArgs OnTaskCreatingRemote(PSContextInfo contextInfo, Guid eventHandlerUid, StatusCreateTaskPreEventArgs e) 
            {
                // just cancel everything for now
                e.Cancel = true;
                return e;
            }
            ...
        }
    }
    

    This one is binded to the event Statusing - TaskCreating like this:

    Class Name: EventHandlersTest.TaskEventReceiverDemo

    Url: http://localhost:6569/EventHandlersTest/TaskEventReceiver.svc

    Again, url is correct - I can access it in browser.

Now problematic flow: I created a SharePoint Task List Project, then I go there and click on New Task, fill in required name - it creates a task. Event isn't received, object of class TaskEventReceiverDemo is not created and the method OnTaskCreatingRemote is not invoked.

I'm not sure if IStatusingEventReceiverRemote is a correct interface, because there is no really helpful descriptions in the reference, so I made assumptions only based on method names.

I also tried to implement IResourceEventReceiverRemote, particularly method OnCreatingRemote and bind it to Resource - OnCreating - the same result (and it seems to be logical because Task is not a Resource).

Question: Can someone shed some light on what is the name of event which would be rised when I create a task such as described in problematic flow? Or maybe I am doing something wrong and cannot figure it out.

Thanks in advance.

Yuriy Ivaskevych
  • 956
  • 8
  • 18

1 Answers1

0

Looks like I've found an aswer (at least partial one)

I've created all services needed to cover all the interfaces in namespace Microsoft.Office.Project.Server.Events and in every implemented method I did logging to a file.

After this I subscribed all Server Side Event Handlers from SP Central Admin and started playing with CRUDing tasks for SharePoint Task List Project type.

I hoped this would reveal me the needed method with the help of my logging. However, results were kind of surprising: Nothing in logs, which means that CRUDing tasks for SharePoint Task List Project doesn't fire any event.

Btw, handlers were correct and subscribed properly because I could see logs say for Creating Project. And for another type of project - Enterprise Project - task events actually fired and were obvious: Statusing - TaskCreating, etc.

I would be grateful if someone could explain me why events do fire for creating tasks in Enterprise Project but not in SP Task List one, because I answered my question only partially.

Yuriy Ivaskevych
  • 956
  • 8
  • 18