Subversion Repositories SmartDukaan

Rev

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

Rev 8525 Rev 8526
Line 34... Line 34...
34
import com.amazonaws.mws.model.RequestReportRequest;
34
import com.amazonaws.mws.model.RequestReportRequest;
35
import com.amazonaws.mws.samples.GetReportSample;
35
import com.amazonaws.mws.samples.GetReportSample;
36
 
36
 
37
public class FeedbackRequestEmailSender {
37
public class FeedbackRequestEmailSender {
38
 
38
 
39
	protected static Logger log = Logger.getLogger(FeedbackRequestEmailSender.class);
39
	//protected static Logger log = Logger.getLogger(FeedbackRequestEmailSender.class);
40
	public static void main(String... args){
40
	public static void main(String... args){
41
		/************************************************************************
41
		/************************************************************************
42
		 * Access Key ID and Secret Access Key ID, obtained from:
42
		 * Access Key ID and Secret Access Key ID, obtained from:
43
		 * http://aws.amazon.com
43
		 * http://aws.amazon.com
44
		 ***********************************************************************/
44
		 ***********************************************************************/
Line 172... Line 172...
172
		"Yours Sincerely,<br>" +
172
		"Yours Sincerely,<br>" +
173
		"Saholic Team<br>";
173
		"Saholic Team<br>";
174
 
174
 
175
		String emailIdFrom= "help@saholic.com";
175
		String emailIdFrom= "help@saholic.com";
176
 
176
 
177
		String shipmentReportRequestId = null;		
177
		String shipmentReportRequestId = null;	
-
 
178
		int i=1;
178
		while(true){
179
		while(true){
179
 
180
 
180
			try {
181
			try {
181
				shipmentReportRequestId = RequestReportSample.invokeRequestReport(service, fullfilledShipmentReportRequest);
182
				shipmentReportRequestId = RequestReportSample.invokeRequestReport(service, fullfilledShipmentReportRequest);
182
				break;
183
				break;
183
			} catch (MarketplaceWebServiceException e1) {
184
			} catch (MarketplaceWebServiceException e1) {
184
				// TODO Auto-generated catch block
185
				// TODO Auto-generated catch block
185
				e1.printStackTrace();
186
				e1.printStackTrace();
186
			}
187
			}
-
 
188
			i =i +1;
187
		}
189
		}
-
 
190
		System.out.println("i's Value.... "+i);
188
		String returnsReportRequestId = null;
191
		String returnsReportRequestId = null;
-
 
192
		int j=1;
189
		while(true){
193
		while(true){
190
			try {
194
			try {
191
				returnsReportRequestId = RequestReportSample.invokeRequestReport(service, returnsReportRequest);
195
				returnsReportRequestId = RequestReportSample.invokeRequestReport(service, returnsReportRequest);
192
				break;
196
				break;
193
			} catch (MarketplaceWebServiceException e1) {
197
			} catch (MarketplaceWebServiceException e1) {
194
				// TODO Auto-generated catch block
198
				// TODO Auto-generated catch block
195
				e1.printStackTrace();
199
				e1.printStackTrace();
196
			}
200
			}
-
 
201
			j =j +1;
197
		}
202
		}
-
 
203
		System.out.println("j's Value.... "+j);
-
 
204
		int m=0;
198
		while(true){
205
		while(true){
199
			GetReportListRequest requestShipmentReportList = new GetReportListRequest();
206
			GetReportListRequest requestShipmentReportList = new GetReportListRequest();
200
			requestShipmentReportList.setMerchant( merchantId );
207
			requestShipmentReportList.setMerchant( merchantId );
201
 
208
 
202
			GetReportListRequest requestReturnsReportList = new GetReportListRequest();
209
			GetReportListRequest requestReturnsReportList = new GetReportListRequest();
Line 223... Line 230...
223
				requestShipmentReport.setReportId( requestIdShipmentReportIdmap.get(shipmentReportRequestId) );
230
				requestShipmentReport.setReportId( requestIdShipmentReportIdmap.get(shipmentReportRequestId) );
224
				OutputStream shipmentReport=null;
231
				OutputStream shipmentReport=null;
225
				try {
232
				try {
226
					shipmentReport = new FileOutputStream( "/tmp/AmazonFullFilledShipmentReport.txt" );
233
					shipmentReport = new FileOutputStream( "/tmp/AmazonFullFilledShipmentReport.txt" );
227
				} catch (FileNotFoundException e) {
234
				} catch (FileNotFoundException e) {
228
					log.error("Error Getting Shipment Report :- ", e);
235
					//log.error("Error Getting Shipment Report :- ", e);
229
				}
236
				}
230
				requestShipmentReport.setReportOutputStream( shipmentReport );
237
				requestShipmentReport.setReportOutputStream( shipmentReport );
231
				GetReportSample.invokeGetReport(service, requestShipmentReport);
238
				GetReportSample.invokeGetReport(service, requestShipmentReport);
232
 
239
 
233
				System.out.println("Shipment Report ready please check\n");
240
				System.out.println("Shipment Report ready please check\n");
234
				CSVReader shipmentReportReader = null; 
241
				CSVReader shipmentReportReader = null; 
235
				try {
242
				try {
236
					shipmentReportReader = new CSVReader(new FileReader("/tmp/AmazonFullFilledShipmentReport.txt"),'\t');
243
					shipmentReportReader = new CSVReader(new FileReader("/tmp/AmazonFullFilledShipmentReport.txt"),'\t');
237
				} catch (FileNotFoundException e) {
244
				} catch (FileNotFoundException e) {
238
					log.error("Error Reading Shipment Report :- ", e);
245
					//log.error("Error Reading Shipment Report :- ", e);
239
				}
246
				}
240
 
247
 
241
				requestReturnsReport.setReportId( requestIdReturnsReportIdmap.get(returnsReportRequestId) );
248
				requestReturnsReport.setReportId( requestIdReturnsReportIdmap.get(returnsReportRequestId) );
242
				OutputStream returnsReport=null;
249
				OutputStream returnsReport=null;
243
				try {
250
				try {
244
					returnsReport = new FileOutputStream( "/tmp/AmazonReturnsReport.txt" );
251
					returnsReport = new FileOutputStream( "/tmp/AmazonReturnsReport.txt" );
245
				} catch (FileNotFoundException e) {
252
				} catch (FileNotFoundException e) {
246
					log.error("Error Getting Returns Report :- ", e);
253
					//log.error("Error Getting Returns Report :- ", e);
247
				}
254
				}
248
				requestReturnsReport.setReportOutputStream( returnsReport );
255
				requestReturnsReport.setReportOutputStream( returnsReport );
249
				GetReportSample.invokeGetReport(service, requestReturnsReport);
256
				GetReportSample.invokeGetReport(service, requestReturnsReport);
250
 
257
 
251
				System.out.println("Return Report ready please check\n");
258
				System.out.println("Return Report ready please check\n");
252
				CSVReader returnsReportReader = null; 
259
				CSVReader returnsReportReader = null; 
253
				try {
260
				try {
254
					returnsReportReader = new CSVReader(new FileReader("/tmp/AmazonReturnsReport.txt"),'\t');
261
					returnsReportReader = new CSVReader(new FileReader("/tmp/AmazonReturnsReport.txt"),'\t');
255
				} catch (FileNotFoundException e) {
262
				} catch (FileNotFoundException e) {
256
					log.error("Error Reading Returns Report :- ", e);
263
					//log.error("Error Reading Returns Report :- ", e);
257
				}
264
				}
258
 
265
 
259
 
266
 
260
				String [] shipmentReportData;
267
				String [] shipmentReportData;
261
				String [] returnsReportData;
268
				String [] returnsReportData;
Line 285... Line 292...
285
						}
292
						}
286
						}
293
						}
287
 
294
 
288
					}
295
					}
289
				} catch (IOException e) {
296
				} catch (IOException e) {
290
					log.error("Error Reading IO operations :- ", e);
297
					//log.error("Error Reading IO operations :- ", e);
291
				} 
298
				} 
292
 
299
 
293
				break;
300
				break;
294
			}
301
			}
295
			else{ 
302
			else{ 
296
				log.info("Report not ready\n");
303
				System.out.println("Report not ready\n");
297
				try {
304
				try {
298
					Thread.sleep(5*60*1000);
305
					Thread.sleep(5*60*1000);
299
				} catch (InterruptedException e) {
306
				} catch (InterruptedException e) {
300
					log.error("Error During getting Response :- ", e);
307
					//log.error("Error During getting Response :- ", e);
301
				}
308
				}
302
			}
309
			}
-
 
310
			m=m+1;
303
		}
311
		}
-
 
312
		System.out.println("m's Value.... "+m);
304
 
313
 
305
		HelperClient helperServiceClient;
314
		//HelperClient helperServiceClient;
306
		try {
315
		try {
307
			helperServiceClient = new HelperClient("helper_service_server_host_prod", "helper_service_server_port_prod");
316
			//helperServiceClient = new HelperClient("helper_service_server_host_prod", "helper_service_server_port_prod");
308
			in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
317
			//in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
309
			System.out.print("Email Id List: \n");
318
			System.out.print("Email Id List: \n");
310
			for(int i=0; i<fbaCustomersEmails.size();i++){
319
			for(int k=0; k<fbaCustomersEmails.size();i++){
311
				System.out.print(fbaCustomersEmails.get(i)+"\n");
320
				System.out.print(fbaCustomersEmails.get(i)+"\n");
312
				client.saveUserEmailForSending(Arrays.asList(new String[] {fbaCustomersEmails.get(i)}), emailIdFrom, "Feedback Request", emailBody, "AmazonMFN", "AmazonFeedback", null, Arrays.asList(new String[] {"amit.sirohi@shop2020.in"}), 1);
321
				//client.saveUserEmailForSending(Arrays.asList(new String[] {fbaCustomersEmails.get(i)}), emailIdFrom, "Feedback Request", emailBody, "AmazonMFN", "AmazonFeedback", null, Arrays.asList(new String[] {"amit.sirohi@shop2020.in"}), 1);
313
			}
322
			}
314
		} catch (Exception e) {
323
		} catch (Exception e) {
315
			log.error("Error Getting Helper Client :- ", e);
324
			//log.error("Error Getting Helper Client :- ", e);
316
		}
325
		}
317
 
326
 
318
 
327
 
319
 
328
 
320
		// Note that depending on the type of report being downloaded, a report can reach 
329
		// Note that depending on the type of report being downloaded, a report can reach