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