How to pause or cancel the jobs for project creation (in Project server 2010)
-
donderdag 26 april 2012 7:35How to pause or cancel the jobs for project creation (in Project server 2010
) programmatically- Verplaatst door Sapna Shukla - Project MVPMVP, Moderator donderdag 26 april 2012 7:45 (From:Project Standard and Professional General Questions and Answers)
Alle reacties
-
vrijdag 27 april 2012 9:30
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
- Bewerkt door Amit Khare - Project Management Consultant vrijdag 27 april 2012 9:30
- Als antwoord gemarkeerd door MsSPJ maandag 30 april 2012 12:51
-
maandag 30 april 2012 12:49
Hi Amit ,
Thanks for your help.Will you please reply for this post
Thanks and Regards,
Swati Jain