public ActionResult SmaCertificate(string approval_id)
        {
            if (approval_id != null)
            {
                dynamic _param = new ExpandoObject();
                _param.approval_id = approval_id;

                var _client = new HttpClient();
                _client.BaseAddress = new Uri("http://server-erp2.sma.gov.jm:1786/api/data/");
                _client.DefaultRequestHeaders.Accept.Clear();
                _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var _content = new StringContent(JsonConvert.SerializeObject(_param), Encoding.UTF8, "application/json");
                HttpResponseMessage _response = _client.PostAsync("GetSmaCertificate", _content).Result;
                if (_response.IsSuccessStatusCode)
                {
                    string             result      = _response.Content.ReadAsStringAsync().Result;
                    Models.Certificate certificate = JsonConvert.DeserializeObject <Models.Certificate>(result);
                    return(View(certificate));
                }
                else
                {
                    Models.Certificate certificate = new Models.Certificate();
                    return(View(certificate.GetDefaultSample()));
                }
            }
            else
            {
                Models.Certificate certificate = new Models.Certificate();
                return(View(certificate.GetDefaultSample()));
            }
        }
示例#2
0
        public Models.Certificate FetchCertificateForExam(LIM.Exam.Models.Exam azureExam)
        {
            Models.Certificate inst_report = FetchCertificatetByID(azureExam.ID);

            if (inst_report == null)
            {
                return(null);
            }

            inst_report.Path = Path.Combine(this._ContentRootPath, inst_report.Path);

            using (LocalReport rpt = new LocalReport()
            {
                ReportPath = inst_report.Path,
                DisplayName = inst_report.Title
            })
            {
                rpt.SetParameters(new ReportParameter()
                {
                    Name = "Name", Values = { azureExam.TakerName }
                });

                inst_report.FileName = (azureExam.TakerName + " " + rpt.DisplayName).Replace(" ", ".").Replace("/", ".") + ".pdf";

                inst_report.FileContents = rpt.Render("pdf");
            }

            return(inst_report);
        }
示例#3
0
        public byte[] FetchZipOfCertificatesForUsers(int intRptID, string[] arrNames)
        {
            byte[] compressedBytes = null;

            Models.Certificate inst_report = FetchCertificatetByID(intRptID);

            if (inst_report == null)
            {
                return(compressedBytes);
            }

            inst_report.Path = Path.Combine(_ContentRootPath, inst_report.Path);

            //====================================

            using (LocalReport rpt = new LocalReport()
            {
                ReportPath = inst_report.Path,
                DisplayName = inst_report.Title
            })
                using (MemoryStream zipStream = new MemoryStream())
                {
                    using (System.IO.Compression.ZipArchive zip = new System.IO.Compression.ZipArchive(zipStream, System.IO.Compression.ZipArchiveMode.Create, true))
                    {
                        foreach (string strName in arrNames)
                        {
                            rpt.SetParameters(new ReportParameter()
                            {
                                Name = "Name", Values = { strName }
                            });

                            string strFileName = (strName + " " + rpt.DisplayName).Replace(" ", ".").Replace("/", ".") + ".pdf";

                            System.IO.Compression.ZipArchiveEntry entry = zip.CreateEntry(strFileName.ToLower());

                            using (Stream entryStream = entry.Open())
                                using (MemoryStream rptStream = new MemoryStream(rpt.Render("pdf")))
                                {
                                    rptStream.CopyTo(entryStream);
                                }
                        }
                    }

                    compressedBytes = zipStream.ToArray();
                }

            return(compressedBytes);
        }
示例#4
0
 public void GetPDF()
 {
     Models.Certificate cert = new Models.Certificate();
     cert.GenerateDocument();
 }