| Line 428... |
Line 428... |
| 428 |
else{
|
428 |
else{
|
| 429 |
exitfetchinghistory = false;
|
429 |
exitfetchinghistory = false;
|
| 430 |
}
|
430 |
}
|
| 431 |
i++;
|
431 |
i++;
|
| 432 |
}
|
432 |
}
|
| 433 |
if(inventoryhistoryItemMap.entrySet().size()==0){
|
- |
|
| 434 |
try {
|
- |
|
| 435 |
mailer.sendSSLMessage(sendTo,"Error : Last Inventory Sent still not updated"+ sdf.format(System.currentTimeMillis()),"This e-mail is sent when there is some time lag on inventory updation on snapdeal ", emailFromAddress, password, new ArrayList<File>());
|
- |
|
| 436 |
} catch (MessagingException e) {
|
- |
|
| 437 |
|
- |
|
| 438 |
e.printStackTrace();
|
- |
|
| 439 |
}
|
- |
|
| 440 |
}
|
- |
|
| 441 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
433 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 442 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
434 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 443 |
List<SnapdealInventoryItem> snapdealInventoryItemHistoryList = inventoryClient.getSnapdealInventorySnapshot();
|
435 |
List<SnapdealInventoryItem> snapdealInventoryItemHistoryList = inventoryClient.getSnapdealInventorySnapshot();
|
| 444 |
if(snapdealInventoryItemHistoryList.size()>0){
|
436 |
if(snapdealInventoryItemHistoryList.size()>0){
|
| 445 |
for(SnapdealInventoryItem snapdealInventoryItem:snapdealInventoryItemHistoryList){
|
437 |
for(SnapdealInventoryItem snapdealInventoryItem:snapdealInventoryItemHistoryList){
|
| Line 711... |
Line 703... |
| 711 |
|
703 |
|
| 712 |
|
704 |
|
| 713 |
|
705 |
|
| 714 |
|
706 |
|
| 715 |
@SuppressWarnings("deprecation")
|
707 |
@SuppressWarnings("deprecation")
|
| 716 |
public static void main(String[] args) throws NumberFormatException, TException,MessagingException {
|
708 |
public static void main(String[] args) throws NumberFormatException, TException,MessagingException, InterruptedException {
|
| 717 |
try {
|
709 |
try {
|
| 718 |
handleLogin();
|
710 |
handleLogin();
|
| 719 |
} catch (ClientProtocolException e2) {
|
711 |
} catch (ClientProtocolException e2) {
|
| 720 |
System.out.println("Handle login failed");
|
712 |
System.out.println("Handle login failed");
|
| 721 |
e2.printStackTrace();
|
713 |
e2.printStackTrace();
|
| Line 871... |
Line 863... |
| 871 |
UDSI.handleLogin();
|
863 |
UDSI.handleLogin();
|
| 872 |
UDSI.updateInventory(sent_inventory,inventory.getSupc());
|
864 |
UDSI.updateInventory(sent_inventory,inventory.getSupc());
|
| 873 |
} catch (ClientProtocolException e) {
|
865 |
} catch (ClientProtocolException e) {
|
| 874 |
System.out.println("Could not login and update inventory");
|
866 |
System.out.println("Could not login and update inventory");
|
| 875 |
e.printStackTrace();
|
867 |
e.printStackTrace();
|
| - |
|
868 |
continue;
|
| 876 |
} catch (IOException e) {
|
869 |
} catch (IOException e) {
|
| 877 |
System.out.println("Could not login and update inventory I/O");
|
870 |
System.out.println("Could not login and update inventory I/O");
|
| 878 |
e.printStackTrace();
|
871 |
e.printStackTrace();
|
| - |
|
872 |
continue;
|
| 879 |
}
|
873 |
}
|
| 880 |
}
|
874 |
}
|
| 881 |
if(inventory.getAvailableInventory()!=0 && sent_inventory==0){
|
875 |
if(inventory.getAvailableInventory()!=0 && sent_inventory==0){
|
| 882 |
outOfStockItems.append("<tr>"
|
876 |
outOfStockItems.append("<tr>"
|
| 883 |
+ "<td>" + inventory.getProductName() +"</td>"
|
877 |
+ "<td>" + inventory.getProductName() +"</td>"
|
| Line 983... |
Line 977... |
| 983 |
transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
|
977 |
transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
|
| 984 |
} catch (Exception ex) {
|
978 |
} catch (Exception ex) {
|
| 985 |
ex.printStackTrace();
|
979 |
ex.printStackTrace();
|
| 986 |
}
|
980 |
}
|
| 987 |
}
|
981 |
}
|
| - |
|
982 |
int retry = 3;
|
| - |
|
983 |
boolean feedsuccess =false;
|
| - |
|
984 |
while(retry>0){
|
| - |
|
985 |
try {
|
| - |
|
986 |
lastUpdatedInventoryTime = lastSentInventoryTime;
|
| - |
|
987 |
fetchinventoryhistoryfromsnapdeal();
|
| - |
|
988 |
} catch (UnsupportedEncodingException e1) {
|
| - |
|
989 |
System.out.println("Error while fetching inventory update result");
|
| - |
|
990 |
e1.printStackTrace();
|
| - |
|
991 |
}
|
| - |
|
992 |
if(inventoryhistoryItemMap.entrySet().size()==iterator -1){
|
| - |
|
993 |
feedsuccess = true;
|
| - |
|
994 |
break;
|
| - |
|
995 |
}
|
| - |
|
996 |
Thread.sleep(2*60*1000);
|
| - |
|
997 |
retry --;
|
| - |
|
998 |
}
|
| - |
|
999 |
|
| 988 |
String PANEL_TEXT_MAIL = "";
|
1000 |
String PANEL_TEXT_MAIL = "";
|
| 989 |
if(PANEL){
|
1001 |
if(PANEL){
|
| 990 |
PANEL_TEXT_MAIL = " (Using Panel)";
|
1002 |
PANEL_TEXT_MAIL = " (Using Panel)";
|
| 991 |
}
|
1003 |
}
|
| 992 |
String emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
1004 |
String emailSubjectTxt;
|
| 993 |
String text;
|
1005 |
String text;
|
| - |
|
1006 |
String tableHeader;
|
| - |
|
1007 |
if(feedsuccess){
|
| - |
|
1008 |
emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
| 994 |
String tableHeader = "<tr>"
|
1009 |
tableHeader = "<tr>"
|
| 995 |
+ "<td>" + "Product Name" +"</td>"
|
1010 |
+ "<td>" + "Product Name" +"</td>"
|
| 996 |
+"<td>" + "Item ID" + "</td>"
|
1011 |
+"<td>" + "Item ID" + "</td>"
|
| 997 |
+"<td>" + "Old Inventory" + "</td>"
|
1012 |
+"<td>" + "Old Inventory" + "</td>"
|
| 998 |
+"<td>" + "New Inventory" + "</td>"
|
1013 |
+"<td>" + "New Inventory" + "</td>"
|
| 999 |
+"</tr>";
|
1014 |
+"</tr>";
|
| - |
|
1015 |
|
| 1000 |
if(backInStockItems.length() > 0){
|
1016 |
if(backInStockItems.length() > 0){
|
| 1001 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+backInStockItems.toString()+"</table></html>";
|
1017 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+backInStockItems.toString()+"</table></html>";
|
| 1002 |
try {
|
1018 |
try {
|
| 1003 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
1019 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
| 1004 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
1020 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
| 1005 |
} catch (MessagingException e) {
|
1021 |
} catch (MessagingException e) {
|
| 1006 |
e.printStackTrace();
|
1022 |
e.printStackTrace();
|
| 1007 |
}
|
1023 |
}
|
| 1008 |
}
|
1024 |
}
|
| 1009 |
emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
1025 |
emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
| 1010 |
if(outOfStockItems.length() > 0){
|
1026 |
if(outOfStockItems.length() > 0){
|
| 1011 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+outOfStockItems.toString()+"</table></html>";
|
1027 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+outOfStockItems.toString()+"</table></html>";
|
| 1012 |
try {
|
1028 |
try {
|
| 1013 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
1029 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
| 1014 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
1030 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
| - |
|
1031 |
} catch (MessagingException e) {
|
| - |
|
1032 |
e.printStackTrace();
|
| - |
|
1033 |
}
|
| - |
|
1034 |
}
|
| - |
|
1035 |
emailSubjectTxt = "Snapdeal Inventory Updated for " +(iterator-1)+" items "+ sdf.format(System.currentTimeMillis())+PANEL_TEXT_MAIL;
|
| - |
|
1036 |
if(inventoryChangeItems.length() > 0){
|
| - |
|
1037 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+inventoryChangeItems.toString()+"</table></html>";
|
| - |
|
1038 |
try {
|
| - |
|
1039 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
| 1015 |
} catch (MessagingException e) {
|
1040 |
} catch (MessagingException e) {
|
| 1016 |
e.printStackTrace();
|
1041 |
e.printStackTrace();
|
| - |
|
1042 |
}
|
| 1017 |
}
|
1043 |
}
|
| 1018 |
}
|
1044 |
}
|
| - |
|
1045 |
else{
|
| 1019 |
emailSubjectTxt = "Snapdeal Inventory Updates sent for " +(iterator-1)+" items "+ sdf.format(System.currentTimeMillis())+PANEL_TEXT_MAIL;
|
1046 |
emailSubjectTxt = "Snapdeal Inventory Could not be updated "+PANEL_TEXT_MAIL+" " +sdf.format(System.currentTimeMillis());
|
| 1020 |
if(inventoryChangeItems.length() > 0){
|
- |
|
| 1021 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+inventoryChangeItems.toString()+"</table></html>";
|
- |
|
| 1022 |
try {
|
- |
|
| 1023 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
1047 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password,"Please contact Engg ");
|
| 1024 |
} catch (MessagingException e) {
|
- |
|
| 1025 |
e.printStackTrace();
|
- |
|
| 1026 |
}
|
- |
|
| 1027 |
}
|
1048 |
}
|
| 1028 |
|
- |
|
| 1029 |
tableHeader = "<tr>"
|
1049 |
tableHeader = "<tr>"
|
| 1030 |
+ "<td>" + "Product Name" +"</td>"
|
1050 |
+ "<td>" + "Product Name" +"</td>"
|
| 1031 |
+"<td>" + "Item ID" + "</td>"
|
1051 |
+"<td>" + "Item ID" + "</td>"
|
| 1032 |
+"<td>" + "Available - Reserve" + "</td>"
|
1052 |
+"<td>" + "Available - Reserve" + "</td>"
|
| 1033 |
+"<td>" + "Total Held" + "</td>"
|
1053 |
+"<td>" + "Total Held" + "</td>"
|