Exemplo n.º 1
0
 public EnvUtil(Uri pwaUri)
 {
     _mapper                 = new FluentMapper(new PsMappingConfiguration());
     _projectPsiService      = PsiContext.Get <IProject>(pwaUri);
     _statusingPsiService    = PsiContext.Get <IStatusing>(pwaUri);
     _resourcePsiService     = PsiContext.Get <IResource>(pwaUri);
     _customFieldsPsiService = PsiContext.Get <ICustomFields>(pwaUri);
     _queuePsiService        = PsiContext.Get <IQueueSystem>(pwaUri);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Get service for given pwa uri.
        /// </summary>
        /// <typeparam name="TService">Interface of the service. Can be IProject, IResource, IQueueSystem etc.</typeparam>
        /// <param name="pwaUri">The Project Web App uri, should have slash at the end, for example http://server/pwa/. </param>
        /// <example>
        /// var projectService = PsiContext.Get&lt;IProject&gt;(new Uri("http://server/pwa/"));
        /// var projectDs = projectService.Invoke(p => p.ReadProjectList());
        /// </example>
        /// <returns>PsiService instance.</returns>
        public static PsiService <TService> Get <TService>(Uri pwaUri)
        {
            var channelType = typeof(TService);

            Trace.TraceInformation("PsiService<{0}> for url {1} requested.", channelType.Name, pwaUri);
            if (!CachedServices.ContainsKey(pwaUri))
            {
                Trace.TraceInformation("No Psi services for url {0} found in cache. Create a new entry.", pwaUri);
                CachedServices.Add(pwaUri, new Dictionary <Type, object>());
            }

            var entry = CachedServices[pwaUri];

            if (!entry.ContainsKey(channelType))
            {
                Trace.TraceInformation("PsiService<{0}> for url {1} not found in cache. Create a new PsiService<{0}> and add it to cache.", channelType.Name, pwaUri);
                var psiService = new PsiService <TService>(pwaUri);
                entry.Add(channelType, psiService);
                return(psiService);
            }

            Trace.TraceInformation("PsiContext for endpoint {0} returned from cache.", pwaUri);
            return(entry[channelType] as PsiService <TService>);
        }
        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 cfs = new List <BasicProjectCustomField>
            {
                new BasicProjectCustomField
                {
                    MdPropUid      = Guid.NewGuid(),
                    MdPropName     = "Test - Project - Text",
                    MdEntTypeUid   = PsEntityType.Project.GetAttr <GuidAttribute>().Guid,
                    MdPropTypeEnum = PsDataType.String
                },

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

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

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

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

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

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

            _envUtil.CreateCustomFields(cfs);

            var simpleProject = new BasicProject
            {
                ProjUid              = Settings.DefaultProjectGuid,
                ProjName             = Settings.DefaultProjectName,
                ProjType             = (int)ProjectType.Project,
                WprojDescription     = Settings.DefaultProjectName,
                TestProjectText      = "10",
                TestProjectNumber    = 20,
                TestProjectCost      = 3000,
                TestProjectDuration  = 4000,
                TestProjectDate      = DateTime.Parse("1991-02-16", CultureInfo.InvariantCulture),
                TestProjectYesNoTrue = true
            };

            _envUtil.CreateProject(simpleProject);
        }
        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);
        }
Exemplo n.º 5
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);
        }