Esempio n. 1
0
        public Scoring(Models.Assessment.Assessment assessment)
        {
            ResponseId = assessment.ResponseId;
            FirstName = GetAnswerValue(assessment, QuestionCache.FirstNameQuestionNo);
            LastName = GetAnswerValue(assessment, QuestionCache.LastNameQuestionNo);
            CompanyName = GetAnswerValue(assessment, QuestionCache.CompanyQuestionNo);
            Email = GetAnswerValue(assessment, QuestionCache.EmailQuestionNo);

            var _repo = new AssessmentRepo();
            long choiceId = 0;

            choiceId = GetAnswerChoiceId(assessment, QuestionCache.IndustryQuestionNo);
            Industry = _repo.GetAnswerChoiceName(choiceId);

            choiceId = GetAnswerChoiceId(assessment, QuestionCache.OrgSizeQuestionNo);
            OrgSize = _repo.GetAnswerChoiceName(choiceId);

            choiceId = GetAnswerChoiceId(assessment, QuestionCache.CountryQuestionNo);
            Location = _repo.GetAnswerChoiceName(choiceId);
        }
        private void DownloadPdfReport(int responseId)
        {
            try
            {
                var db = new AssessmentRepo();
                var model = db.GetAnswers(QuestionCache.AssessmentName, _cultureName, responseId);
                var scoringModel = new ScoringModel();
                var report = scoringModel.GetReport(model);

                using (var ms = new System.IO.MemoryStream())
                {
                    // create report
                    var pdf = new PdfReport();
                    pdf.GenerateReport(report, ms, null);

                    // Send response to browser
                    Response.Clear();
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    //HttpContext.Current.Response.ContentType = "pdf/application";                                       // Causes the pdf file to download rather than display in browser
                    Response.ContentType = "application/pdf";                                                             // Causes the pdf file to display directly in browser
                    Response.AddHeader("content-disposition", "inline;filename=\"" + SmtpMail.ReportFilename + "\"");   // Filename is required if downloading rather than displaying pdf
                    Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
                    Response.Flush();
                    Response.End();
                    Response.Close();
                }
            }
            catch (Exception e)
            {
                Logger.Log(LogLevel.Error, e.Message);
            }
        }