Example #1
0
        /// <summary>
        /// Runs template to generate html with required data.
        /// </summary>
        /// <param name="templateId"></param>
        /// <returns></returns>
        public ViewModels.Template GenerateHtmlFromTemplate(int templateId, string mrn, int apptId)
        {
            Logger.Debug("GenerateHtmlFromTemplate: Start");
            Entities.HtmlTemplate _template = GetTemplate(templateId);
            string tempFileName             = Guid.NewGuid().ToString();
            string tempPath = HttpContext.Current.Server.MapPath(System.IO.Path.Combine(Constants.RAFilePath, "Temp"));

            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }

            string path = System.IO.Path.Combine(tempPath, tempFileName);

            System.IO.File.WriteAllText(path, _template.TemplateString);
            string finalHtml = CreateHtmlDocument(path, mrn, apptId);
            string tempFile  = System.IO.Path.GetTempFileName();

            try
            {
                // Task.Factory.StartNew(() => GeneratePdfFromHtml(finalHtml, tempFile));
                GeneratePdfFromHtml(finalHtml, tempFile);
                File.Delete(path);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            Logger.Debug("GenerateHtmlFromTemplate: End");
            return(new ViewModels.Template()
            {
                Id = templateId,
                FinalHtml = finalHtml,
                TemplateName = _template.TemplateName,
                PdfFilePath = tempFile,
                DownloadFileName = string.Format("{0}-{1}", apptId, mrn)
            });
        }
Example #2
0
 public Entities.HtmlTemplate InsertTemplate(Entities.HtmlTemplate template)
 {
     throw new NotImplementedException();
 }
Example #3
0
 public void Save(Entities.HtmlTemplate template)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public int UpdateHtmlTemplate(Entities.HtmlTemplate HtmlTemplate)
 {
     return(dbContext.HtmlTemplate.Update(HtmlTemplate));
 }
Example #5
0
 public void Insert(Entities.HtmlTemplate template)
 {
     dbContext.HtmlTemplate.Insert(template);
 }