public async Task <IHttpActionResult> Create(Guid activityTemplateId, string label = null, string name = null, int?order = null, Guid?parentNodeId = null, Guid?authorizationTokenId = null)
        {
            using (var uow = _uowFactory.Create())
            {
                if (parentNodeId != null && _planService.IsPlanActiveOrExecuting(parentNodeId.Value))
                {
                    return(new LockedHttpActionResult());
                }
                if (!_activityTemplateService.Exists(activityTemplateId))
                {
                    return(BadRequest("Activity template doesn't exist"));
                }
                ;
                var userId = User.Identity.GetUserId();
                var result = await _activityService.CreateAndConfigure(uow, userId, activityTemplateId, label, name, order, parentNodeId, !parentNodeId.HasValue, authorizationTokenId) as ActivityDO;

                return(Ok(Mapper.Map <ActivityDTO>(result)));
            }
        }
Esempio n. 2
0
        private async Task <IHttpActionResult> CreateSolution(string solutionName)
        {
            var userId = User.Identity.GetUserId();

            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                ActivityTemplateDO activityTemplate;

                var activityTemplateInfo = _activityTemplate.GetActivityTemplateInfo(solutionName);

                if (!string.IsNullOrEmpty(activityTemplateInfo.Version))
                {
                    activityTemplate = _activityTemplate
                                       .GetQuery()
                                       .FirstOrDefault(x => x.Name == activityTemplateInfo.Name && x.Version == activityTemplateInfo.Version);
                }
                else
                {
                    activityTemplate = _activityTemplate.GetQuery()
                                       .Where(x => x.Name == solutionName)
                                       .AsEnumerable()
                                       .OrderByDescending(x => int.Parse(x.Version))
                                       .FirstOrDefault();
                }
                if (activityTemplate == null)
                {
                    throw new MissingObjectException($"Activity template (solution) name {solutionName} doesn't exist");
                }
                ObjectFactory.GetInstance <ITracker>().Track(_security.GetCurrentAccount(uow), "Loaded Solution", new Segment.Model.Properties().Add("Solution Name", solutionName));
                var result = await _activity.CreateAndConfigure(
                    uow,
                    userId,
                    activityTemplate.Id,
                    name : activityTemplate.Label,
                    createPlan : true);

                return(Ok(PlanMappingHelper.MapPlanToDto((PlanDO)result)));
            }
        }
Esempio n. 3
0
 public Task <PlanNodeDO> CreateAndConfigure(IUnitOfWork uow, string userId, Guid activityTemplateId, string label = null, string name = null, int?order = null, Guid?parentNodeId = null, bool createPlan = false, Guid?authorizationTokenId = null, PlanVisibility newPlanVisibility = PlanVisibility.Standard)
 {
     return(_activity.CreateAndConfigure(uow, userId, activityTemplateId, label, name, order, parentNodeId, createPlan, authorizationTokenId, newPlanVisibility));
 }
        private async Task ConfigureSaveJiraActivity(IUnitOfWork uow, Fr8AccountDO systemUser, ActivityTemplateDO[] activityTemplates, Guid planId)
        {
            var saveJiraTemplate = activityTemplates.FirstOrDefault(x => x.Name == "Save_Jira_Issue" && x.Version == "1" && x.Terminal.Name == "terminalAtlassian");

            if (saveJiraTemplate == null)
            {
                throw new ApplicationException("Save Jira Issue v1 activity template was not found in Atlassian terminal");
            }
            var saveJiraActivity = await _activity.CreateAndConfigure(uow, systemUser.Id, saveJiraTemplate.Id, saveJiraTemplate.Label, saveJiraTemplate.Label, 3, planId).ConfigureAwait(false) as ActivityDO;

            using (var storage = _crateManager.GetUpdatableStorage(saveJiraActivity))
            {
                var controls = storage.CrateContentsOfType <StandardConfigurationControlsCM>().SingleOrDefault();
                if (controls == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain controls crate");
                }
                var projectSelector = controls.FindByName <DropDownList>("AvailableProjects");
                if (projectSelector == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain project selector");
                }
                projectSelector.SelectByKey("fr8test");
            }
            saveJiraActivity = Mapper.Map <ActivityDO>(await _activity.Configure(uow, systemUser.Id, saveJiraActivity).ConfigureAwait(false));
            using (var storage = _crateManager.GetUpdatableStorage(saveJiraActivity))
            {
                var controls          = storage.CrateContentsOfType <StandardConfigurationControlsCM>().SingleOrDefault();
                var issueTypeSelector = controls.FindByName <DropDownList>("AvailableIssueTypes");
                if (issueTypeSelector == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain issue type selector");
                }
                issueTypeSelector.SelectByKey("Task");
            }
            saveJiraActivity = Mapper.Map <ActivityDO>(await _activity.Configure(uow, systemUser.Id, saveJiraActivity).ConfigureAwait(false));
            using (var storage = _crateManager.GetUpdatableStorage(saveJiraActivity))
            {
                var controls         = storage.CrateContentsOfType <StandardConfigurationControlsCM>().SingleOrDefault();
                var prioritySelector = controls.FindByName <DropDownList>("AvailablePriorities");
                if (prioritySelector == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain priority selector");
                }
                prioritySelector.SelectByKey("Normal");
                var assigneeSelector = controls.FindByName <DropDownList>("Asignee");
                if (assigneeSelector == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain asignee selector");
                }
                assigneeSelector.SelectByValue("admin");
                var summary = controls.FindByName <TextSource>("SummaryTextSource");
                if (summary == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain summary field");
                }
                summary.ValueSource = TextSource.SpecificValueSource;
                summary.TextValue   = "New Manifest Submission";
                var description = controls.FindByName <TextSource>("DescriptionTextSource");
                if (description == null)
                {
                    throw new ApplicationException("Save Jira Issue doesn't contain description field");
                }
                description.ValueSource  = TextSource.UpstreamValueSrouce;
                description.SelectedItem = new FieldDTO(MessageName);
                description.selectedKey  = MessageName;
            }
            await _activity.Configure(uow, systemUser.Id, saveJiraActivity).ConfigureAwait(false);
        }