public byte[] GetPdfTpuStampeBUS(string appCode, string stringa_id, int progAllegato, string pathFolder) { Comunicazioni com = SessionManager <Comunicazioni> .get(stringa_id); byte[] resp = null; if (com.ComAllegati != null && com.ComAllegati.Count != 0) { ComAllegato all = com.ComAllegati[progAllegato]; switch (all.AllegatoExt.ToUpper()) { case "PDF": resp = all.AllegatoFile; break; case "PRU": resp = GetPdfTpuStampeBUS(all.AllegatoTpu, all.AllegatoFile, pathFolder); break; default: break; } } return(resp); }
public static Attachment ConvertToAttachment(ComAllegato allegato) { Stream stream = new MemoryStream(allegato.AllegatoFile); Attachment attache = new Attachment(stream, allegato.AllegatoName); return(attache); }
public ComAllegatoType(ComAllegato a) : base(a) { if (a == null || a.IsValid == false) { this.m_IsNull = true; return; } this.m_ID_ALLEGATOIsNull = !a.IdAllegato.HasValue; this.m_REF_ID_COMIsNull = !a.RefIdCom.HasValue; if (a.FlgProtToUpl == AllegatoProtocolloStatus.UNKNOWN) { this.m_FLG_PROT_TO_UPL = ((int)AllegatoProtocolloStatus.FALSE).ToString(); } else { this.m_FLG_PROT_TO_UPL = ((int)a.FlgProtToUpl).ToString(); } if (a.FlgInsProt == AllegatoProtocolloStatus.UNKNOWN) { this.m_FLG_INS_PROT = ((int)AllegatoProtocolloStatus.FALSE).ToString(); } else { this.m_FLG_INS_PROT = ((int)a.FlgInsProt).ToString(); } }
/// <summary> /// Mappa un record su di un oggetto Nominativo. /// </summary> /// <param name="dr">datarecord</param> /// <remarks>RIVEDERE</remarks> /// <returns></returns> //internal static Nominativo MapToNominativo(IDataRecord dr, string keyField) //{ // Nominativo nr = (Nominativo)new NominativoFactory().CreateObject(); // nr.RubricaContatti = (Contatto)dr.GetValue("RUBR_CONTATTI"); // nr.RubricaEntita = (Entita)dr.GetValue("RUBR_ENTITA"); // nr.RubricaAddress = (Indirizzo)dr.GetValue("RUBR_ADDRESS"); // //nr.RubricaContatti.IdContact = (Int64)dr.GetDecimal(keyField); // //nr.RubricaContatti.Nome = dr.GetString("NOME"); // //nr.Cognome = dr.GetString("COGNOME"); // //nr.CodiceFiscale = dr.GetString("CODFIS"); // //nr.RagioneSociale = dr.GetString("RAGIONESOCIALE"); // //nr.Ufficio = dr.GetString("UFFICIO"); // //nr.PartitaIVA = dr.GetString("PIVA"); // //nr.Fax = dr.GetString("FAX"); // //nr.Mail = dr.GetString("MAIL"); // //nr.Telefono = dr.GetString("TELEFONO"); // ///* INDIRIZZO */ // //nr.Recapito = new Indirizzo(); // //nr.Recapito.Stato = dr.GetString("STATO"); // //nr.Recapito.Provincia = dr.GetString("PROVINCIA"); // //nr.Recapito.Citta = dr.GetString("CITTA"); // //nr.Recapito.Sedime = dr.GetString("SEDIME"); // //nr.Recapito.Via = dr.GetString("VIA"); // //nr.Recapito.Numero = (Int32)dr.GetDecimal("NUMERO"); // //nr.Recapito.Lettera = dr.GetString("LETTERA"); // //nr.Recapito.CAP = dr.GetString("CAP"); // return nr; //} internal static ComAllegato MapToAllegatoComunicazione(IDataRecord dr) { ComAllegato alleg = new ComAllegato(); if (dr.IsDBNull("ID_ALLEGATO")) { alleg.IdAllegato = null; } else { alleg.IdAllegato = dr.GetInt64("ID_ALLEGATO"); } if (dr.IsDBNull("REF_ID_COM")) { alleg.RefIdCom = null; } else { alleg.RefIdCom = dr.GetInt64("REF_ID_COM"); } alleg.AllegatoTpu = dr.GetString("ALLEGATO_TPU"); alleg.AllegatoFile = dr.GetBytes("ALLEGATO_FILE"); alleg.AllegatoExt = dr.GetString("ALLEGATO_EXT"); alleg.FlgInsProt = (AllegatoProtocolloStatus)int.Parse(dr.GetString("FLG_INS_PROT")); alleg.FlgProtToUpl = (AllegatoProtocolloStatus)int.Parse(dr.GetString("FLG_PROT_TO_UPL")); //alleg.ProtRef = dr.GetString("PROT_REF"); alleg.AllegatoName = dr.GetString("ALLEGATO_NAME"); return(alleg); }
public Mail GetMailByComId(string comId) { Mail mail = null; using (IMailMessageDao dao = this.getDaoContext().DaoImpl.MailMessageDao) { Message msg = dao.GetOutBoxMessageByComId(comId); if (msg != null) { mail = new Mail() { IdMail = msg.Id, MailSender = msg.From.Email, Subject = msg.Subject, MailText = msg.BodyHtml.Text, SendDate = msg.Date }; if (msg.To.Count > 0) { mail.Refs = new List <SendMail.Model.MailRefs>(); foreach (Address a in msg.To) { SendMail.Model.MailRefs mr = new SendMail.Model.MailRefs() { AddresseeMail = a.Email }; mail.Refs.Add(mr); } } if (msg.Attachments.Count > 0) { mail.Attachments = new List <ComAllegato>(); foreach (MimePart att in msg.Attachments) { ComAllegato ca = new ComAllegato { AllegatoName = att.Filename }; mail.Attachments.Add(ca); } } } } return(mail); }
protected void Button1_Click(object sender, EventArgs e) { try { Message msg; ComunicazioniService comunicazioniService = new ComunicazioniService(); if (MailMessageComposer.CurrentSendMailExist()) { msg = MailMessageComposer.CurrentSendMailGet(); } else { msg = new Message(); } msg.Subject = SubjectTextBox.Text; if (String.IsNullOrEmpty(ToTextBox.Text.Trim()) && String.IsNullOrEmpty(CCTextBox.Text.Trim()) && String.IsNullOrEmpty(BCCTextBox.Text.Trim())) { ErrorLabel.Text = "Inserire almeno un destinatario"; ErrorLabel.Visible = true; return; } msg.To.Clear(); msg.Cc.Clear(); msg.Bcc.Clear(); this.addEmailsTo(ToTextBox.Text, msg); this.addEmailsCc(CCTextBox.Text, msg); this.addEmailCcn(BCCTextBox.Text, msg); msg.Date = System.DateTime.Now; //mantengo il vecchio testo perché in caso di ErrorEventArgs lo devo ripristinare bodyBag = msg.BodyHtml.Text; SendMail.Model.BodyChunk bb = new SendMail.Model.BodyChunk(); string txt = BodyTextBox.Text; string[] lst = txt.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string l in lst) { bb.Line.Add(l); } //inserisco il testo libero in testa a quello preformattato HtmlNode newNode = null; if (bb.Line.Count != 0) { newNode = HtmlNode.CreateNode(bb.getAsHtml()); } HtmlDocument d = new HtmlDocument(); if (!String.IsNullOrEmpty(PreformattedBody.Text)) { d.LoadHtml(PreformattedBody.Text); } if (newNode != null) { if (d.DocumentNode.Descendants().Count() != 0) { HtmlNode root = d.DocumentNode.Descendants().SingleOrDefault(x => x.Name.Equals("body", StringComparison.InvariantCultureIgnoreCase)); if (root == null) { root = d.DocumentNode.Descendants().FirstOrDefault(x => x.NodeType == HtmlNodeType.Element); } if (root != null) { root.PrependChild(newNode); } else { d.DocumentNode.PrependChild(newNode); } } else { d.DocumentNode.PrependChild(newNode); } } msg.BodyHtml.Text = d.DocumentNode.InnerHtml; //se non sono inclusi gli allegati originali if (MailEditabile == true && cbIncludiAllegati.Checked == false) { for (int i = 0; i < msg.Attachments.Count; i++) { //rimuovo gli allegati originali if (msg.Attachments[i].ParentMessage != null) { msg.Attachments.RemoveAt(i); } } } foreach (MimePart mm in msg.Attachments) { if (mm.BinaryContent == null || mm.BinaryContent.Length < 10) { if (!String.IsNullOrEmpty(mm.ContentId)) { string idAttach = mm.ContentId.Trim(new char[] { '<', '>' }); long idAtt = -1; if (long.TryParse(idAttach, out idAtt)) { ComAllegato all = comunicazioniService .LoadAllegatoComunicazioneById(long.Parse(idAttach)); mm.BinaryContent = all.AllegatoFile; } } } } switch (CurrentAction) { case MailActions.REPLY_TO: case MailActions.REPLY_ALL: case MailActions.RE_SEND: case MailActions.FORWARD: msg.InReplyTo = msg.Id.ToString(); break; } ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = null; if (WebMailClientManager.AccountExist()) { mailUser = WebMailClientManager.getAccount(); } if (mailUser != null) { MailServerFacade f = MailServerFacade.GetInstance(mailUser); if (mailUser.IsManaged) { try { SendMail.Model.ComunicazioniMapping.Comunicazioni c = new SendMail.Model.ComunicazioniMapping.Comunicazioni( SendMail.Model.TipoCanale.MAIL, this.SottoTitolo, msg, MySecurityProvider.CurrentPrincipal.MyIdentity.UserName, 2, "O"); if (c.MailComunicazione.MailRefs != null && c.MailComunicazione.MailRefs.Count != 0) { c.RubricaEntitaUsed = (from cont in c.MailComunicazione.MailRefs select new SendMail.Model.ComunicazioniMapping.RubrEntitaUsed { Mail = cont.MailDestinatario, TipoContatto = cont.TipoRef }).ToList(); } comunicazioniService.InsertComunicazione(c); } catch (Exception ex) { ManagedException mex = new ManagedException("Errore nel salvataggio della mail", "MAIL_CMP_002", "", ex.StackTrace, ex); ErrorLog err = new ErrorLog(mex); _log.Error(err); ErrorLabel.Text = "Errore nell'invio del messaggio"; ErrorLabel.Visible = true; return; } } else { f.sendMail(msg); } (this.Page as BasePage).info.AddInfo("Il messaggio e' stato spedito correttamente"); MailMessageComposer.CurrentSendMailClear(); onMailSent(); } else { ((BasePage)this.Page).info.AddInfo("Account inesistente."); } } catch (Exception ex) { if (ex.GetType() != typeof(ManagedException)) { _log.Error(new Com.Delta.Logging.Errors.ErrorLog(new ManagedException(ex.Message, "FAC_007", string.Empty, string.Empty, ex))); } //_log.Error(new Com.Delta.Logging.Errors.ErrorLog("FAC_007", ex, string.Empty, string.Empty, string.Empty)); MailMessageComposer.CurrentSendMailGet().BodyHtml.Text = bodyBag; ErrorLabel.Visible = true; ErrorLabel.Text = ex.Message; return; } Label5.Visible = true; }