Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string S1 = this.Request.Params["x"]; //proviene da sp_exp_licenzauso

            this.Response.Clear();
            if (S1 == null || S1 == "")
            {
                return;
            }
            string error;

            Conn = GetVars.GetSystemDataAccess(this, out error);
            if (Conn == null)
            {
                return;
            }

            ldpauth = new ldapauth(Conn);
            if (!ldpauth.getconfig())
            {
                return;
            }

            DoLDAP(S1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Si collega al dipartimento "codice" con un determinato user e pwd.
        /// Se user e pwd sono nulle accede con un utente predefinito.
        /// </summary>
        /// <param name="codice">Codice dipartimento.</param>
        /// <param name="user">Nome utente.</param>
        /// <param name="pwd">Password.</param>
        /// <param name="datacontabile">Data contabile.</param>
        void ConnectToDepartment(string codice, string user, string pwd, DateTime datacontabile)
        {
            string              error;
            DataAccess          Conn   = GetVars.GetSystemDataAccess(this, out error);
            MetaMasterBootstrap master = Page.Master as MetaMasterBootstrap;

            master?.setUniversita(Session["system_config_nome_universita"] as string);
            if (codice.Trim().Length == 0)
            {
                labExtMessage.Text = "Non è stato selezionato alcun dipartimento";
                return;
            }

            //Attenzione: leggere da XML IP del server e NomeDB
            //Inserire da codice NomeUtente e Password
            string    filterdip = "(codicedipartimento=" + QueryCreator.quotedstrvalue(codice, true) + ")";
            DataTable CodDip    = Conn.RUN_SELECT("codicidipartimenti", "*", null, filterdip, null, true);

            if ((CodDip == null) || (CodDip.Rows.Count == 0))
            {
                //Dati non corretti
                WebLog.Log(this, codice + ": Codice non corretto");
                labExtMessage.Text = "Il codice inserito non è corretto.";
                return;
            }

            if (CodDip.Rows.Count > 1)
            {
                //Attenzione nel DB non è garantita l'unicità dei dati.
                labExtMessage.Text = "Chiedere al Responsabile del servizio " +
                                     "l'assegnazione di un nuovo Codice";
                WebLog.Log(this, "Attenzione!!! Duplicazione di codici per " + codice);
                return;
            }

            string  err  = "";
            DataRow myDr = CodDip.Rows[0];

            Session["Dipartimento"] = myDr["Dipartimento"].ToString();

            //Creo la connessione.
            DataAccess UsrConn = GetVars.CreateUserConn(this, myDr, user, pwd, datacontabile, out err);

            if (UsrConn == null)
            {
                err = "Connessione per l'utente '" + user + "' rifiutata. <br/> Controllare Nome Utente e/o Password";
                string err2 = "Connessione al db del dipartimento " + codice +
                              " non riuscita. <br/>" + err;
                labExtMessage.Text = err2;
                WebLog.Log(this, err2);
                return;
            }
        }
Exemplo n.º 3
0
        DataAccess GetDepartmentConn(string dep)
        {
            DataSet Cfg = GetVars.GetConfigDataSet(this);

            if (Cfg.Tables[0].Rows.Count == 0)
            {
                Error("Servizio non installato correttamente. Manca il file di configurazione.");
                return(null);
            }
            string     error;
            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                Error("Connessione al db di sistema non riuscita.");
                return(null);
            }
            return(GetDepAccess(Conn, dep));
        }
Exemplo n.º 4
0
        public static void Log(System.Web.UI.Page P, string Azione)
        {
            DataSet DS = new DataSet("log");

            DS.CaseSensitive = false;
            DataAccess Conn = GetVars.GetSystemDataAccess(P);

            if (Conn == null)
            {
                return;
            }
            Conn.Open();
            if (Conn.openError)
            {
                return;
            }
            DataTable T = Conn.CreateTableByName("logweb", "*");

            DS.Tables.Add(T);
            DataRow R = T.NewRow();

            R["IDLog"]              = Guid.NewGuid().ToString();
            R["IP"]                 = P.Request.UserHostAddress;
            R["Azione"]             = Azione;
            R["Data"]               = DateTime.Now;
            R["CodiceDipartimento"] = NoNull(GetVars.GetCodDip(P));
            R["Dipartimento"]       = NoNull(GetVars.GetDip(P));
            R["DipServer"]          = NoNull(Conn.GetSys("server"));
            R["DipDatabase"]        = NoNull(Conn.GetSys("database"));
            R["NomeReport"]         = NoNull(P.Session["ReportName"]);
            T.Rows.Add(R);
            string tipoUtente = NoNull(P.Session["TipoUtente"]).ToString();

            if (tipoUtente.ToLower() == "fornitore")
            {
                R["Utente"]      = NoNull(P.Session["Fornitore"]);
                R["LoginUtente"] = NoNull(P.Session["LoginFornitore"]);
            }
            if (tipoUtente.ToLower() == "responsabile")
            {
                R["Utente"]      = NoNull(P.Session["Responsabile"]);
                R["LoginUtente"] = NoNull(P.Session["LoginResponsabile"]);
            }
            if (tipoUtente.ToLower() == "utente")
            {
                R["Utente"]      = NoNull(P.Session["Utente"]);
                R["LoginUtente"] = NoNull(P.Session["Utente"]);
            }
            if (tipoUtente.ToLower() == "utente ldap")
            {
                R["Utente"]      = NoNull(P.Session["Utente"]);
                R["LoginUtente"] = NoNull(P.Session["Utente"]);
            }


            PostData PD = new PostData();

            PD.initClass(DS, Conn);
            ProcedureMessageCollection MCOLL = PD.DO_POST_SERVICE();

            if (MCOLL.CanIgnore && MCOLL.Count > 0)
            {
                PD.DO_POST_SERVICE();
            }
            Conn.Close();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMessaggio.Text  = "";
            labExtMessage.Text = "";

            // Imposta il nome dell'utente identificato dall'intentity provider.
            if (Session["samlemail"] == null)
            {
                lblMessaggio.Text = "Autenticazione fallita.";
                WebLog.Log(this, "Autenticazione fallita.");
                //Response.Redirect("DefaultSAML.aspx");
                return;
            }

            txtNomeUtente.Text = Session["samlemail"].ToString();

            if (!Page.IsPostBack)
            {
                Session["utente"]             = "";
                Session["Responsabile"]       = "";
                Session["Fornitore"]          = "";
                Session["CodiceResponsabile"] = null;
                Session["CodiceFornitore"]    = null;
                Session["TipoUtente"]         = null;

                txtDataContabile.Text = HelpForm.StringValue(DateTime.Now, "x.y");
            }

            DataSet Cfg = GetVars.GetConfigDataSet(this);

            if (Cfg.Tables[0].Rows.Count == 0)
            {
                lblMessaggio.Text = "Servizio non installato correttamente. Manca il file di configurazione.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }

            string error;

            Conn = GetVars.GetSystemDataAccess(this, out error);
            if (Conn == null)
            {
                lblMessaggio.Text = "Connessione al DB di sistema non riuscita.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            else
            {
                lblMessaggio.Text = "Il servizio Web è attivo.";
            }
            MetaMasterBootstrap master = Page.Master as MetaMasterBootstrap;

            master?.setUniversita(Session["system_config_nome_universita"] as string);

            GetVars.ClearUserConn(this);

            if (Request != null)
            {
                string dep = Request.Params["dep"];
                if (!string.IsNullOrEmpty(dep))
                {
                    Label3.Visible          = false;
                    cmbDipartimento.Visible = false;
                }
            }

            AggiornaElencoDipartimenti();
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                labMsg.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    labMsg.Text += error;
                }
                return;
            }
            if (Session["pwd_system"] != null)
            {
                LabelPasswordCfg.Visible = false;
            }
            // Put user code to initialize the page here
            if (IsPostBack)
            {
                string pwdsys = Request.Form["txtPwdSystem"].ToString();
                if (Session["pwd_system"] == null)
                {
                    if (pwdsys != "web report fc-hires")
                    {
                        labMsg.Text = "Password di sistema non accettata.";
                        return;
                    }
                    Session["pwd_system"] = "1";
                }
                string          dip    = txtDip.Text;
                string          codice = txtCodice.Text;
                string          ip     = txtIP.Text;
                string          db     = txtDB.Text;
                string          user   = txtUser.Text;
                string          pwd    = Request.Form["txtPWD"].ToString();
                Easy_DataAccess Conn   = new Easy_DataAccess(
                    "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);
                if (Conn == null)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Open();
                if (Conn.OpenError)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Close();
                DataSet     DS        = new Dipartimenti();
                QueryHelper QHS       = sys.GetQueryHelper();
                string      searchdip = QHS.CmpEq("CodiceDipartimento", codice);
                if (sys.RUN_SELECT_COUNT("CodiciDipartimenti", searchdip, true) > 0)
                {
                    labMsg.Text = "Codice dipartimento già esistente, sarà aggiornato.";
                    DataTable T = DS.Tables[0];
                    sys.RUN_SELECT_INTO_TABLE(T, null, searchdip, null, false);
                    DataRow R = T.Rows[0];
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                }
                else
                {
                    DataTable T = DS.Tables[0];
                    DataRow   R = T.NewRow();
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                    T.Rows.Add(R);
                }
                PostData CP = new PostData();
                CP.InitClass(DS, sys);
                ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();
                if (!MCOLL.CanIgnore)
                {
                    labMsg.Text = "Delle regole di sicurezza impediscono l'update del db di sistema!!";
                    return;
                }

                if (MCOLL.Count > 0)
                {
                    MCOLL = CP.DO_POST_SERVICE();
                    if (!MCOLL.CanIgnore)
                    {
                        labMsg.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                        return;
                    }
                }

                labMsg.Text = "DB DI SISTEMA Aggiornato correttamente.";
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Master.SetTitle("WebEasy - Accesso Servizi Dipartimento  ");
            lblMessaggio.Text  = "";
            labExtMessage.Text = "";
            error_dep          = false;
            if (!Page.IsPostBack || Page.Session.IsNewSession)
            {
                Session["utente"]             = "";
                Session["Responsabile"]       = "";
                Session["Fornitore"]          = "";
                Session["CodiceResponsabile"] = null;
                Session["CodiceFornitore"]    = null;
            }
            if (Request != null)
            {
                if (Request.Params["x"] != null && Request.Params["x"].ToString() != "")
                {
                    Session["DepCode"] = Request.Params["x"];
                }
            }
            if (Session["DepCode"] == null || Session["DepCode"].ToString() == "")
            {
                lblMessaggio.Text = "E' necessario chiamare la pagina magazzino_out.aspx con il parametro dep=codice dipartimento";
                WebLog.Log(this, "Parametro dep non fornito.");
                error_dep = true;
                return;
            }

            //if (Session["DoLogon"] == null || !((bool)Session["DoLogon"])) {
            //    lblMessaggio.Text = "Applicazione non inizializzata correttamente.";
            //    WebLog.Log(this, "Applicazione non inizializzata correttamente.");
            //    return;
            //}

            DataSet Cfg = GetVars.GetConfigDataSet(this);

            if (Cfg.Tables[0].Rows.Count == 0)
            {
                lblMessaggio.Text = "Servizio non installato correttamente. Manca il file di configurazione.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            MetaMaster MM = Master as MetaMaster;
            //if (MM != null) MM.ShowClientMessage("NINO", false);

            string error;

            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                //lblMessaggio.Text = "Connessione al DB di sistema non riuscita." + error;
                //Attenzione qui l'errore contiene la password del Database !
                lblMessaggio.Text = "Connessione al DB di sistema non riuscita.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            lblMessaggio.Text = "Il servizio Web è attivo";
            GetVars.ClearUserConn(this);
        }
Exemplo n.º 8
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (error_dep)
            {
                return;
            }

            string     error;
            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                return;
            }

            DateTime D = DateTime.Now;

            object Onedip = Session["DepCode"];

            if (Onedip == null)
            {
                MetaPage.SessionTimeOut(this);
                return;
            }
            //Onedip = "amministrazione";

            ConnectToDepartment(Onedip.ToString(), null, null, D);
            Easy_DataAccess UsrConnTemp = GetVars.GetUserConn(this);

            if (UsrConnTemp == null || UsrConnTemp.Open() == false)
            {
                //Il Server del Dipartimento non è in rete.
                //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                labExtMessage.Text = "Il Server del Dipartimento " + Onedip.ToString() + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + Onedip.ToString() + "non risponde.");
                return;
            }



            DataSet DDecode = UsrConnTemp.CallSP("calc_bookingid", new object[] { txtCodice.Text }, true);

            UsrConnTemp.Close();
            if (DDecode == null || DDecode.Tables.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento o codice errato.";
                return;
            }

            DataTable TDecode = DDecode.Tables[0];

            if (TDecode.Rows.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento  o codice errato.";
                return;
            }

            DataRow RCode = TDecode.Rows[0];

            if (RCode["iddep"].ToString() == "")
            {
                lblMessaggio.Text = "Errore nella lettura del codice a barre";
                txtCodice.Text    = "";
                return;
            }
            string depcode   = RCode["iddep"].ToString();
            string idbooking = RCode["idbooking"].ToString();

            ConnectToDepartment(depcode, null, null, D);

            Easy_DataAccess UsrConn = GetVars.GetUserConn(this);

            if (UsrConn == null || UsrConn.Open() == false)
            {
                //Il Server del Dipartimento non è in rete.
                //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                labExtMessage.Text = "Il Server del Dipartimento " + depcode + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + depcode + "non risponde.");
                return;
            }

            labExtMessage.Text = "Connessione al server effettuata.";



            ScaricaPrenotazione(UsrConn, idbooking);
        }
Exemplo n.º 9
0
        bool ConnectToDepartment(string codice, string user, string pwd, DateTime datacontabile)
        {
            string     error;
            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);


            if (codice.Trim().Length == 0)
            {
                lblError.Text = "Non è stato selezionato alcun dipartimento";
                return(false);
            }

            if (user == "")
            {
                lblError.Text = "Nessun nome utente specificato";
                return(false);
            }

            if (pwd == "")
            {
                lblError.Text = "Nessuna password specificata";
                return(false);
            }


            Session["DBSysConn"] = Conn;
            //Attenzione: leggere da XML IP del server e NomeDB
            //Inserire da codice NomeUtente e Password


            string    filterdip = "(codicedipartimento=" + QueryCreator.quotedstrvalue(codice, true) + ")";
            DataTable CodDip    = Conn.RUN_SELECT("codicidipartimenti", "*", null, filterdip, null, true);

            if ((CodDip == null) || (CodDip.Rows.Count == 0))
            {
                //Dati non corretti
                lblError.Text = "Il codice inserito non è corretto.";
                return(false);
            }
            if (CodDip.Rows.Count > 1)
            {
                //Attenzione nel DB non è garantita l'unicità dei dati.
                lblError.Text = "Chiedere al Responsabile del servizio " +
                                "l'assegnazione di un nuovo Codice";
                return(false);
            }

            string  err  = "";
            DataRow myDr = CodDip.Rows[0];

            Session["Dipartimento"] = myDr["Dipartimento"].ToString();


            //Creo la connessione.
            DataAccess UsrConn = GetVars.CreateUserConn(this, myDr, user, pwd, datacontabile, out err);

            if (UsrConn == null)
            {
                err = "Connessione per l'utente '" + user + "' rifiutata. Controllare Nome Utente e/o Password";
                string err2 = "Connessione al db del dipartimento " + codice +
                              " non riuscita. <br/>" + err;
                lblError.Text = err2;
                return(false);
            }
            Session["DBUserConn"] = UsrConn;
            return(true);
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Master.SetTitle("WebEasy - Accesso Servizi Dipartimento  ");
            lblMessaggio.Text  = "";
            labExtMessage.Text = "";



            if (!Page.IsPostBack || Page.Session.IsNewSession)
            {
                Session["utente"]             = "";
                Session["Responsabile"]       = "";
                Session["Fornitore"]          = "";
                Session["CodiceResponsabile"] = null;
                Session["CodiceFornitore"]    = null;
            }

            if (Request != null)
            {
                if (Request.Params["x"] != null && Request.Params["x"].ToString() != "")
                {
                    Session["DepCode"] = Request.Params["x"];
                }
            }

            if (Session["DepCode"] == null || Session["DepCode"].ToString() == "")
            {
                lblMessaggio.Text = "E' necessario chiamare la pagina magazzino_in.aspx con il parametro dep=codice dipartimento";
                WebLog.Log(this, "Parametro dep non fornito.");
                return;
            }

            //if (Session["DoLogon"] == null || !((bool)Session["DoLogon"])) {
            //    lblMessaggio.Text = "Applicazione non inizializzata correttamente.";
            //    WebLog.Log(this, "Applicazione non inizializzata correttamente.");
            //    return;
            //}

            DataSet Cfg = GetVars.GetConfigDataSet(this);

            if (Cfg.Tables[0].Rows.Count == 0)
            {
                lblMessaggio.Text = "Servizio non installato correttamente. Manca il file di configurazione.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            MetaMaster MM = Master as MetaMaster;
            //if (MM != null) MM.ShowClientMessage("NINO", false);

            string error;

            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                //lblMessaggio.Text = "Connessione al DB di sistema non riuscita." + error;
                //Attenzione qui l'errore contiene la password del Database !
                lblMessaggio.Text = "Connessione al DB di sistema non riuscita.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            lblMessaggio.Text = "Il servizio Web è attivo";
            GetVars.ClearUserConn(this);
            MetaMaster master = Page.Master as MetaMaster;

            master?.setUniversita(Session["system_config_nome_universita"] as string);

            if (!Page.IsPostBack)
            {
                ldapauth ldpauth = new ldapauth(Conn);
                if (!ldpauth.getconfig())
                {
                    rbTipuUtente.Items.RemoveAt(3);
                }
            }

            //WebLog.Log(this, "Visualizza Login_Servizi");

            DateTime D = DateTime.Now;

            if (IsPostBack)
            {
                if (txtNomeUtente.Text == "")
                {
                    lblMessaggio.Text = "Il nome utente è un campo obbligatorio.";
                    //MM.ShowClientMessage("Il nome utente è un campo obbligatorio.", "Errore",
                    //          System.Windows.Forms.MessageBoxButtons.OK);

                    return;
                }
                if (txtPassword.Text == "")
                {
                    lblMessaggio.Text = "La password è un campo obbligatorio.";
                    //MM.ShowClientMessage("La password è un campo obbligatorio.", "Errore",
                    //        System.Windows.Forms.MessageBoxButtons.OK);

                    return;
                }
            }

            if (IsPostBack && Request != null)
            {
                //Cerco prima nella tabella contatto e poi nella tabella responsabile.
                string NomeUtente = txtNomeUtente.Text;
                string Password   = txtPassword.Text; // Request.Form["txtPassword"].ToString();

                if (rbTipuUtente.SelectedValue == "1" || rbTipuUtente.SelectedValue == "2")
                {
                    //Responsabile o Fornitore
                    ConnectToDepartment(Session["DepCode"].ToString(), null, null, D);
                }

                if (rbTipuUtente.SelectedValue == "3")  //Utente dell'applicazione
                {
                    ConnectToDepartment(Session["DepCode"].ToString(), NomeUtente, txtPassword.Text, D);
                }

                bool ldapauthok = false;

                if (rbTipuUtente.SelectedValue == "4")   // Utente LDAP
                {
                    ldapauth lauth = new ldapauth(Conn);
                    if (!lauth.getconfig())
                    {
                        // Nessuna configurazione LDAP
                        lblMessaggio.Text = lauth.ErrorMsg;
                        return;
                    }
                    else
                    {
                        if (!lauth.Authenticate(NomeUtente, txtPassword.Text))
                        {
                            // autenticazione fallita
                            lblMessaggio.Text = lauth.ErrorMsg;
                            return;
                        }
                        else
                        {
                            // autenticazione LDAP riuscita
                            NomeUtente = lauth.user_decoded;
                            ConnectToDepartment(Session["DepCode"].ToString(), null, null, D);
                            ldapauthok = true;
                        }
                    }
                }



                //Connessione al Server.Database privato del software.
                Easy_DataAccess UsrConn = GetVars.GetUserConn(this);

                if (UsrConn == null)
                {
                    return;                  //Messaggio già viualizzato da ConnectToDepartment()
                }
                QueryHelper QHS = UsrConn.GetQueryHelper();



                string user     = null;
                string forename = null;
                string lastname = null;
                string cf       = null;
                string email    = null;



                if (rbTipuUtente.SelectedValue == "3")
                {
                    if (!CambioDataConsentita(UsrConn, D))
                    {
                        UsrConn.Close();
                        labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                        //                        MM.ShowClientMessage("Accesso non consentito in tale data in base alla gestione della sicurezza.", "Errore",
                        //                                  System.Windows.Forms.MessageBoxButtons.OK);
                        lblMessaggio.Text = "Accesso negato";
                        return;
                    }
                }
                if (UsrConn.Open() == false)
                {
                    //Il Server del Dipartimento non è in rete.
                    //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                    labExtMessage.Text = "Il Server del Dipartimento non risponde.\r" +
                                         "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                         "Provi in seguito";
                    txtNomeUtente.ReadOnly = true;
                    WebLog.Log(this, "Il Server del dipartimento non risponde.");
                    return;
                }

                UsrConn.Close();
                Meta_EasyDispatcher Disp = new Meta_EasyDispatcher(UsrConn);
                ApplicationState    APS  = new ApplicationState(Disp, UsrConn);

                string path     = this.MapPath(".");
                string filename = Path.Combine(path, "proxyserver.html");
                if (File.Exists(filename))
                {
                    StreamReader SR      = new StreamReader(filename);
                    string       webauth = SR.ReadToEnd();
                    webauth          = webauth.Replace("\n", "").Replace("\r", "").Trim();
                    APS.webautorithy = webauth;
                    SR.Close();
                }


                APS.SaveApplicationState(this);
                labExtMessage.Text = "Connessione al server effettuata.";

                if (rbTipuUtente.SelectedValue == "1")
                {
                    int countresp = UsrConn.RUN_SELECT_COUNT("manager",
                                                             QHS.CmpEq("userweb", NomeUtente), false);
                    if (countresp > 1)
                    {
                        lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login";
                        WebLog.Log(this, "Attenzione !!! Login assegnata a piu responsabili");
                        return;
                    }
                    DataTable Responsabile = UsrConn.RUN_SELECT("manager", "*", null,
                                                                QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false);
                    if (Responsabile.Rows.Count == 0)
                    {
                        //Dati non corretti
                        labExtMessage.Text = "Nome utente o password non sono corretti.";
                        WebLog.Log(this, "Nome Resp:" + NomeUtente + " e password:"******" non corretti");
                        return;
                    }
                    Session["LoginResponsabile"]    = NomeUtente;
                    Session["PasswordResponsabile"] = Password;
                    Session["Responsabile"]         = Responsabile.Rows[0]["title"].ToString();
                    Session["CodiceResponsabile"]   = Responsabile.Rows[0]["idman"];
                    Session["TipoUtente"]           = "responsabile";
                    WebLog.Log(this, "Riconosciuto responsabile: " + Session["Responsabile"].ToString());
                }

                if (rbTipuUtente.SelectedValue == "2")
                {
                    int countforn = UsrConn.RUN_SELECT_COUNT("registryreferenceview",
                                                             QHS.CmpEq("userweb", NomeUtente), false);
                    if (countforn > 1)
                    {
                        lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login";
                        WebLog.Log(this, "Attenzione !!! Login assegnata a piu fornitori");
                        return;
                    }
                    DataTable Contatto = UsrConn.RUN_SELECT("registryreferenceview", "*", null,
                                                            QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false);
                    if (Contatto.Rows.Count == 0)
                    {
                        //Dati non corretti
                        labExtMessage.Text = "Nome utente o password non sono corretti.";
                        WebLog.Log(this, "Nome Fornitore:" + NomeUtente + " e password:"******" non corretti");
                        return;
                    }

                    Session["LoginFornitore"]    = NomeUtente;
                    Session["Fornitore"]         = Contatto.Rows[0]["registry"];
                    Session["CodiceFornitore"]   = Contatto.Rows[0]["idreg"];
                    Session["PasswordFornitore"] = Password;
                    Session["TipoUtente"]        = "fornitore";
                    WebLog.Log(this, "Riconosciuto fornitore: " + Session["Fornitore"].ToString());
                }

                if (rbTipuUtente.SelectedValue == "3")
                {
                    Session["TipoUtente"]     = "utente";
                    Session["Utente"]         = NomeUtente;
                    Session["PasswordUtente"] = Password;
                }

                if (ldapauthok || (rbTipuUtente.SelectedValue == "1") ||
                    (rbTipuUtente.SelectedValue == "2") || (rbTipuUtente.SelectedValue == "3"))
                {
                    int    userkind = Convert.ToInt32(rbTipuUtente.SelectedValue);
                    string filter   = QHS.AppAnd(QHS.CmpEq("username", NomeUtente),
                                                 QHS.CmpEq("codicedipartimento", Session["DepCode"].ToString()),
                                                 QHS.CmpEq("userkind", userkind)
                                                 );
                    // prelevare l'idflowchart e poi fare la connecttodepartment
                    DataTable virtualuser = Conn.RUN_SELECT("virtualuser", "*", null, filter, null, false);
                    if (virtualuser != null && virtualuser.Rows.Count != 0)
                    {
                        user     = virtualuser.Rows[0]["sys_user"].ToString();
                        forename = virtualuser.Rows[0]["forename"].ToString();
                        lastname = virtualuser.Rows[0]["surname"].ToString();
                        email    = virtualuser.Rows[0]["email"].ToString();
                        cf       = virtualuser.Rows[0]["cf"].ToString();

                        UsrConn.SetUsr("HasVirtualUser", "S");
                        // Controllare se è anche un responsabile
                        // Vediamo se esiste un manager il cui login="******"
                        // se si, assegnamo le due variabili di responsabile come
                        // nel caso "2"
                        filter = QHS.CmpEq("userweb", virtualuser.Rows[0]["username"].ToString());
                        DataTable manager = UsrConn.RUN_SELECT("manager", "*", null, filter, null, false);
                        if (manager != null && manager.Rows.Count != 0)
                        {
                            Session["Responsabile"]       = manager.Rows[0]["title"].ToString();
                            Session["CodiceResponsabile"] = manager.Rows[0]["idman"];
                        }

                        EasySecurity sec = UsrConn.Security as EasySecurity;
                        UsrConn.externalUser = NomeUtente;
                        sec.SetSys("user", user);
                        sec.SetUsr("usergrouplist", null);
                        sec.CalculateGroupList();
                        sec.RecalcUserEnvironment();
                        sec.ReadAllGroupOperations();
                        sec.SetUsr("forename", forename);
                        sec.SetUsr("surname", lastname);
                        sec.SetUsr("email", email);
                        sec.SetUsr("cf", cf);
                        if (!CambioDataConsentita(UsrConn, D))
                        {
                            labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                            lblMessaggio.Text  = "Accesso negato";
                            return;
                        }
                    }
                    else
                    {
                        if (ldapauthok)
                        {
                            lblMessaggio.Text = "Utente non valido.";
                            return;
                        }
                    }
                }



                if (rbTipuUtente.SelectedValue == "4")
                {
                    Session["TipoUtente"]     = "Utente LDAP";
                    Session["Utente"]         = forename + " " + lastname;
                    Session["PasswordUtente"] = Password;
                }

                StampaReport(UsrConn, cf);


                //Response.Redirect("IndiceReport.aspx");
            }
        }
Exemplo n.º 11
0
        protected void brnAdd_Click(object sender, EventArgs e)
        {
            if (Session["SysPasswordOk"] == null)
            {
                lblmessages.Text =
                    "Prima di procedere alla configurazione, inserire la Password di abilitazione alla configurazione.";
                return;
            }
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                lblmessages.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    lblmessages.Text += error;
                }
                return;
            }

            string          dip    = txtDip.Text;
            string          codice = txtCodice.Text;
            string          ip     = txtIP.Text;
            string          db     = txtDB.Text;
            string          user   = txtUser.Text;
            string          pwd    = txtPWD.Text;
            Easy_DataAccess Conn   = new Easy_DataAccess(
                "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);

            if (Conn == null)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Open();
            if (Conn.OpenError)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Close();
            DataSet DS = new Dipartimenti();

            if (sys.RUN_SELECT_COUNT("CodiciDipartimenti",
                                     "(CodiceDipartimento=" +
                                     QueryCreator.quotedstrvalue(codice, true) + ")", true) > 0)
            {
                lblmessages.Text = "Codice dipartimento già esistente.";
                return;
            }
            DataTable T = DS.Tables[0];
            DataRow   R = T.NewRow();

            R["CodiceDipartimento"] = codice;
            R["dipartimento"]       = dip;
            R["IPserver"]           = GetVars.CryptPassword(ip);
            R["NomeDB"]             = GetVars.CryptPassword(db);
            R["UserDB"]             = GetVars.CryptPassword(user);
            R["PassDB"]             = GetVars.CryptPassword(pwd);
            T.Rows.Add(R);
            PostData CP = new PostData();

            CP.InitClass(DS, sys);

            ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();

            if (!MCOLL.CanIgnore)
            {
                lblmessages.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                return;
            }
            else
            {
                if (MCOLL.Count > 0)
                {
                    CP.DO_POST_SERVICE();
                }
            }


            lblmessages.Text = "DB DI SISTEMA Aggiornato correttamente.";
        }