| Line 17... |
Line 17... |
| 17 |
|
17 |
|
| 18 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
18 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 19 |
import org.apache.commons.lang.StringUtils;
|
19 |
import org.apache.commons.lang.StringUtils;
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
20 |
import org.apache.logging.log4j.LogManager;
|
| 21 |
import org.apache.logging.log4j.Logger;
|
21 |
import org.apache.logging.log4j.Logger;
|
| 22 |
import org.apache.solr.common.util.Hash;
|
- |
|
| 23 |
import org.openqa.selenium.OutputType;
|
22 |
import org.openqa.selenium.OutputType;
|
| 24 |
import org.openqa.selenium.TakesScreenshot;
|
23 |
import org.openqa.selenium.TakesScreenshot;
|
| 25 |
import org.openqa.selenium.WebDriver;
|
24 |
import org.openqa.selenium.WebDriver;
|
| 26 |
import org.openqa.selenium.chrome.ChromeDriver;
|
25 |
import org.openqa.selenium.chrome.ChromeDriver;
|
| - |
|
26 |
import org.openqa.selenium.chrome.ChromeOptions;
|
| 27 |
import org.springframework.beans.factory.annotation.Autowired;
|
27 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 28 |
import org.springframework.core.io.ByteArrayResource;
|
28 |
import org.springframework.core.io.ByteArrayResource;
|
| 29 |
import org.springframework.mail.javamail.JavaMailSender;
|
29 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 30 |
import org.springframework.stereotype.Component;
|
30 |
import org.springframework.stereotype.Component;
|
| 31 |
import org.springframework.transaction.annotation.Transactional;
|
31 |
import org.springframework.transaction.annotation.Transactional;
|
| Line 106... |
Line 106... |
| 106 |
@Autowired
|
106 |
@Autowired
|
| 107 |
private LineItemRepository lineItemRepository;
|
107 |
private LineItemRepository lineItemRepository;
|
| 108 |
|
108 |
|
| 109 |
@Autowired
|
109 |
@Autowired
|
| 110 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
110 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
| 111 |
|
111 |
|
| 112 |
@Autowired
|
112 |
@Autowired
|
| 113 |
private CsService csService;
|
113 |
private CsService csService;
|
| 114 |
|
114 |
|
| 115 |
|
- |
|
| 116 |
@Autowired
|
115 |
@Autowired
|
| 117 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
116 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
| 118 |
|
117 |
|
| 119 |
@Autowired
|
118 |
@Autowired
|
| 120 |
private TargetSlabRepository targetSlabRepository;
|
119 |
private TargetSlabRepository targetSlabRepository;
|
| Line 705... |
Line 704... |
| 705 |
}
|
704 |
}
|
| 706 |
|
705 |
|
| 707 |
public void mailDashboardScreenshots() throws Exception {
|
706 |
public void mailDashboardScreenshots() throws Exception {
|
| 708 |
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
|
707 |
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
|
| 709 |
|
708 |
|
| - |
|
709 |
|
| - |
|
710 |
|
| - |
|
711 |
|
| - |
|
712 |
ChromeOptions options = new ChromeOptions();
|
| - |
|
713 |
options.addArguments("--headless");
|
| - |
|
714 |
options.addArguments("--no-sandbox");
|
| - |
|
715 |
options.addArguments("start-maximized");
|
| - |
|
716 |
options.addArguments("disable-infobars");
|
| - |
|
717 |
options.addArguments("--disable-extensions");
|
| - |
|
718 |
|
| 710 |
WebDriver driver = new ChromeDriver();
|
719 |
WebDriver driver = new ChromeDriver();
|
| 711 |
driver.manage().window().maximize();
|
720 |
driver.manage().window().maximize();
|
| 712 |
//Deleting all the cookies
|
721 |
// Deleting all the cookies
|
| 713 |
driver.manage().deleteAllCookies();
|
722 |
driver.manage().deleteAllCookies();
|
| 714 |
//Specifiying pageLoadTimeout and Implicit wait
|
723 |
// Specifiying pageLoadTimeout and Implicit wait
|
| 715 |
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
|
724 |
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
|
| 716 |
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
725 |
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
| - |
|
726 |
|
| - |
|
727 |
|
| 717 |
Map<String, Set<Integer>> authUserPartnerIdMapping = csService.getAuthUserPartnerIdMapping();
|
728 |
Map<String, Set<Integer>> authUserPartnerIdMapping = csService.getAuthUserPartnerIdMapping();
|
| 718 |
Set<Integer> allPartners = new HashSet<>();
|
729 |
Set<Integer> allPartners = new HashSet<>();
|
| 719 |
Map<Integer, String> partnerSnapshotMap = new HashMap<>();
|
730 |
Map<Integer, String> partnerSnapshotMap = new HashMap<>();
|
| 720 |
authUserPartnerIdMapping.values().stream().forEach(x->allPartners.addAll(x));
|
731 |
authUserPartnerIdMapping.values().stream().forEach(x -> allPartners.addAll(x));
|
| 721 |
System.out.println(allPartners.size());
|
732 |
System.out.println(allPartners.size());
|
| 722 |
for(int fofoId : allPartners) {
|
733 |
for (int fofoId : allPartners) {
|
| 723 |
driver.get("https://partners.smartdukaan.com/12dashboard34?fofoId=" + fofoId);
|
734 |
driver.get("https://partners.smartdukaan.com/12dashboard34?fofoId=" + fofoId);
|
| 724 |
String base64Image = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
|
735 |
String base64Image = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
|
| 725 |
partnerSnapshotMap.put(fofoId, base64Image);
|
736 |
partnerSnapshotMap.put(fofoId, base64Image);
|
| 726 |
|
737 |
|
| 727 |
}
|
738 |
}
|
| 728 |
for(Map.Entry<String, Set<Integer>> entry : authUserPartnerIdMapping.entrySet()) {
|
739 |
for (Map.Entry<String, Set<Integer>> entry : authUserPartnerIdMapping.entrySet()) {
|
| 729 |
String email = entry.getKey();
|
740 |
String email = entry.getKey();
|
| 730 |
Set<Integer> partnerIds = entry.getValue();
|
741 |
Set<Integer> partnerIds = entry.getValue();
|
| 731 |
StringBuffer body = new StringBuffer();
|
742 |
StringBuffer body = new StringBuffer();
|
| 732 |
for(int fofoId: partnerIds) {
|
743 |
for (int fofoId : partnerIds) {
|
| 733 |
body.append(String.format("<br><image src=\"%s\" />", partnerSnapshotMap.get(fofoId)));
|
744 |
body.append(String.format("<br><image src=\"%s\" />", partnerSnapshotMap.get(fofoId)));
|
| 734 |
}
|
745 |
}
|
| 735 |
Utils.sendHtmlMailWithAttachments(mailSender, new String[]{"amit.gupta@shop2020.in"}, new String[] {}, String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())), body.toString());
|
746 |
Utils.sendHtmlMailWithAttachments(mailSender, new String[] { "amit.gupta@shop2020.in" }, new String[] {},
|
| - |
|
747 |
String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())),
|
| - |
|
748 |
body.toString());
|
| 736 |
}
|
749 |
}
|
| 737 |
driver.quit();
|
750 |
driver.quit();
|
| 738 |
}
|
751 |
}
|
| 739 |
}
|
752 |
}
|
| 740 |
|
753 |
|