Subversion Repositories SmartDukaan

Rev

Rev 15599 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15599 Rev 15603
Line 66... Line 66...
66
	}
66
	}
67
	public UpdateSDPricingUsingPanel() {
67
	public UpdateSDPricingUsingPanel() {
68
	}
68
	}
69
	public static void main(String... args) throws ClientProtocolException, IOException, TTransportException, CatalogServiceException, TException{
69
	public static void main(String... args) throws ClientProtocolException, IOException, TTransportException, CatalogServiceException, TException{
70
		Item item = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient().getItem(2231);
70
		Item item = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient().getItem(2231);
71
		UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(22200f,"1108903",item,System.currentTimeMillis());
71
		UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(49000f,"SDL850558681",item,System.currentTimeMillis());
72
		logger.info("Calling Thread to update price at snapdeal");
72
		logger.info("Calling Thread to update price at snapdeal");
73
		updatePriceOnSnapdeal.start();	
73
		updatePriceOnSnapdeal.start();	
74
 
74
 
75
	}
75
	}
-
 
76
	
76
	int updatePricing(Float price,String supc,Item item,Long timestamp) throws Exception{
77
	int updatePricing(Float price,String supc,Item item,Long timestamp) throws Exception{
77
		logger.info("Calling Update Snapdeal Price Constructor --" + " Price :" +price + " Supc :"+supc +" Item ID:" +item.getId());
78
		logger.info("Calling Update Snapdeal Price Constructor --" + " Price :" +price + " Supc :"+supc +" Item ID:" +item.getId());
78
		SnapdealSessionCookie sdSessionCookie = new SnapdealSessionCookie();
79
		SnapdealSessionCookie sdSessionCookie = new SnapdealSessionCookie();
79
		String cookies = "";
80
		String cookies = "";
80
		JSONObject cookieObject = null;
81
		JSONObject cookieObject = null;
Line 185... Line 186...
185
		}
186
		}
186
		logger.info("----Login Successful----" );
187
		logger.info("----Login Successful----" );
187
	}
188
	}
188
	public void run()
189
	public void run()
189
	{
190
	{
-
 
191
		logger.info("inside run");
190
		try {
192
		try {
191
			this.updatePricing(this.price,this.supc,this.item,timestamp);
193
			this.updatePricing(this.price,this.supc,this.item,timestamp);
192
			boolean retry =true;
194
			boolean retry =true;
193
			SnapdealSessionCookie sdSessionCookie = new SnapdealSessionCookie();
195
			SnapdealSessionCookie sdSessionCookie = new SnapdealSessionCookie();
194
			String cookies = "";
196
			String cookies = "";
Line 216... Line 218...
216
			"Item ID : " +this.item.getId() +"\n"+
218
			"Item ID : " +this.item.getId() +"\n"+
217
			"SUPC : " +this.supc +"\n"+
219
			"SUPC : " +this.supc +"\n"+
218
			"Updated Price : " +this.price;
220
			"Updated Price : " +this.price;
219
			try{
221
			try{
220
				mailer.sendSSLMessage(sendTo, "Price updated on Snapdeal ( Item ID " + this.item.getId()+ " )",text, emailFromAddress , password,new ArrayList<File>());
222
				mailer.sendSSLMessage(sendTo, "Price updated on Snapdeal ( Item ID " + this.item.getId()+ " )",text, emailFromAddress , password,new ArrayList<File>());
-
 
223
				logger.info("mail sent");
221
			}
224
			}
222
			catch(Exception e){
225
			catch(Exception e){
223
				logger.info("Exception"+e);
226
				logger.info("Exception"+e);
224
			}
227
			}
225
			ArrayList<Long> updateList = new ArrayList<Long>();
228
			ArrayList<Long> updateList = new ArrayList<Long>();
226
			try {
229
			try {
-
 
230
				logger.info("creating client");
227
				Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
231
				Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
228
 
232
				
229
				updateList.add(this.item.getId());
233
				updateList.add(this.item.getId());
-
 
234
				logger.info(updateList.toString());
230
				catalogClient.updateMarketPlacePriceUpdateStatus(updateList,this.timestamp,OrderSource.SNAPDEAL.getValue());
235
				catalogClient.updateMarketPlacePriceUpdateStatus(updateList,this.timestamp,OrderSource.SNAPDEAL.getValue());
-
 
236
				logger.info("client call done");
231
			} catch (TException e) {
237
			} catch (TException e) {
232
				try {
238
				try {
233
					new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient().updateMarketPlacePriceUpdateStatus(updateList, timestamp,OrderSource.SNAPDEAL.getValue());
239
					new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient().updateMarketPlacePriceUpdateStatus(updateList, timestamp,OrderSource.SNAPDEAL.getValue());
234
				} catch (TTransportException e1) {
240
				} catch (TTransportException e1) {
235
					e1.printStackTrace();
241
					e1.printStackTrace();