| Line 29... |
Line 29... |
| 29 |
import org.apache.thrift.transport.TTransportException;
|
29 |
import org.apache.thrift.transport.TTransportException;
|
| 30 |
import org.slf4j.Logger;
|
30 |
import org.slf4j.Logger;
|
| 31 |
import org.slf4j.LoggerFactory;
|
31 |
import org.slf4j.LoggerFactory;
|
| 32 |
|
32 |
|
| 33 |
public class UpdateSDPricingUsingPanel extends Thread{
|
33 |
public class UpdateSDPricingUsingPanel extends Thread{
|
| 34 |
private DefaultHttpClient client;
|
34 |
private static DefaultHttpClient httpClient = new DefaultHttpClient();
|
| 35 |
private Float price;
|
35 |
private Float price;
|
| 36 |
private String supc;
|
36 |
private String supc;
|
| 37 |
private Item item;
|
37 |
private Item item;
|
| 38 |
private Long timestamp;
|
38 |
private Long timestamp;
|
| 39 |
public String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
39 |
public String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
| Line 67... |
Line 67... |
| 67 |
String.valueOf(price.intValue())));
|
67 |
String.valueOf(price.intValue())));
|
| 68 |
nameValuePairs.add(new BasicNameValuePair("id",
|
68 |
nameValuePairs.add(new BasicNameValuePair("id",
|
| 69 |
supc));
|
69 |
supc));
|
| 70 |
nameValuePairs.add(new BasicNameValuePair("oper","edit"));
|
70 |
nameValuePairs.add(new BasicNameValuePair("oper","edit"));
|
| 71 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
71 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| 72 |
HttpResponse response = client.execute(post);
|
72 |
HttpResponse response = httpClient.execute(post);
|
| 73 |
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
73 |
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 74 |
String line = "";
|
74 |
String line = "";
|
| 75 |
while ((line = rd.readLine()) != null) {
|
75 |
while ((line = rd.readLine()) != null) {
|
| 76 |
System.out.println(line);
|
76 |
System.out.println(line);
|
| 77 |
}
|
77 |
}
|
| Line 81... |
Line 81... |
| 81 |
public void handleLogin() throws ClientProtocolException, IOException{
|
81 |
public void handleLogin() throws ClientProtocolException, IOException{
|
| 82 |
logger.info("----Inside Handle Login ----" );
|
82 |
logger.info("----Inside Handle Login ----" );
|
| 83 |
HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
|
83 |
HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
|
| 84 |
HttpResponse response = null;
|
84 |
HttpResponse response = null;
|
| 85 |
try {
|
85 |
try {
|
| 86 |
response = client.execute(get);
|
86 |
response = httpClient.execute(get);
|
| 87 |
} catch (ClientProtocolException e) {
|
87 |
} catch (ClientProtocolException e) {
|
| 88 |
e.printStackTrace();
|
88 |
e.printStackTrace();
|
| 89 |
logger.info("Exception" + e);
|
89 |
logger.info("Exception" + e);
|
| 90 |
} catch (IOException e) {
|
90 |
} catch (IOException e) {
|
| 91 |
e.printStackTrace();
|
91 |
e.printStackTrace();
|
| Line 140... |
Line 140... |
| 140 |
nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
|
140 |
nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
|
| 141 |
nameValuePairs.add(new BasicNameValuePair("execution",ex));
|
141 |
nameValuePairs.add(new BasicNameValuePair("execution",ex));
|
| 142 |
nameValuePairs.add(new BasicNameValuePair("lt",lt));
|
142 |
nameValuePairs.add(new BasicNameValuePair("lt",lt));
|
| 143 |
nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
|
143 |
nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
|
| 144 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
144 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| 145 |
response = client.execute(post);
|
145 |
response = httpClient.execute(post);
|
| 146 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
146 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 147 |
line = "";
|
147 |
line = "";
|
| 148 |
while ((line = rd.readLine()) != null) {
|
148 |
while ((line = rd.readLine()) != null) {
|
| 149 |
System.out.println(line);
|
149 |
System.out.println(line);
|
| 150 |
}
|
150 |
}
|
| 151 |
get = new HttpGet("http://seller.snapdeal.com/pricing");
|
151 |
get = new HttpGet("http://seller.snapdeal.com/pricing");
|
| 152 |
response = client.execute(get);
|
152 |
response = httpClient.execute(get);
|
| 153 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
153 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 154 |
while ((line = rd.readLine()) != null) {
|
154 |
while ((line = rd.readLine()) != null) {
|
| 155 |
//System.out.println(line);
|
155 |
//System.out.println(line);
|
| 156 |
}
|
156 |
}
|
| 157 |
logger.info("----Login Successful----" );
|
157 |
logger.info("----Login Successful----" );
|
| 158 |
}
|
158 |
}
|
| 159 |
public void run()
|
159 |
public void run()
|
| 160 |
{
|
160 |
{
|
| 161 |
try {
|
161 |
try {
|
| 162 |
client = new DefaultHttpClient();
|
- |
|
| 163 |
this.handleLogin();
|
162 |
this.handleLogin();
|
| 164 |
this.updatePricing(this.price,this.supc,this.item,timestamp);
|
163 |
this.updatePricing(this.price,this.supc,this.item,timestamp);
|
| 165 |
boolean retry =true;
|
164 |
boolean retry =true;
|
| 166 |
while(retry){
|
165 |
while(retry){
|
| 167 |
Thread.sleep(2*60*1000);
|
166 |
Thread.sleep(2*60*1000);
|
| 168 |
HttpGet get = new HttpGet("http://seller.snapdeal.com/pricing/search?searchType=SUPC&searchValue="+this.supc+"&gridType=normal&_search=false&nd="+System.currentTimeMillis()+"&rows=30&page=1&sidx=&sord=asc");
|
167 |
HttpGet get = new HttpGet("http://seller.snapdeal.com/pricing/search?searchType=SUPC&searchValue="+this.supc+"&gridType=normal&_search=false&nd="+System.currentTimeMillis()+"&rows=30&page=1&sidx=&sord=asc");
|
| 169 |
HttpResponse response = client.execute(get);
|
168 |
HttpResponse response = httpClient.execute(get);
|
| 170 |
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
169 |
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 171 |
String line = "";
|
170 |
String line = "";
|
| 172 |
while ((line = rd.readLine()) != null) {
|
171 |
while ((line = rd.readLine()) != null) {
|
| 173 |
logger.info(line);
|
172 |
logger.info(line);
|
| 174 |
if(line.contains("\"pendingUpdate\":false\"")){
|
173 |
if(line.contains("\"pendingUpdate\":false\"")){
|