Ejemplo n.º 1
0
 /// <summary>
 /// Decrypt a string
 /// </summary>
 public static string Decrypt(string Text,string Key)
 {
     string result = Text;
     rc4encrypt crypt = new rc4encrypt();
     crypt.password = Key;
     crypt.plaintext = Text;
     result = crypt.EnDeCrypt();
     return(result);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Decrypt a string
        /// </summary>
        public static string Decrypt(string Text, string Key)
        {
            string     result = Text;
            rc4encrypt crypt  = new rc4encrypt();

            crypt.password  = Key;
            crypt.plaintext = Text;
            result          = crypt.EnDeCrypt();
            return(result);
        }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String load             = Request["load"];
        String mode             = Request["mode"];
        string connectionString = "";
        string dbpath           = Server.MapPath("/");

        //dbpath=Mid(dbpath,1,Instrrev(dbpath,"\")-1)
        //checklast=Mid(dbpath,Instrrev(dbpath,"\")+1)

        //If checklast="admin" Then
        //dbpath=Mid(dbpath,1,Instrrev(dbpath,"\")-1)
        //checklast=Mid(dbpath,Instrrev(dbpath,"\")+1)
        //End if

        //If checklast="web" Or checklast="public_html" Or checklast="admin" Then dbpath=Mid(dbpath,1,Instrrev(dbpath,"\")-1)
        //'If checklast="web" Or checklast="public_html" Or checklast="progettiamo" Or checklast="admin" Then dbpath=Mid(dbpath,1,Instrrev(dbpath,"\")-1)
        dbpath = dbpath.Substring(0, dbpath.LastIndexOf("\\"));
        dbpath = dbpath.Substring(0, dbpath.LastIndexOf("\\"));
        dbpath = dbpath + "\\database\\";
        string dbname = "dsm_progettiamo.v1.mdb";



        main.rc4encrypt rc4 = new rc4encrypt();
        rc4.Password = "******";


        dbpath = dbpath + dbname;
        DataTable dt       = null;
        String    SQL      = "SELECT * FROM p_projects WHERE ID=" + load;
        string    filename = "";
        int       adm_area = Session["adm_area"] == null ? 0 : (int)Session["adm_area"];

        if (adm_area > 0)
        {
            SQL = "SELECT * FROM p_projects WHERE ID=" + load + " AND CO_p_area=" + Session["adm_area"];
        }
        try
        {
            connectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;" + "Data Source='" + dbpath + "';";


            using (OleDbConnection con = new OleDbConnection(connectionString))
            {
                con.Open();

                using (OleDbCommand command = new OleDbCommand(SQL, con))
                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        dt = new DataTable();
                        dt.Columns.Add("Ente/Società", typeof(String));
                        dt.Columns.Add("Cognome", typeof(String));
                        dt.Columns.Add("Nome", typeof(String));
                        dt.Columns.Add("Fr.", typeof(String));
                        dt.Columns.Add("Email", typeof(String));
                        dt.Columns.Add("Tel.", typeof(String));
                        dt.Columns.Add("Cap", typeof(String));
                        dt.Columns.Add("Luogo", typeof(String));
                        dt.Columns.Add("Indirizzo", typeof(String));
                        dt.Columns.Add("Data", typeof(String));

                        while (reader.Read())
                        {
                            filename = reader["TA_nome"].ToString();
                            SQL      = "SELECT DISTINCT ID FROM (SELECT ID FROM QU_projects_promises WHERE CO_p_projects=" + load + " ORDER BY DT_data)";


                            using (OleDbCommand com2 = new OleDbCommand(SQL, con))
                            {
                                using (OleDbDataReader rec1 = com2.ExecuteReader())
                                {
                                    string refu = "";
                                    while (rec1.Read())
                                    {
                                        refu = rec1["ID"].ToString();

                                        SQL = "SELECT SUM(IN_promessa) as promesso,MAX(DT_data) as lastdata FROM QU_projects_promises WHERE CO_p_projects=" + load + " AND ID=" + refu;

                                        using (OleDbCommand com3 = new OleDbCommand(SQL, con))
                                        {
                                            using (OleDbDataReader rec2 = com3.ExecuteReader())
                                            {
                                                while (rec2.Read())
                                                {
                                                    string promesso = rec2["promesso"].ToString();
                                                    string lastdata = rec2["lastdata"].ToString();
                                                    SQL = "SELECT * FROM registeredusers WHERE ID=" + refu;
                                                    using (OleDbCommand com4 = new OleDbCommand(SQL, con))
                                                        using (OleDbDataReader rec3 = com4.ExecuteReader())
                                                        {
                                                            while (rec3.Read())
                                                            {
                                                                string email = rec3["TA_email"].ToString();

                                                                //EnDecrypt.CryptedText = email;
                                                                //EnDecrypt.Decrypt();
                                                                //email = System.Web.HttpUtility.UrlDecode(email);
                                                                //rc4.URLDecode(email);
                                                                //throw new Exception(rc4.URLDecode(email));
                                                                if (!String.IsNullOrEmpty(email))
                                                                {
                                                                    rc4.PlainText = email;

                                                                    email = rc4.EnDeCrypt(2);
                                                                }

                                                                string telefono = rec3["TA_telefono"].ToString();
                                                                //EnDecrypt.CryptedText = telefono;
                                                                //EnDecrypt.Decrypt();
                                                                if (!String.IsNullOrEmpty(telefono))
                                                                {
                                                                    rc4.PlainText = telefono;
                                                                    telefono      = rc4.EnDeCrypt(2);
                                                                }
                                                                dt.Rows.Add(rec3["TA_ente"], DecodeFromUtf8((String)rec3["TA_cognome"]), DecodeFromUtf8((String)rec3["TA_nome"]), promesso, email, telefono, rec3["TA_cap"], rec3["TA_citta"], rec3["TA_indirizzo"], lastdata);
                                                            }
                                                        }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
            }
        }

        catch (Exception ex)
        {
            Response.Write(dbpath + "<br/>" + ex.Message + "<br/>" + ex.StackTrace);
            Response.End();
            return;
        }


        downloadExcel(filename, dt, mode);
    }