private void inviaSGA() { HSga = LblSga.Text; string formatdate = DateTime.Now.Millisecond.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(); string fileName = ""; if (hidprog.Value == "2") // vodafone { fileName = @"\XSLT\XSLsgaRptVod04.xslt"; } else { fileName = @"\XSLT\XSLsgaRpt04.xslt"; } string PathSgaXlst = Server.MapPath(Request.ApplicationPath + fileName); TheSite.Classi.RptRtf.SGARTF trs = new TheSite.Classi.RptRtf.SGARTF(); trs.FileXlst = PathSgaXlst; int wr_id = Convert.ToInt32(this.txtWrHidden.Text); string[] Files = trs.GeneraRtf(wr_id, formatdate); TheSite.Classi.MailSend mail = new TheSite.Classi.MailSend(); SaveInvio(Files[1], DocType.SGA); mail.SendMail(Files[0], wr_id, DocType.SGA); //recupero data di invio sga DataSet DsData = _ClManCorrettiva.GetDataInvioSga(itemId, DocType.SGA); if (DsData.Tables[0].Rows.Count == 1) { DataRow _DrData = DsData.Tables[0].Rows[0]; LblInvioSga.Text = _DrData["data_invio"].ToString(); } // }
// private void inviaSGA() // { // HSga=LblSga.Text; // string formatdate=DateTime.Now.Millisecond.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() +DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() +DateTime.Now.Year.ToString(); // string fileName=""; // if (hidprog.Value=="2") // vodafone // fileName = @"\XSLT\XSLsgaRptVod04.xslt"; // else // fileName = @"\XSLT\XSLsgaRpt04.xslt"; // string PathSgaXlst = Server.MapPath(Request.ApplicationPath + fileName); // TheSite.Classi.RptRtf.SGARTF trs = new TheSite.Classi.RptRtf.SGARTF(); // trs.FileXlst = PathSgaXlst; // int wr_id = Convert.ToInt32(this.txtWrHidden.Text); // string[] Files=trs.GeneraRtf(wr_id,formatdate); // TheSite.Classi.MailSend mail=new TheSite.Classi.MailSend(); // SaveInvio(Files[1],DocType.SGA); // mail.SendMail(Files[0],wr_id,DocType.SGA); // //recupero data di invio sga // DataSet DsData = _ClManCorrettiva.GetDataInvioSga(itemId,DocType.SGA); // // if (DsData.Tables[0].Rows.Count == 1) // { // DataRow _DrData = DsData.Tables[0].Rows[0]; // LblInvioSga.Text=_DrData["data_invio"].ToString(); // } // // // } private void inviaDie() { HSga = LblSga.Text; int wr_id = Convert.ToInt32(this.txtWrHidden.Text); string formatdate = DateTime.Now.Millisecond.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(); TheSite.XSLT.DIE die = new TheSite.XSLT.DIE(wr_id, formatdate); string[] Files = die.GenerateDIE(); TheSite.Classi.MailSend mail = new TheSite.Classi.MailSend(); mail.SendMail(Files[0], wr_id, DocType.DIE); SaveInvio(Files[1], DocType.DIE); }
private void DataGridRicerca_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Download") { string[] param; string [] bl; string file = ""; string[] filename; string filedownload = ""; if (e.Item.Cells[7].Text == "SGA" || e.Item.Cells[7].Text == "DIE") { param = e.CommandArgument.ToString().Split(','); bl = param[1].Split(' '); file = Server.MapPath("../Doc_DB") + "\\" + bl[1] + "\\" + param[0] + "\\" + param[1]; filename = Path.GetFileName(file).Split(' '); filedownload = Server.MapPath("../Doc_DB") + "\\" + filename[1] + "\\" + param[0] + "\\" + filename[0] + " " + filename[1] + " " + filename[2] + ".rtf"; Response.Clear(); Response.ContentType = "application/rtf"; if (File.Exists(filedownload)) { File.Delete(filedownload); } File.Copy(file, filedownload); } else { filedownload = Server.MapPath("../Doc_DB") + "\\" + e.Item.Cells[3].Text.Trim() + "\\" + e.Item.Cells[6].Text.Trim(); filedownload = filedownload.Replace(".xls", ".zip"); Response.Clear(); Response.ContentType = "application/zip"; } Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(filedownload)); Response.WriteFile(filedownload); Response.End(); } if (e.CommandName == "Invio") { string[] param; string [] bl; string file = ""; string[] filename; string filedownload = ""; if (e.Item.Cells[7].Text == "SGA" || e.Item.Cells[7].Text == "DIE") { param = e.CommandArgument.ToString().Split(','); bl = param[1].Split(' '); file = Server.MapPath("../Doc_DB") + "\\" + bl[1] + "\\" + param[0] + "\\" + param[1]; filename = Path.GetFileName(file).Split(' '); filedownload = Server.MapPath("../Doc_DB") + "\\" + filename[1] + "\\" + param[0] + "\\" + filename[0] + " " + filename[1] + " " + filename[2] + ".rtf"; if (File.Exists(filedownload)) { File.Delete(filedownload); } File.Copy(file, filedownload); } else { param = e.CommandArgument.ToString().Split(','); filedownload = Server.MapPath("../Doc_DB") + "\\" + e.Item.Cells[3].Text.Trim() + "\\" + e.Item.Cells[6].Text.Trim(); } TheSite.Classi.MailSend mail = new TheSite.Classi.MailSend(); DocType TipoDc; if (e.Item.Cells[7].Text == "SGA") { TipoDc = DocType.SGA; } else if (e.Item.Cells[7].Text == "DIE") { TipoDc = DocType.DIE; } else { TipoDc = DocType.XLS; } string FileZip = ""; if (TipoDc == DocType.XLS) { FileZip = filedownload; } else { FileZip = Path.GetDirectoryName(filedownload) + @"\" + Path.GetFileNameWithoutExtension(filedownload) + ".zip"; if (File.Exists(FileZip)) { File.Delete(FileZip); } ZipOutputStream s = new ZipOutputStream(File.Create(FileZip)); s.SetLevel(5); // 0 - store only to 9 - means best compression FileStream fs = File.OpenRead(filedownload); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(Path.GetFileName(filedownload)); s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); s.Finish(); s.Close(); fs.Close(); } if (e.Item.Cells[7].Text == "SGA" || e.Item.Cells[7].Text == "DIE") { mail.SendMail(FileZip, int.Parse(param[0]), TipoDc); } else { mail.SendMailXls(FileZip, TipoDc, Convert.ToInt32(e.Item.Cells[10].Text)); } } }
public string GENERAPDFSGA(int wr_id, string sga, string username) { System.Web.UI.Page pg = new Page(); string pathRptSource; ReportDocument crReportDocument = new ReportDocument(); Classi.ManCorrettiva.MANCORRETTIVASFOGLIARDL _RichiestaIntervento = new Classi.ManCorrettiva.MANCORRETTIVASFOGLIARDL(); DataSet Ds = _RichiestaIntervento.ReportSGA(wr_id); dsRapportino dsP = new dsRapportino(); int i = 0; for (i = 0; i <= Ds.Tables[0].Rows.Count - 1; i++) { dsP.Tables["sga"].ImportRow(Ds.Tables[0].Rows[i]); } pathRptSource = pg.Server.MapPath("../Report/RptSGA1.rpt"); crReportDocument.Load(pathRptSource); crReportDocument.SetDataSource(dsP); //string Fname = pg.Server.MapPath("../Report/" + pg.Session.SessionID.ToString() + ".pdf");// ExportOptions optExp; DiskFileDestinationOptions optDsk = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions optPdfRtf = new PdfRtfWordFormatOptions(); optExp = crReportDocument.ExportOptions; optExp.ExportFormatType = ExportFormatType.PortableDocFormat; optExp.FormatOptions = optPdfRtf; optExp.ExportDestinationType = ExportDestinationType.DiskFile; //-----inserire nome del file nuovo string STORENAME = "PACK_TRACCIA_DOC.SP_INS_SGA"; conn.Open(); System.Data.OracleClient.OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = STORENAME; OracleParameter par1 = new OracleParameter(); par1.ParameterName = "p_id_wr"; par1.OracleType = System.Data.OracleClient.OracleType.Number; par1.Direction = ParameterDirection.Input; par1.Value = wr_id; par1.Size = 100; cmd.Parameters.Add(par1); OracleParameter par2 = new OracleParameter(); par2.ParameterName = "p_user"; par2.OracleType = System.Data.OracleClient.OracleType.VarChar; par2.Direction = ParameterDirection.Input; par2.Size = 50; par2.Value = username; cmd.Parameters.Add(par2); OracleParameter par3 = new OracleParameter(); par3.ParameterName = "p_sga"; par3.OracleType = System.Data.OracleClient.OracleType.VarChar; par3.Direction = ParameterDirection.Input; par3.Size = 100; par3.Value = sga; cmd.Parameters.Add(par3); OracleParameter par4 = new OracleParameter(); par4.ParameterName = "p_codice"; par4.OracleType = System.Data.OracleClient.OracleType.VarChar; par4.Direction = ParameterDirection.Output; par4.Size = 50; par4.Value = ""; cmd.Parameters.Add(par4); cmd.ExecuteNonQuery(); string NOMESGA = cmd.Parameters["p_codice"].Value.ToString(); // OracleDataReader rdr = cmd.ExecuteReader(); // string pr=rdr.GetString(); //string pr=cmd.ExecuteScalar(); conn.Close(); cmd.Dispose(); //@"C:\Inetpub\wwwroot\RL\Doc_DB\" //optDsk.DiskFileName = pathRptSource+sga+".pdf"; optDsk.DiskFileName = @System.Configuration.ConfigurationSettings.AppSettings["DIRSGA"] + NOMESGA; //Fname; optExp.DestinationOptions = optDsk; crReportDocument.Export(); string FileZip = Path.GetDirectoryName(optDsk.DiskFileName) + @"\" + Path.GetFileNameWithoutExtension(optDsk.DiskFileName) + ".zip"; if (File.Exists(FileZip)) { File.Delete(FileZip); } ZipOutputStream s = new ZipOutputStream(File.Create(FileZip)); s.SetLevel(5); // 0 - store only to 9 - FileStream fs = File.OpenRead(optDsk.DiskFileName); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(Path.GetFileName(optDsk.DiskFileName)); s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); s.Finish(); s.Close(); fs.Close(); TheSite.Classi.MailSend mail = new TheSite.Classi.MailSend(); //mail.SendMail(optDsk.DiskFileName,wr_id,DocType.SGA); mail.SendMail(FileZip, wr_id, DocType.SGA); return(optDsk.DiskFileName); }