public TestResult DoTest() { MSProject.Application application = null; DateTime startTime = DateTime.Now; try { application = COMObject.Create <MSProject.Application>(COMObjectCreateOptions.CreateNewCore); MSProject.Project newProject = application.Projects.Add(); newProject.Tasks.Add("Task 0"); newProject.Tasks.Add("Task 1"); newProject.Tasks.Add("Task 2"); newProject.Tasks.Add("Task 3"); newProject.Tasks.Add("Task 4"); newProject.Tasks.Add("Task 5"); newProject.Tasks.Add("Task 6"); newProject.Tasks.Add("Task 7"); newProject.Tasks.Add("Task 8"); newProject.Tasks.Add("Task 9"); return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "")); } catch (Exception exception) { return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "")); } finally { if (null != application) { application.Quit(PjSaveType.pjDoNotSave); application.Dispose(); } } }
public TestResult DoTest() { NetOffice.Settings.Default.MessageFilter.Enabled = true; MSProject.Application application = null; DateTime startTime = DateTime.Now; try { application = new MSProject.Application(); application.ProjectTaskNewEvent += new MSProject.Application_ProjectTaskNewEventHandler(ApplicationProjectTaskNewEvent); application.ProjectBeforeCloseEvent += new MSProject.Application_ProjectBeforeCloseEventHandler(ApplicationProjectBeforeCloseEvent); application.ProjectBeforeTaskChangeEvent += new MSProject.Application_ProjectBeforeTaskChangeEventHandler(ApplicationProjectBeforeTaskChangeEvent); application.ProjectBeforeTaskDeleteEvent += new MSProject.Application_ProjectBeforeTaskDeleteEventHandler(ApplicationProjectBeforeTaskDeleteEvent); MSProject.Project newProject = application.Projects.Add(); MSProject.Task task1 = newProject.Tasks.Add("Task 1"); MSProject.Task task2 = newProject.Tasks.Add("Task 2"); task2.Delete(); application.FileCloseAll(PjSaveType.pjDoNotSave); if (TaskDeleteEventCalled && TaskChangeEventCalled && BeforeCloseEventCalled && TaskChangeEventCalled) { return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "")); } else { string errorMessage = ""; if (!TaskDeleteEventCalled) { errorMessage += "ProjectBeforeTaskDeleteEvent failed "; } if (!TaskChangeEventCalled) { errorMessage += "ProjectBeforeTaskChangeEvent failed "; } if (!BeforeCloseEventCalled) { errorMessage += "ProjectBeforeCloseEvent failed "; } if (!TaskNewEventCalled) { errorMessage += "ProjectTaskNewEvent failed "; } return(new TestResult(false, DateTime.Now.Subtract(startTime), errorMessage, null, "")); } } catch (Exception exception) { return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "")); } finally { NetOffice.Settings.Default.MessageFilter.Enabled = false; if (null != application) { application.Quit(PjSaveType.pjDoNotSave); application.Dispose(); } } }
void ApplicationProjectTaskNewEvent(MSProject.Project pj, int ID) { TaskNewEventCalled = true; }
void ApplicationProjectBeforeCloseEvent(MSProject.Project pj, ref bool Cancel) { BeforeCloseEventCalled = true; }
public virtual void NewProject(NetOffice.MSProjectApi.Project pj) { InvokerService.InvokeInternal.ExecuteMethod(this, "NewProject", pj); }
public virtual void ProjectCalculate(NetOffice.MSProjectApi.Project pj) { InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectCalculate", pj); }
public virtual void ProjectBeforeSave(NetOffice.MSProjectApi.Project pj, bool saveAsUi, bool cancel) { InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectBeforeSave", pj, saveAsUi, cancel); }
public virtual void ProjectBeforePrint(NetOffice.MSProjectApi.Project pj, bool cancel) { InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectBeforePrint", pj, cancel); }