public static string generateOutputFile(enumOutputType outputType, string strTemplate, StyleSheet Style, int SwitchID, enumSwitchType SwitchType) { try { clsClient client = new clsClient(HttpContext.Current.Session["requestclientid"].ToString()); switch (outputType) { case enumOutputType.PDF: string Path = HttpContext.Current.Server.MapPath("~/Output/PDF/"); string PDFPath = string.Format("{0}{1}_{2}_{3}_{4:yyyy-MM-dd}.pdf", Path, SwitchType.ToString(), (new clsIFA(int.Parse(HttpContext.Current.Session["ifaid"].ToString()))).propIFA_Name, client.propForename + " " + client.propSurname, DateTime.Now); using (clsPDF O = new clsPDF() { StyleSheet = Style }) { O.PageSetup(PageSize.LETTER, 40, 40, 30, 15); O.FromHTMLString(strTemplate); O.StartCreate(PDFPath); LogOutput(enumSwitchType.Portfolio, SwitchID, PDFPath, enumOutputType.PDF); } return(PDFPath); default: return(""); } } catch (System.Net.Mail.SmtpException SE) { throw new clsOutputException(SE.Message, SE); } catch (Exception ex) { throw new clsOutputException(ex.Message, ex); } }
public static string generateOutputFile(enumOutputType outputType,string strTemplate, StyleSheet Style,int SwitchID,enumSwitchType SwitchType) { try { clsClient client = new clsClient(HttpContext.Current.Session["requestclientid"].ToString()); switch (outputType) { case enumOutputType.PDF: string Path = HttpContext.Current.Server.MapPath("~/Output/PDF/"); string PDFPath = string.Format("{0}{1}_{2}_{3}_{4:yyyy-MM-dd}.pdf", Path, SwitchType.ToString(), (new clsIFA(int.Parse(HttpContext.Current.Session["ifaid"].ToString()))).propIFA_Name, client.propForename +" "+ client.propSurname, DateTime.Now); using (clsPDF O = new clsPDF(){StyleSheet = Style}) { O.PageSetup(PageSize.LETTER, 40, 40, 30, 15); O.FromHTMLString(strTemplate); O.StartCreate(PDFPath); LogOutput(enumSwitchType.Portfolio,SwitchID,PDFPath,enumOutputType.PDF); } return PDFPath; default: return ""; } } catch (System.Net.Mail.SmtpException SE) { throw new clsOutputException(SE.Message, SE); } catch (Exception ex) { throw new clsOutputException(ex.Message, ex); } }
private void assinarArquivo(FileInfo arquivoAssinar, ReleaseJucecProperties releaseJucec, ConfiguracaoProperties configApp) { clsPDF clsPDF = new clsPDF(); string xml = string.Empty; string idCertificadoNOde = string.Empty; try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(new clsCertificados { Licenca = this.pegaCodLicenca() }.ListarCertificadosPessoais()); if (string.IsNullOrEmpty(configApp.NomeCertificado)) { throw new Exception("Tag [nomeCertificado] não configurada no arquivo .config."); } log.escreveLog("Buscando Certificado" + "Nome do Certificado " + configApp.NomeCertificado, configApp); foreach (XmlNode xmlNode in xmlDocument.SelectNodes("//Certificado")) { log.escreveLog("XML Node: " + xmlNode.InnerText.ToUpper(), configApp); if (xmlNode.InnerText.ToUpper().Contains(configApp.NomeCertificado.ToUpper())) { idCertificadoNOde = xmlNode.SelectSingleNode("IDCertificado").FirstChild.InnerText; log.escreveLog(string.Format("Id do Certificado {0} encontrado para {1}:...", configApp.NomeCertificado.ToString(), idCertificadoNOde), configApp); break; } } if (string.IsNullOrEmpty(idCertificadoNOde)) { throw new Exception(string.Format("Certificado não encontrado nesta maquina [{0}]!.{1}É preciso existir um certificado válido para [{2}]", Environment.MachineName, Environment.NewLine, idCertificadoNOde)); } clsPDF.Licenca = this.pegaCodLicenca(); xml = clsPDF.Assinar(this.carregaXML(arquivoAssinar, idCertificadoNOde)); log.escreveLog("Aviso: " + xml.ToString(), configApp); log.escreveLog("Aviso: Caminho: " + arquivoAssinar.FullName, configApp); xmlDocument.LoadXml(xml); string xmlErro = xmlDocument.SelectSingleNode("//DeskSignerSDKPDF/CodErro").FirstChild.InnerText; if (xmlErro != "0") { log.escreveLog("Erro ao assinar o Arquivo " + this.traducaoErro(xmlErro).ToString(), configApp); } } catch (Exception ex) { log.escreveLog("Erro ao assinar o Arquivo " + ex.ToString(), configApp); throw ex; } finally { clsPDF = null; } }