public List <BackEndUserMailUserMapping> GetMailUserByUserId(long userId, int userRole) { List <BackEndUserMailUserMapping> listStart = null; try { using (OracleCommand oCmd = base.CurrentConnection.CreateCommand()) { if (userRole < 2) { oCmd.CommandText = "SELECT MAIL_USERS_SENDER_BACKEND.REF_ID_USER, " + "MAIL_USERS_SENDER_BACKEND.REF_ID_SENDER ID_SENDER, " + "MAIL_USERS_SENDER_BACKEND.ROLE AS ROLE_MAIL " + "FROM MAIL_USERS_SENDER_BACKEND " + "WHERE REF_ID_USER = :REF_ID_USER"; oCmd.Parameters.Add("REF_ID_USER", userId); } else { oCmd.CommandText = "SELECT DISTINCT ID_SENDER, 1 AS \"ROLE_MAIL\"" + " FROM MAIL_SENDERS" + " ORDER BY 1"; } using (OracleDataReader r = oCmd.ExecuteReader()) { listStart = new List <BackEndUserMailUserMapping>(); while (r.Read()) { BackEndUserMailUserMapping b = DaoOracleDbHelper.MapToBackEndUserMailUserMapping(r); MailUser mu = this.Context.DaoImpl.MailAccountDao.GetById(b.MailSenderId); listStart.Add(new BackEndUserMailUserMapping(mu, b.MailAccessLevel)); } } } } catch (Exception e) { //TASK: Allineamento log - Ciro if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione lista emails abilitate per utente: " + userId.ToString() + " E077 Dettagli Errore: " + e.Message, "ERR_077", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } //Com.Delta.Logging.Errors.ErrorLogInfo error = new Com.Delta.Logging.Errors.ErrorLogInfo(); //error.freeTextDetails = "Errore nella creazione lista emails abilitate per utente: " + userId.ToString() + " E077 Dettagli Errore: " + e.Message; //error.logCode = "ERR_077"; //error.passiveparentcodeobjectID = string.Empty; //error.passiveobjectGroupID = userId.ToString(); //error.passiveobjectID = string.Empty; //error.passiveapplicationID = string.Empty; //log.Error(error); listStart = null; } return(listStart); }
public List <BackEndUserMailUserMapping> GetMailUserByUserId(long userId, int userRole) { List <BackEndUserMailUserMapping> listStart = null; try { using (var dbcontext = new FAXPECContext()) { if (userRole < 2) { var v = dbcontext.MAIL_USERS_SENDER_BACKEND.Where(x => x.REF_ID_USER == userId).ToList(); if (v.Count > 0) { listStart = new List <BackEndUserMailUserMapping>(); BackEndUserMailUserMapping b = new BackEndUserMailUserMapping(); foreach (MAIL_USERS_SENDER_BACKEND a in v) { b.MailSenderId = (long)a.REF_ID_SENDER; b.MailAccessLevel = int.Parse(a.ROLE.ToString()); MailAccountSQLDb mailaccount = new MailAccountSQLDb(); MailUser mu = mailaccount.GetById(b.MailSenderId); listStart.Add(new BackEndUserMailUserMapping(mu, b.MailAccessLevel)); } } } else { var f = dbcontext.MAIL_SENDERS.OrderBy(x => x.ID_SENDER).ToList(); if (f.Count > 0) { listStart = new List <BackEndUserMailUserMapping>(); BackEndUserMailUserMapping b = new BackEndUserMailUserMapping(); foreach (MAIL_SENDERS s in f) { b.MailSenderId = s.ID_SENDER; b.MailAccessLevel = 1; MailAccountSQLDb mailaccount = new MailAccountSQLDb(); MailUser mu = mailaccount.GetById(b.MailSenderId); listStart.Add(new BackEndUserMailUserMapping(mu, b.MailAccessLevel)); } } } } } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione lista emails abilitate per utente: " + userId.ToString() + " E077 Dettagli Errore: " + e.Message, "ERR_077", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } listStart = null; } return(listStart); }
public ICollection <BackendUser> GetAll() { List <BackendUser> listaUtenti = new List <BackendUser>(); try { using (var dbcontext = new FAXPECContext()) { using (var oCmd = dbcontext.Database.Connection.CreateCommand()) { oCmd.CommandText = "SELECT MAIL_USERS_BACKEND.ID_USER, " + "MAIL_USERS_BACKEND.USER_NAME, " + "MAIL_USERS_BACKEND.COGNOME, " + "MAIL_USERS_BACKEND.NOME, " + "MAIL_USERS_BACKEND.DEPARTMENT, " + "MAIL_USERS_BACKEND.MUNICIPIO, " + "MAIL_USERS_BACKEND.DOMAIN, " + "MAIL_USERS_BACKEND.ROLE ROLE_USER " + "FROM [FAXPEC].[FAXPEC].[MAIL_USERS_BACKEND] "; oCmd.Connection.Open(); using (var r = oCmd.ExecuteReader()) { if (r.HasRows) { listaUtenti = new List <BackendUser>(); while (r.Read()) { BackendUser bUser = AutoMapperConfiguration.MapToBackendUser(r); if (bUser != null && bUser.UserId >= 0) { BackEndUserMailUserMapping b = new BackEndUserMailUserMapping(); b.MailSenderId = 0; b.MailAccessLevel = 0; List <BackEndUserMailUserMapping> bList = new List <BackEndUserMailUserMapping>(); bList.Add(b); bUser.MappedMails = bList; } listaUtenti.Add(bUser); } } } oCmd.Connection.Close(); } } } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione lista utenti generale E172 Dettagli Errore: " + e.Message, "ERR_172", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } listaUtenti = null; } return(listaUtenti); }
/// <param name="dr">datarecord</param> /// <remarks>RIVEDERE</remarks> /// <summary> /// Mappa un record su di un oggetto BackEndUserMailUserMapping. /// </summary>/// <returns></returns> internal static BackEndUserMailUserMapping MapToBackEndUserMailUserMapping(IDataRecord dr) { BackEndUserMailUserMapping b = new BackEndUserMailUserMapping(); b.MailSenderId = (long)dr.GetValue("ID_SENDER"); b.MailAccessLevel = int.Parse(dr.GetValue("ROLE_MAIL").ToString()); return(b); }
public List <BackendUser> GetDipendentiDipartimentoAbilitati(Decimal idSender) { List <BackendUser> listaDipendenti = null; try { using (OracleCommand oCmd = base.CurrentConnection.CreateCommand()) { oCmd.CommandText = "SELECT MAIL_USERS_BACKEND.ID_USER, " + "MAIL_USERS_BACKEND.USER_NAME, " + "MAIL_USERS_BACKEND.COGNOME, " + "MAIL_USERS_BACKEND.NOME, " + "MAIL_USERS_BACKEND.DEPARTMENT, " + "MAIL_USERS_BACKEND.MUNICIPIO, " + "MAIL_USERS_BACKEND.DOMAIN, " + "MAIL_USERS_BACKEND.ROLE ROLE_USER, " + "MAIL_USERS_SENDER_BACKEND.REF_ID_SENDER ID_SENDER, " + "MAIL_USERS_SENDER_BACKEND.ROLE AS ROLE_MAIL " + "FROM MAIL_USERS_BACKEND, MAIL_USERS_SENDER_BACKEND " + "WHERE MAIL_USERS_BACKEND.ID_USER = MAIL_USERS_SENDER_BACKEND.REF_ID_USER " + "AND MAIL_USERS_SENDER_BACKEND.REF_ID_SENDER = :ID_SENDER " + "ORDER BY MAIL_USERS_SENDER_BACKEND.DATA_INSERIMENTO DESC"; oCmd.Parameters.Add("ID_SENDER", idSender); using (OracleDataReader r = oCmd.ExecuteReader()) { if (r.HasRows) { listaDipendenti = new List <BackendUser>(); while (r.Read()) { BackendUser bUser = DaoOracleDbHelper.MapToBackendUser(r); if (bUser != null && bUser.UserId >= 0) { BackEndUserMailUserMapping b = DaoOracleDbHelper.MapToBackEndUserMailUserMapping(r); List <BackEndUserMailUserMapping> bList = new List <BackEndUserMailUserMapping>(); bList.Add(b); bUser.MappedMails = bList; } listaDipendenti.Add(bUser); } } } } } catch (Exception e) { //TASK: Allineamento log - Ciro if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione lista utenti abilitati per email: " + idSender.ToString() + " E072 Dettagli Errore: " + e.Message, "ERR_072", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } //Com.Delta.Logging.Errors.ErrorLogInfo error = new Com.Delta.Logging.Errors.ErrorLogInfo(); //error.freeTextDetails = "Errore nella creazione lista utenti abilitati per email: " + idSender.ToString() + " E072 Dettagli Errore: " + e.Message; //error.logCode = "ERR_072"; //error.passiveparentcodeobjectID = string.Empty; //error.passiveobjectGroupID = idSender.ToString(); //error.passiveobjectID = string.Empty; //error.passiveapplicationID = string.Empty; //log.Error(error); listaDipendenti = null; } return(listaDipendenti); }
public List <BackendUser> GetDipendentiDipartimentoAbilitati(Decimal idSender) { List <BackendUser> listaDipendenti = new List <BackendUser>(); try { using (var dbcontext = new FAXPECContext()) { using (var oCmd = dbcontext.Database.Connection.CreateCommand()) { oCmd.CommandText = "SELECT MAIL_USERS_BACKEND.ID_USER, " + "MAIL_USERS_BACKEND.USER_NAME, " + "MAIL_USERS_BACKEND.COGNOME, " + "MAIL_USERS_BACKEND.NOME, " + "MAIL_USERS_BACKEND.DEPARTMENT, " + "MAIL_USERS_BACKEND.MUNICIPIO, " + "MAIL_USERS_BACKEND.DOMAIN, " + "MAIL_USERS_BACKEND.ROLE ROLE_USER, " + "MAIL_USERS_SENDER_BACKEND.REF_ID_SENDER ID_SENDER, " + "MAIL_USERS_SENDER_BACKEND.ROLE AS ROLE_MAIL " + "FROM [FAXPEC].[FAXPEC].[MAIL_USERS_BACKEND], [FAXPEC].[FAXPEC].[MAIL_USERS_SENDER_BACKEND] " + "WHERE MAIL_USERS_BACKEND.ID_USER = MAIL_USERS_SENDER_BACKEND.REF_ID_USER " + "AND MAIL_USERS_SENDER_BACKEND.REF_ID_SENDER = " + idSender + " ORDER BY MAIL_USERS_SENDER_BACKEND.DATA_INSERIMENTO DESC"; oCmd.Connection.Open(); using (var r = oCmd.ExecuteReader()) { if (r.HasRows) { listaDipendenti = new List <BackendUser>(); while (r.Read()) { BackendUser bUser = AutoMapperConfiguration.MapToBackendUser(r); if (bUser != null && bUser.UserId >= 0) { BackEndUserMailUserMapping b = new BackEndUserMailUserMapping(); b.MailSenderId = (long)r.GetDecimal("ID_SENDER"); b.MailAccessLevel = int.Parse(r.GetString("ROLE_MAIL")); List <BackEndUserMailUserMapping> bList = new List <BackEndUserMailUserMapping>(); bList.Add(b); bUser.MappedMails = bList; } listaDipendenti.Add(bUser); } } } oCmd.Connection.Close(); } } } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione lista utenti abilitati per email: " + idSender.ToString() + " E072 Dettagli Errore: " + e.Message, "ERR_072", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } listaDipendenti = null; } return(listaDipendenti); }