How to pause or cancel the jobs for project creation (in Project server 2010)

Answered How to pause or cancel the jobs for project creation (in Project server 2010)

  • Thursday, 26 April 2012 7:35 AM
     
     
    How to pause or cancel the jobs for project creation (in Project server 2010
    ) programmatically

All Replies

  • Friday, 27 April 2012 9:30 AM
     
     Answered Has Code

    Hi there--

    You can write a project server event handler which can cancel the job based on the condition.
    In below sample code, the project is validated on Publish event if the name doesn't start with prj, it cancels the operation.

    public override void OnPublishing(PSContextInfo contextInfo, 
        ProjectPrePublishEventArgs e)
    {
        base.OnPublishing(contextInfo, e);
        . . .
    }


    // Create an EventLog instance and assign its source.
        EventLog myLog = new EventLog();
        myLog.Source = "Project Event Handler";
        // Get information from the event arguments, and 
        // write an entry to the Application event log. 
        string userName = contextInfo.UserName.ToString();
        string projectName = e.ProjectName.ToString();
        int eventId = 3651;
        string logEntry;
        e.Cancel = false;
        if (projectName.Substring(0, 3).Equals("Prj"))
        {
            logEntry = "User: " + userName + 
                "\nProject: " + projectName +
                "\nThe project name is valid. Publishing...";
            myLog.WriteEntry(logEntry, EventLogEntryType.Information, eventId);
        }
        else
        {
            logEntry = "User: " + userName + 
                "\nInvalid project name: " + projectName +
               "\nTo be published, the project name must start with 'Prj'.";
            myLog.WriteEntry(logEntry, EventLogEntryType.Warning, eventId);
            e.Cancel = true;
        }

    Here is the basic & sample:
    http://technet.microsoft.com/en-us/library/gg982976.aspx
    http://msdn.microsoft.com/en-us/library/gg615466.aspx
    http://blogs.msdn.com/b/chrisfie/archive/2010/06/03/project-server-2010-delegation-audit-event-handler.aspx

    Good luck.


    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82


  • Monday, 30 April 2012 12:49 PM
     
     

    Hi Amit ,

    Thanks for your help.Will you please reply for this post

    http://social.msdn.microsoft.com/Forums/en/project2010custprog/thread/fee2b965-34b0-4b08-ab0b-5bddda4f8de9

    Thanks and Regards,

    Swati Jain