Пример #1
0
        private void SendDoc()
        {
            if (UploadFile.PostedFile != null && UploadFile.PostedFile.FileName != "")
            {
                string PathOut = Path.Combine(Server.MapPath("../Doc_Db"), @"KPI\KPI Vod\KPI Eseguiti");
                if (!Directory.Exists(PathOut))
                {
                    Directory.CreateDirectory(PathOut);
                }

                string FileName = Path.Combine(PathOut, Path.GetFileName(UploadFile.PostedFile.FileName));

                UploadFile.PostedFile.SaveAs(FileName);

                string        ConnectionStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
                KPIVod.KPIVod kpi           = new KPIVod.KPIVod(FileName, Context.User.Identity.Name, ConnectionStr);
                // lblMessage.Text= kpi.ReadDocument().ToString();
                kpi.ReadDocument();
                string scriptString = "<script language=JavaScript>alert('Il file è stato elaborato correttamente.');</script>";

                if (!this.IsClientScriptBlockRegistered("clientScriptexp"))
                {
                    this.RegisterStartupScript("clientScriptexp", scriptString);
                }
            }
        }
        private void BtGenera_Click(object sender, System.EventArgs e)
        {
            BtSalva.Visible = true;
            string ConnectionStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];

            KPIVod.KPIVod kpi        = new KPIVod.KPIVod(ConnectionStr);
            string        FileMaster = Path.Combine(Server.MapPath("../MasterExcel"), "KPI_Vodafone.xls");
            string        PathOut    = Path.Combine(Server.MapPath("../Doc_Db"), @"KPI\KPI Vod\KPI Eseguiti");
            string        Fname      = kpi.WriteReport(FileMaster, PathOut, Convert.ToInt32(DropMeseIni.SelectedValue), Convert.ToInt32(DropMeseFine.SelectedValue), Convert.ToInt32(DropAnno.SelectedValue));

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(Fname));
            FileInfo f = new FileInfo(Fname);

            Response.AddHeader("Content-Length", f.Length.ToString());
            Response.AddHeader("Last-Modified: ", f.LastWriteTimeUtc.ToString());
            Response.WriteFile(Fname);
            Response.Flush();
            Response.Close();
            if (File.Exists(Fname))
            {
                File.Delete(Fname);
            }
        }
Пример #3
0
        private void BtSalva_Click(object sender, System.EventArgs e)
        {
            // chiama dll
            string ConnectionStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];

            KPIVod.KPIVod kpi        = new KPIVod.KPIVod(ConnectionStr);
            string        FileMaster = Path.Combine(Server.MapPath("../MasterExcel"), "KPI_Vodafone.xls");
            string        PathOut    = Path.Combine(Server.MapPath("../Doc_Db"), @"KPI\KPI Vod\KPI Eseguiti");
            string        file       = kpi.WriteReport(FileMaster, PathOut, Convert.ToInt32(DropMeseIni.SelectedValue), Convert.ToInt32(DropMeseFine.SelectedValue), Convert.ToInt32(DropAnno.SelectedValue));

            TheSite.Classi.SoddCliente.KPI _kpi = new TheSite.Classi.SoddCliente.KPI();

            S_Controls.Collections.S_ControlsCollection control = new S_Controls.Collections.S_ControlsCollection();

            S_Controls.Collections.S_Object p = new S_Object();
            p.ParameterName = "P_NOMEFILE";
            p.DbType        = CustomDBType.VarChar;
            p.Direction     = ParameterDirection.Input;
            p.Index         = control.Count;
            p.Size          = 50;
            p.Value         = Path.GetFileName(file);
            control.Add(p);

            p = new S_Object();
            p.ParameterName = "P_USERNAME";
            p.DbType        = CustomDBType.VarChar;
            p.Direction     = ParameterDirection.Input;
            p.Index         = control.Count;
            p.Size          = 10;
            p.Value         = Context.User.Identity.Name;
            control.Add(p);

            p = new S_Object();
            p.ParameterName = "P_DATESTART";
            p.DbType        = CustomDBType.VarChar;
            p.Direction     = ParameterDirection.Input;
            p.Index         = control.Count;
            p.Size          = 10;
            p.Value         = DropMeseIni.SelectedValue + "/" + DropAnno.SelectedValue;
            control.Add(p);

            p = new S_Object();
            p.ParameterName = "P_DATEEND";
            p.DbType        = CustomDBType.VarChar;
            p.Direction     = ParameterDirection.Input;
            p.Index         = control.Count;
            p.Size          = 10;
            p.Value         = DropMeseFine.SelectedValue + "/" + DropAnno.SelectedValue;
            control.Add(p);

            _kpi.SaveReportVod(control);

            string scriptString = "<script language=JavaScript>alert('Il file è stato salvato correttamente.');</script>";

            if (!this.IsClientScriptBlockRegistered("clientScriptexp"))
            {
                this.RegisterStartupScript("clientScriptexp", scriptString);
            }
        }