Subversion Repositories SmartDukaan

Rev

Rev 5140 | Rev 6322 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5140 Rev 5181
Line 1... Line 1...
1
package in.shop2020.catalog.util;
1
package in.shop2020.catalog.util;
2
 
2
 
3
import in.shop2020.utils.GmailUtils;
3
import in.shop2020.utils.GmailUtils;
-
 
4
import in.shop2020.utils.Utils;
4
 
5
 
5
import java.io.ByteArrayOutputStream;
6
import java.io.ByteArrayOutputStream;
6
import java.io.FileNotFoundException;
7
import java.io.FileNotFoundException;
7
import java.io.FileOutputStream;
8
import java.io.FileOutputStream;
8
import java.io.IOException;
9
import java.io.IOException;
9
import java.text.DateFormat;
10
import java.text.DateFormat;
10
import java.text.SimpleDateFormat;
11
import java.text.SimpleDateFormat;
11
import java.util.Date;
12
import java.util.Date;
12
 
13
 
13
 
14
 
-
 
15
 
14
public class ReportSender implements Runnable {
16
public class ReportSender implements Runnable {
-
 
17
	static String EXPORT_PATH  = "/var/lib/tomcat6/webapps/export/";
15
	@Override
18
	@Override
16
	public void run() {
19
	public void run() {
17
		ReportGenerator repGen = new ReportGenerator();
20
		ReportGenerator repGen = new ReportGenerator();
18
		ByteArrayOutputStream baos = repGen.generateExcelStream(ReportGenerator.TYPE_BOTH);
21
		ByteArrayOutputStream baos = repGen.generateExcelStream(ReportGenerator.TYPE_BOTH);
19
		if(baos != null){
22
		if(baos != null){
Line 26... Line 29...
26
			String fileName = "items."+ dateFormatter.format(new Date()) + ".xls";
29
			String fileName = "items."+ dateFormatter.format(new Date()) + ".xls";
27
			byte [] bytes = baos.toByteArray();
30
			byte [] bytes = baos.toByteArray();
28
			   
31
			   
29
		     try
32
		     try
30
		     {
33
		     {
31
		      FileOutputStream fos = new FileOutputStream(fileName);
34
		      FileOutputStream fos = new FileOutputStream(EXPORT_PATH + fileName);
32
		         
35
		         
33
		      /*
36
		      /*
34
		       * To write byte array to a file, use
37
		       * To write byte array to a file, use
35
		       * void write(byte[] bArray) method of Java FileOutputStream class.
38
		       * void write(byte[] bArray) method of Java FileOutputStream class.
36
		       *
39
		       *
Line 56... Line 59...
56
		     {
59
		     {
57
		      System.out.println("IOException : " + ioe);
60
		      System.out.println("IOException : " + ioe);
58
		     }
61
		     }
59
 
62
 
60
			try {
63
			try {
61
				gm.sendSSLMessage(recepients, subject, "PFA", from, password, fileName);
64
				gm.sendSSLMessage(recepients, subject, "PFA", from, password, EXPORT_PATH + fileName);
62
			} catch (Exception e) {
65
			} catch (Exception e) {
63
				e.printStackTrace();
66
				e.printStackTrace();
64
			}
67
			}
65
		}
68
		}
66
	}
69
	}