예제 #1
0
        public async Task <IEnumerable <PlanDTO> > GetPlansByName(string name, PlanVisibility visibility = PlanVisibility.Standard)
        {
            var url = $"{GetHubUrlWithApiVersion()}/plans?name={name}&visibility={visibility}";
            var uri = new Uri(url);

            return(await _restfulServiceClient.GetAsync <IEnumerable <PlanDTO> >(uri, null, await GetHMACHeader(uri)));
        }
예제 #2
0
 private IHttpActionResult GetByName(string name, PlanVisibility visibility = PlanVisibility.Standard)
 {
     using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
     {
         var curPlans  = _plan.GetByName(uow, _security.GetCurrentAccount(uow), name, visibility);
         var fullPlans = curPlans.Select(curPlan => PlanMappingHelper.MapPlanToDto(curPlan)).ToList();
         return(Ok(fullPlans));
     }
 }
예제 #3
0
        public static bool BooleanValue(this PlanVisibility value)
        {
            switch (value)
            {
            case PlanVisibility.Internal: return(true);

            case PlanVisibility.Standard: return(false);

            default: throw new ArgumentOutOfRangeException("value");
            }
        }
예제 #4
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));
 }
예제 #5
0
 public PlanDO Create(IUnitOfWork uow, string name, string category = "", string ownerId = "", PlanVisibility visibility = PlanVisibility.Standard)
 {
     //TODO: probably worth add a check that only admin can create plan with specific owner Id and internal plan visibility
     return(_target.Create(uow, name, category, ownerId, visibility));
 }
예제 #6
0
 public IList <PlanDO> GetByName(IUnitOfWork uow, Fr8AccountDO account, string name, PlanVisibility visibility)
 {
     return(_target.GetByName(uow, account, name, visibility));
 }
예제 #7
0
        public PlanDO Create(IUnitOfWork uow, string name, string category = "", string ownerId = "", PlanVisibility visibility = PlanVisibility.Standard)
        {
            var plan = new PlanDO
            {
                Id         = Guid.NewGuid(),
                Name       = name,
                Fr8Account = string.IsNullOrEmpty(ownerId) ? _security.GetCurrentAccount(uow) : uow.UserRepository.FindOne(x => x.Id == ownerId),
                PlanState  = PlanState.Inactive,
                Visibility = visibility,
                Category   = category
            };

            uow.PlanRepository.Add(plan);
            return(plan);
        }
예제 #8
0
        public IList <PlanDO> GetByName(IUnitOfWork uow, Fr8AccountDO account, string name, PlanVisibility visibility)
        {
            if (name != null)
            {
                return
                    (uow.PlanRepository.GetPlanQueryUncached()
                     .Where(r => r.Fr8Account.Id == account.Id && r.Name == name)
                     .Where(p => p.PlanState != PlanState.Deleted && p.Visibility == visibility)
                     .ToList());
            }

            return
                (uow.PlanRepository.GetPlanQueryUncached()
                 .Where(r => r.Fr8Account.Id == account.Id)
                 .Where(p => p.PlanState != PlanState.Deleted && p.Visibility == visibility)
                 .ToList());
        }
 public Task <IEnumerable <PlanDTO> > GetPlansByName(string name, PlanVisibility visibility = PlanVisibility.Standard)
 {
     throw new NotImplementedException();
 }
예제 #10
0
        public async 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)
        {
            if (parentNodeId != null && createPlan)
            {
                throw new ArgumentException("Parent node id can't be set together with create plan flag");
            }

            if (parentNodeId == null && !createPlan)
            {
                throw new ArgumentException("Either Parent node id or create plan flag must be set");
            }

            // to avoid null pointer exception while creating parent node if label is null
            if (name == null)
            {
                name = userId + "_" + activityTemplateId;
            }

            PlanNodeDO parentNode;
            PlanDO     plan = null;

            if (createPlan)
            {
                plan = ObjectFactory.GetInstance <IPlan>().Create(uow, name, ownerId: userId, visibility: newPlanVisibility);

                plan.ChildNodes.Add(parentNode = new SubplanDO
                {
                    StartingSubPlan = true,
                    Name            = name + " #1"
                });
            }
            else
            {
                parentNode = uow.PlanRepository.GetById <PlanNodeDO>(parentNodeId);

                if (parentNode is PlanDO)
                {
                    if (((PlanDO)parentNode).StartingSubplan == null)
                    {
                        parentNode.ChildNodes.Add(parentNode = new SubplanDO
                        {
                            StartingSubPlan = true,
                            Name            = name + " #1"
                        });
                    }
                    else
                    {
                        parentNode = ((PlanDO)parentNode).StartingSubplan;
                    }
                }
            }

            var activity = new ActivityDO
            {
                Id = Guid.NewGuid(),
                ActivityTemplateId   = activityTemplateId,
                CrateStorage         = _crateManager.EmptyStorageAsStr(),
                AuthorizationTokenId = authorizationTokenId
            };

            parentNode.AddChild(activity, order);

            uow.SaveChanges();

            var configuredActivity = await CallActivityConfigure(uow, userId, activity);

            UpdateActivityProperties(uow, configuredActivity);

            if (createPlan)
            {
                return(plan);
            }

            return(activity);
        }
 public Task <IEnumerable <PlanDTO> > GetPlansByName(string name, PlanVisibility visibility = PlanVisibility.Standard)
 {
     throw new NotImplementedException("Terminals can't communicate with an unknown hub");
 }