| Line 371... |
Line 371... |
| 371 |
e.printStackTrace();
|
371 |
e.printStackTrace();
|
| 372 |
}
|
372 |
}
|
| 373 |
|
373 |
|
| 374 |
}
|
374 |
}
|
| 375 |
private static void fetchinventoryhistoryfromsnapdeal() throws UnsupportedEncodingException, TException{
|
375 |
private static void fetchinventoryhistoryfromsnapdeal() throws UnsupportedEncodingException, TException{
|
| 376 |
HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
|
- |
|
| 377 |
HttpGet get;
|
- |
|
| 378 |
BufferedReader rd= null;
|
- |
|
| 379 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
- |
|
| 380 |
nameValuePairs.add(new BasicNameValuePair("j_username",
|
- |
|
| 381 |
"khushal.bhatia@saholic.com"));
|
- |
|
| 382 |
nameValuePairs.add(new BasicNameValuePair("j_password",
|
- |
|
| 383 |
"sonline"));
|
- |
|
| 384 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
- |
|
| 385 |
HttpResponse response = null;
|
- |
|
| 386 |
try {
|
- |
|
| 387 |
response = client.execute(post);
|
- |
|
| 388 |
} catch (ClientProtocolException e) {
|
- |
|
| 389 |
// TODO Auto-generated catch block
|
- |
|
| 390 |
e.printStackTrace();
|
- |
|
| 391 |
} catch (IOException e) {
|
- |
|
| 392 |
// TODO Auto-generated catch block
|
- |
|
| 393 |
e.printStackTrace();
|
- |
|
| 394 |
}
|
- |
|
| 395 |
try {
|
- |
|
| 396 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
- |
|
| 397 |
} catch (IllegalStateException e1) {
|
- |
|
| 398 |
// TODO Auto-generated catch block
|
- |
|
| 399 |
e1.printStackTrace();
|
- |
|
| 400 |
} catch (IOException e1) {
|
- |
|
| 401 |
// TODO Auto-generated catch block
|
- |
|
| 402 |
e1.printStackTrace();
|
- |
|
| 403 |
}
|
- |
|
| 404 |
String line = "";
|
- |
|
| 405 |
try {
|
- |
|
| 406 |
while ((line = rd.readLine()) != null) {
|
- |
|
| 407 |
//System.out.println(line);
|
- |
|
| 408 |
}
|
- |
|
| 409 |
} catch (IOException e) {
|
- |
|
| 410 |
// TODO Auto-generated catch block
|
- |
|
| 411 |
e.printStackTrace();
|
- |
|
| 412 |
}
|
- |
|
| 413 |
int i = 1;
|
376 |
int i = 1;
|
| 414 |
Gson gson = new Gson();
|
377 |
Gson gson = new Gson();
|
| 415 |
inventoryhistoryItemMap = new HashMap<String,InventoryHistory>();
|
378 |
inventoryhistoryItemMap = new HashMap<String,InventoryHistory>();
|
| 416 |
boolean exitfetchinghistory = true;
|
379 |
boolean exitfetchinghistory = true;
|
| 417 |
System.out.println("Fetching history inventory");
|
380 |
System.out.println("Fetching history inventory");
|
| - |
|
381 |
HttpGet get;
|
| - |
|
382 |
HttpResponse response = null;
|
| - |
|
383 |
BufferedReader rd = null;
|
| 418 |
while(exitfetchinghistory){
|
384 |
while(exitfetchinghistory){
|
| 419 |
//System.out.println("Fetching inventory history page " +i);
|
385 |
//System.out.println("Fetching inventory history page " +i);
|
| 420 |
get = new HttpGet("http://seller.snapdeal.com/inventory/search?gridType=history&_search=false&nd="+time+"&rows=30&page="+i+"&sidx=&sord=dsc");
|
386 |
get = new HttpGet("http://seller.snapdeal.com/inventory/search?gridType=history&_search=false&nd="+time+"&rows=30&page="+i+"&sidx=&sord=dsc");
|
| - |
|
387 |
|
| 421 |
try {
|
388 |
try {
|
| 422 |
response = client.execute(get);
|
389 |
response = client.execute(get);
|
| 423 |
} catch (ClientProtocolException e) {
|
390 |
} catch (ClientProtocolException e) {
|
| 424 |
// TODO Auto-generated catch block
|
391 |
// TODO Auto-generated catch block
|
| 425 |
e.printStackTrace();
|
392 |
e.printStackTrace();
|
| 426 |
} catch (IOException e) {
|
393 |
} catch (IOException e) {
|
| 427 |
// TODO Auto-generated catch block
|
394 |
// TODO Auto-generated catch block
|
| 428 |
e.printStackTrace();
|
395 |
e.printStackTrace();
|
| 429 |
}
|
396 |
}
|
| - |
|
397 |
|
| 430 |
try {
|
398 |
try {
|
| 431 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
399 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 432 |
} catch (IllegalStateException e) {
|
400 |
} catch (IllegalStateException e) {
|
| 433 |
// TODO Auto-generated catch block
|
401 |
// TODO Auto-generated catch block
|
| 434 |
e.printStackTrace();
|
402 |
e.printStackTrace();
|
| Line 438... |
Line 406... |
| 438 |
}
|
406 |
}
|
| 439 |
InventoryHistoryItems inventoryhistoryitems = (InventoryHistoryItems) gson.fromJson(rd, InventoryHistoryItems.class);
|
407 |
InventoryHistoryItems inventoryhistoryitems = (InventoryHistoryItems) gson.fromJson(rd, InventoryHistoryItems.class);
|
| 440 |
if(inventoryhistoryitems.getRows().size()!=0){
|
408 |
if(inventoryhistoryitems.getRows().size()!=0){
|
| 441 |
//System.out.println("Parsing page " + i);
|
409 |
//System.out.println("Parsing page " + i);
|
| 442 |
for(InventoryHistory inventoryhistory : inventoryhistoryitems.getRows()){
|
410 |
for(InventoryHistory inventoryhistory : inventoryhistoryitems.getRows()){
|
| - |
|
411 |
System.out.println("Inventory History " + inventoryhistory.getSellerSku() +" "+ inventoryhistory.getSupc());
|
| 443 |
if(inventoryhistory.getUpdateTime() > lastUpdatedInventoryTime){
|
412 |
if(inventoryhistory.getUpdateTime() > lastUpdatedInventoryTime){
|
| 444 |
if(inventoryhistoryItemMap.containsKey(inventoryhistory.getSellerSku())){
|
413 |
if(inventoryhistoryItemMap.containsKey(inventoryhistory.getSellerSku())){
|
| 445 |
if(inventoryhistoryItemMap.get(inventoryhistory.getSellerSku()).getUpdateTime() < inventoryhistory.getUpdateTime()){
|
414 |
if(inventoryhistoryItemMap.get(inventoryhistory.getSellerSku()).getUpdateTime() < inventoryhistory.getUpdateTime()){
|
| 446 |
inventoryhistoryItemMap.put(inventoryhistory.getSellerSku(),inventoryhistory);
|
415 |
inventoryhistoryItemMap.put(inventoryhistory.getSellerSku(),inventoryhistory);
|
| 447 |
}
|
416 |
}
|
| Line 499... |
Line 468... |
| 499 |
}
|
468 |
}
|
| 500 |
}
|
469 |
}
|
| 501 |
}
|
470 |
}
|
| 502 |
|
471 |
|
| 503 |
private static void fetchcurrentinventoryfromsnapdeal() throws UnsupportedEncodingException, TException{
|
472 |
private static void fetchcurrentinventoryfromsnapdeal() throws UnsupportedEncodingException, TException{
|
| 504 |
/*client = new DefaultHttpClient();
|
- |
|
| 505 |
HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
|
- |
|
| 506 |
BufferedReader rd= null;
|
- |
|
| 507 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
- |
|
| 508 |
nameValuePairs.add(new BasicNameValuePair("j_username",
|
- |
|
| 509 |
"khushal.bhatia@saholic.com"));
|
- |
|
| 510 |
nameValuePairs.add(new BasicNameValuePair("j_password",
|
- |
|
| 511 |
"sonline"));
|
- |
|
| 512 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
- |
|
| 513 |
HttpResponse response = null;
|
- |
|
| 514 |
try {
|
- |
|
| 515 |
response = client.execute(post);
|
- |
|
| 516 |
} catch (ClientProtocolException e) {
|
- |
|
| 517 |
// TODO Auto-generated catch block
|
- |
|
| 518 |
e.printStackTrace();
|
- |
|
| 519 |
} catch (IOException e) {
|
- |
|
| 520 |
// TODO Auto-generated catch block
|
- |
|
| 521 |
e.printStackTrace();
|
- |
|
| 522 |
}
|
- |
|
| 523 |
try {
|
- |
|
| 524 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
- |
|
| 525 |
} catch (IllegalStateException e1) {
|
- |
|
| 526 |
// TODO Auto-generated catch block
|
- |
|
| 527 |
e1.printStackTrace();
|
- |
|
| 528 |
} catch (IOException e1) {
|
- |
|
| 529 |
// TODO Auto-generated catch block
|
- |
|
| 530 |
e1.printStackTrace();
|
- |
|
| 531 |
}
|
- |
|
| 532 |
String line = "";
|
- |
|
| 533 |
try {
|
- |
|
| 534 |
while ((line = rd.readLine()) != null) {
|
- |
|
| 535 |
System.out.println(line);
|
- |
|
| 536 |
}
|
- |
|
| 537 |
} catch (IOException e) {
|
- |
|
| 538 |
// TODO Auto-generated catch block
|
- |
|
| 539 |
e.printStackTrace();
|
- |
|
| 540 |
}*/
|
- |
|
| 541 |
int i = 1;
|
473 |
int i = 1;
|
| 542 |
int items=0;
|
474 |
int items=0;
|
| 543 |
Gson gson = new Gson();
|
475 |
Gson gson = new Gson();
|
| 544 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
476 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
| 545 |
currentInventoryItemList = new ArrayList<Inventory>();
|
477 |
currentInventoryItemList = new ArrayList<Inventory>();
|
| Line 686... |
Line 618... |
| 686 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
618 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
| 687 |
}
|
619 |
}
|
| 688 |
|
620 |
|
| 689 |
}
|
621 |
}
|
| 690 |
|
622 |
|
| - |
|
623 |
public static void handleLogin() throws ClientProtocolException, IOException{
|
| - |
|
624 |
HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
|
| - |
|
625 |
HttpResponse response = null;
|
| - |
|
626 |
try {
|
| - |
|
627 |
response = client.execute(get);
|
| - |
|
628 |
} catch (ClientProtocolException e) {
|
| - |
|
629 |
// TODO Auto-generated catch block
|
| - |
|
630 |
e.printStackTrace();
|
| - |
|
631 |
} catch (IOException e) {
|
| - |
|
632 |
// TODO Auto-generated catch block
|
| - |
|
633 |
e.printStackTrace();
|
| - |
|
634 |
}
|
| - |
|
635 |
BufferedReader rd = null;
|
| - |
|
636 |
try {
|
| - |
|
637 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
638 |
} catch (IllegalStateException e1) {
|
| - |
|
639 |
// TODO Auto-generated catch block
|
| - |
|
640 |
e1.printStackTrace();
|
| - |
|
641 |
} catch (IOException e1) {
|
| - |
|
642 |
// TODO Auto-generated catch block
|
| - |
|
643 |
e1.printStackTrace();
|
| - |
|
644 |
}
|
| - |
|
645 |
String line = "";
|
| - |
|
646 |
StringBuffer sb = new StringBuffer();
|
| - |
|
647 |
try {
|
| - |
|
648 |
while ((line = rd.readLine()) != null) {
|
| - |
|
649 |
sb.append(line);
|
| - |
|
650 |
System.out.println(line);
|
| - |
|
651 |
}
|
| - |
|
652 |
} catch (IOException e) {
|
| - |
|
653 |
// TODO Auto-generated catch block
|
| - |
|
654 |
e.printStackTrace();
|
| - |
|
655 |
}
|
| - |
|
656 |
int i= sb.toString().indexOf("name=\"lt\" value=");
|
| - |
|
657 |
char[] charArray = sb.toString().toCharArray();
|
| - |
|
658 |
String lt = "";
|
| - |
|
659 |
int j=0;
|
| - |
|
660 |
for(j=i+16;j<=charArray.length;j++){
|
| - |
|
661 |
|
| - |
|
662 |
if(charArray[j]==' '){
|
| - |
|
663 |
break;
|
| - |
|
664 |
}
|
| - |
|
665 |
}
|
| - |
|
666 |
lt = sb.substring(i+17,j-1);
|
| - |
|
667 |
System.out.println("LT VALUE " + lt);
|
| - |
|
668 |
i= sb.toString().indexOf("name=\"execution\" value=");
|
| - |
|
669 |
charArray = sb.toString().toCharArray();
|
| - |
|
670 |
String ex = "";
|
| - |
|
671 |
j=0;
|
| - |
|
672 |
for(j=i+24;j<=charArray.length;j++){
|
| - |
|
673 |
if(charArray[j]==' '){
|
| - |
|
674 |
break;
|
| - |
|
675 |
}
|
| - |
|
676 |
}
|
| - |
|
677 |
ex = sb.substring(i+24,j-1);
|
| - |
|
678 |
System.out.println("EXECUTION VALUE " + ex);
|
| - |
|
679 |
HttpPost post = new HttpPost("http://selleraccounts.snapdeal.com/keymaker/login");
|
| - |
|
680 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
| - |
|
681 |
nameValuePairs.add(new BasicNameValuePair("username",
|
| - |
|
682 |
"khushal.bhatia@saholic.com"));
|
| - |
|
683 |
nameValuePairs.add(new BasicNameValuePair("password",
|
| - |
|
684 |
"sonline"));
|
| - |
|
685 |
nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
|
| - |
|
686 |
nameValuePairs.add(new BasicNameValuePair("execution",ex));
|
| - |
|
687 |
nameValuePairs.add(new BasicNameValuePair("lt",lt));
|
| - |
|
688 |
nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
|
| - |
|
689 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| - |
|
690 |
response = client.execute(post);
|
| - |
|
691 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
692 |
line = "";
|
| - |
|
693 |
while ((line = rd.readLine()) != null) {
|
| - |
|
694 |
//System.out.println(line);
|
| - |
|
695 |
}
|
| - |
|
696 |
get = new HttpGet("http://seller.snapdeal.com/inventory/");
|
| - |
|
697 |
response = client.execute(get);
|
| - |
|
698 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
699 |
while ((line = rd.readLine()) != null) {
|
| - |
|
700 |
//System.out.println(line);
|
| - |
|
701 |
}
|
| - |
|
702 |
}
|
| - |
|
703 |
|
| - |
|
704 |
|
| - |
|
705 |
|
| - |
|
706 |
|
| 691 |
@SuppressWarnings("deprecation")
|
707 |
@SuppressWarnings("deprecation")
|
| 692 |
public static void main(String[] args) throws NumberFormatException, TException, ClientProtocolException, IOException, MessagingException {
|
708 |
public static void main(String[] args) throws NumberFormatException, TException, ClientProtocolException, IOException, MessagingException {
|
| - |
|
709 |
handleLogin();
|
| 693 |
fetchinventoryhistoryfromsnapdeal();
|
710 |
fetchinventoryhistoryfromsnapdeal();
|
| 694 |
fetchcurrentinventoryfromsnapdeal();
|
711 |
fetchcurrentinventoryfromsnapdeal();
|
| 695 |
calculateinventory();
|
712 |
calculateinventory();
|
| 696 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogServiceClient = null;
|
713 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogServiceClient = null;
|
| 697 |
try {
|
714 |
try {
|