Beispiel #1
0
        public ActionResult DownloadResume(Guid fileReferenceId)
        {
            try
            {
                var member = CurrentMember;

                // Make sure the file is on of the member's resume files.

                var resumeFileReference = _candidateResumeFilesQuery.GetResumeFile(member.Id, fileReferenceId);
                if (resumeFileReference == null)
                {
                    return(HttpNotFound());
                }

                var fileReference = _filesQuery.GetFileReference(fileReferenceId);
                if (fileReference == null)
                {
                    return(HttpNotFound());
                }

                return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType, fileReference.FileName));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View("Error"));
        }
        public ActionResult Photo(Guid candidateId)
        {
            // Get the employer.

            var employer = CurrentEmployer;

            // Get the view to the member.

            var view = _employerMemberViewsQuery.GetProfessionalView(employer, candidateId);

            if (view.PhotoId == null)
            {
                return(HttpNotFound());
            }

            // Return the file.

            var fileReference = _filesQuery.GetFileReference(view.PhotoId.Value);

            if (fileReference == null)
            {
                return(HttpNotFound());
            }

            return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType));
        }
Beispiel #3
0
        private ActionResult GetResumeFile(Guid fileId)
        {
            const string method = "Resume";

            try
            {
                // Look for the file first.

                var file = _filesQuery.GetFileReference(fileId);
                if (file == null || file.FileData.FileType != FileType.Resume)
                {
                    return(HttpNotFound());
                }

                // Authenticate.

                _serviceAuthenticationManager.AuthenticateRequest(HttpContext, IntegratorPermissions.GetJobApplication);

                return(File(_filesQuery.OpenFile(file), file.MediaType, file.FileName));
            }
            catch (Exception ex)
            {
                EventSource.Raise(Event.Error, method, "Cannot process the request.", ex, new StandardErrorHandler());
                return(new TextResult("Error: " + ex.Message));
            }
        }
Beispiel #4
0
 protected string OpenFile(FileReference fileReference)
 {
     using (var stream = _filesQuery.OpenFile(fileReference))
     {
         var reader = new StreamReader(stream);
         return(reader.ReadToEnd());
     }
 }
Beispiel #5
0
        private void SendEmailWithResumeFile(InternalApplication application, ICommunicationUser member, JobAd jobAd)
        {
            var fileReference = _filesQuery.GetFileReference(application.ResumeFileId.Value);
            var stream        = _filesQuery.OpenFile(fileReference);

            // Send the email.

            _emailsCommand.TrySend(new JobApplicationEmail(member, application, jobAd, stream, fileReference.FileName));
        }
        private void SendResumeFile(InternalApplication application, ICommunicationUser member, JobAdEntry jobAd, IEnumerable <ApplicationAnswer> answers)
        {
            // Open the file and send it.

            var resumeFileReference = _filesQuery.GetFileReference(application.ResumeFileId.Value);

            using (var stream = _filesQuery.OpenFile(resumeFileReference))
            {
                _sendJobG8Command.SendApplication(member, jobAd, resumeFileReference.FileName, new StreamFileContents(stream), application, answers);
            }
        }
Beispiel #7
0
        private void AddAttachments(TemplateEmail email, ICollection <FileReference> fileReferences)
        {
            if (fileReferences != null && fileReferences.Count > 0)
            {
                var attachments = new List <CommunicationAttachment>();
                foreach (var fileReference in fileReferences)
                {
                    var stream = _filesQuery.OpenFile(fileReference);
                    attachments.Add(new ContentAttachment(stream, fileReference.FileName, MediaType.GetMediaTypeFromExtension(Path.GetExtension(fileReference.FileName), MediaType.Text)));
                }

                email.AddAttachments(attachments);
            }
        }
Beispiel #8
0
        public ActionResult Photo(Guid id)
        {
            // Get the file reference.

            var file = _filesQuery.GetFileReference(id);

            if (file == null)
            {
                return(HttpNotFound());
            }

            // Write the file out.

            return(File(_filesQuery.OpenFile(file), file.MediaType));
        }
Beispiel #9
0
        public ActionResult Logo(Guid fileId)
        {
            // Look for the file.
            // No checks are made etc to determine whether the current user uploaded the logo.

            var fileReference = _filesQuery.GetFileReference(fileId);

            if (fileReference == null || fileReference.FileData.FileType != FileType.CompanyLogo)
            {
                return(HttpNotFound());
            }

            // Return the file.

            return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType));
        }
Beispiel #10
0
        protected static void WriteFileToOutput(HttpContext context, FileReference file, bool asAttachment)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            using (var fileStream = _filesQuery.OpenFile(file))
            {
                context.Response.Clear();
                HttpHelper.SetResponseToFileDownload(context.Response, (asAttachment ? file.FileName : null), file.MediaType, fileStream.Length);
                StreamHelper.CopyStream(fileStream, context.Response.OutputStream);
            }
        }
Beispiel #11
0
        public ActionResult Logo(Guid jobAdId)
        {
            var jobAd = _jobAdsQuery.GetJobAd <JobAd>(jobAdId);

            if (jobAd == null || jobAd.LogoId == null || !jobAd.Features.IsFlagSet(JobAdFeatures.Logo))
            {
                return(HttpNotFound());
            }

            var fileReference = _filesQuery.GetFileReference(jobAd.LogoId.Value);

            if (fileReference == null || fileReference.FileData.FileType != FileType.CompanyLogo)
            {
                return(HttpNotFound());
            }

            // Return the file.

            return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType));
        }
Beispiel #12
0
        public ActionResult Photo(Guid friendId)
        {
            var friend = _membersQuery.GetMember(friendId);

            if (friend == null || friend.PhotoId == null)
            {
                return(HttpNotFound());
            }

            var fileReference = _filesQuery.GetFileReference(friend.PhotoId.Value);

            if (fileReference == null || fileReference.FileData.FileType != FileType.ProfilePhoto)
            {
                return(HttpNotFound());
            }

            // Return the file.

            return(File(_filesQuery.OpenFile(fileReference), fileReference.MediaType));
        }
Beispiel #13
0
        public ActionResult Parse(Guid fileReferenceId)
        {
            Guid?parsedResumeId = null;

            try
            {
                // Load the resume.

                var fileReference = _filesQuery.GetFileReference(fileReferenceId);
                if (fileReference == null)
                {
                    return(JsonNotFound("file"));
                }

                var stream       = _filesQuery.OpenFile(fileReference);
                var parsedResume = _parseResumesCommand.ParseResume(stream, fileReference.FileName);

                // Save the parsed resume.

                _parsedResumesCommand.CreateParsedResume(parsedResume);
                parsedResumeId = parsedResume.Id;

                if (parsedResume.Resume == null || parsedResume.Resume.IsEmpty)
                {
                    throw new InvalidResumeException();
                }
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonParsedResumeModel
            {
                Id = parsedResumeId,
            }));
        }
Beispiel #14
0
        ParsedResume IParseResumesCommand.ParseResume(FileReference fileReference)
        {
            var stream = _filesQuery.OpenFile(fileReference);

            return(ParseResume(GetByteData(stream), fileReference.FileName));
        }