How to pause or cancel the jobs for project creation (in Project server 2010)
-
Thursday, 26 April 2012 7:35 AMHow to pause or cancel the jobs for project creation (in Project server 2010
) programmatically- Moved by Sapna Shukla - Project MVPMVP, Moderator Thursday, 26 April 2012 7:45 AM (From:Project Standard and Professional General Questions and Answers)
All Replies
-
Friday, 27 April 2012 9:30 AM
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.aspxGood luck.
Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82
- Edited by Amit Khare - Project Management Consultant Friday, 27 April 2012 9:30 AM
- Marked As Answer by MsSPJ Monday, 30 April 2012 12:51 PM
-
Monday, 30 April 2012 12:49 PM
Hi Amit ,
Thanks for your help.Will you please reply for this post
Thanks and Regards,
Swati Jain