예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
 void ApplicationProjectTaskNewEvent(MSProject.Project pj, int ID)
 {
     TaskNewEventCalled = true;
 }
예제 #4
0
 void ApplicationProjectBeforeCloseEvent(MSProject.Project pj, ref bool Cancel)
 {
     BeforeCloseEventCalled = true;
 }
예제 #5
0
 public virtual void NewProject(NetOffice.MSProjectApi.Project pj)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "NewProject", pj);
 }
예제 #6
0
 public virtual void ProjectCalculate(NetOffice.MSProjectApi.Project pj)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectCalculate", pj);
 }
예제 #7
0
 public virtual void ProjectBeforeSave(NetOffice.MSProjectApi.Project pj, bool saveAsUi, bool cancel)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectBeforeSave", pj, saveAsUi, cancel);
 }
예제 #8
0
 public virtual void ProjectBeforePrint(NetOffice.MSProjectApi.Project pj, bool cancel)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "ProjectBeforePrint", pj, cancel);
 }