Example #1
0
        protected void btnSalva_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 pwd    = txtPWD.Text;
            string server = txtServer.Text;
            string db     = txtDB.Text;
            string user   = txtUser.Text;

            string report = txtReport.Text;

            if (!System.IO.Directory.Exists(report))
            {
                lblmessages.Text = "La Directory specificata per i report è inesistente.";
                return;
            }

            string       path     = MapPath("cfg");
            string       filename = Path.Combine(path, "config.xml");
            FileStream   FileS    = new FileStream(filename, FileMode.OpenOrCreate);
            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);
            CryptoS.Flush();
            CryptoS.Close();
            CryptoS.Dispose();
            FileS.Close();
            FileS.Dispose();
            lblmessages.Text  = "File di configurazione Creato correttamente";
            lblmessages.Text += " Aggiungere le autorizzazioni <b>CONTROLLO COMPLETO</b> " +
                                " all'utente impersonato per la cartella ReportPDF <br/>, e rimuovere le autorizzazioni in" +
                                " scrittura per la cartella cfg.";
        }
Example #2
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.";
            }
        }