Example #1
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);
 }
Example #2
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);
         }
     }
 }
Example #3
0
 public void Delete(decimal id)
 {
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             var oldserver = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == (double)id).First();
             dbcontext.MAILSERVERS.Remove(oldserver);
             dbcontext.SaveChanges();
         }
         catch (Exception ex)
         {
             //Allineamento log - Ciro
             if (ex.GetType() != typeof(ManagedException))
             {
                 ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA + " " + ex.Message,
                                                             "DAL_UNIQUE_CODE_1",
                                                             string.Empty,
                                                             string.Empty,
                                                             ex);
                 ErrorLogInfo er = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
             else
             {
                 throw;
             }
             //throw new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA, "DAL_UNIQUE_CODE", "", "", "", "", "", ex);
         }
     }
 }
Example #4
0
        public MailServer GetById(decimal id)
        {
            MailServer mailserver = null;

            using (var dbcontext = new FAXPECContext())
            {
                try
                {
                    var m = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == (double)id).First();
                    mailserver = AutoMapperConfiguration.FromMailServersToModel(m);
                }
                catch (SqlException oex)
                {
                    //Allineamento log - Ciro
                    if (oex.GetType() != typeof(ManagedException))
                    {
                        ManagedException mEx = new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO + oex.Message,
                                                                    "DAL_TIT_010",
                                                                    string.Empty,
                                                                    string.Empty,
                                                                    oex);
                        ErrorLogInfo er = new ErrorLogInfo(mEx);
                        log.Error(er);
                        throw mEx;
                    }
                    else
                    {
                        throw;
                    }
                    //throw new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO, "DAL_TIT_010", "", "", "", "", "", oex);
                }
            }
            return(mailserver);
        }
Example #5
0
        protected void odsServerConfig_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            if (this.IdServer_ViewState != decimal.MinusOne)
            {
                try
                {
                    MailServerConfigFacade facade = MailServerConfigFacade.GetInstance();
                    e.ObjectInstance = facade.LoadServerConfigById(this.IdServer_ViewState);
                }
                catch (Exception ex)
                {
                    if (ex.GetType() != typeof(ManagedException))
                    {
                        ManagedException mEx = new ManagedException("Errore nel caricamento della configurazione del server", "CM020",
                                                                    string.Empty, string.Empty, ex.InnerException);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);
                        err.loggingAppCode = "WEB_MAIL";
                        err.objectID       = this.Context.Session.SessionID;
                        log.Error(err);

                        info.AddMessage(mEx.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    }
                    else
                    {
                        info.AddMessage(ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    }
                }
            }
            else
            {
                e.ObjectInstance = new MailServer();
            }
        }
        public HttpResponseMessage getStatByUserMail(string utente, string mail,
                                                     string dt, string df,
                                                     int?page, int?start, int?limit, string sort, string dir)
        {
            StatModel model = new StatModel();

            try
            {
                BackendUserService bus       = new BackendUserService();
                DateTime           datainzio = DateTime.Parse(dt);
                DateTime           datafine  = DateTime.Parse(df);
                int starti                 = start.HasValue ? Convert.ToInt32(start) : 1;
                int recordPagina           = limit.HasValue ? Convert.ToInt32(limit) : 10;
                int tot                    = 0;
                List <UserResultItem> list = bus.GetStatsInBox(mail, utente, datainzio, datafine, starti, recordPagina, ref tot);
                model.Totale     = tot.ToString();
                model.success    = "true";
                model.ElencoStat = list;
                return(this.Request.CreateResponse <StatModel>(HttpStatusCode.OK, model));
            }
            catch (Exception ex)
            {
                ErrorLogInfo error = new ErrorLogInfo();
                error.freeTextDetails = ex.Message + " " + "Parameteri: " + utente + " " + mail + " " + dt + " " + df;
                error.logCode         = "ERR_S01";
                error.loggingAppCode  = "PEC";
                error.loggingTime     = System.DateTime.Now;
                error.uniqueLogID     = System.DateTime.Now.Ticks.ToString();
                log.Error(error);
                model.message = ex.Message;
                model.success = "false";
                return(this.Request.CreateResponse <StatModel>(HttpStatusCode.OK, model));
            }
        }
Example #7
0
 public void Insert(SendMail.Model.RubricaMapping.RubricaEntita entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             var rubr = DaoSQLServerDBHelper.MapToRubrEntita(entity, true);
             dbcontext.RUBR_ENTITA.Add(rubr);
             int r = dbcontext.SaveChanges();
             if (r == 1)
             {
                 entity.IdReferral = (long)rubr.ID_REFERRAL;
             }
             else
             {
                 //Allineamento log - Ciro
                 ManagedException mEx = new ManagedException("Errore inserimento ",
                                                             "RUB_ORA003",
                                                             string.Empty,
                                                             string.Empty,
                                                             null);
                 ErrorLogInfo er = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
         }
         catch
         {
             throw;
         }
     }
 }
 public ICollection <MailServer> GetAll()
 {
     using (OracleCommand ocmd = new OracleCommand())
     {
         // preparo il command
         ocmd.Connection  = base.CurrentConnection;
         ocmd.CommandText = "SELECT * FROM MAILSERVERS";
         // eseguo il command
         try
         {
             return(DaoOracleDbHelper <MailServer> .ExecSelectCommand(ocmd, DaoOracleDbHelper.MapToMailServer));
         }
         catch (OracleException oex)
         {
             //Allineamento log - Ciro
             if (oex.GetType() != typeof(ManagedException))
             {
                 ManagedException mEx = new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO + oex.Message,
                                                             "DAL_TIT_001",
                                                             string.Empty,
                                                             string.Empty,
                                                             oex);
                 ErrorLogInfo er = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
             else
             {
                 throw;
             }
             //throw new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO, "DAL_TIT_001", "", "", "", "", "", oex);
         }
     }
 }
Example #9
0
        public ICollection <Titolo> GetSottotitoliByIdPadre(decimal titoloKey)
        {
            using (OracleCommand ocmd = new OracleCommand())
            {
                ocmd.Connection  = base.CurrentConnection;
                ocmd.CommandText = "SELECT ID_SOTTOTITOLO AS ID_TITOLO, COM_CODE AS APP_CODE, SOTTOTITOLO AS TITOLO , PROT_CODE, ACTIVE FROM COMUNICAZIONI_SOTTOTITOLI WHERE REF_ID_TITOLO = :pREF_ID_TIT ORDER BY SOTTOTITOLO";
                ocmd.Parameters.Add("pREF_ID_TIT", titoloKey);
                List <string> mappingList = new List <string>()
                {
                    "ID_TITOLO", "TITOLO", "PROT_CODE", "DELETED", "APP_CODE"
                };


                // eseguo il command
                try
                {
                    return(DaoOracleDbHelper <Titolo> .ExecSelectCommand(ocmd, DaoOracleDbHelper.MapToTitolo, mappingList));
                }
                catch (OracleException oex)
                {
                    //TASK: Allineamento log - Ciro
                    ManagedException mEx = new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO,
                                                                "DAL_TIT_001", string.Empty,
                                                                string.Empty, oex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;
                    //throw new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO, "DAL_TIT_001", "", "", "", "", "", oex);
                }
            }
        }
Example #10
0
 public void Insert(MailRefs entity)
 {
     try
     {
         using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
         {
             oCmd.CommandText = cmdInsertMailRefs;
             oCmd.Parameters.Add("MAILID", entity.RefIdMail);
             oCmd.Parameters.Add("DEST", entity.AddresseeMail);
             oCmd.Parameters.Add("TIPO", entity.AddresseeClass.ToString());
             oCmd.BindByName = true;
             oCmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         //Allineamento log - Ciro
         if (ex.GetType() != typeof(ManagedException))
         {
             ManagedException mEx = new ManagedException(ex.Message, "ERR_INS001", string.Empty, string.Empty, ex);
             ErrorLogInfo     er  = new ErrorLogInfo(mEx);
             er.objectID = entity.IdRef.ToString();
             log.Error(er);
             throw mEx;
         }
         else
         {
             throw ex;
         }
     }
 }
Example #11
0
        public HttpResponseMessage GetAllRoles()
        {
            RolesModel m = new RolesModel();

            try
            {
                var roleStore = new RoleStore();
                var roles     = roleStore.GetAll().Result;
                m.RolesList = roles;
                m.Totale    = roles.Count.ToString();
                m.success   = "true";
            }
            catch (Exception ex)
            {
                ErrorLogInfo error = new ErrorLogInfo();
                error.freeTextDetails = ex.Message;
                error.logCode         = "ERR_R001";
                error.loggingAppCode  = "PEC";
                error.loggingTime     = System.DateTime.Now;
                error.uniqueLogID     = System.DateTime.Now.Ticks.ToString();
                log.Error(error);
                m.message = ex.Message;
                m.success = "false";
                return(this.Request.CreateResponse <RolesModel>(HttpStatusCode.InternalServerError, m));
            }
            return(this.Request.CreateResponse <RolesModel>(HttpStatusCode.OK, m));
        }
Example #12
0
        public void setDefaultContact(long idTitolo, long refOrg, long idContatto)
        {
            using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
            {
                oCmd.CommandText = cmdSetDefaultContact;
                oCmd.Parameters.Add(new OracleParameter("pCONTATTO", OracleDbType.Int64, idContatto, ParameterDirection.Input));
                oCmd.Parameters.Add(new OracleParameter("pIDTITOLO", OracleDbType.Int64, idTitolo, ParameterDirection.Input));
                oCmd.Parameters.Add(new OracleParameter("pIDENTITA", OracleDbType.Int64, refOrg, ParameterDirection.Input));
                oCmd.BindByName = true;
                try
                {
                    int ret = oCmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    //TASK: Allineamento log - Ciro
                    if (!ex.GetType().Equals(typeof(ManagedException)))
                    {
                        ManagedException mEx = new ManagedException(ex.Message,
                                                                    "ORA_ERR007", string.Empty, string.Empty, ex);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);

                        _log.Error(err);
                        throw mEx;
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
        }
Example #13
0
        protected void odsServerConfig_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {
            MailServer ms = e.InputParameters[0] as MailServer;

            try
            {
                MailServerConfigFacade facade = MailServerConfigFacade.GetInstance();
                facade.insertServerConfig(ms);
                this.IdServer_ViewState = ms.Id;
                info.AddMessage("Operazione effettuata", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.OK);
            }
            catch (ManagedException mEx)
            {
                info.AddMessage(mEx.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
            }
            catch (Exception ex)
            {
                ManagedException mEx = new ManagedException("Errore nell'inserimento del nuovo server", "CM010",
                                                            string.Empty, string.Empty, ex.InnerException);
                ErrorLogInfo err = new ErrorLogInfo(mEx);
                err.loggingAppCode = "WEB_MAIL";
                err.objectID       = this.Context.Session.SessionID;
                if (MySecurityProvider.CurrentPrincipal != null && MySecurityProvider.CurrentPrincipal.MyIdentity != null)
                {
                    err.userID = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName;
                }
                log.Error(err);
                info.AddMessage(mEx.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
            }
        }
Example #14
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);
         }
     }
 }
Example #15
0
        public int GetMessageSize(string uid)
        {
            switch (InProtoGet())
            {
            case IncomingProtocols.POP3:
                int idx = this.Pop3.Pop3Client.GetMessageIndex(uid);
                if (idx > 0)
                {
                    return(this.Pop3.Pop3Client.GetMessageSize(idx));
                }
                else
                {
                    return(-1);
                }
                break;

            case IncomingProtocols.IMAP:
                //throw new ManagedException("Imap not supported at all!", String.Empty, String.Empty, String.Empty, null);
                //TASK: Allineamento log - Ciro
                ManagedException mEx = new ManagedException("Imap not supported at all!",
                                                            "ERR_MAIL_0114", string.Empty,
                                                            string.Empty, null);
                ErrorLogInfo err = new ErrorLogInfo(mEx);

                _log.Error(mEx);
                throw mEx;
                break;

            default:
                return(0);
            }
        }
        public void Delete(decimal id)
        {
            OracleCommand ocmd = new OracleCommand();

            ocmd.CommandText = deleteStatement;
            ocmd.Parameters.Add("pID_SVR", id);
            ocmd.Connection = base.CurrentConnection;
            try
            {
                ocmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                //Allineamento log - Ciro
                if (ex.GetType() != typeof(ManagedException))
                {
                    ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA + " " + ex.Message,
                                                                "DAL_UNIQUE_CODE_1",
                                                                string.Empty,
                                                                string.Empty,
                                                                ex);
                    ErrorLogInfo er = new ErrorLogInfo(mEx);
                    log.Error(er);
                    throw mEx;
                }
                else
                {
                    throw;
                }
                //throw new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA, "DAL_UNIQUE_CODE", "", "", "", "", "", ex);
            }
        }
Example #17
0
 public void sendMail(Message message)
 {
     try
     {
         this.Smtp.SendMail(message, _AccSettings);
     }
     catch (Exception ex)
     {
         //TASK: Allineamento log - Ciro
         if (ex.GetType() != typeof(ManagedException))
         {
             ManagedException mEx = new ManagedException("Non posso leggere la casella postale. Dettaglio: " + ex.Message,
                                                         "ERR_MAIL_0008", string.Empty,
                                                         string.Empty, ex);
             ErrorLogInfo err = new ErrorLogInfo(mEx);
             _log.Error(mEx);
             throw mEx;
         }
         else
         {
             throw;
         }
         //throw new ManagedException("Non posso leggere la casella postale"
         //                          , "ERR_MAIL_0008", "MailServerFacade.cs", "sendMail", "smtpController.sendMail", "", "", ex
         //                          );
     }
 }
Example #18
0
        private void addEmailsTo(string mails, Message message)
        {
            mails = mails.Trim();
            mails.Replace(" ", "");
            string[] toArray = mails.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
            string   pattern = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";

            for (int i = 0; i < toArray.Length; i++)
            {
                if (toArray[i] != String.Empty)
                {
                    if (Regex.IsMatch(toArray[i], pattern))
                    {
                        if (!selectEmail(message.To).Contains(toArray[i]))
                        {
                            message.To.Add(toArray[i]);
                        }
                    }
                    else
                    {
                        //Allineamento log - Ciro
                        ManagedException mEx = new ManagedException("La mail " + toArray[i] + "non è una mail valida", "ERR_MF_001", string.Empty, string.Empty, null);
                        ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                        er.objectID = mails;
                        _log.Error(er);
                        throw mEx;
                    }
                }
            }
            //throw new ManagedException("La mail " + toArray[i] + "non è una mail valida", "ERR_MF_001", null, null, null, null, null, null);
        }
Example #19
0
        protected void odsMailConfig_Updating(object sender, ObjectDataSourceMethodEventArgs e)
        {
            try
            {
                MailAccountService mailAccountService = new MailAccountService();
                MailUser           mu = e.InputParameters[0] as MailUser;
                if (!IsValidEmailDesc(mu.EmailAddress))
                {
                    e.Cancel = true;
                    info.AddMessage("Errore nel formato della mail", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }
                mailAccountService.Update(mu);
                info.AddMessage("Operazione effettauata", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.OK);
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(ManagedException))
                {
                    ManagedException mEx = new ManagedException("Errore nel caricamento della configurazione della mail", "CM008",
                                                                string.Empty, string.Empty, ex.InnerException);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);
                    err.loggingAppCode = "WEB_MAIL";
                    err.objectID       = this.Context.Session.SessionID;
                    log.Error(err);

                    info.AddMessage(mEx.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                }
                else
                {
                    info.AddMessage(ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                }
            }
            e.Cancel = true;
        }