void buildReleaseRecord(EnterpriseManagementObject emoReleaseRecord, EnterpriseManagementObject emoProject) { try { //get the project associated with the original change request and query project server for it. var projectGuid = (Guid)emoProject[null, "GUID"].Value; projectConnector.LoadProject(projectGuid); //load the first level project task data PublishedProject project = projectConnector.Projects.FirstOrDefault(p => p.Id == projectGuid); if (project == null) { EventLog.WriteEntry(strEventLogTitle, string.Format("Project was not found on Project Server. It may have been removed.\r\n\r\nProject Name: {0}\r\nProject GUID: {1}", emoProject.DisplayName, (emoProject[null, "GUID"].Value == null) ? string.Empty : emoProject[null, "GUID"].Value.ToString()), EventLogEntryType.Warning); } else { projectConnector.LoadProjectTaskData(project, 1); //get all activities in the release record var lstReleaseRecordActivites = emg.EntityObjects.GetRelatedObjects <EnterpriseManagementObject>(emoReleaseRecord.Id, mprRelationships.First(r => r.Name == "System.WorkItemContainsActivity"), TraversalDepth.OneLevel, ObjectQueryOptions.Default); buildActivitiesList(lstReleaseRecordActivites, emoReleaseRecord, emoProject, project); EventLog.WriteEntry(strEventLogTitle, string.Format("Succsesfully processed '{0}' activities list. Any changes will be submiited to the database.", emoReleaseRecord.DisplayName)); } } catch (SharePoint.Client.ServerException ex) { exceptionsList.Add(new BuildReleaseRecordException(string.Format("An error occured while building '{0}' activities. The related Project is '{1}'.", emoReleaseRecord.DisplayName, emoProject.DisplayName), ex)); } }