Subversion Repositories SmartDukaan

Rev

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

Rev 12899 Rev 13122
Line 53... Line 53...
53
import com.amazonaws.mws.model.IdList;
53
import com.amazonaws.mws.model.IdList;
54
import com.amazonaws.mws.model.Message;
54
import com.amazonaws.mws.model.Message;
55
import com.amazonaws.mws.model.Order;
55
import com.amazonaws.mws.model.Order;
56
import com.amazonaws.mws.model.RequestReportRequest;
56
import com.amazonaws.mws.model.RequestReportRequest;
57
 
57
 
-
 
58
import com.amazonaws.mws.samples.Consumer;
-
 
59
 
58
public class FetchAmazonXMLSalesSnapshot{
60
public class FetchAmazonXMLSalesSnapshot{
59
	public static void main(String... args){
61
	public static void main(String... args){
60
		/************************************************************************
62
		/************************************************************************
61
		 * Access Key ID and Secret Access Key ID, obtained from:
63
		 * Access Key ID and Secret Access Key ID, obtained from:
62
		 * http://aws.amazon.com
64
		 * http://aws.amazon.com
Line 161... Line 163...
161
		System.out.println("Order Start Date  " + orderStartDate  + "Order End Date  " + orderEndDate);
163
		System.out.println("Order Start Date  " + orderStartDate  + "Order End Date  " + orderEndDate);
162
		orderreportrequest.setStartDate(orderStartDate);
164
		orderreportrequest.setStartDate(orderStartDate);
163
		orderreportrequest.setEndDate(orderEndDate);
165
		orderreportrequest.setEndDate(orderEndDate);
164
		long inventorytimediff = System.currentTimeMillis() - 7*24*60*60*1000;
166
		long inventorytimediff = System.currentTimeMillis() - 7*24*60*60*1000;
165
		GregorianCalendar ist = new GregorianCalendar();
167
		GregorianCalendar ist = new GregorianCalendar();
166
		ist.setTimeInMillis(inventorytimediff);
168
        ist.setTimeInMillis(inventorytimediff);
167
		ist.setTimeInMillis(ordertimediff);
169
        ist.setTimeInMillis(ordertimediff);
168
		XMLGregorianCalendar  inventoryStartDate = df.newXMLGregorianCalendar(ist);
170
        XMLGregorianCalendar  inventoryStartDate = df.newXMLGregorianCalendar(ist);
169
		XMLGregorianCalendar inventoryEndDate = df.newXMLGregorianCalendar(new GregorianCalendar());
171
        XMLGregorianCalendar inventoryEndDate = df.newXMLGregorianCalendar(new GregorianCalendar());
170
		System.out.println("Inventory Start Date  " + inventoryStartDate  + "Inventory End Date  " + inventoryEndDate);
172
        System.out.println("Inventory Start Date  " + inventoryStartDate  + "Inventory End Date  " + inventoryEndDate);
171
		inventoryhealthreportrequest.setStartDate(inventoryStartDate);
173
		inventoryhealthreportrequest.setStartDate(inventoryStartDate);
172
		inventoryhealthreportrequest.setEndDate(inventoryEndDate);
174
		inventoryhealthreportrequest.setEndDate(inventoryEndDate);
173
		Map<String,String> requestIdreportIdmap;
175
		Map<String,String> requestIdreportIdmap;
174
		String orderreportrequestId = null;
176
		String orderreportrequestId = null;
175
		String inventoryhealthreportrequestId = null;
177
		String inventoryhealthreportrequestId = null;
Line 422... Line 424...
422
							}
424
							}
423
						}
425
						}
424
					}
426
					}
425
 
427
 
426
					InventoryClient inventoryServiceClient = null;
428
					InventoryClient inventoryServiceClient = null;
427
					TransactionClient transactionServiceClient = null;
429
					//TransactionClient transactionServiceClient = null;
428
					CatalogClient catalogServiceClient = null;
430
					CatalogClient catalogServiceClient = null;
429
					try {
431
					try {
430
						inventoryServiceClient = new InventoryClient();
432
						inventoryServiceClient = new InventoryClient();
431
						transactionServiceClient = new TransactionClient();
433
						//transactionServiceClient = new TransactionClient();
432
						//catalogServiceClient = new CatalogClient();
434
						//catalogServiceClient = new CatalogClient();
433
						catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
435
						catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
434
					} catch (Exception e) {
436
					} catch (Exception e) {
435
						e.printStackTrace();
437
						e.printStackTrace();
436
					}	
438
					}	
Line 740... Line 742...
740
					}
742
					}
741
					System.out.println("Order Details to be Updated Size... "+fbaSalesSnapShotList.size());
743
					System.out.println("Order Details to be Updated Size... "+fbaSalesSnapShotList.size());
742
					boolean tryagain = true;
744
					boolean tryagain = true;
743
					while(tryagain){
745
					while(tryagain){
744
						try{
746
						try{
745
							transactionServiceClient.getClient().bulkAddOrUpdateAmazonFbaSalesSnapshot(fbaSalesSnapShotList);
747
							Consumer.bulkAddOrUpdateAmazonFbaSalesSnapshot(fbaSalesSnapShotList);
746
							tryagain=false;
748
							tryagain=false;
747
						}
749
						}
748
						catch(Exception ex){
750
						catch(Exception ex){
749
						}
751
						}
750
					}
752
					}
Line 756... Line 758...
756
					e.printStackTrace();
758
					e.printStackTrace();
757
				}
759
				}
758
				break;
760
				break;
759
			}
761
			}
760
			else{ 
762
			else{ 
761
				System.out.println("Report not ready");
763
				System.out.println("Report not ready.Sleeping for two minutes.");
762
				try {
764
				try {
763
					Thread.sleep(5*60*1000);
765
					Thread.sleep(2*60*1000);
764
				} catch (InterruptedException e) {
766
				} catch (InterruptedException e) {
765
					// TODO Auto-generated catch block
767
					// TODO Auto-generated catch block
766
					e.printStackTrace();
768
					e.printStackTrace();
767
				}
769
				}
768
			}
770
			}
Line 777... Line 779...
777
 
779
 
778
	}
780
	}
779
 
781
 
780
 
782
 
781
 
783
 
782
}
-
 
783
784
}
-
 
785