Subversion Repositories SmartDukaan

Rev

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

Rev 5131 Rev 5140
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
 
4
 
5
import java.io.ByteArrayOutputStream;
5
import java.io.ByteArrayOutputStream;
-
 
6
import java.io.FileNotFoundException;
-
 
7
import java.io.FileOutputStream;
-
 
8
import java.io.IOException;
6
import java.text.DateFormat;
9
import java.text.DateFormat;
7
import java.text.SimpleDateFormat;
10
import java.text.SimpleDateFormat;
8
import java.util.Date;
11
import java.util.Date;
9
 
12
 
10
 
13
 
Line 14... Line 17...
14
		ReportGenerator repGen = new ReportGenerator();
17
		ReportGenerator repGen = new ReportGenerator();
15
		ByteArrayOutputStream baos = repGen.generateExcelStream(ReportGenerator.TYPE_BOTH);
18
		ByteArrayOutputStream baos = repGen.generateExcelStream(ReportGenerator.TYPE_BOTH);
16
		if(baos != null){
19
		if(baos != null){
17
			GmailUtils gm = new GmailUtils();
20
			GmailUtils gm = new GmailUtils();
18
			DateFormat dateFormatter = new SimpleDateFormat("yyyy.MM.dd");
21
			DateFormat dateFormatter = new SimpleDateFormat("yyyy.MM.dd");
19
			String[] recepients = {"cnc.center@shop2020.in, ashutosh.saxena@shop2020.in, chaitanya.vats@shop2020.in"};
22
			String[] recepients = {"cnc.center@shop2020.in", "ashutosh.saxena@shop2020.in", "chaitnaya.vats@shop2020.in"};
20
			String subject = "Items that require your attention.";
23
			String subject = "Items that require your attention.";
21
			String from = "cnc.center@shop2020.in";
24
			String from = "cnc.center@shop2020.in";
22
			String password = "5h0p2o2o";
25
			String password = "5h0p2o2o";
23
			String fileName = "items."+ dateFormatter.format(new Date()) + ".xls";
26
			String fileName = "items."+ dateFormatter.format(new Date()) + ".xls";
24
			byte [] bytes = baos.toByteArray(); 
27
			byte [] bytes = baos.toByteArray();
-
 
28
			   
-
 
29
		     try
-
 
30
		     {
-
 
31
		      FileOutputStream fos = new FileOutputStream(fileName);
-
 
32
		         
-
 
33
		      /*
-
 
34
		       * To write byte array to a file, use
-
 
35
		       * void write(byte[] bArray) method of Java FileOutputStream class.
-
 
36
		       *
-
 
37
		       * This method writes given byte array to a file.
-
 
38
		       */
-
 
39
		     
-
 
40
		       fos.write(bytes);
-
 
41
		     
-
 
42
		      /*
-
 
43
		       * Close FileOutputStream using,
-
 
44
		       * void close() method of Java FileOutputStream class.
-
 
45
		       *
-
 
46
		       */
-
 
47
		     
-
 
48
		       fos.close();
-
 
49
		     
-
 
50
		     }
-
 
51
		     catch(FileNotFoundException ex)
-
 
52
		     {
-
 
53
		      System.out.println("FileNotFoundException : " + ex);
-
 
54
		     }
-
 
55
		     catch(IOException ioe)
-
 
56
		     {
-
 
57
		      System.out.println("IOException : " + ioe);
-
 
58
		     }
-
 
59
 
25
			try {
60
			try {
26
				gm.sendSSLMessage(recepients, subject, "PFA", from, password, fileName, bytes, "application/xls");
61
				gm.sendSSLMessage(recepients, subject, "PFA", from, password, fileName);
27
			} catch (Exception e) {
62
			} catch (Exception e) {
28
				e.printStackTrace();
63
				e.printStackTrace();
29
			}
64
			}
30
		}
65
		}
31
	}
66
	}