コード例 #1
0
        public async Task <IHttpActionResult> Post()
        {
            FileDO fileDO = null;

            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var currentUserId = _security.GetCurrentUser();

                await Request.Content.ReadAsMultipartAsync(new MultipartMemoryStreamProvider()).ContinueWith(tsk =>
                {
                    var prvdr = tsk.Result;

                    foreach (HttpContent ctnt in prvdr.Contents)
                    {
                        Stream stream = ctnt.ReadAsStreamAsync().Result;
                        var fileName  = ctnt.Headers.ContentDisposition.FileName.Replace("\"", string.Empty);
                        fileDO        = new FileDO
                        {
                            DockyardAccountID = currentUserId
                        };


                        _fileService.Store(uow, fileDO, stream, fileName);
                    }
                });

                return(Ok(fileDO));
            }
        }
コード例 #2
0
        public IHttpActionResult CheckPermission(string userId, PermissionType permissionType, string objectType)
        {
            // Check that the correct userid is supplied.
            // We need User to provide User Id in order to return the correct cached value.
            // Otherwise all users would receive the same cached value.
            if (userId != _securityServices.GetCurrentUser())
            {
                return(BadRequest("User Id does not correspond to the current user identity."));
            }

            return(Ok(_securityServices.UserHasPermission(permissionType, objectType)));
        }
コード例 #3
0
ファイル: Plan.cs プロジェクト: patel-pragnesh/fr8core-dev
        public void CreateOrUpdate(IUnitOfWork uow, PlanDO submittedPlan)
        {
            if (submittedPlan.Id == Guid.Empty)
            {
                submittedPlan.Id         = Guid.NewGuid();
                submittedPlan.PlanState  = PlanState.Inactive;
                submittedPlan.Fr8Account = _security.GetCurrentAccount(uow);
                if (string.IsNullOrEmpty(submittedPlan.Name))
                {
                    submittedPlan.Name = "Untitled Plan " + (UserPlansCount(uow, _security.GetCurrentUser()) + 1);
                }

                submittedPlan.ChildNodes.Add(new SubplanDO(true)
                {
                    Id   = Guid.NewGuid(),
                    Name = "Starting Subplan"
                });

                uow.PlanRepository.Add(submittedPlan);
            }
            else
            {
                var curPlan = uow.PlanRepository.GetById <PlanDO>(submittedPlan.Id);
                if (curPlan == null)
                {
                    throw new EntityNotFoundException();
                }

                curPlan.Name         = submittedPlan.Name;
                curPlan.Description  = submittedPlan.Description;
                curPlan.Category     = submittedPlan.Category;
                curPlan.LastUpdated  = DateTimeOffset.UtcNow;
                curPlan.IsApp        = submittedPlan.IsApp;
                curPlan.AppLaunchURL = submittedPlan.AppLaunchURL;
            }
        }
コード例 #4
0
        public async Task <IHttpActionResult> RunMonitoring()
        {
            //We don't need to wait for the result as the purpose of this method is just to initiate a start (as a double-check measure)
            var currentUser = _securityServices.GetCurrentUser();

            _pusher.NotifyUser(new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericInfo,
                Subject          = "Manifest Registry Monitoring",
                Message          = "Preparing to launch manifest registry monitoring...",
                Collapsed        = false
            }, currentUser);
            var resultNotification = new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericSuccess,
                Subject          = "Manifest Registry Monitoring",
                Collapsed        = true
            };
            ManifestRegistryMonitorResult result;

            try
            {
                result = await _manifestRegistryMonitor.StartMonitoringManifestRegistrySubmissions();

                resultNotification.Message = result.IsNewPlan
                    ? $"New plan with Id {result.PlanId} was created and started to monitor manifest registry"
                    : $"An existing plan with Id {result.PlanId} was used to monitor manifest registry";
            }
            catch (Exception ex)
            {
                resultNotification.NotificationType = NotificationType.GenericFailure;
                resultNotification.Message          = $"Failed to manually start manifest registry monitoring. Reason - {ex.Message}. See incidents and error logs for more details";
                Logger.GetLogger().Error("Failed to manually start manifest registry monitoring", ex);
                throw;
            }
            finally
            {
                _pusher.NotifyUser(resultNotification, currentUser);
            }
            return(Ok());
        }
コード例 #5
0
        private void UnexpectedError(Exception ex)
        {
            var incident = new IncidentDO
            {
                Fr8UserId = _sercurity.GetCurrentUser(),
                Data      = string.Join(
                    "Unexpected error: ",
                    ex.Message,
                    ex.StackTrace ?? ""
                    ),
                PrimaryCategory   = "Terminal",
                SecondaryCategory = "Authentication",
                Component         = "Hub",
                Activity          = "Unexpected Error"
            };

            SaveAndLogIncident(incident);
        }
コード例 #6
0
        private void ActivityResponseReceived(ActivityDO activityDo, ActivityResponse responseType)
        {
            var template = _activityTemplate.GetByKey(activityDo.ActivityTemplateId);

            var factDO = new FactDO()
            {
                PrimaryCategory   = "Container",
                SecondaryCategory = "Activity",
                Activity          = "Process Execution",
                Status            = responseType.ToString(),
                ObjectId          = activityDo.Id.ToString(),
                Fr8UserId         = _security.GetCurrentUser(),
                CreatedByID       = _security.GetCurrentUser(),
                Data = string.Join(Environment.NewLine, "Activity Name: " + template?.Name)
            };

            SaveAndLogFact(factDO);
        }