private static CasellaRegistro GetMail(DataRow rowMailRegistro) { CasellaRegistro mail = new CasellaRegistro(); mail.IdRegistro = rowMailRegistro["ID_REGISTRO"].ToString(); mail.EmailRegistro = rowMailRegistro["VAR_EMAIL_REGISTRO"].ToString(); mail.UserMail = rowMailRegistro["VAR_USER_MAIL"].ToString(); mail.PwdMail = Crypter.Decode(rowMailRegistro["VAR_PWD_MAIL"].ToString(), mail.UserMail); mail.ServerSMTP = rowMailRegistro["VAR_SERVER_SMTP"].ToString(); if (rowMailRegistro["CHA_SMTP_SSL"] != DBNull.Value) { mail.SmtpSSL = rowMailRegistro["CHA_SMTP_SSL"].ToString(); } if (rowMailRegistro["CHA_POP_SSL"] != DBNull.Value) { mail.PopSSL = rowMailRegistro["CHA_POP_SSL"].ToString(); } if (rowMailRegistro["NUM_PORTA_SMTP"] != DBNull.Value) { mail.PortaSMTP = Convert.ToInt32(rowMailRegistro["NUM_PORTA_SMTP"]); } if (rowMailRegistro["CHA_SMTP_STA"] != DBNull.Value) { mail.SmtpSta = rowMailRegistro["CHA_SMTP_STA"].ToString(); } mail.ServerPOP = rowMailRegistro["VAR_SERVER_POP"].ToString(); if (rowMailRegistro["NUM_PORTA_POP"] != DBNull.Value) { mail.PortaPOP = Convert.ToInt32(rowMailRegistro["NUM_PORTA_POP"]); } mail.UserSMTP = rowMailRegistro["VAR_USER_SMTP"].ToString(); mail.PwdSMTP = Crypter.Decode(rowMailRegistro["VAR_PWD_SMTP"].ToString(), mail.UserSMTP); mail.IboxIMAP = rowMailRegistro["VAR_INBOX_IMAP"].ToString(); mail.ServerIMAP = rowMailRegistro["VAR_SERVER_IMAP"].ToString(); if (rowMailRegistro["NUM_PORTA_IMAP"] != DBNull.Value) { mail.PortaIMAP = Convert.ToInt32(rowMailRegistro["NUM_PORTA_IMAP"]); } mail.TipoConnessione = rowMailRegistro["VAR_TIPO_CONNESSIONE"].ToString(); mail.BoxMailElaborate = rowMailRegistro["VAR_BOX_MAIL_ELABORATE"].ToString(); mail.MailNonElaborate = rowMailRegistro["VAR_MAIL_NON_ELABORATE"].ToString(); mail.ImapSSL = rowMailRegistro["CHA_IMAP_SSL"].ToString(); mail.SoloMailPEC = rowMailRegistro["VAR_SOLO_MAIL_PEC"].ToString(); if (rowMailRegistro["CHA_RICEVUTA_PEC"] != DBNull.Value) { mail.RicevutaPEC = rowMailRegistro["CHA_RICEVUTA_PEC"].ToString(); } mail.Principale = rowMailRegistro["VAR_PRINCIPALE"].ToString(); mail.Note = rowMailRegistro["VAR_NOTE"].ToString(); // Per gestione pendenti tramite PEC mail.MailRicevutePendenti = rowMailRegistro["VAR_MAIL_RIC_PENDENTE"].ToString(); mail.MessageSendMail = rowMailRegistro["VAR_MESSAGE_SEND_MAIL"].ToString(); mail.OverwriteMessageAmm = (string.IsNullOrEmpty(rowMailRegistro["CHA_OVERWRITE_MESSAGE_AMM"].ToString()) || rowMailRegistro["CHA_OVERWRITE_MESSAGE_AMM"].ToString().Equals("0")) ? false : true; return(mail); }
protected void RegisterModifyBtnSavePw_Click(object sender, EventArgs e) { OrgRegistro register = GestManager.GetRegisterAmm(SelectedRegister.systemId); CasellaRegistro[] caselle = GestManager.GetMailRegistro(register.IDRegistro); CasellaRegistro casellaDaAggiornare = new CasellaRegistro(); if (caselle != null && caselle.Length > 0) { casellaDaAggiornare = (from c in caselle where c.EmailRegistro.ToUpper().Equals(SelectedRegister.email.ToUpper()) select c).FirstOrDefault(); } if (casellaDaAggiornare != null) { register.Mail = BuildMailRegistro(casellaDaAggiornare); if (checkField(register.Mail.Password)) { register.Mail.Password = this.RegisterModifyNewPwTxt.Text; register.Mail.PasswordSMTP = this.RegisterModifyNewPwTxt.Text; casellaDaAggiornare.PwdMail = this.RegisterModifyNewPwTxt.Text; casellaDaAggiornare.PwdSMTP = this.RegisterModifyNewPwTxt.Text; ValidationResultInfo result = GestManager.UpdateRegistro(register); if (result.Value) { result = GestManager.UpdateMailRegistro(register.IDRegistro, new CasellaRegistro[] { casellaDaAggiornare }); } if (result.Value) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false); Response.Write("<html><body><script type=\"text/javascript\">parent.closeAjaxModal('RegisterModify','up');</script></body></html>"); Response.End(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "parent.ajaxDialogModal('ErrorRegisterModify', 'error', '');", true); return; } } else { return; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "parent.ajaxDialogModal('ErrorRegisterModify', 'error', '');", true); return; } }
/// <summary> /// Reperimento elenco caselle di posta di un registro/rf in amministrazione /// </summary> /// <param name="idRegistro"></param> /// <returns></returns> public static CasellaRegistro[] GetMailRegistro(string idRegistro) { CasellaRegistro [] mail_registri = null; DocsPaDB.Query_DocsPAWS.Amministrazione dbAmministrazione = new DocsPaDB.Query_DocsPAWS.Amministrazione(); DataSet ds = dbAmministrazione.GetDsMailRegistro(idRegistro); if (ds.Tables.Count > 0) { int index = 0; mail_registri = new CasellaRegistro[ds.Tables["MAIL_REGISTRI"].Rows.Count]; foreach (DataRow row in ds.Tables["MAIL_REGISTRI"].Rows) { mail_registri[index] = GetMail(row); ++index; } } return(mail_registri); }
private MailRegistro BuildMailRegistro(CasellaRegistro casella) { MailRegistro mail = new MailRegistro(); mail.Email = casella.EmailRegistro; mail.UserID = casella.UserMail; mail.Password = casella.PwdMail; mail.ServerSMTP = casella.ServerSMTP; mail.ServerPOP = casella.ServerPOP; mail.inbox = casella.IboxIMAP; mail.mailElaborate = casella.BoxMailElaborate; mail.serverImap = casella.ServerIMAP; mail.tipoPosta = casella.TipoConnessione; mail.mailNonElaborate = casella.MailNonElaborate; mail.IMAPssl = casella.ImapSSL; mail.soloMailPec = casella.SoloMailPEC; // Per gestione pendenti tramite PEC mail.MailRicevutePendenti = casella.MailRicevutePendenti; try { mail.PortaSMTP = casella.PortaSMTP; mail.PortaPOP = casella.PortaPOP; mail.portaIMAP = casella.PortaIMAP; } catch (Exception e) { } mail.UserSMTP = casella.UserSMTP; mail.PasswordSMTP = casella.PwdSMTP; mail.POPssl = casella.PopSSL; mail.SMTPssl = casella.SmtpSSL; mail.SMTPsslSTA = casella.SmtpSta; mail.IMAPssl = casella.ImapSSL; mail.pecTipoRicevuta = casella.RicevutaPEC; return(mail); }