Exemple #1
0
        public void MetaData_BeforeFill()
        {
            if (DS.license.Rows.Count == 0)
            {
                return;
            }
            DataRow R = DS.license.Rows[0];

            if (InformazioniNonPresenti(R))
            {
                CalcolaInformazioni(R);
                SetImpostazioniDefault(R);
                abilitaricalcolo = true;
            }

            if (R["checkflag"].ToString() != CheckFlags.CalcolaCheckFlag(R))
            {
                if (!MessaggioDisableVisualizzato)
                {
                    MessageBox.Show("Questo db non è autorizzato dalla Software & More. Contattare il servizio assistenza");
                    MessaggioDisableVisualizzato = true;
                }
                Meta.CanSave   = false;
                Meta.CanInsert = false;
                btnOK.Visible  = false;
                Easy_DataAccess CD = Meta.Conn as Easy_DataAccess;
                if (CD != null)
                {
                    CD.ReadOnly = true;
                }
            }
            if (((R["servername"].ToString().ToUpper() != RealServerName.ToUpper()) &&
                 (R["serverbackup1"].ToString().ToUpper() != RealServerName.ToUpper()) &&
                 (R["serverbackup2"].ToString().ToUpper() != RealServerName.ToUpper())) ||
                (R["dbname"].ToString() != RealDBName))
            {
                MessageBox.Show("Da questo accesso risulta che il db n." +
                                R["iddb"].ToString() +
                                " il nuovo server è " + RealServerName +
                                " ed il nuovo nomedb è " + RealDBName +
                                ". Contattare la software and more per fare (ri)abilitare questo db all'uso del programma.");

                bool IsAdmin = false;
                if (Meta.GetSys("FlagMenuAdmin") != null)
                {
                    IsAdmin = (Meta.GetSys("FlagMenuAdmin").ToString() == "S");
                }

                Meta.CanSave   = IsAdmin;
                Meta.CanInsert = false;
                btnOK.Visible  = IsAdmin;
                Easy_DataAccess CD = Meta.Conn as Easy_DataAccess;
                if (CD != null)
                {
                    CD.ReadOnly = !IsAdmin;
                }
                btnReset.Visible         = IsAdmin;
                btnRemoveLicense.Visible = IsAdmin;
            }
        }
Exemple #2
0
        Easy_DataAccess ottieniConnessioneNuovoEsercizio(DataAccess Conn, int newEsercizio)
        {
            if (!DatiValidi(Conn, newEsercizio))
            {
                return(null);
            }

            DateTime newDate = new DateTime(newEsercizio, 12, 31);

            if (!CambioDataConsentita(Conn, newDate))
            {
                MessageBox.Show("L'utente non ha diritto ad agire nell'esercizio " + newEsercizio, "Errore");
                return(null);
            }
            Easy_DataAccess newConn = (Easy_DataAccess)Conn.Duplicate();

            newConn.SetSys("esercizio", newEsercizio);
            newConn.SetSys("datacontabile", newDate);


            newConn.RecalcUserEnvironment(Conn.GetSys("idflowchart"), Conn.GetSys("ndetail"));
            newConn.ReadAllGroupOperations();

            return(newConn);
        }
Exemple #3
0
        private void btnApplica_Click(object sender, EventArgs e)
        {
            string    error         = "";
            string    dettaglio     = "";
            DataTable Tdbdepartment = Meta.Conn.RUN_SELECT("dbdepartment", "iddbdepartment,description", null, null, null, true);

            foreach (DataRow dip in Tdbdepartment.Rows)
            {
                MyDataAccess = Easy_DataAccess.getEasyDataAccess("DSN", Meta.GetSys("server").ToString(), Meta.GetSys("database").ToString(),
                                                                 Meta.GetSys("user").ToString(), txtpassword.Text.Trim(), null, dip["iddbdepartment"].ToString(), (int)Meta.GetSys("esercizio"),
                                                                 (DateTime)Meta.GetSys("datacontabile"), out error, out dettaglio);
                if (MyDataAccess == null)
                {
                    MessageBox.Show(error + "\n" + dettaglio, "Attenzione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (!MyDataAccess.Open())
                {
                    error     = "Non è stato possibile effettuare il collegamento al dipartimento" + dip["iddbdepartment"].ToString();
                    dettaglio = MyDataAccess.LastError;
                    MessageBox.Show(error + "\n" + dettaglio, "Attenzione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    continue;
                }
                string currDip = "\nid: " + dip["iddbdepartment"].ToString() + " \nNome:" + dip["description"].ToString();
                doApplica(MyDataAccess, currDip);
                MyDataAccess.Destroy();
            }

            MessageBox.Show(this, "Fine operazione.", "Informazione", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #4
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            string password1 = txtPassword.Text;
            string password2 = txtConferma.Text;

            if (password1 != password2)
            {
                MessageBox.Show(this, "Digitare la stessa parola sia nel campo 'password' che nel campo 'conferma password'");
                this.DialogResult = DialogResult.None;
                return;
            }
            if (password1.Length == 0)
            {
                MessageBox.Show(this, "La password deve essere composta da almeno 1 carattere");
                this.DialogResult = DialogResult.None;
                return;
            }
            byte[] password = Easy_DataAccess.CryptString(password1.PadRight(31));
            string errore;

            byte[]          nuovoAlfa1;
            Easy_DataAccess newConn = Conn.getDepartmentConnection(idDbDepartment, password, out errore, out nuovoAlfa1);

            if (errore != null)
            {
                MessageBox.Show(this, "La password inserita non è valida per operare sul dipartimento " + idDbDepartment + "\r\n." + errore);
                this.DialogResult = DialogResult.None;
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
Exemple #5
0
 public FrmLinkUser(Easy_DataAccess Conn)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     this.Conn = Conn;
 }
Exemple #6
0
        public void MetaData_AfterLink()
        {
            Meta         = MetaData.GetMetaData(this);
            Meta.CanSave = false;

            Conn = Meta.Conn as Easy_DataAccess;

            QHC = new CQueryHelper();
            QHS = Conn.GetQueryHelper();

            department = Conn.GetSys("userdb").ToString();
        }
Exemple #7
0
        public FrmPassword(Easy_DataAccess mainConn, string iddbdepartment)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            idDbDepartment = iddbdepartment;
            Conn           = mainConn;
        }
Exemple #8
0
        /// <summary>
        /// Si collega ad un certo dipartimento usando una combinazione user/password. Se user e password
        ///  in ingresso sono nulle, prende quelle della riga RowDipartimento passate come parametro
        /// </summary>
        /// <param name="P"></param>
        /// <param name="RowDipartimento">Riga con dati del dipartimento a cui collegarsi</param>
        /// <param name="user">user login, opzionale</param>
        /// <param name="password">password, opzionale</param>
        /// <param name="DataCont"></param>
        /// <param name="err"></param>
        /// <returns></returns>
        public static DataAccess CreateUserConn(System.Web.UI.Page P, DataRow RowDipartimento,
                                                string user, string password, DateTime DataCont,
                                                out string err)
        {
            if (user != null && user != "")
            {
                RowDipartimento["UserDB"] = CryptPassword(user);
            }
            if (password != null && password != "")
            {
                RowDipartimento["PassDB"] = CryptPassword(password);
            }


            string msg;

            err = "";
            byte[]          CodiceDip = CryptPassword(RowDipartimento["CodiceDipartimento"].ToString());
            Easy_DataAccess C         = Easy_DataAccess.getEasyDataAccess("usrDSN",
                                                                          DecryptPassword(ConvBytes(RowDipartimento["IPserver"])),
                                                                          DecryptPassword(ConvBytes(RowDipartimento["NomeDB"])),
                                                                          DecryptPassword(ConvBytes(RowDipartimento["UserDB"])),
                                                                          DecryptPassword(ConvBytes(RowDipartimento["PassDB"])),
                                                                          "", //oldpwd
                                                                          RowDipartimento["CodiceDipartimento"].ToString(),
                                                                          DataCont.Year,
                                                                          DataCont, out err, out msg);

            err = "Tentata Connessione a " +
                  DecryptPassword(ConvBytes(RowDipartimento["IPserver"])) +
                  "#" +
                  DecryptPassword(ConvBytes(RowDipartimento["NomeDB"])) +
                  "#" +
                  DecryptPassword(ConvBytes(RowDipartimento["UserDB"]));
            if (C == null)
            {
                return(null);
            }
            if (!C.Open())
            {
                err = err + C.LastError;
                return(null);
            }
            C.persisting = false;
            P.Session["SessionUserDataAccess"] = C;
            SetUsrVar(P, "Dipartimento", RowDipartimento["Dipartimento"]);
            SetUsrVar(P, "CodiceDipartimento", RowDipartimento["CodiceDipartimento"]);
            C.SetUsr("localreportdir", GetConfigVar(P, "Report"));
            //Conn.sys["localreportdir"]= GetConfigVar(P,"Report");
            return(C);
        }
Exemple #9
0
//		private string getNuovoAlfa1(string passwordDipart) {
//			byte[] alfa = mainConn.sha256UserPassword();
//			byte[] g1 = DataAccess.CryptString(passwordDipart.PadRight(31));
//			byte[] alfa1 = xor(alfa, g1);
//			return QueryCreator.ByteArrayToString(alfa1);
//		}

        public void MetaData_BeforePost()
        {
            DataRow rDepartment = HelpForm.GetLastSelected(DS.dbdepartment);

            if (rDepartment == null)
            {
                return;
            }
            string passwordDipart = rDepartment["!password"] as string;

            textBox1.Text = passwordDipart;

            string       userAmmin    = (string)Meta.Conn.GetSys("user");
            MetaData     metaDBAccess = MetaData.GetMetaData(this, "dbaccess");
            MetaData     metaDBUser   = MetaData.GetMetaData(this, "dbuser");
            UTF8Encoding encoding     = new UTF8Encoding();

            string    filtroUtente = "(login="******")";
            DataTable tUtenti      = DataAccess.RUN_SELECT(mainConn, "dbuser", null, null, filtroUtente, null, null, true);

            DataRow[] rUtenti = tUtenti.Select(filtroUtente);
            if (rUtenti.Length == 0)
            {
                MetaData.SetDefault(DS.dbuser, "login", userAmmin);
                metaDBUser.Get_New_Row(null, DS.dbuser);
            }

            string filtroAccesso = filtroUtente + " and (iddbdepartment="
                                   + QueryCreator.quotedstrvalue(rDepartment["iddbdepartment"], true) + ")";

            DataAccess.RUN_SELECT_INTO_TABLE(mainConn, DS.dbaccess, null, filtroAccesso, null, true);
            MetaData.SetDefault(DS.dbaccess, "login", userAmmin);

            string iddbdepartment = (string)rDepartment["iddbdepartment"];
            string errore;

            byte[] g1 = mainConn.getDepartmentPassword(iddbdepartment, out errore);
            if (g1 == null)
            {
                metaDBAccess.Get_New_Row(rDepartment, DS.dbaccess);
                g1 = Easy_DataAccess.CryptString(passwordDipart.PadRight(31));
            }
            DataRow[] righeAccesso = rDepartment.GetChildRows("dbdepartmentdbaccess");
            foreach (DataRow rAccess in righeAccesso)
            {
                byte[] alfa  = mainConn.sha256UserPassword();
                byte[] alfa1 = xor(alfa, g1);
                rAccess["alpha1"] = QueryCreator.ByteArrayToString(alfa1);
            }
        }
Exemple #10
0
 private void FrmViewReport_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (ReportDoc != null)
     {
         ReportDoc.Dispose();
         ReportDoc = null;
     }
     if (crViewer != null)
     {
         crViewer.ReportSource = null;
     }
     this.Params       = null;
     this.ModuleReport = null;
     this.meta         = null;
     this.Conn         = null;
 }
Exemple #11
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            string login = (string)Meta.Conn.GetSys("user");

//			GetData.SetStaticFilter(DS.dbaccess, "(login="******")");
//			GetData.CacheTable(DS.dbdepartment, null, "description", false);

            dataAccess = (Easy_DataAccess)Meta.Conn;
            bool isAdmin = (bool)Meta.GetSys("IsSystemAdmin");

//						getPasswordDeiDipartimenti();
            //			Meta.CanSave=IsAdmin;
            //			Meta.CanInsert=IsAdmin;
            //			Meta.CanInsertCopy=IsAdmin;
            //			Meta.CanCancel=IsAdmin;
        }
Exemple #12
0
        protected void btnok_Click(object sender, EventArgs e)
        {
            Easy_DataAccess Conn         = GetVars.GetUserConn(Page);
            bool            err          = false;
            string          idcustomuser = Conn.GetSys("idcustomuser") as string;
            object          idflowchart  = cmbruolo.SelectedValue;
            object          ndetail      = Conn.GetSys("ndetail");
            object          currdate     = Conn.GetSys("datacontabile");

            string sel = cmbruolo.SelectedValue;

            if (sel == "" || sel == null)
            {
                return;
            }

            if (sel.IndexOf("§") < 0)
            {
                return;
            }
            string [] ss = sel.Split('§');
            ndetail     = CfgFn.GetNoNullInt32(ss[1]);
            idflowchart = ss[0];
            string filter = QHS.AppAnd(QHS.CmpEq("idcustomuser", idcustomuser),
                                       QHS.CmpEq("idflowchart", idflowchart),
                                       QHS.CmpEq("ndetail", ndetail));
            object title = Conn.DO_READ_VALUE("flowchartuser", filter, "title");

            if (title == DBNull.Value)
            {
                title = Conn.DO_READ_VALUE("flowchart", QHS.CmpEq("idflowchart", idflowchart), "title");
            }

            Conn.RecalcUserEnvironment(idflowchart, ndetail);
            Conn.ReadAllGroupOperations();

            Session["SavedFlowChart"] = null;
            if (title != null)
            {
                Session["SavedFlowChart"] = title;
            }

            Response.Redirect("IndiceReport.aspx");
        }
Exemple #13
0
        public FrmViewReport(DataRow DRModuleReport,
                             Easy_DataAccess MyDA,
                             DataRow Params,
                             MetaData meta)
        {
            InitializeComponent();
            toolBar.Enabled   = false;
            this.Params       = Params;
            this.ModuleReport = DRModuleReport;
            Conn      = MyDA;
            this.meta = meta;

            foreach (DataColumn c in Params.Table.Columns)
            {
                elencoparametri += c.ColumnName + "=" + Params[c.ColumnName].ToString() + ";";
            }

            Text = ModuleReport["description"].ToString();
        }
Exemple #14
0
//		private string leggiPasswordDelDipIniziale(DataTable tDipAmmin, object iddbdepartment) {
//			string filtroDip = "(iddbdepartment=" + QueryCreator.quotedstrvalue(iddbdepartment, false) + ")";
//			DataRow rAccess = tDipAmmin.Select(filtroDip)[0];
//			byte[] alfa1 = QueryCreator.StringToByteArray((string)rAccess["alpha1"]);
//
//			UTF8Encoding encoding = new UTF8Encoding();
//			SHA256 shaM = new SHA256Managed();
//			byte[] initialPassword = encoding.GetBytes(Easy_DataAccess.INITIAL_PASSWORD);
//			byte[] alfa = shaM.ComputeHash(initialPassword);
//			byte[] up = xor(alfa, alfa1);
//			return DataAccess.DecryptString(up);
//		}
//
//		private string leggiPasswordDelDipCambiata(DataTable tDipAmmin, object iddbdepartment) {
//			string filtroDip = "(iddbdepartment=" + QueryCreator.quotedstrvalue(iddbdepartment, false) + ")";
//			DataRow rAccess = tDipAmmin.Select(filtroDip)[0];
//			string sAlfa1 = (string) rAccess["alpha1"];
//			byte[] alfa1 = QueryCreator.StringToByteArray(sAlfa1);
//
//			byte[] alfa = dataAccess.sha256UserPassword();
//			byte[] up = xor(alfa, alfa1);
//			try {
//				return DataAccess.DecryptString(up);
//			} catch (CryptographicException) {
//				return null;
//			}
//		}
//
        private void button1_Click(object sender, System.EventArgs e)
        {
            DataTable t  = Meta.Conn.RUN_SELECT("tabelle", null, null, null, null, null, false);
            DataSet   ds = new DataSet();

            ds.Tables.Add(t);
            ds.WriteXml("c:/tabelle.xml");
            string    filtroAmmin = "(login="******"user"), false) + ")";
            DataTable tDipAmmin   = DataAccess.RUN_SELECT(Meta.Conn, "dbaccess", null, null, filtroAmmin, null, null, true);

            textBox1.Text = null;
            foreach (DataRow rDepartment in tDipAmmin.Rows)
            {
                string iddbdepartment = (string)rDepartment["iddbdepartment"];
                string errore;
                string passwordDip = Easy_DataAccess.DecryptString(dataAccess.getDepartmentPassword(iddbdepartment, out errore));
                textBox1.Text += rDepartment["iddbdepartment"] + ": " + passwordDip + "\r\n";
            }
        }
Exemple #15
0
        private void invitaACorreggerePasswordDeiDipartimenti()
        {
            string    userAmmin    = (string)Meta.Conn.GetSys("user");
            string    filtroUtente = "(login="******")";
            DataTable t            = DataAccess.RUN_SELECT(mainConn, "dbaccess", null, null, filtroUtente, null, null, true);
            string    dipErrati    = "";

            foreach (DataRow r in t.Rows)
            {
                string          iddbdepartment = (string)r["iddbdepartment"];
                string          errore;
                Easy_DataAccess eda = mainConn.getDepartmentConnection(iddbdepartment, out errore);
                if (errore != null)
                {
                    dipErrati += ", " + iddbdepartment;
                }
            }
            if (dipErrati != "")
            {
                Console.WriteLine("Password errate nei dipartimenti " + dipErrati.Substring(2));
            }
        }
Exemple #16
0
        private bool doApplica(Easy_DataAccess CurrDataAccess, string CurrDip)
        {
            QueryHelper QHS                        = Meta.Conn.GetQueryHelper();
            object      idcustomgroup              = "ORGANIGRAMMA";
            string      filterallexistent          = QHS.CmpEq("idgroup", idcustomgroup);
            string      deletecustomgroupoperation = "delete from customgroupoperation where " + filterallexistent;

            CurrDataAccess.SQLRunner(deletecustomgroupoperation, false);
            string insertcustomgroupoperation =
                "insert into customgroupoperation (idgroup,operation,tablename,allowcondition,denycondition," +
                "defaultisdeny,ct,cu,lt,lu) " +
                "select idcustomgroup,operation,tablename,allowcondition,denycondition,defaultisdeny," +
                "getdate(),'Software and More',getdate(),'Software and More' from securitycondition ";

            CurrDataAccess.SQLRunner(insertcustomgroupoperation, false, 300);

            string deleteuserenvironment =
                "delete from userenvironment where " +
                " idcustomuser in (select idcustomuser from customusergroup where " + QHS.CmpEq("idcustomgroup", idcustomgroup) + ") " +
                " AND variablename in (select variablename from securityvar)";

            CurrDataAccess.SQLRunner(deleteuserenvironment, false, 300);
            string insertuserenvironment =
                "insert into userenvironment (idcustomuser,variablename,value,flagadmin,kind,lt,lu) " +
                " select U.idcustomuser,S.variablename,S.value,'N',S.kind,getdate(),'Software and More' from securityvar S " +
                " cross join customusergroup U where " + QHS.CmpEq("U.idcustomgroup", idcustomgroup);

            CurrDataAccess.SQLRunner(insertuserenvironment, false, 300);

            //MessageBox.Show(this, "Sicurezza applicata con successo!");

            //MessageBox.Show(this, "Errore nel salvataggio della sicurezza!", "Errore");


            return(true);
        }
Exemple #17
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            Easy_DataAccess DepConn = (Easy_DataAccess)MetaData.GetConnection(this);
            string          old     = txtOld.Text;
            string          user    = DepConn.GetSys("user").ToString();

            DataAccess Try = new DataAccess("temp",
                                            DepConn.GetSys("server").ToString(), DepConn.GetSys("database").ToString(),
                                            user, old, DateTime.Now.Year, DateTime.Now);

            Try.Open();
            if (Try.OpenError)
            {
                MessageBox.Show(this, "La vecchia password inserita non è corretta!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }

            PwdConfirm   Confirm = new PwdConfirm("s");
            DialogResult Res     = Confirm.ShowDialog(this);

            if (Res != DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                return;
            }
            string new1 = txtNew1.Text;
            string new2 = Confirm.txtPwd.Text;

            if (new1 != new2)
            {
                MessageBox.Show(this, "La password inserita come conferma era diversa!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }
            byte [] oldalfa = Easy_DataAccess.getAlfaFromPassword(old);
            byte [] newalfa = Easy_DataAccess.getAlfaFromPassword(new1);
            if (DepConn.changeUserPassword(oldalfa, newalfa))
            {
                object PWDOLD = (old == "") ? DBNull.Value : (object)old;
                object PWDNEW = (new1 == "") ? DBNull.Value : (object)new1;
                string err;
                string sql = "sp_password " +
                             QueryCreator.quotedstrvalue(PWDOLD, true) + "," +
                             QueryCreator.quotedstrvalue(PWDNEW, true);
                object O = Try.DO_SYS_CMD(sql, out err);
                Try.Destroy();
                if (err != null)
                {
                    QueryCreator.ShowError(this, "Errore nell'impostazione della password", err);
                    DepConn.changeUserPassword(oldalfa, newalfa);                   //Annulla l'azione del precedente!!
                    DialogResult = DialogResult.None;
                    return;
                }
                DepConn.SetSys("password", new1);
                if (new1 == Easy_DataAccess.INITIAL_PASSWORD)
                {
                    DepConn.SetSys("initial_password_set", "S");
                }
                else
                {
                    DepConn.SetSys("initial_password_set", "N");
                }
                MessageBox.Show(this, "Password reimpostata con successo");
            }
            else
            {
                MessageBox.Show(this, "Non è stato possibile cambiare la password");
            }
        }
Exemple #18
0
        public bool ShowReport()
        {
            string errmess;


            //pdoc.DefaultPageSettings.PaperSize = GetSystemSize(ReportDoc.PrintOptions.PaperSize);
            //pdoc.DefaultPageSettings.Landscape = (ModuleReport["orientation"].ToString().ToUpper() == "P");

            string papersize = ModuleReport["papersize"].ToString();

            if (papersize.ToUpper() == "ASK")
            {
                frmSelectPrinter frm = new resultparameter_default.frmSelectPrinter(papersize);
                if (frm.ShowDialog(this) != DialogResult.OK)
                {
                    return(false);
                }
                printerName = frm.cmbPrn.Text;
            }
            else
            {
                printerName = getPrinterNameFor(papersize);
            }



            if (printerName == null)
            {
                return(false);
            }

            ReportDoc = Easy_DataAccess.GetReport(Conn, ModuleReport, Params, out errmess);
            if (ReportDoc == null)
            {
                MessageBox.Show(errmess, "Attenzione",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                errore = true;
                return(false);
            }

            try {
                ReportDoc.PrintOptions.PrinterName = printerName; //PDIAL.PrinterSettings.PrinterName;
            }
            catch {
                errore = true;
                MessageBox.Show("La stampante di nome " + printerName + " non appare essere correttamente installata.", "Errore");
                return(false);
            }


            ReportDispatcherClass.SetDefaultOrientation(ref ReportDoc, ModuleReport);

            //formato dal report al printer dialog

            //eseguo bind del report
            crViewer.ReportSource = ReportDoc; //ReportDoc;

            Cursor.Current = Cursors.Default;

            toolBar.Enabled = true;
            return(true);
        }
Exemple #19
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            string msg = "Utente impersonato è :" + System.Environment.UserName;

            labUsr.Text = msg;


            if (IsPostBack)
            {
                string pwdsys = Request.Form["txtPwdSystem"].ToString();
                string pwd    = Request.Form["txtPWD"].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 server = txtServer.Text;
                string db     = txtDB.Text;
                string user   = txtUser.Text;

                Easy_DataAccess Conn = new Easy_DataAccess(
                    "mydsn", server, 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();


                string report = txtReport.Text;
                if (!System.IO.Directory.Exists(report))
                {
                    labMsg.Text = "Il percorso specificato per i report non esiste";
                    return;
                }

                string       path     = MapPath("cfg");
                string       filename = Path.Combine(path, "config.xml");
                FileStream   FileS    = new FileStream(filename, FileMode.Create);
                CryptoStream CryptoS  = new CryptoStream(FileS,
                                                         new TripleDESCryptoServiceProvider().CreateEncryptor(
                                                             new byte[] { 75, 12, 0, 215, 93, 89, 45, 11, 171, 96, 4, 64, 13, 158, 36, 190 },
                                                             new byte[] { 68, 13, 99, 43, 149, 192, 145, 43, 83, 19, 238, 57, 128, 38, 12, 4 }
                                                             ), CryptoStreamMode.Write);

                DataSet   DS = new AllDataSet.LastConnection();
                DataTable T  = DS.Tables[0];
                DataRow   R  = T.NewRow();
                R["Server"]   = server;
                R["DataBase"] = db;
                R["user"]     = user;
                R["Password"] = pwd;
                R["Report"]   = report;
                T.Rows.Add(R);
                DS.WriteXml(CryptoS, XmlWriteMode.WriteSchema);
                //DS.WriteXml(FileS, XmlWriteMode.WriteSchema);
                CryptoS.FlushFinalBlock();
                CryptoS.Close();
                CryptoS.Dispose();
                //FileS.Flush();
                FileS.Close();
                FileS.Dispose();
                labMsg.Text  = "File di configurazione Creato correttamente nella cartella" + path;
                labMsg.Text += " Ricordarsi ora di aggiungere le autorizzazioni di CONTROLLO COMPLETO " +
                               " all'utente impersonato per la cartella ReportPDF, e rimuovere le autorizzazioni in" +
                               " scrittura per la cartella cfg.";
            }
        }
Exemple #20
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);
        }
Exemple #21
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.";
            }
        }
Exemple #22
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string  FileName;
            DataRow Rep = Session["ExportRow"] as DataRow;

            if (Rep == null)
            {
                return;
            }

            string MyGuid = Session.SessionID.ToString();
            string str;

            str = DateTime.Now.ToString();
            str = str.Replace("/", "");
            str = str.Replace(".", "");
            str = str.Replace(" ", "");
            //Costruisce il nome del File (AnnoMeseGiornoOraMinutiSecondi)
            //FileName = str.Substring(4,4) + str.Substring(2,2) + str.Substring(0,2) + "h" + str.Substring(8,str.Length - 8);
            string prefix = Session["TipoUtente"] as String;

            if (prefix == "fornitore")
            {
                prefix += "-" + Session["CodiceFornitore"].ToString();
            }
            if (prefix == "responsabile")
            {
                prefix += "-" + Session["CodiceResponsabile"].ToString();
            }
            prefix = GetVars.GetUsrVar(this, "CodiceDipartimento").ToString() + "-" + prefix + "-";
            prefix = prefix.Replace("\\", "");
            prefix = prefix.Replace("/", "");
            prefix = prefix.Replace("*", "");
            prefix = prefix.Replace("?", "");
            prefix = prefix.Replace("$", "");
            prefix = prefix.Replace("%", "");

            MetaMaster MM = Master as MetaMaster;


            FileName = prefix + Rep["procedurename"].ToString() + "-" + System.Guid.NewGuid().ToString();

            DataTable UserPar = (DataTable)Session["UserPar"];

            if (UserPar == null)
            {
                return;
            }
            DataRow Par = UserPar.Rows[0];
            string  errmess;

            Easy_DataAccess Conn = GetVars.GetUserConn(this);


            // Restituisce il percorso fisico locale della cartella ReportPDF  ex: c:\inetpub\wwwroot\.....
            string FilePath = this.MapPath("ReportPDF");

            if (!FilePath.EndsWith("\\"))
            {
                FilePath += "\\";
            }

            string filenametodelete = FilePath + prefix + "*.*";

            string  [] existingreports = System.IO.Directory.GetFiles(
                FilePath, prefix + "*.*");
            foreach (string filename in existingreports)
            {
                System.IO.File.Delete(filename);
            }
            string fileFormat = Rep["fileformat"].ToString();
            string extension  = "";

            switch (fileFormat)
            {
            case "F":
                extension = ".txt";
                break;

            case "T":
                extension = ".txt";
                break;

            case "C":
                extension = ".csv";
                break;

            case "E":
                extension = ".xlsx";
                break;
            }

            string PDFfilePathRedir =   //FilePath +
                                      "ReportPDF/" +
                                      FileName + extension;
            string PDFfilePathToCreate = FilePath +
                                         FileName + extension;


            int          count           = 0;
            const string DummyPrimaryKey = "DummyPrimaryKeyField";
            const string DummyField      = "reportname";


            object[] ReportParams = new object[UserPar.Columns.Count - 2];
            foreach (DataColumn C in UserPar.Columns)
            {
                string colname = C.ColumnName;
                if (colname == DummyPrimaryKey)
                {
                    continue;
                }
                if (colname == DummyField)
                {
                    continue;
                }
                bool Convert = (bool)C.ExtendedProperties["ConvertNullToPerc"];
                Type tipo    = Par.Table.Columns[colname].DataType;
                if (Convert && (tipo == typeof(string)) && (Par[colname].ToString() == ""))
                {
                    Par[colname] = "%";
                }
                ReportParams[count++] = Par[colname];
            }

            int timeout = 300;

            try {
                if (Rep["timeout"] != DBNull.Value)
                {
                    timeout = Convert.ToInt32(
                        Rep["timeout"]) * 60;
                    if (timeout == 0)
                    {
                        timeout = 300;
                    }
                }
            }
            catch {
            }
            string  ExportName = Rep["procedurename"].ToString();
            DataSet Out        = Conn.CallSP(ExportName, ReportParams, true, timeout);


            if ((Out == null) || (Out.Tables.Count == 0))
            {
                string mym = "La stored procedure " + ExportName +
                             " è stata valutata e non ha restituito alcun risultato.";
                //MM.ShowClientMessage(mym, "Avviso",  System.Windows.Forms.MessageBoxButtons.OK);
                Session["CloseWindow"] = true;
                Session["Messaggio"]   = mym;


                Response.Redirect("Messaggio.aspx");
                return;
            }
            if (Out.Tables[0].Rows.Count == 0)
            {
                string mym = "La stored procedure " + ExportName +
                             " è stata valutata e non ha restituito alcun risultato.";
                //MM.ShowClientMessage(mym, "Avviso",       System.Windows.Forms.MessageBoxButtons.OK);

                Session["CloseWindow"] = true;
                Session["Messaggio"]   = mym;
                Session["UserPar"]     = null;
                Session["ExportRow"]   = null;

                Response.Redirect("Messaggio.aspx");
                return;
            }

            DataTable OutTable = Out.Tables[0];

            OutTable.TableName = Rep["description"].ToString();

            string result = null;

            switch (fileFormat)
            {
            case "F": metadatalibrary.exportclass.dataTableToFixedLengthFile(OutTable, false, PDFfilePathToCreate); break;

            case "T": metadatalibrary.exportclass.dataTableToTabulationSeparatedValues(OutTable, false, PDFfilePathToCreate); break;

            case "C": metadatalibrary.exportclass.dataTableToCommaSeparatedValues(OutTable, false, PDFfilePathToCreate); break;

            case "E": result = metadatalibrary.exportclass.DataTableToExcel(OutTable, true, null, null,
                                                                            PDFfilePathToCreate);
                break;
            }
            if (!string.IsNullOrEmpty(result))
            {
                Session["Messaggio"] = result;
                //MM.ShowClientMessage(result, "Avviso", System.Windows.Forms.MessageBoxButtons.OK);
                Session["CloseWindow"] = true;
                Response.Redirect("Messaggio.aspx");
                return;
            }
            //Visualizza il Report in formato PDF
            //WebLog.Log(this,"Visualizza il file in formato PDF");
            Response.Clear();

            Session["UserPar"]   = null;
            Session["ExportRow"] = null;
            Response.Redirect(PDFfilePathRedir);
        }
Exemple #23
0
        private void GeneraImpegniEScritture(string elencoCedolini)
        {
            if (elencoCedolini == "")
            {
                return;
            }
            DataSet   Temp       = new DataSet();
            DataTable tCedolino  = DataAccess.CreateTableByName(Meta.Conn, "payroll", "*");
            DataTable tContratto = DataAccess.CreateTableByName(Meta.Conn, "parasubcontract", "*");

            Temp.Tables.Add(tCedolino);
            Temp.Tables.Add(tContratto);
            string filtroCedolini = QHS.FieldInList("idpayroll", elencoCedolini);

            DataAccess.RUN_SELECT_INTO_TABLE(Meta.Conn, tCedolino, null, filtroCedolini, null, true);
            string elencoContratti = QHS.FieldInList("idcon", QueryCreator.ColumnValues(tCedolino, null, "idcon", true));

            DataAccess.RUN_SELECT_INTO_TABLE(Meta.Conn, tContratto, null, elencoContratti, null, true);

            bool       calcolaTutto = false;
            DataAccess Conn         = Meta.Conn;
            int        esercizio    = Conn.GetEsercizio();

            MetaData metaParasubMain = Meta.Dispatcher.Get("parasubcontract");

            metaParasubMain.DS = Temp;
            EP_Manager mainManager = new EP_Manager(metaParasubMain, null, null, null, null, null, null, null, null, "payroll");

            foreach (DataRow CurrCedolino in tCedolino.Rows)
            {
                if (!calcolaTutto)
                {
                    int          idCedolino = CfgFn.GetNoNullInt32(CurrCedolino["idpayroll"]);
                    AskOperation ao         = new AskOperation(idCedolino);
                    DialogResult dr         = ao.ShowDialog();
                    if (dr != DialogResult.OK)
                    {
                        continue;
                    }
                    switch (ao.operazioneScelta)
                    {
                    case AskOperation.operazione.Si: {
                        break;
                    }

                    case AskOperation.operazione.SiTutti: {
                        calcolaTutto = true;
                        break;
                    }

                    case AskOperation.operazione.No: {
                        continue;
                    }

                    case AskOperation.operazione.NoTutti: {
                        return;
                    }
                    }
                }

                Meta_EasyDispatcher d           = null;
                Easy_DataAccess     newConn     = null;
                MetaData            metaParasub = null;
                int  annostop = esercizio;
                bool erroriep = false;
                if (CurrCedolino["stop"] != DBNull.Value && (((DateTime)CurrCedolino["stop"]).Year < esercizio))
                {
                    annostop = ((DateTime)CurrCedolino["stop"]).Year;
                }
                DataRow CurrContratto = tContratto.Select(QHC.CmpEq("idcon", CurrCedolino["idcon"]))[0];

                string descrizione =
                    "Contratto n." + CurrContratto["ncon"].ToString() + " del " +
                    CurrContratto["ycon"].ToString() + " - " +
                    "Cedolino n. " + CurrCedolino["npayroll"] + "/" + CurrCedolino["fiscalyear"];



                EP_Manager epManagerCedolino = mainManager;
                if (annostop < esercizio & (mainManager.UsaImpegniDiBudget || mainManager.UsaScritture))
                {
                    //Genera impegni e scritture nell'anno di competenza del cedolino
                    newConn = ottieniConnessioneNuovoEsercizio(Conn, annostop);
                    if (newConn == null)
                    {
                        MessageBox.Show("Ci sono problemi nell'accedere all'anno " + annostop + ", non saranno generati impegni di budget o scritture", "Errore");
                        erroriep = true;
                    }
                    else
                    {
                        d                      = new Meta_EasyDispatcher(newConn);
                        metaParasub            = d.Get("parasubcontract");
                        metaParasub.DS         = Meta.DS;
                        metaParasub.LinkedForm = this;
                        epManagerCedolino      = new EP_Manager(metaParasub, null, null, null, null, null, null, null, null, "payroll");
                    }
                }

                if ((erroriep == false) && epManagerCedolino.abilitaScritture(CurrCedolino))
                {
                    epManagerCedolino.setForcedCurrentRow(CurrCedolino);
                    epManagerCedolino.afterPost();
                }

                if (newConn != null)
                {
                    newConn.Destroy();
                    metaParasub.Destroy();
                    epManagerCedolino.Dispose();
                }
            }
        }
Exemple #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string FileName;
            string cmd   = Session["AttachmentCommand"] as string;
            string fname = Session["AttachmentFileName"] as string;

            if (cmd == null)
            {
                return;
            }

            string MyGuid = Session.SessionID.ToString();
            string str;

            str = DateTime.Now.ToString();
            str = str.Replace("/", "");
            str = str.Replace(".", "");
            str = str.Replace(" ", "");
            //Costruisce il nome del File (AnnoMeseGiornoOraMinutiSecondi)
            //FileName = str.Substring(4,4) + str.Substring(2,2) + str.Substring(0,2) + "h" + str.Substring(8,str.Length - 8);
            string prefix = Session["TipoUtente"] as String;

            if (prefix == "fornitore")
            {
                prefix += "-" + Session["CodiceFornitore"].ToString();
            }
            if (prefix == "responsabile")
            {
                prefix += "-" + Session["CodiceResponsabile"].ToString();
            }


            prefix = GetVars.GetUsrVar(this, "CodiceDipartimento").ToString() + "-" + prefix + "-";
            prefix = prefix.Replace("\\", "");
            prefix = prefix.Replace("/", "");
            prefix = prefix.Replace("*", "");
            prefix = prefix.Replace("?", "");
            prefix = prefix.Replace("$", "");
            prefix = prefix.Replace("%", "");


            FileName = prefix + "-" + System.Guid.NewGuid().ToString() + fname;

            string errmess;

            Easy_DataAccess Conn = GetVars.GetUserConn(this);
            object          doc  = Conn.DO_SYS_CMD(cmd, true);



            if (doc == null || doc == DBNull.Value)
            {
                Session["Messaggio"]          = "Documento non trovato";
                Session["CloseWindow"]        = true;
                Session["AttachmentCommand"]  = null;
                Session["AttachmentFileName"] = null;
                Response.Redirect("Messaggio.aspx");
                return;
            }


            // Restituisce il percorso fisico locale della cartella ReportPDF  ex: c:\inetpub\wwwroot\.....
            string FilePath = this.MapPath("ReportPDF");

            if (!FilePath.EndsWith("\\"))
            {
                FilePath += "\\";
            }

            string filenametodelete = FilePath + prefix + "*.*";

            string[] existingreports = System.IO.Directory.GetFiles(
                FilePath, prefix + "*.*");
            foreach (string filename in existingreports)
            {
                System.IO.File.Delete(filename);
            }

            string PDFfilePathRedir =   //FilePath +
                                      "ReportPDF/" +
                                      FileName;

            string     sw = Path.Combine(FilePath, FileName);
            FileStream FS = new FileStream(sw, FileMode.Create, FileAccess.Write);

            byte[] ByteArray = (byte[])doc;

            int n = ByteArray.Length;

            if (n == 0)
            {
                Session["Messaggio"]          = "Documento non trovato";
                Session["CloseWindow"]        = true;
                Session["AttachmentCommand"]  = null;
                Session["AttachmentFileName"] = null;
                Response.Redirect("Messaggio.aspx");
                return;
            }

            try {
                FS.Write(ByteArray, 0, n);//<<<<<<<<<
                FS.Flush();
                FS.Close();
            }
            catch {
                string mym = "Non è stato possibile completare il salvataggio del file. \r";
                Session["CloseWindow"] = true;
                Session["Messaggio"]   = mym;
                Response.Redirect("Messaggio.aspx");
                return;
            }
            //Visualizza il Report in formato PDF
            //WebLog.Log(this,"Visualizza il file in formato PDF");
            Session["AttachmentCommand"]  = null;
            Session["AttachmentFileName"] = null;

            Response.Redirect(PDFfilePathRedir);
        }
Exemple #25
0
        protected void btnOk_Click(object sender, ImageClickEventArgs e)
        {
            if (Conn == null)
            {
                return;
            }

            DateTime D;

            try {
                D = (DateTime)HelpForm.GetObjectFromString(typeof(DateTime), txtDataContabile.Text, "x.y");
            }
            catch {
                lblMessaggio.Text = "La data contabile è un campo obbligatorio.";
                return;
            }

            string codicedipartimento = null;

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

            if (string.IsNullOrEmpty(codicedipartimento))
            {
                if (cmbDipartimento.SelectedValue != "" && cmbDipartimento.SelectedValue != null)
                {
                    codicedipartimento = cmbDipartimento.SelectedValue;
                }
            }

            if (string.IsNullOrEmpty(codicedipartimento))
            {
                lblMessaggio.Text = "E' obbligatorio scegliere un dipartimento";
            }

            //Cerco prima nella tabella contatto e poi nella tabella responsabile.
            string NomeUtente = txtNomeUtente.Text;

            //rbTipuUtente.SelectedValue == "5" IMPLICITAMENTE

            // Connessione al dipartimento.
            ConnectToDepartment(codicedipartimento, null, null, D);

            //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();

            if (!DatiValidi(D, UsrConn))
            {
                lblMessaggio.Text = string.Format("L'esercizio {0} non è stato creato!", D.Year);
                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.";
                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.";

            int    userkind = 5; // utente SSO (SAML/Shibboleth)
            string user     = null;
            string forename = null;
            string lastname = null;
            string cf       = null;
            string email    = null;

            string filter = QHS.AppAnd(
                QHS.CmpEq("username", NomeUtente),
                QHS.CmpEq("codicedipartimento", codicedipartimento),
                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))
                {
                    UsrConn.Close();
                    labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                    lblMessaggio.Text  = "Accesso negato";
                    return;
                }
            }
            else
            {
                lblMessaggio.Text = "Utente non valido.";
                return;
            }

            Session["TipoUtente"]     = "Utente SSO";
            Session["Utente"]         = string.Format("{0} {1}", forename, lastname);
            Session["PasswordUtente"] = null; // non la conosciamo

            Session["SavedFlowChart"] = null;
            object idflowchart = UsrConn.GetSys("idflowchart");

            if (idflowchart != null && idflowchart != DBNull.Value)
            {
                object title = UsrConn.DO_READ_VALUE("flowchart", QHS.CmpEq("idflowchart", idflowchart), "title");
                if (title != null && title != DBNull.Value)
                {
                    Session["SavedFlowChart"] = title;
                }
            }

            Session["SavedHomePage"] = "LoginSAML.aspx";
            Response.Redirect("IndiceReport.aspx");
        }
Exemple #26
0
 public void MetaData_AfterLink()
 {
     Meta     = MetaData.GetMetaData(this);
     mainConn = (Easy_DataAccess)Meta.Conn;
     invitaACorreggerePasswordDeiDipartimenti();
 }
Exemple #27
0
        public void MetaData_BeforePost()
        {
            if (DS.license.Rows.Count == 0)
            {
                return;
            }
            Easy_DataAccess E = Meta.Conn as Easy_DataAccess;

            if (E != null)
            {
                if (((Easy_DataAccess)Meta.Conn).ReadOnly)
                {
                    return;
                }
            }
            PostData.RemoveFalseUpdates(DS);
            //if (!DS.HasChanges()) return;
            DataRow R = DS.license.Rows[0];

            if (CfgFn.GetNoNullInt32(R["iddb"]) == 0)
            {
                int mycode = RichiediCodice();
                if (mycode > 0)
                {
                    R["iddb"] = mycode;
                    if (abilitaricalcolo)
                    {
                        SetImpostazioniDefault(R);
                    }
                }
                else
                {
                    string xx = Meta.GetSys("FlagMenuAdmin") as string;
                    if (xx == null)
                    {
                        xx = "";
                    }
                    if (xx.ToUpper() == "S")
                    {
                        string     pwdChangeServer;
                        FrmAskCode F = new FrmAskCode(0);
                        F.txtID.PasswordChar = '?';
                        DialogResult D = F.ShowDialog(this);
                        if (D != DialogResult.OK)
                        {
                            return;
                        }
                        pwdChangeServer = F.txtID.Text;
                        if (pwdChangeServer == "DoMasterSetDB")
                        {
                            FrmAskCode   FF = new FrmAskCode(0);
                            DialogResult DD = FF.ShowDialog(this);
                            if (DD == DialogResult.OK)
                            {
                                mycode = CfgFn.GetNoNullInt32(
                                    HelpForm.GetObjectFromString(typeof(int), FF.txtID.Text, "x.y"));
                                if (mycode > 0)
                                {
                                    R["iddb"] = mycode;
                                }
                            }
                        }
                    }
                }
                string RealCheck = CheckFlags.CalcolaCheckFlag(R);
                R["checkflag"] = RealCheck;
            }
        }
Exemple #28
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            Easy_DataAccess DepConn = (Easy_DataAccess)MetaData.GetConnection(this);
            string          old     = txtOld.Text;
            string          dbuser  = DepConn.GetSys("userdb").ToString();

            DataAccess Try = new DataAccess("temp",
                                            DepConn.GetSys("server").ToString(), DepConn.GetSys("database").ToString(),
                                            dbuser, old, DateTime.Now.Year, DateTime.Now);

            Try.Open();
            if (Try.OpenError)
            {
                MessageBox.Show(this, "La vecchia password inserita non è corretta!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }

            PwdConfirm   Confirm = new PwdConfirm(1);
            DialogResult Res     = Confirm.ShowDialog(this);

            if (Res != DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                return;
            }
            string new1 = txtNew1.Text.ToUpper();
            string new2 = Confirm.txtPwd.Text.ToUpper();

            if (new1 != new2)
            {
                MessageBox.Show(this, "La password inserita come conferma era diversa!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }
            if (new1.Length == 0)
            {
                MessageBox.Show(this, "La password deve essere composta da almeno 1 carattere");
                this.DialogResult = DialogResult.None;
                return;
            }
            byte [] oldpwd = DataAccess.CryptString(old);
            byte [] newpwd = DataAccess.CryptString(new1);
            if (DepConn.changeDepartmentPassword(oldpwd, newpwd))
            {
                object PWDOLD = (old == "") ? DBNull.Value : (object)old;
                object PWDNEW = (new1 == "") ? DBNull.Value : (object)new1;
                string err;
                string sql = "sp_password " +
                             QueryCreator.quotedstrvalue(PWDOLD, true) + "," +
                             QueryCreator.quotedstrvalue(PWDNEW, true);
                object O = Try.DO_SYS_CMD(sql, out err);
                Try.Destroy();
                if (err != null)
                {
                    QueryCreator.ShowError(this, "Errore nell'impostazione della password", err);
                    DepConn.changeDepartmentPassword(oldpwd, newpwd);                   //Annulla l'azione del precedente!!
                    DialogResult = DialogResult.None;
                    return;
                }
                DepConn.SetSys("passworddb", new1);
                MessageBox.Show(this, "Password reimpostata con successo");
            }
            else
            {
                MessageBox.Show(this, "Non è stato possibile cambiare la password");
            }
        }
Exemple #29
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string  FileName;
            DataRow Rep = Session["ModuleReportRow"] as DataRow;

            if (Rep == null)
            {
                return;
            }

            string MyGuid = Session.SessionID.ToString();
            string str;

            str = DateTime.Now.ToString();
            str = str.Replace("/", "");
            str = str.Replace(".", "");
            str = str.Replace(" ", "");
            //Costruisce il nome del File (AnnoMeseGiornoOraMinutiSecondi)
            //FileName = str.Substring(4,4) + str.Substring(2,2) + str.Substring(0,2) + "h" + str.Substring(8,str.Length - 8);
            string prefix = Session["TipoUtente"] as String;

            if (prefix == "fornitore")
            {
                prefix += "-" + Session["CodiceFornitore"].ToString();
            }
            if (prefix == "responsabile")
            {
                prefix += "-" + Session["CodiceResponsabile"].ToString();
            }
            prefix = GetVars.GetUsrVar(this, "CodiceDipartimento").ToString() + "-" + prefix + "-";
            prefix = prefix.Replace("\\", "");
            prefix = prefix.Replace("/", "");
            prefix = prefix.Replace("*", "");
            prefix = prefix.Replace("?", "");
            prefix = prefix.Replace("$", "");
            prefix = prefix.Replace("%", "");


            FileName = prefix + Rep["reportname"].ToString() + "-" + System.Guid.NewGuid().ToString();

            DataTable UserPar = (DataTable)Session["UserPar"];

            if (UserPar == null)
            {
                return;
            }
            DataRow Par = UserPar.Rows[0];
            string  errmess;

            Easy_DataAccess Conn     = GetVars.GetUserConn(this);
            ReportDocument  myRptDoc = Easy_DataAccess.GetReport(Conn, Rep, Par, out errmess);

            if (myRptDoc == null)
            {
                Session["Messaggio"]       = errmess;
                Session["CloseWindow"]     = true;
                Session["UserPar"]         = null;
                Session["ModuleReportRow"] = null;

                Response.Redirect("Messaggio.aspx");
                return;
            }


            // Restituisce il percorso fisico locale della cartella ReportPDF  ex: c:\inetpub\wwwroot\.....
            string FilePath = this.MapPath("ReportPDF");

            if (!FilePath.EndsWith("\\"))
            {
                FilePath += "\\";
            }

            string filenametodelete = FilePath + prefix + "*.*";

            string  [] existingreports = System.IO.Directory.GetFiles(
                FilePath, prefix + "*.*");
            foreach (string filename in existingreports)
            {
                System.IO.File.Delete(filename);
            }

            string PDFfilePathRedir =                   //FilePath +
                                      "ReportPDF/" +
                                      FileName + ".pdf";
            string myFilePdf = ExportToPdf(myRptDoc, FileName, FilePath);

            myRptDoc.Close();
            myRptDoc.Dispose();
            if (myFilePdf == null)
            {
                string mym = "Non è stato possibile completare l'esportazione in formato PDF. \r";
                mym += "E' probabile che i parametri inseriti non siano corretti. \r";
                mym += "Qualora avesse bisogno di assistenza può contattare il servizio assistenza ";
                Session["CloseWindow"] = true;
                Session["Messaggio"]   = mym;
                Response.Redirect("Messaggio.aspx");
                return;
            }
            //Visualizza il Report in formato PDF
            //WebLog.Log(this,"Visualizza il file in formato PDF");
            Session["UserPar"]         = null;
            Session["ModuleReportRow"] = null;
            GC.Collect();
            Response.Redirect(PDFfilePathRedir);
        }
Exemple #30
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");
            }
        }