Esempio n. 1
0
        protected void btnInserisciUtente_Click(object sender, EventArgs e)
        {
            // INSERISCO UTENTE
            Esito  esito  = new Esito();
            Utenti utente = CreaOggettoUtente(ref esito);

            //if (esito.Codice != Esito.ESITO_OK)
            //{
            //    basePage.ShowWarning("Controllare i campi evidenziati");
            //}
            if (esito.Codice == Esito.ESITO_OK)
            {
                NascondiErroriValidazione();

                int iRet = Anag_Utenti_BLL.Instance.CreaUtente(utente, ref esito);
                if (iRet > 0)
                {
                    // UNA VOLTA INSERITO CORRETTAMENTE PUO' ESSERE MODIFICATO
                    hf_idUtente.Value       = iRet.ToString();
                    ViewState["idUtente"]   = hf_idUtente.Value;
                    hf_tipoOperazione.Value = "VISUALIZZAZIONE";
                }

                if (esito.Codice != Esito.ESITO_OK)
                {
                    log.Error(esito.Descrizione);
                    basePage.ShowError(esito.Descrizione);
                }
                basePage.ShowSuccess("Inserito Utente " + utente.Username);
                btnEditUtente_Click(null, null);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, Utenti utenti)
        {
            if (id != utenti.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(utenti);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UtentiExists(utenti.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["listaOrari"] = GetOrari();
            ViewData["Sesso"]      = GetSesso();
            return(View(utenti));
        }
 /// <summary>
 /// Replace per gli utenti
 /// </summary>
 public static string Replace(this string text, Utenti utenti)
 {
     if (utenti == null) return text;
     if (string.IsNullOrEmpty(text)) return string.Empty;
     var sb = new StringBuilder(text);
     return sb.Replace(utenti).ToString();
 }
Esempio n. 4
0
 public Utenti MapDtoToUpdateUtenti(UtentiDto utentiDto, Utenti utenti)
 {
     utenti.UteId                      = utentiDto.UteId;
     utenti.UtePassword                = utentiDto.UtePassword;
     utenti.UteNome                    = utentiDto.UteNome;
     utenti.UteRuolo                   = utentiDto.UteRuolo;
     utenti.UteAttivo                  = utentiDto.UteAttivo;
     utenti.UteInsTimestamp            = utentiDto.UteInsTimestamp;
     utenti.UteInsUteId                = utentiDto.UteInsUteId;
     utenti.UteModTimestamp            = utentiDto.UteModTimestamp;
     utenti.UteModUteId                = utentiDto.UteInsUteId; //this is done willingly
     utenti.UteTitolo                  = utentiDto.UteTitolo;
     utenti.UteProfilo                 = utentiDto.UteProfilo;
     utenti.UteMail                    = utentiDto.UteMail;
     utenti.UteTelefono                = utentiDto.UteTelefono;
     utenti.UteAltriRiferimenti        = utentiDto.UteAltriRiferimenti;
     utenti.UteDeveloper               = utentiDto.UteDeveloper;
     utenti.UteTipoClientEmail         = utentiDto.UteTipoClientEmail;
     utenti.UteSede                    = utentiDto.UteSede;
     utenti.UteLimiteMaxSms            = utentiDto.UteLimiteMaxSms;
     utenti.UteRapportiniEmailInvio    = utentiDto.UteRapportiniEmailInvio;
     utenti.UteRapportiniUtentiGestiti = utentiDto.UteRapportiniUtentiGestiti;
     utenti.UteModalitaDebug           = utentiDto.UteModalitaDebug;
     utenti.UteUsaVpn                  = utentiDto.UteUsaVpn;
     utenti.UteRicerchePortaliMaxNum   = utentiDto.UteRicerchePortaliMaxNum;
     utenti.UteRisId                   = utentiDto.UteRisId;
     utenti.UteCliId                   = utentiDto.UteCliId;
     return(utenti);
 }
Esempio n. 5
0
        private Utenti CreaOggettoUtente(ref Esito esito)
        {
            Utenti utente = new Utenti();

            if (string.IsNullOrEmpty((string)ViewState["idUtente"]))
            {
                ViewState["idUtente"] = "0";

                MD5    md5Hash      = MD5.Create();
                string pwdEncrypted = GetMd5Hash(md5Hash, ConfigurationManager.AppSettings["DEFAULT_PASSWORD"]);
                md5Hash.Dispose();
                utente.Password = pwdEncrypted;
            }
            else
            {
                utente.Password = getPassword(Convert.ToInt16(ViewState["idUtente"].ToString()));
            }
            utente.Id            = Convert.ToInt16(ViewState["idUtente"].ToString());
            utente.Id_tipoUtente = Convert.ToInt32(cmbMod_TipoUtente.SelectedValue);

            utente.Cognome  = BasePage.ValidaCampo(tbMod_Cognome, "", true, ref esito);
            utente.Nome     = BasePage.ValidaCampo(tbMod_Nome, "", false, ref esito);
            utente.Username = BasePage.ValidaCampo(tbMod_Username, "", true, ref esito);

            utente.Email = BasePage.ValidaIndirizzoEmail(tbMod_Email, true, ref esito);

            utente.Descrizione = BasePage.ValidaCampo(tbMod_Descrizione, "", false, ref esito);
            utente.Attivo      = true;

            return(utente);
        }
Esempio n. 6
0
        protected void btnEliminaImageButton_Click(object sender, ImageClickEventArgs e)
        {
            //Server.Transfer("~/utenti.aspx");
            Utenti utente = (Utenti)Parent.Page;

            utente.showEliminaPopup();
        }
Esempio n. 7
0
        public UtentiOptimizedDto MapUtentiToOptimizedDto(Utenti utenti)
        {
            UtentiOptimizedDto utentiOptimizedDto = new UtentiOptimizedDto();

            utentiOptimizedDto.UteId   = utenti.UteId;
            utentiOptimizedDto.UteNome = utenti.UteNome;
            return(utentiOptimizedDto);
        }
Esempio n. 8
0
        /// <summary>
        /// 	Email inviata all'utente dopo che si è registrato con il link
        /// </summary>
        /// <param name = "utenti"></param>
        public static void NuovaRegistrazione(Utenti utenti)
        {
            if (utenti == null) return;

            string contenuto = Etichette.GetItem(Etichette.EtichetteEnum.EmailRegistrazioneUtenteContenuto, utenti.Lingue).Valore.Replace(utenti);
            string oggetto = Etichette.GetItem(Etichette.EtichetteEnum.EmailRegistrazioneUtenteOggetto, utenti.Lingue).Valore.Replace(utenti);
            InviaEmail(Settings.Config.Email.SenderNoReply, utenti.Email, oggetto, contenuto, utenti.Lingue);
        }
Esempio n. 9
0
        public ActionResult ElencoUtenti()
        {
            Utenti utenti = new Utenti();
            utenti.Add(new Utente { Nome = "Pamela", Cognome = "Sanchini" });
            utenti.Add(new Utente { Nome = "Onorio", Cognome = "Pompizii" });

            return View(utenti);
        }
Esempio n. 10
0
        public string delete(int itemgroup)
        {
            Utenti ad = db.Utenti.Where(x => x.id == itemgroup).First();

            db.Utenti.Attach(ad);
            db.Utenti.Remove(ad);
            db.SaveChanges();

            return("OK");
        }
Esempio n. 11
0
        public List <Utenti> CaricaListaUtenti(ref Esito esito, bool soloAttivi = true)
        {
            List <Utenti> listaUtenti = new List <Utenti>();

            try
            {
                using (SqlConnection con = new SqlConnection(sqlConstr))
                {
                    string query = "SELECT * FROM anag_utenti";
                    if (soloAttivi)
                    {
                        query += " WHERE ATTIVO = 1";
                    }
                    using (SqlCommand cmd = new SqlCommand(query))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())

                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                sda.Fill(dt);
                                if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                                {
                                    foreach (DataRow riga in dt.Rows)
                                    {
                                        Utenti utente = new Utenti();
                                        utente.Id            = riga.Field <int>("id");
                                        utente.Cognome       = riga.Field <string>("cognome");
                                        utente.Nome          = riga.Field <string>("nome");
                                        utente.Descrizione   = riga.Field <string>("descrizione");
                                        utente.Username      = riga.Field <string>("username");
                                        utente.Password      = riga.Field <string>("password");
                                        utente.Id_tipoUtente = riga.Field <int>("id_tipoUtente");
                                        utente.Email         = riga.Field <string>("email");
                                        utente.Attivo        = riga.Field <bool>("attivo");

                                        listaUtenti.Add(utente);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
            }

            return(listaUtenti);
        }
Esempio n. 12
0
        protected string GetUtenteRuolo(DocsPaWR.ItemReportPregressi report)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(report.idUtente))
            {
                DocsPaWR.Utente utente = null;
                if (this.Utenti == null)
                {
                    this.Utenti = new Dictionary <string, DocsPaWR.Utente>();
                }

                if (Utenti.ContainsKey(report.idUtente))
                {
                    utente = Utenti[report.idUtente];
                }
                else
                {
                    utente = UserManager.GetUtenteByIdPeople(report.idUtente);
                    Utenti.Add(report.idUtente, utente);
                }

                if (utente != null)
                {
                    result = utente.nome + " " + utente.cognome;
                }
            }

            if (!string.IsNullOrEmpty(report.idRuolo))
            {
                if (this.Ruoli == null)
                {
                    this.Ruoli = new Dictionary <string, DocsPaWR.Ruolo>();
                }
                DocsPaWR.Ruolo ruolo = null;

                if (Ruoli.ContainsKey(report.idRuolo))
                {
                    ruolo = Ruoli[report.idRuolo];
                }
                else
                {
                    ruolo = UserManager.getRuoloByIdGruppo(report.idRuolo, this.Page);
                    Ruoli.Add(report.idRuolo, ruolo);
                }

                if (ruolo != null)
                {
                    result = result + " (" + ruolo.descrizione + ")";
                }
            }

            return(result);
        }
        public ActionResult PasswordRecovery(string email)
        {
            AjaxMessagge resultMessage = new AjaxMessagge();

            if (db.Utenti.Where(x => x.email == email).Count() == 0)
            {
                resultMessage.Success     = false;
                resultMessage.Message     = "emailnontrovata".Translate();
                resultMessage.RedirectUrl = "/";
            }
            else
            {
                Utenti u = db.Utenti.Where(x => x.email == email).FirstOrDefault();

                // invio password

                string mailbody = db.Emailtemplate.Where(x => x.lang == (u.lang != "it"?"en":"it") && x.name == "recuperopassword").Select(x => x.template).FirstOrDefault().Replace("%pass%", u.password);


                MailMessage m = new MailMessage();
                m.From = new MailAddress("*****@*****.**");
                m.To.Add(email);
                m.IsBodyHtml   = true;
                m.Body         = mailbody;
                m.BodyEncoding = Encoding.UTF8;
                m.Subject      = "msg_recuperopassword".Translate();

                SmtpClient s = new SmtpClient("smtp.office365.com");
                s.Port      = 587;
                s.EnableSsl = true;
                System.Net.NetworkCredential c = new System.Net.NetworkCredential();

                c.UserName    = "******";
                c.Password    = "******";
                s.Credentials = c;

                try
                {
                    s.Send(m);
                    resultMessage.Success     = true;
                    resultMessage.Message     = string.Format("emailinviata".Translate());
                    resultMessage.RedirectUrl = "/";
                }
                catch
                {
                    resultMessage.Success     = false;
                    resultMessage.Message     = string.Format("err_inviomail".Translate());
                    resultMessage.RedirectUrl = "/";
                }
            }

            return(Json(resultMessage));
        }
Esempio n. 14
0
        public IActionResult SaveUtente([FromBody] Utenti utente)
        {
            if (utente == null)
            {
                return(BadRequest(new InfoMsg(DateTime.Today, "E' necessario inserire i dati dell'utente")));
            }

            //Contolliamo se l'utente è presente
            var isPresent = userRepository.CheckUser(utente.UserId);

            if (isPresent != null)
            {
                return(StatusCode(422, new InfoMsg(DateTime.Today, $"Utente {utente.UserId} presente in uso! Impossibile inserire!")));
            }

            //Contolliamo se la fidelity è presente
            var isCodFid = userRepository.CheckUserByFid(utente.CodFidelity);

            if (isCodFid != null)
            {
                return(StatusCode(422, new InfoMsg(DateTime.Today, $"CodFid {utente.CodFidelity} in uso! Impossibile inserire!")));
            }

            //Verifichiamo che i dati siano corretti
            if (!ModelState.IsValid)
            {
                string ErrVal = "";

                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        ErrVal += modelError.ErrorMessage + " - ";
                    }
                }

                return(BadRequest(new InfoMsg(DateTime.Today, ErrVal)));
            }

            PasswordHasher Hasher = new PasswordHasher();

            //Crptiamo la Password
            utente.Password = Hasher.Hash(utente.Password);

            //verifichiamo che i dati siano stati regolarmente inseriti nel database
            if (!userRepository.InsUtente(utente))
            {
                return(StatusCode(500, new InfoMsg(DateTime.Today, $"Ci sono stati problemi nell'inserimento dell'Utente {utente.UserId}.")));
            }

            return(Ok(new InfoMsg(DateTime.Today, $"Inserimento Utente {utente.UserId} eseguito con successo!")));
        }
 private void SetRevisore(Utente revisore)
 {
     Revisore = revisore;
     SetEsecutore(null);
     if (revisore == null)
     {
         cmbReviewer.SelectedItem = null;
     }
     else
     {
         cmbExecutor.ItemsSource = Utenti?.Where(utente => utente.RuoId == (short)App.RuoloDesc.Esecutore && utente.RevisoreID == Revisore.Id);
     }
 }
Esempio n. 16
0
        private static void GetSendas(UserInfo utente)
        {
            string pathNameDomain    = "LDAP://" + sDomain + "/" + utente.Distinguishedname;
            var    direcotyEntry     = new DirectoryEntry(pathNameDomain, username, password);
            var    directorySearcher = new DirectorySearcher(direcotyEntry);

            directorySearcher.PropertiesToLoad.Add("msExchRecipientTypeDetails");
            directorySearcher.PropertiesToLoad.Add("distinguishedname");
            directorySearcher.PropertiesToLoad.Add("mail");
            var res = directorySearcher.FindOne();

            DirectoryEntry              ssStoreObj  = res.GetDirectoryEntry();
            ActiveDirectorySecurity     StoreobjSec = ssStoreObj.ObjectSecurity;
            AuthorizationRuleCollection Storeacls   = StoreobjSec.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier));

            foreach (ActiveDirectoryAccessRule ace in Storeacls)
            {
                if (ace.IdentityReference.Value != "S-1-5-7" & ace.IdentityReference.Value != "S-1-1-0" & ace.IsInherited != true & ace.IdentityReference.Value != "S-1-5-10")
                {
                    if (ace.ActiveDirectoryRights.ToString() == "ExtendedRight")
                    {
                        bool found = false;

                        try
                        {
                            filead.WriteLine(utente.Mail + "," + Utenti.Find(x => x.ObjectSID.Contains(ace.IdentityReference.Value)).Mail + ",SendAS," + exRighthash[ace.ObjectType.ToString()].ToString() + ",,");
                            Trace.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmss") + "::INF::SendAS::OK::SendAS permission of --> " + utente.Mail + " exported successfully");
                            found = true;
                        }
                        catch
                        {
                        }

                        try
                        {
                            filead.WriteLine(utente.Mail + "," + GruppiInfo.Find(x => x.ObjectSID.Contains(ace.IdentityReference.Value)).samaccountname + ",SendAS," + exRighthash[ace.ObjectType.ToString()].ToString() + ",,");
                            Trace.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmss") + "::INF::SendAS::OK::SendAS permission of --> " + utente.Mail + " exported successfully");
                            found = true;
                        }
                        catch
                        {
                        }

                        if (!found)
                        {
                            Trace.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmss") + "::WRN::Cannot resolve SID " + ace.IdentityReference.Value);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        public ContentResult getDetail(int id)
        {
            //db.Configuration.ProxyCreationEnabled = false;
            // ritorna la pagina singola per ottenere i dati da inserire nel form di modifica
            Utenti pai = db.Utenti.Where(d => d.id == id).First();

            //return Json(pai);
            // return JsonConvert.SerializeObject(pai)

            return(Content(JsonConvert.SerializeObject(pai, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }), "application/json"));
        }
Esempio n. 18
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var user = new Utenti(Input.Email)
                {
                    Email       = Input.Email,
                    PhoneNumber = Input.PhoneNumber,
                    Name        = Input.Name
                };

                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    _emailSender.EnableSSL = _configuration.GetValue <bool>("EmailSender:EnableSSL");
                    _emailSender.HostSmtp  = _configuration["EmailSender:Host"];
                    _emailSender.Port      = _configuration.GetValue <int>("EmailSender:Port");
                    _emailSender.FromEmail = _configuration["EmailSender:EmailName"];
                    _emailSender.Password  = _configuration["EmailSender:Password"];

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    // await _signInManager.SignInAsync(user, isPersistent: false);
                    StatusSuccess = "Your account has been created succesfully. Verification email sent. Please check your email to confirm it.";
                    return(RedirectToPage());
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Esempio n. 19
0
        /// <summary>Restituisce il numero totale di coin in circolazione</summary>
        /// <returns>Num monete</returns>
        #endregion
        public int AggiornaBilancio()
        {
            #region SpiegazioneCodice

            //foreach (Utente utente in Utenti)
            //{
            //    bilancio += utente.Saldo.Count;
            //}
            //return bilancio;

            #endregion

            return(Utenti.Sum(utente => utente.Saldo.Count));
        }
Esempio n. 20
0
        public async Task <IActionResult> Create(Utenti utenti)
        {
            if (ModelState.IsValid)
            {
                utenti.DataInserimento = DateTime.Now;
                utenti.Eta             = new DateTime(DateTime.Now.Subtract(utenti.DataNascita).Ticks).Year - 1;
                _context.Add(utenti);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["listaOrari"] = GetOrari();
            ViewData["Sesso"]      = GetSesso();
            return(View(utenti));
        }
Esempio n. 21
0
        /// <summary>
        /// Modifica dei metadati di un fascicolo
        /// </summary>
        /// <param name="fascicolo"></param>
        /// <returns></returns>
        public virtual bool ModifyProject(DocsPaVO.fascicolazione.Fascicolo fascicolo)
        {
            bool result = false;

            using (DocsPaDB.Query_DocsPAWS.Fascicoli fascicoli = new DocsPaDB.Query_DocsPAWS.Fascicoli())
            {
                Ruolo ruolo = null;
                using (DocsPaDB.Query_DocsPAWS.Utenti u = new Utenti())
                    ruolo = u.getRuoloById(fascicolo.creatoreFascicolo.idCorrGlob_Ruolo);
                fascicolo.folderSelezionato = fascicoli.GetFolder(fascicolo.creatoreFascicolo.idPeople, ruolo.idGruppo, fascicolo.systemID);
                CreateFolderHermes(fascicolo, ruolo);
                result = fascicoli.SetFascicolo(this.UserInfo, fascicolo);
            }

            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// Ricerca un utente.
        /// </summary>
        /// <param name="idUtente">ID univoco dell'utente.</param>
        /// <returns>Oggetto di tipo utentea</returns>

        #endregion
        public Utente RicercaUtente(int?idUtente)
        {
            #region spiegazioneCodice
            //foreach (var utente in Utenti)
            //{
            //    if (utente.Nome == nome)
            //    {
            //        return utente;
            //    }
            //}
            //return null;
            //questo blocco di codice equivale all'espressione seguente
            #endregion

            return(Utenti.FirstOrDefault(utente => utente.IdUnivoco == idUtente));
        }
Esempio n. 23
0
        /// <summary>
        /// Verifica l'esistenza dell'utente all'interno della lista degli utenti.
        /// </summary>
        /// <param name="nome">Nome dell'utente da verificare.</param>
        /// <returns>Utente esiste (true/false)</returns>

        #endregion
        public bool VerificaUtente(string nome)
        {
            #region spiegazioneCodice
            //foreach (var utente in Utenti)
            //{
            //    if (utente.Nome == nome)
            //    {
            //        return true;
            //    }
            //}
            //return false;
            //questo blocco di codice equivale all'espressione seguente
            #endregion

            return(Utenti.Any(utente => utente.Nome == nome));
        }
 /// <summary>
 /// Replace per gli utenti
 /// </summary>
 public static StringBuilder Replace(this StringBuilder sb, Utenti utenti)
 {
     if (utenti == null) return sb;
     string linkConfermaRegistrazione = SiteManager.WebPath + "/confermaregistrazione?id=" + utenti.Id;
     sb = sb.Replace("[UID]", utenti.Id.ToString())
         .Replace("[UNOME]", utenti.Nome)
         .Replace("[UPASSWORD]", utenti.Passw)
         .Replace("[UEMAIL]", utenti.Email)
         .Replace("[UDATAACCESSO]", utenti.DataAccesso.ToString())
         .Replace("[UDATAREGISTRAZIONE]", utenti.DataRegistrazione.ToString())
         .Replace("[UIPREGISTRAZIONE]", utenti.IpRegistrazione)
         .Replace("[UIPACCESSO]", utenti.IpAccesso)
         .Replace("[ULINKREGISTRAZIONE]", linkConfermaRegistrazione)
         .Replace("[UCREDITI]", utenti.Crediti.ToString())
         .Replace("[UACCESSI]", utenti.Accessi.ToString());
     return sb;
 }
Esempio n. 25
0
 /// <summary>
 /// Replace per gli utenti
 /// </summary>
 internal static string Replace(this string text, Utenti utenti)
 {
     string linkConfermaRegistrazione = "<a href=\"" + Settings.Config.WebPath + "/" + utenti.Lingue.IsoCode.ToLower() + "/subscriptionconfirm?id=" + utenti.Id + "\">" + Etichette.GetItem(Etichette.EtichetteEnum.LinkEmailSubscription, utenti.Lingue).Valore + "</a>";
     var sb = new StringBuilder(text);
     sb = sb.Replace("[UID]", utenti.Id.ToString())
         .Replace("[UNOME]", utenti.Nome)
         .Replace("[UCOGNOME]", utenti.Cognome)
         .Replace("[UPASSWORD]", utenti.Password)
         .Replace("[UEMAIL]", utenti.Email)
         .Replace("[UDATAACCESSO]", utenti.DataAccesso.ToString())
         .Replace("[UDATAREGISTRAZIONE]", utenti.DataRegistrazione.ToString())
         .Replace("[UIPREGISTRAZIONE]", utenti.IpRegistrazione)
         .Replace("[UIPACCESSO]", utenti.IpAccesso)
         .Replace("[ULINKREGISTRAZIONE]", linkConfermaRegistrazione)
         .Replace("[UACCESSI]", utenti.Accessi.ToString());
     return sb.ToString();
 }
Esempio n. 26
0
        /// <summary>
        /// Modifica dei metadati di un fascicolo
        /// </summary>
        /// <param name="fascicolo"></param>
        /// <returns></returns>
        public virtual bool ModifyProject(DocsPaVO.fascicolazione.Fascicolo fascicolo)
        {
            bool ret = false;

            using (DocsPaDB.Query_DocsPAWS.Fascicoli fascicoli = new DocsPaDB.Query_DocsPAWS.Fascicoli())
                ret = fascicoli.SetFascicolo(UserInfo, fascicolo);

            string valorechiave = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_PROJECT_STRUCTURE");

            if (!string.IsNullOrEmpty(valorechiave) && valorechiave.Equals("1") && !fascicolo.HasStrutturaTemplate)
            {
                Ruolo r = new Utenti().GetRuoloByIdGruppo(UserInfo.idGruppo);
                CreateStrutturaFascicolo(fascicolo, UserInfo, r);
            }

            return(ret);
        }
Esempio n. 27
0
        public async Task <IActionResult> OnPostGetUserRoleAsync(string UtenteRuoloId)
        {
            if (!string.IsNullOrWhiteSpace(UtenteRuoloId))
            {
                Utenti utente = _db.Utenti.Where(u => u.Id.Equals(UtenteRuoloId, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                RuoliDiUtente = await _userManager.GetRolesAsync(utente);

                if (RuoliDiUtente.Count == 0)
                {
                    RuoliDiUtente = null;
                    HasRuolo      = -1;
                }
                return(Page());
            }

            return(Page());
        }
Esempio n. 28
0
        public DocsPaVO.FriendApplication.FriendApplication getFriendApplication(string friendApplication, string codiceRegistro)
        {
            DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider();
            DocsPaVO.FriendApplication.FriendApplication friendApplicationResutl = null;

            try
            {
                DocsPaUtils.Query queryMng = DocsPaUtils.InitQuery.getInstance().getQuery("GET_FRIEND_APPLICATION");
                queryMng.setParam("friendApplication", friendApplication);
                queryMng.setParam("codRegistro", codiceRegistro);
                string commandText = queryMng.getSQL();
                System.Diagnostics.Debug.WriteLine("SQL - getFriendApplication - FriendApplication.cs - QUERY : " + commandText);
                logger.Error("SQL - getFriendApplication - FriendApplication.cs - QUERY : " + commandText);
                DataSet ds = new DataSet();
                dbProvider.ExecuteQuery(ds, commandText);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    friendApplicationResutl = new DocsPaVO.FriendApplication.FriendApplication();
                    friendApplicationResutl.codiceApplicazione = ds.Tables[0].Rows[i]["COD_APPLICAZIONE"].ToString();
                    friendApplicationResutl.codiceRegistro     = ds.Tables[0].Rows[i]["COD_REGISTRO"].ToString();
                    friendApplicationResutl.idPeopleFactory    = ds.Tables[0].Rows[i]["ID_PEOPLE_FACTORY"].ToString();
                    friendApplicationResutl.idGruppoFactory    = ds.Tables[0].Rows[i]["ID_GRUPPO_FACTORY"].ToString();
                    friendApplicationResutl.idRegistro         = ds.Tables[0].Rows[i]["ID_REGISTRO"].ToString();

                    Utenti utenti = new Utenti();
                    friendApplicationResutl.utente          = utenti.getUtenteById(friendApplicationResutl.idPeopleFactory);
                    friendApplicationResutl.utente.idPeople = friendApplicationResutl.idPeopleFactory;

                    friendApplicationResutl.ruolo = utenti.GetRuoloByIdGruppo(friendApplicationResutl.idGruppoFactory);
                    utenti.GetRegistro(friendApplicationResutl.idRegistro, ref friendApplicationResutl.registro);
                    friendApplicationResutl.utente.ruoli = new ArrayList();
                    friendApplicationResutl.utente.ruoli.Add(friendApplicationResutl.ruolo);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Errore in FriendApplication  - metodo: getFriendApplication", ex);
                throw ex;
            }
            finally
            {
                dbProvider.Dispose();
            }
            return(friendApplicationResutl);
        }
Esempio n. 29
0
        public async Task <IActionResult> OnPostAddUserToRoleAsync(string UtenteId, string RuoloId)
        {
            Utenti utente = _db.Utenti.Where(u => u.Id.Equals(UtenteId, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();

            Models.Ruoli ruoli  = _db.Ruoli.Where(r => r.Id.Equals(RuoloId, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
            var          result = await _userManager.AddToRoleAsync(utente, ruoli.Name);

            if (result.Succeeded)
            {
                TempMessageAdd = "Role assigned successfully for this user  !";
            }
            else
            {
                TempMessageAdd = "The Role exists for this user!";
                return(Page());
            }
            return(RedirectToPage());
        }
Esempio n. 30
0
        public async Task <IActionResult> OnPostDeleteUserFromRoleAsync(string UtenteIdDel, string RuoloIdDel)
        {
            Utenti utente = _db.Utenti.Where(u => u.Id.Equals(UtenteIdDel, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();

            Models.Ruoli ruoli = _db.Ruoli.Where(r => r.Id.Equals(RuoloIdDel, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
            if (await _userManager.IsInRoleAsync(utente, ruoli.Name))
            {
                await _userManager.RemoveFromRoleAsync(utente, ruoli.Name);

                TempMessageDel = "Role removed from this user successfully !";
            }
            else
            {
                TempMessageDel = "This user doesn't belong to selected role.";
            }

            return(Page());
        }
Esempio n. 31
0
 public void Login()
 {
     do
     {
         Console.WriteLine("inserisci username (email)");
         string email = Console.ReadLine();
         Console.WriteLine("inserisci password");
         string pass   = Console.ReadLine();
         var    utente = Utenti.FirstOrDefault(u => u.Email == email && u.Password == pass);
         if (utente == null)
         {
             Console.WriteLine("Username o password errati");
             continue;
         }
         UtenteLoggato = utente;
         Console.WriteLine("login effettuato con successo");
         return;
     } while (true);
 }
Esempio n. 32
0
        public Utenti getUtenteById(int idUtente, ref Esito esito)
        {
            Utenti utente = new Utenti();

            try
            {
                using (SqlConnection con = new SqlConnection(sqlConstr))
                {
                    string query = "SELECT * FROM anag_utenti where id = " + idUtente.ToString();
                    using (SqlCommand cmd = new SqlCommand(query))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                sda.Fill(dt);
                                if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                                {
                                    utente.Id            = dt.Rows[0].Field <int>("id");
                                    utente.Cognome       = dt.Rows[0].Field <string>("cognome");
                                    utente.Nome          = dt.Rows[0].Field <string>("nome");
                                    utente.Descrizione   = dt.Rows[0].Field <string>("descrizione");
                                    utente.Username      = dt.Rows[0].Field <string>("username");
                                    utente.Password      = dt.Rows[0].Field <string>("password");
                                    utente.Id_tipoUtente = dt.Rows[0].Field <int>("id_tipoUtente");
                                    utente.Email         = dt.Rows[0].Field <string>("email");
                                    utente.Attivo        = dt.Rows[0].Field <bool>("attivo");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
            }
            return(utente);
        }
Esempio n. 33
0
        public Utenti getUtenteByUserAndEmail(string username, string email, ref Esito esito)
        {
            Utenti utente = new Utenti();

            try
            {
                using (SqlConnection con = new SqlConnection(sqlConstr))
                {
                    string query = "SELECT * FROM ANAG_UTENTI WHERE USERNAME = '******'", "''") + "' AND EMAIL = '" + email.Replace("'", "''") + "'";
                    using (SqlCommand cmd = new SqlCommand(query))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                sda.Fill(dt);
                                if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                                {
                                    utente.Id            = dt.Rows[0].Field <int>("id");
                                    utente.Cognome       = dt.Rows[0].Field <string>("cognome");
                                    utente.Nome          = dt.Rows[0].Field <string>("nome");
                                    utente.Descrizione   = dt.Rows[0].Field <string>("descrizione");
                                    utente.Username      = dt.Rows[0].Field <string>("username");
                                    utente.Password      = dt.Rows[0].Field <string>("password");
                                    utente.Id_tipoUtente = dt.Rows[0].Field <int>("id_tipoUtente");
                                    utente.Email         = dt.Rows[0].Field <string>("email");
                                    utente.Attivo        = dt.Rows[0].Field <bool>("attivo");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
            }
            return(utente);
        }
Esempio n. 34
0
        public bool Authenticate(string username, string password)
        {
            bool retVal = false;

            PasswordHasher Hasher = new PasswordHasher();

            Utenti utente = this.alphaShopDbContext.Utenti
                            .Include(r => r.Profili)
                            .Where(c => c.UserId == username)
                            .FirstOrDefault();

            if (utente != null)
            {
                string EncryptPwd = utente.Password;

                retVal = Hasher.Check(EncryptPwd, password).Verified;
            }

            return(retVal);
        }
        private void CmbClienti_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ConfermaSalvataggio();
            Cliente = (sender as ComboBox)?.SelectedItem as Cliente;
            SetRevisore(null);
            SetArea(null);
            cmbExecutor.ItemsSource = null;
            if (Cliente == null || Cliente.ID == null)
            {
                return;
            }

            // Utenti = cUtenti.GetUtentiByIdCliente(Cliente.ID);
            Utenti = cUtenti.GetUtentiXCliente(Cliente.ID);

            cmbReviewer.ItemsSource = Utenti?.Where(utente => utente.RuoId == (int)App.RuoloDesc.Reviewer);
            CartelleCliente         = cCartelle.GetCartelleByCliente(Cliente.ID);
            CaricaRiepilogo(trvRiepilogo, Utenti, CartelleCliente);
            cmbAree.ItemsSource = cCartelle.GetAree().Where(a => CartelleCliente.Any(c => a.Codice == c.Codice));
        }
Esempio n. 36
0
        protected void __Button_Salva_Click(object sender, EventArgs e)
        {
            Utenti utente;

            if (GetQueryStringId != -1) utente = Utenti.GetItem(Utenti.KeyColumnsEnum.Id, GetQueryStringId);
            else utente = new Utenti();

            utente.CodiceFiscale = __TextBox_CodiceFiscale.Text;
            utente.Cognome = HttpUtility.HtmlEncode(__TextBox_Cognome.Text);
            utente.DataAccesso = DateTime.Now;
            utente.DataRegistrazione = DateTime.Now;
            utente.Email = __TextBox_Email.Text;
            utente.IpAccesso = Request.UserHostAddress;
            utente.IpRegistrazione = Request.UserHostAddress;
            utente.Lingue = Lingue.GetItem(Lingue.KeyColumnsEnum.Id, int.Parse(__DropDownList_Lingue.SelectedValue));
            utente.Nome = HttpUtility.HtmlEncode(__TextBox_Nome.Text);
            utente.RagioneSociale = HttpUtility.HtmlEncode(__TextBox_RagioneSociale.Text);
            utente.PartitaIva = __TextBox_PartitaIva.Text;
            utente.Password = __TextBox_Password.Text;
            utente.Ruolo = Ruoli.GetItem(Ruoli.KeyColumnsEnum.Id, int.Parse(__DropDownList_Ruoli.SelectedValue));
            utente.EmailVerificata = __CheckBox_EmailVerificata.Checked;
            utente.PrezzoSconti = PrezzoSconti.GetItem(PrezzoSconti.KeyColumnsEnum.Id, int.Parse(__DropDownList_TipologiaSconto.SelectedValue));
            utente.MailingList = __CheckBox_MailingList.Checked;

            if (GetQueryStringId != -1)
                Utenti.Save(out Avviso, utente);
            else
            {
                if (Utenti.RegistrazioneDatiUtente(out Avviso, ref utente))
                    Id = utente.Id;
            }

            if (string.IsNullOrEmpty(Avviso)) MessageBoxOk();
            else MessageBox(Avviso);

            __Button_Indirizzi.Enabled = Id != -1;
        }
Esempio n. 37
0
 /// <summary>
 /// Invia una email all'utente avvisando che i crediti sono terminati e il rialzo automatico non è piu attivato
 /// </summary>
 internal static void CreditiTerminati(Utenti utenti)
 {
     if (utenti == null) return;
     string oggetto = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailCreditiTerminatiOggetto).Valore.Replace(utenti);
     string contenuto = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailCreditiTerminatiContenuto).Valore.Replace(utenti);
     InviaEmail(Settings.Config.Email.SenderNoReply, Settings.Config.Email.SenderNoReply, oggetto, contenuto);
 }
Esempio n. 38
0
 /// <summary>
 /// Imposta i cookies per l'accesso
 /// </summary>
 /// <param name="utenti"></param>
 internal static void WriteCookiesUser(Utenti utenti)
 {
     if (utenti == null) return;
     HttpContext.Current.Response.Cookies[Settings.Config.WebPath]["email"] = utenti.Email;
     HttpContext.Current.Response.Cookies[Settings.Config.WebPath]["passw"] = utenti.Password;
     HttpContext.Current.Response.Cookies[Settings.Config.WebPath]["lang"] = utenti.Lingue.IsoCode;
     HttpContext.Current.Response.Cookies[Settings.Config.WebPath].Expires = DateTime.Now.AddDays(30);
 }
Esempio n. 39
0
        /// <summary>
        /// Invia una email di test
        /// </summary>
        public static void MailingListTest(string contenuto, string oggetto)
        {
            Utenti utente = new Utenti();
            utente.Accessi = 123;
            utente.Attivo = true;
            utente.DataAccesso = DateTime.Now;
            utente.DataRegistrazione = DateTime.Now.AddYears(-1).AddMonths(-6);
            utente.Email = "*****@*****.**";
            utente.IpAccesso = "123.123.123.123";
            utente.IpRegistrazione = "123.123.123.123";
            utente.Nome = "Nome Utente";
            utente.Passw = "Password Utente";
            utente.SitoIscrizione = "Sito iscrizione";

            //Per ogni lingua invio l'email
            oggetto = oggetto.Replace(utente); //Prendo titolo e testo in base alla descrizione
            contenuto = contenuto.Replace(utente);

            Common.Email.ManagerEmail.InviaEmail(contenuto, oggetto, Settings.Config.Email.SenderMailingList, Settings.Config.Email.DestinationTestMailingList);
        }
Esempio n. 40
0
        /// <summary>
        /// 	Invia l'email all'utente con l'elenco dei primi 20 annunci che scadono entro 7 giorni
        /// </summary>
        internal static void AnnunciInScadenza(Utenti utenti)
        {
            if (utenti == null) return;

            //Tutti gli annunci nel database senza distinzione da utilizzare nel sistema
            var annunciCollection = AnnunciCollection.GetList("Utenti.Id == " + utenti.Id + " && Attivo == True && AvvisoScadenza == False && DataScadenza < @0", DateTime.Now.AddDays(7));

            if (annunciCollection.Count > 0) return;

            //Prendo l'html della email dalla configurazione globale
            string htmlScadenzaSetteGiorniOggetto = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailScadenzaSetteGiorniOggetto).Valore.Replace(utenti);
            string htmlScadenzaSetteGiorniHeader = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailScadenzaSetteGiorniHeader).Valore.Replace(utenti);
            string htmlScadenzaSetteGiorniElemento = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailScadenzaSetteGiorniElemento).Valore;
            string htmlScadenzaSetteGiorniFooter = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailScadenzaSetteGiorniFooter).Valore.Replace(utenti);

            var avvisoScadenza = new StringBuilder();

            avvisoScadenza.Append(htmlScadenzaSetteGiorniHeader);

            //Dagli annunci in scadenza, prendo solo quelli dell'utente corrente e solo i primi 10
            foreach (Annunci annuncio in annunciCollection.Take(20))
            {
                avvisoScadenza.Append(htmlScadenzaSetteGiorniElemento.Replace(annuncio));

                //Attivo il check dell'avviso scadenza come inviato
                var annuncioSave = annuncio;
                annuncio.AvvisoScadenza = true;
                string avviso;
                Annunci.Save(out avviso, ref annuncioSave);
            }

            avvisoScadenza.Append(htmlScadenzaSetteGiorniFooter);

            InviaEmail(Settings.Config.Email.SenderNoReply, utenti.Email, htmlScadenzaSetteGiorniOggetto, avvisoScadenza.ToString());
        }
Esempio n. 41
0
        /// <summary>
        /// Invia l'email all'utente avvisando che gli annunci sono scaduti
        /// </summary>
        internal static void AnnunciScaduti(Utenti utenti)
        {
            if (utenti == null) return;

            //Tutti gli annunci nel database senza distinzione da utilizzare nel sistema
            var annunciCollection = AnnunciCollection.GetList("Utenti.Id == " + utenti.Id + " && Attivo == True && DataScadenza < @0", DateTime.Now);
            if (annunciCollection.Count > 0) return;

            //Prendo l'html della email dalla configurazione globale
            string htmlStatisticheOggetto = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailAnnunciScadutiOggetto).Valore.Replace(utenti);
            string htmlStatisticheHeader = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailAnnunciScadutiHeader).Valore.Replace(utenti);
            string htmlStatisticheElemento = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailAnnunciScadutiElemento).Valore;
            string htmlStatisticheFooter = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailAnnunciScadutiFooter).Valore.Replace(utenti);

            var avvisoScadenza = new StringBuilder();

            avvisoScadenza.Append(htmlStatisticheHeader);

            //Dagli annunci in scadenza, prendo solo quelli dell'utente corrente e solo i primi 10
            foreach (Annunci annuncio in annunciCollection.Take(20))
                avvisoScadenza.Append(htmlStatisticheElemento.Replace(annuncio));

            avvisoScadenza.Append(htmlStatisticheFooter);

            InviaEmail(Settings.Config.Email.SenderNoReply, utenti.Email, htmlStatisticheOggetto, avvisoScadenza.ToString());

            //Disattivo gli annunci
            foreach (Annunci annuncio in annunciCollection)
            {
                var ann = Annunci.GetItem(Annunci.KeyColumnsEnum.Id, annuncio.Id);
                ann.Attivo = false;
                string avviso;
                Annunci.Save(out avviso, ref ann);
            }
        }
Esempio n. 42
0
        /// <summary>
        /// Invia l'email all'utente chiedendo di confermare la registrazione
        /// </summary>
        internal static void RegistrazioneConfermaUtente(Utenti utente)
        {
            if (utente == null) return;
            if (utente.Attivo) return;

            string contenuto = ConfigurazioneSito.GetItem(ConfigurazioneSito.ConfigurazioneSitoEnum.EmailRegistrazioneContenuto).Valore.Replace(utente);
            string oggetto = ConfigurazioneSito.GetItem(ConfigurazioneSito.ConfigurazioneSitoEnum.EmailRegistrazioneOggetto).Valore.Replace(utente);

            InviaEmail(Settings.Config.Email.SenderNoReply, utente.Email, oggetto, contenuto);
        }
Esempio n. 43
0
        /// <summary>
        /// Invia le statistiche mensili dei primi 20 annunci ad un utente
        /// </summary>
        internal static void StatisticheUtente(Utenti utenti)
        {
            if (utenti == null) return;

            //Tutti gli annunci nel database senza distinzione da utilizzare nel sistema
            var annunciCollection = AnnunciCollection.GetList("Utenti.Id == " + utenti.Id + "");

            if (annunciCollection.Count > 0) return;

            //Prendo l'html della email dalla configurazione globale
            string htmlStatisticheOggetto = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailStatisticheOggetto).Valore.Replace(utenti);
            string htmlStatisticheHeader = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailStatisticheHeader).Valore.Replace(utenti);
            string htmlStatisticheElemento = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailStatisticheElemento).Valore;
            string htmlStatisticheFooter = Configurazione.GetItem(Configurazione.ConfigurazioneEnum.EmailStatisticheFooter).Valore.Replace(utenti);

            var avvisoScadenza = new StringBuilder();

            avvisoScadenza.Append(htmlStatisticheHeader);

            //Dagli annunci in scadenza, prendo solo quelli dell'utente corrente e solo i primi 10
            foreach (Annunci annuncio in annunciCollection.Take(20))
                avvisoScadenza.Append(htmlStatisticheElemento.Replace(annuncio));

            avvisoScadenza.Append(htmlStatisticheFooter);

            InviaEmail(Settings.Config.Email.SenderNoReply, utenti.Email, htmlStatisticheOggetto, avvisoScadenza.ToString());
        }