public void CreateProject <T>(T project)
        {
            var customFieldsDataSet = _customFieldsPsiService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Project.GetAttr <GuidAttribute>().Guid));

            var ds = new ProjectDataSet();

            _mapper.Map(project, ds.Project);
            _mapper.Map(project, ds.ProjectCustomFields, externalData: new Dictionary <string, object>
            {
                { customFieldsDataSet.DataSetName, customFieldsDataSet },
                { "PROJ_UID", ds.Project[0].PROJ_UID }
            });

            var createProjectJobUid = Guid.NewGuid();

            _projectPsiService.Invoke(p => p.QueueCreateProject(createProjectJobUid, ds, false));
            Wait(createProjectJobUid);

            var publishProjectJobUid = Guid.NewGuid();

            _projectPsiService.Invoke(p => p.QueuePublish(publishProjectJobUid, ds.Project[0].PROJ_UID, true, string.Empty));
            Wait(publishProjectJobUid);
        }
Exemple #2
0
        public void MapDictionaryToTaskRow_ShouldMapDictionaryToNativeTaskFields()
        {
            var projectDs = new ProjectDataSet();
            var row       = projectDs.Task.NewTaskRow();

            var fields = new Dictionary <string, object>
            {
                { projectDs.Task.TASK_IDColumn.ColumnName, 100 },
                { projectDs.Task.TASK_NAMEColumn.ColumnName, "NewTask" }
            };

            _mapper.Map(fields, row, new NopPropsMatcher());

            Assert.IsTrue(row["TASK_NAME"].Equals("NewTask"));
            Assert.IsTrue(row["TASK_ID"].Equals(DBNull.Value));
        }
        public void GetProject_ByGuid_ShouldReturnProjectEntity()
        {
            var dataSet = _projectService.Invoke(p => p.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore));

            var result = new BasicProject();

            _mapper.Map(dataSet.Project, result);

            Assert.IsTrue(result.ProjName == Settings.DefaultProjectName);
            Assert.IsTrue(result.ProjUid == Settings.DefaultProjectGuid);
            Assert.IsTrue(result.ProjType == ProjectType.Project);
            Assert.IsTrue(result.WprojDescription == Settings.DefaultProjectName);
        }
        public void GetProject_ShouldReturnTaskWithCustomFields()
        {
            var customFields   = _customFieldsService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Task.GetAttr <GuidAttribute>().Guid));
            var projectDataSet = _projectService.Invoke(s => s.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore));

            var project = new TaskMappingProject();

            _mapper.Map(projectDataSet.Project, project);

            var task = new TaskMappingProjectTask();

            _mapper.Map(projectDataSet.Task, task, externalData: new Dictionary <string, object>
            {
                { "TASK_UID", task.TaskUid }
            });

            _mapper.Map(projectDataSet.TaskCustomFields, task, externalData: new Dictionary <string, object>
            {
                { customFields.DataSetName, customFields },
                { "PROJ_UID", Settings.DefaultProjectGuid },
                { "TASK_UID", task.TaskUid }
            });

            Assert.IsTrue(task.TaskName == "Task 1");
            Assert.IsTrue(task.TestTaskText == "10");

            var dict = new Dictionary <string, object>();

            _mapper.Map(projectDataSet.Task, dict, new NopPropsMatcher(), externalData: new Dictionary <string, object>
            {
                { "TASK_UID", task.TaskUid }
            });

            _mapper.Map(projectDataSet.TaskCustomFields, dict, new NopPropsMatcher(), externalData: new Dictionary <string, object>
            {
                { customFields.DataSetName, customFields },
                { "PROJ_UID", Settings.DefaultProjectGuid },
                { "TASK_UID", task.TaskUid }
            });

            Assert.IsTrue(dict["TASK_NAME"].Equals("Task 1"));
            Assert.IsTrue(dict["Test - Task - Text"].Equals("10"));

            var propertiesToUpdate = new Dictionary <string, object>
            {
                { "Test - Task - Text", "20" }
            };

            _mapper.Map(propertiesToUpdate, projectDataSet.TaskCustomFields, new NopPropsMatcher(), externalData: new Dictionary <string, object>
            {
                { customFields.DataSetName, customFields },
                { "PROJ_UID", task.ProjUid },
                { "TASK_UID", task.TaskUid }
            });

            _projectService.Invoke(s => s.CheckOutProject(Settings.DefaultProjectGuid, Settings.DefaultSessionGuid, "TaskMapping"));

            var updateProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(s => s.QueueUpdateProject2(updateProjectJobUid, Settings.DefaultSessionGuid, projectDataSet, false));
            _envUtil.Wait(updateProjectJobUid);

            var checkInJobUid = Guid.NewGuid();

            _projectService.Invoke(s => s.QueueCheckInProject(checkInJobUid, Settings.DefaultProjectGuid, false, Settings.DefaultSessionGuid, "TaskMapping"));
            _envUtil.Wait(checkInJobUid);

            var updatedProjectDs = _projectService.Invoke(s => s.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore));

            var updatedTaskFields = new Dictionary <string, object>();

            _mapper.Map(updatedProjectDs.Task, updatedTaskFields, new NopPropsMatcher(), externalData: new Dictionary <string, object>
            {
                { "TASK_UID", task.TaskUid }
            });

            _mapper.Map(updatedProjectDs.TaskCustomFields, updatedTaskFields, new NopPropsMatcher(), externalData: new Dictionary <string, object>
            {
                { customFields.DataSetName, customFields },
                { "PROJ_UID", Settings.DefaultProjectGuid },
                { "TASK_UID", task.TaskUid }
            });

            Assert.IsTrue(updatedTaskFields["TASK_NAME"].Equals("Task 1"));
            Assert.IsTrue(updatedTaskFields["Test - Task - Text"].Equals("20"));
        }
        public static void ClassInit(TestContext context)
        {
            _envUtil             = new EnvUtil(Settings.PwaUri);
            _mapper              = new FluentMapper(new PsMappingConfiguration());
            _projectService      = PsiContext.Get <IProject>(Settings.PwaUri);
            _customFieldsService = PsiContext.Get <ICustomFields>(Settings.PwaUri);

            ClassCleanup();

            var customFields = new List <TaskMappingCustomFields>
            {
                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - Text",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.String
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - Number",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.Number
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - Cost",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.Cost
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - Duration",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.Duration
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - Date",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.Date
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - YesNo - True",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.YesNo
                },

                new TaskMappingCustomFields
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Task - YesNo - False",
                    MdEntTypeUid   = PsEntityType.Task.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.YesNo
                }
            };

            var project = new TaskMappingProject
            {
                ProjUid  = Settings.DefaultProjectGuid,
                ProjName = Settings.DefaultProjectName,
                ProjType = ProjectType.Project
            };

            var task = new TaskMappingProjectTask
            {
                TaskUid           = Guid.NewGuid(),
                ProjUid           = Settings.DefaultProjectGuid,
                TaskName          = "Task 1",
                TaskStartDate     = DateTime.Now,
                TaskFinishDate    = DateTime.Now.AddDays(10),
                TaskWork          = 5000.0,
                TestTaskText      = "10",
                TestTaskNumber    = 20,
                TestTaskCost      = 3000,
                TestTaskDuration  = 4000,
                TestTaskDate      = DateTime.Parse("1991-02-16", CultureInfo.InvariantCulture),
                TestTaskYesNoTrue = true
            };

            _envUtil.CreateCustomFields(customFields);
            var customFieldsDs = _customFieldsService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Task.GetAttr <GuidAttribute>().Guid));

            var projectCreateDs = new ProjectDataSet();

            _mapper.Map(project, projectCreateDs.Project);
            _mapper.Map(task, projectCreateDs.Task);
            _mapper.Map(task, projectCreateDs.TaskCustomFields, externalData: new Dictionary <string, object>
            {
                { customFieldsDs.DataSetName, customFieldsDs },
                { "PROJ_UID", Settings.DefaultProjectGuid },
                { "TASK_UID", task.TaskUid }
            });

            var createProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(s => s.QueueCreateProject(createProjectJobUid, projectCreateDs, false));
            _envUtil.Wait(createProjectJobUid);

            var publishProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueuePublish(publishProjectJobUid, Settings.DefaultProjectGuid, true, string.Empty));
            _envUtil.Wait(publishProjectJobUid);
        }
Exemple #6
0
        public static void ClassInit(TestContext context)
        {
            _envUtil = new EnvUtil(PwaUri);

            _projectService   = PsiContext.Get <IProject>(PwaUri);
            _resourceService  = PsiContext.Get <IResource>(PwaUri);
            _statusingService = PsiContext.Get <IStatusing>(PwaUri);
            ResGuid           = _resourceService.Invoke(s => s.GetCurrentUserUid());

            ClassCleanup();

            var project = new TaskDetailsProject
            {
                ProjUid          = ProjectGuid,
                ProjName         = ProjectName,
                ProjType         = (int)ProjectType.Project,
                WprojDescription = ProjectName,
                Tasks            = new List <TaskDetailsTask>
                {
                    new TaskDetailsTask {
                        TaskName = "Task 1", TaskWork = 10000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = TaskGuid, ProjUid = ProjectGuid
                    },
                    new TaskDetailsTask {
                        TaskName = "Task 2", TaskWork = 20000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = Guid.NewGuid(), ProjUid = ProjectGuid
                    },
                    new TaskDetailsTask {
                        TaskName = "Task 3", TaskWork = 30000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = Guid.NewGuid(), ProjUid = ProjectGuid
                    },
                }
            };

            var projectTeamResource = new TaskDetailsProjectTeamResource
            {
                ResUid    = ResGuid,
                ProjUid   = ProjectGuid,
                NewResUid = ResGuid
            };

            var assn = new TaskDetailsAssignment
            {
                AssnUid = AssnGuid,
                ResUid  = ResGuid,
                ProjUid = ProjectGuid,
                TaskUid = TaskGuid
            };


            var projectCreateDs = new ProjectDataSet();

            Mapper.Map(project, projectCreateDs.Project);
            Mapper.Map(project.Tasks, projectCreateDs.Task);

            var projectTeamDs = new ProjectTeamDataSet();

            Mapper.Map(projectTeamResource, projectTeamDs.ProjectTeam);

            var projectAssnDs = new ProjectDataSet();

            Mapper.Map(assn, projectAssnDs.Assignment);

            var createProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueueCreateProjectAndCheckOut(createProjectJobUid, SessionGuid, "Unit tests session", projectCreateDs, false));
            _envUtil.Wait(createProjectJobUid);

            var updateProjectTeamJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueueUpdateProjectTeam(updateProjectTeamJobUid, SessionGuid, ProjectGuid, projectTeamDs));
            _envUtil.Wait(updateProjectTeamJobUid);

            //Describe common error : GeneralOnlyInsertsAllowed
            //https://social.msdn.microsoft.com/Forums/en-US/f6cd2eee-3748-47c1-b199-61872b9288b0/im-getting-error-generalonlyinsertsallowed-when-trying-to-add-a-new-task-to-a-project?forum=project2010custprog
            var assnUpdateJobUid = Guid.NewGuid();

            _projectService.Invoke(s => s.QueueAddToProject(assnUpdateJobUid, SessionGuid, projectAssnDs, false));
            _envUtil.Wait(assnUpdateJobUid);

            var checkInProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueueCheckInProject(checkInProjectJobUid, ProjectGuid, false, SessionGuid, "Unit tests session"));
            _envUtil.Wait(checkInProjectJobUid);

            var publishProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueuePublish(publishProjectJobUid, ProjectGuid, true, string.Empty));
            _envUtil.Wait(publishProjectJobUid);

            var publishSummaryProjectJobUid = Guid.NewGuid();

            _projectService.Invoke(p => p.QueuePublishSummary(publishSummaryProjectJobUid, ProjectGuid));
            _envUtil.Wait(publishSummaryProjectJobUid);
        }