示例#1
0
 public void Insert(ActiveUp.Net.Mail.DeltaExt.MailUser entity)
 {
     try
     {
         using (FAXPECContext dbcontext = new FAXPECContext())
         {
             MAIL_SENDERS s = new MAIL_SENDERS();
             s.USERNAME        = entity.LoginId;
             s.ID_MAILSERVER   = entity.Id;
             s.ID_RESPONSABILE = entity.IdResponsabile;
             s.PASSWORD        = entity.Password;
             //  s.ID_RESPONSABILE = 1;
             s.FLG_MANAGED = (entity.FlgManaged == 0) ? "0" : "1";
             s.MAIL        = entity.EmailAddress.ToLower().Trim();
             dbcontext.MAIL_SENDERS.Add(s);
             int resp = dbcontext.SaveChanges();
             if (resp == 1)
             {
                 entity.UserId = dbcontext.MAIL_SENDERS.OrderByDescending(c => c.ID_SENDER).FirstOrDefault().ID_SENDER;
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.GetType().Equals(typeof(ManagedException)))
         {
             ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_004", string.Empty, string.Empty, ex.InnerException);
             ErrorLogInfo     err = new ErrorLogInfo(mEx);
             err.objectID = entity.Id.ToString();
             log.Error(err);
         }
     }
 }
示例#2
0
 public void Update(ActiveUp.Net.Mail.DeltaExt.MailUser entity)
 {
     try
     {
         using (FAXPECContext dbcontext = new FAXPECContext())
         {
             MAIL_SENDERS m = dbcontext.MAIL_SENDERS.Where(x => x.ID_SENDER == entity.UserId).First();
             if (m != null)
             {
                 m.PASSWORD        = entity.Password;
                 m.MAIL            = entity.EmailAddress;
                 m.ID_RESPONSABILE = entity.IdResponsabile;
                 m.ID_MAILSERVER   = entity.Id;
                 m.USERNAME        = entity.LoginId;
                 m.FLG_MANAGED     = (entity.FlgManaged == 0) ? "0" : "1";
                 dbcontext.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.GetType().Equals(typeof(ManagedException)))
         {
             ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_005", string.Empty, string.Empty, ex.InnerException);
             ErrorLogInfo     err = new ErrorLogInfo(mEx);
             err.objectID = entity.Id.ToString();
             log.Error(err);
         }
     }
 }
示例#3
0
 public void Insert(ActiveUp.Net.Mail.DeltaExt.MailUser us, ActiveUp.Net.Mail.Message mex)
 {
     using (MailMessageDaoSQLDb dao = new MailMessageDaoSQLDb())
     {
         dao.Insert(us, mex);
     }
 }
示例#4
0
 public ActiveUp.Net.Mail.DeltaExt.MailUser GetById(decimal id)
 {
     ActiveUp.Net.Mail.DeltaExt.MailUser user = null;
     using (FAXPECContext dbcontext = new FAXPECContext())
     {
         var mailsender = dbcontext.MAIL_SENDERS.Where(x => x.ID_SENDER == id).FirstOrDefault();
         try
         {
             int           idmailserver = (int)mailsender.ID_MAILSERVER;
             MAILSERVERS   ms           = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idmailserver).FirstOrDefault();
             MailServer    s            = AutoMapperConfiguration.FromMailServersToModel(ms);
             int           idmailuser   = (int)mailsender.ID_SENDER;
             List <Folder> list         = GetMailFolders(idmailuser);
             user = DaoSQLServerDBHelper.MapToMailUser(mailsender, s, list);
         }
         catch (Exception ex)
         {
             if (!ex.GetType().Equals(typeof(ManagedException)))
             {
                 ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_006", string.Empty, string.Empty, ex.InnerException);
                 ErrorLogInfo     err = new ErrorLogInfo(mEx);
                 err.objectID = id.ToString();
                 log.Error(err);
             }
             user = null;
         }
     }
     return(user);
 }
        public void Update(ActiveUp.Net.Mail.DeltaExt.MailUser entity)
        {
            try
            {
                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = "UPDATE MAIL_SENDERS " +
                                       "SET MAIL_SENDERS.MAIL = :MAIL, " +
                                       "MAIL_SENDERS.ID_MAILSERVER = :ID_MAILSERVER, " +
                                       "MAIL_SENDERS.USERNAME = :USERNAME, " +
                                       "MAIL_SENDERS.PASSWORD = :PASSWORD " +
                                       "WHERE MAIL_SENDERS.ID_SENDER = :ID_SENDER";

                    oCmd.Parameters.Add("MAIL", entity.EmailAddress);
                    oCmd.Parameters.Add("ID_MAILSERVER", entity.Id);
                    oCmd.Parameters.Add("USERNAME", entity.LoginId);
                    oCmd.Parameters.Add("PASSWORD", entity.Password);
                    oCmd.Parameters.Add("ID_SENDER", entity.UserId);
                    oCmd.BindByName = true;
                    oCmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                //TASK: Allineamento log - Ciro
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_005", string.Empty, string.Empty, ex.InnerException);
                    ErrorLogInfo     err = new ErrorLogInfo(mEx);

                    err.objectID = entity.Id.ToString();
                    log.Error(err);
                }
            }
        }
 public ActiveUp.Net.Mail.DeltaExt.MailUser GetById(decimal id)
 {
     ActiveUp.Net.Mail.DeltaExt.MailUser user = null;
     using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
     {
         oCmd.CommandText = queryBase + " WHERE ID_SENDER = " + id;
         try
         {
             using (OracleDataReader r = oCmd.ExecuteReader(CommandBehavior.SingleRow))
             {
                 while (r.Read())
                 {
                     MailServer    s = GetMailServer(r);
                     List <Folder> l = GetMailFolders(r);
                     user = DaoOracleDbHelper.MapToMailUser(r, s, l);
                 }
             }
         }
         catch
         {
             user = null;
             throw;
         }
     }
     return(user);
 }
示例#7
0
 public void Insert(ActiveUp.Net.Mail.DeltaExt.MailUser us, ActiveUp.Net.Mail.Message mex)
 {
     using (IMailMessageDao dao = getDaoContext().DaoImpl.MailMessageDao)
     {
         dao.Insert(us, mex);
     }
 }
        public void Insert(ActiveUp.Net.Mail.DeltaExt.MailUser entity)
        {
            try
            {
                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = "INSERT INTO MAIL_SENDERS " +
                                       "(ID_SENDER,MAIL,ID_MAILSERVER,USERNAME,PASSWORD,ID_RESPONSABILE,FLG_MANAGED) " +
                                       "VALUES (MAIL_SENDERS_SEQ.NEXTVAL,:MAIL,:ID_MAILSERVER,:USERNAME,:PASSWORD, 1, 0)" +
                                       " RETURNING ID_SENDER INTO :P_UID";

                    oCmd.Parameters.Add("MAIL", entity.EmailAddress);
                    oCmd.Parameters.Add("ID_MAILSERVER", entity.Id);
                    oCmd.Parameters.Add("USERNAME", entity.LoginId);
                    oCmd.Parameters.Add("PASSWORD", entity.Password);
                    oCmd.Parameters.Add("P_UID", OracleDbType.Int64, ParameterDirection.Output);
                    oCmd.BindByName = true;
                    int resp = oCmd.ExecuteNonQuery();
                    if (resp == 1)
                    {
                        entity.UserId = Convert.ToDecimal(oCmd.Parameters["P_UID"].Value.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                //TASK: Allineamento log - Ciro
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_004", string.Empty, string.Empty, ex.InnerException);
                    ErrorLogInfo     err = new ErrorLogInfo(mEx);

                    err.objectID = entity.Id.ToString();
                    log.Error(err);
                }
            }
        }
示例#9
0
 public MailUser saveUser(MailUser e)
 {
     return(e);
 }
示例#10
0
        public HttpResponseMessage SendMailExt(FormDataCollection collection)
        {
            MailModel model = new MailModel();
            string    bodyBag;

            try
            {
                Message msg;
                ComunicazioniService comunicazioniService = new ComunicazioniService();
                if (MailMessageComposer.CurrentSendMailExist())
                {
                    msg = MailMessageComposer.CurrentSendMailGet();
                }
                else
                {
                    msg = new Message();
                }

                msg.Subject = collection["Oggetto"];
                if (String.IsNullOrEmpty(collection["DestinatarioA"]) &&
                    String.IsNullOrEmpty(collection["DestinatarioCC"]) &&
                    String.IsNullOrEmpty(collection["DestinatarioBCC"]))
                {
                    model.message = "Inserire almeno un destinatario";
                    model.success = "false";
                    return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                }
                msg.To.Clear();
                msg.Cc.Clear();
                msg.Bcc.Clear();
                this.addEmailsTo(collection["DestinatarioA"].Trim(), msg);
                if (!(string.IsNullOrEmpty(collection["DestinatarioCC"])))
                {
                    this.addEmailsCc(collection["DestinatarioCC"], msg);
                }
                if (!(string.IsNullOrEmpty(collection["DestinatarioBCC"])))
                {
                    this.addEmailCcn(collection["DestinatarioBCC"], 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 = collection["TestoMail"];
                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 (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 (!(string.IsNullOrEmpty(collection["IncludiAllegati"])) && collection["IncludiAllegati"].ToUpper() == "FALSE")
                {
                    for (int i = 0; i < msg.Attachments.Count; i++)
                    {
                        //rimuovo gli allegati originali
                        if (msg.Attachments[i].ParentMessage != null)
                        {
                            msg.Attachments.RemoveAt(i);
                        }
                    }
                }
                msg.InReplyTo = msg.Id.ToString();
                ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = null;
                if (WebMailClientManager.AccountExist())
                {
                    mailUser = WebMailClientManager.getAccount();
                }

                if (mailUser != null)
                {
                    MailServerFacade f = MailServerFacade.GetInstance(mailUser);
                    msg.From = new Address(mailUser.Casella);
                    if (mailUser.IsManaged)
                    {
                        try
                        {
                            SendMail.Model.ComunicazioniMapping.Comunicazioni c =
                                new SendMail.Model.ComunicazioniMapping.Comunicazioni(
                                    SendMail.Model.TipoCanale.MAIL,
                                    "0",
                                    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();
                            }
                            if (SessionManager <Dictionary <string, DTOFileUploadResult> > .exist(SessionKeys.DTO_FILE))
                            {
                                Dictionary <string, DTOFileUploadResult> dictDto = SessionManager <Dictionary <string, DTOFileUploadResult> > .get(SessionKeys.DTO_FILE);

                                List <DTOFileUploadResult> dto = (List <DTOFileUploadResult>)dictDto.Values.ToList();
                                c.ComAllegati = new List <ComAllegato>();
                                foreach (DTOFileUploadResult dd in dto)
                                {
                                    ComAllegato allegato = new SendMail.Model.ComunicazioniMapping.ComAllegato();
                                    allegato.AllegatoExt  = dd.Extension;
                                    allegato.AllegatoFile = dd.CustomData;
                                    allegato.AllegatoName = dd.FileName;
                                    allegato.AllegatoTpu  = "";
                                    allegato.FlgInsProt   = AllegatoProtocolloStatus.FALSE;
                                    allegato.FlgProtToUpl = AllegatoProtocolloStatus.FALSE;
                                    c.ComAllegati.Add(allegato);
                                }
                            }
                            foreach (MimePart mm in msg.Attachments)
                            {
                                if (mm.BinaryContent != null || mm.BinaryContent.Length > 10)
                                {
                                    if (c.ComAllegati == null)
                                    {
                                        c.ComAllegati = new List <ComAllegato>();
                                    }

                                    ComAllegato allegato = new SendMail.Model.ComunicazioniMapping.ComAllegato();
                                    FileInfo    info     = new FileInfo(mm.Filename);
                                    allegato.AllegatoExt  = info.Extension;
                                    allegato.AllegatoFile = mm.BinaryContent;
                                    allegato.AllegatoName = mm.Filename;
                                    allegato.AllegatoTpu  = "";
                                    allegato.FlgInsProt   = AllegatoProtocolloStatus.FALSE;
                                    allegato.FlgProtToUpl = AllegatoProtocolloStatus.FALSE;
                                    c.ComAllegati.Add(allegato);
                                }
                            }
                            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);
                            model.message = "Errore nell'invio del messaggio";
                            model.success = "false";
                            return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                        }
                    }
                    else
                    {
                        f.sendMail(msg);
                    }

                    model.message = "Email memorizzata correttamente";
                    model.success = "true";
                    return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                }
                else
                {
                    model.message = "Account inesistente";
                    model.success = "false";
                    return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                }
            }
            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)));
                }

                model.message = ex.Message;
                model.success = "false";
                return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
            }
            model.message = "Email memorizzata correttamente";
            model.success = "true";
            return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
        }
示例#11
0
        public HttpResponseMessage GetMail(int idmail, string tipo)
        {
            ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = WebMailClientManager.getAccount();
            SessionManager <Dictionary <string, DTOFileUploadResult> > .del(SessionKeys.DTO_FILE);

            MailModel model = new MailModel();

            SessionManager <List <ViewAttachement> > .del(SessionKeys.ATTACHEMENTS_LIST);

            ViewMail v = new ViewMail();

            if (mailUser == null)
            {
                model.message = "Account non selezionato";
                model.success = "false";
                return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
            }
            try
            {
                Message msg = GetCurrentMessage();
                if (msg == null)
                {
                    model.message = "Messaggio non valido ripetere la selezione";
                    model.success = "false";
                    return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                }
                v.Mail = mailUser.EmailAddress;
                if (tipo != "f")
                {
                    if (selectEmail(msg.To).Contains(mailUser.EmailAddress))
                    {
                        List <Address> l = msg.To.Where(x => !x.Email.Equals(mailUser.EmailAddress)).ToList();
                        v.DestinatarioA = string.Join(";", (from e in l
                                                            select e.Email).ToArray());
                        v.DestinatarioA += msg.From.Email;
                    }
                    else
                    {
                        v.DestinatarioA = msg.From.Email;
                    }
                }
                v.DestinatarioABlank = false;
                if (selectEmail(msg.Cc).Contains(mailUser.EmailAddress))
                {
                    List <Address> lc = msg.Cc.Where(x => !x.Email.Equals(mailUser.EmailAddress)).ToList();
                    v.DestinatarioCC = string.Join(";", (from e in lc
                                                         select e.Email).ToArray());
                }
                v.Oggetto            = String.Concat("Re:", msg.Subject);
                v.TestoMailOriginale = msg.BodyText.TextStripped;
                v.Allegati           = new List <ViewAttachement>();
                if (msg.Attachments.Count > 0)
                {
                    foreach (MimePart a in msg.Attachments)
                    {
                        ViewAttachement va = new ViewAttachement();
                        va.NomeFile   = a.Filename;
                        va.ContentiId = a.ContentId;
                        va.Dimensione = a.Size;
                        v.Allegati.Add(va);
                    }
                }
                model.Mail = new List <ViewMail>();
                model.Mail.Add(v);
                model.success = "true";
                model.Totale  = "1";
                SessionManager <List <ViewAttachement> > .set(SessionKeys.ATTACHEMENTS_LIST, model.Mail.FirstOrDefault().Allegati);
            }
            catch (Exception bex)
            {
                if (bex.GetType() != typeof(ManagedException))
                {
                    ManagedException mEx = new ManagedException(bex.Message, "ERR_E005", string.Empty, string.Empty, bex);
                    ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                    log.Error(er);
                    model.success = "false";
                    model.message = bex.Message;
                    return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
                }
            }
            return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model));
        }