package com.prime.sony.ecommerce.jobs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import com.prime.sony.ecommerce.exceptions.AutodataCheckServiceException;
import com.prime.sony.ecommerce.exceptions.DeleteRequestServiceException;
import com.prime.sony.ecommerce.exceptions.RowStatusServiceException;
import com.prime.sony.ecommerce.service.AutoDataCheckService;
import com.prime.sony.ecommerce.service.RecordStatusService;

//@Component
@Configuration
public class RecordCountReconcilationJob {

	private static final Logger log = LoggerFactory.getLogger(RecordCountReconcilationJob.class);

	
	@Autowired
	private RecordStatusService recordStatusService;
	
	

	@Scheduled(cron = "#{@getCronValueForReconcilation}") 
	public void getProductRowcountStatus() throws Exception {
		  
		  log.info("==>RecordCountReconcilationJob.getProductRowcountStatus()"); 
		  try {
			  recordStatusService.getProductRowcountStatus();
		 } catch (Exception e) {
		  log.error("==> Exception at RecordCountReconcilationJob.getProductRowcountStatus()",e)
		  ;
		  
		  throw new RowStatusServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==RecordCountReconcilationJob.getProductRowcountStatus()"); 
	}
	
	@Scheduled(cron = "#{@getCronValueForReconcilation}") 
	public void getOrderRowcountStatus() throws Exception {
		  
		  log.info("==>RecordCountReconcilationJob.getOrderRowcountStatus()"); 
		  try {
			  recordStatusService.getOrderRowcountStatus();
		 } catch (Exception e) {
		  log.error("==> Exception at RecordCountReconcilationJob.getOrderRowcountStatus()",e)
		  ;
		  
		  throw new RowStatusServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==RecordCountReconcilationJob.getOrderRowcountStatus()"); 
	}
	
	@Scheduled(cron = "#{@getCronValueForReconcilation}") 
	public void getCustomerRowcountStatus() throws Exception {
		  
		  log.info("==>RecordCountReconcilationJob.getCustomerRowcountStatus()"); 
		  try {
			  recordStatusService.getCustomerRowcountStatus();
		 } catch (Exception e) {
		  log.error("==> Exception at RecordCountReconcilationJob.getCustomerRowcountStatus()",e)
		  ;
		  
		  throw new RowStatusServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==RecordCountReconcilationJob.getCustomerRowcountStatus()"); 
	}
	
	@Scheduled(cron = "#{@getCronValueForReconcilation}") 
	public void loadReconcilationProcess() throws Exception {
		  
		  log.info("==>RecordCountReconcilationJob.loadReconcilationProcess()"); 
		  try {
			  recordStatusService.loadReconcilationProcess(); 
		 } catch (Exception e) {
		  log.error("==> Exception at RecordCountReconcilationJob.loadReconcilationProcess()",e)
		  ;
		  
		  throw new RowStatusServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==RecordCountReconcilationJob.loadReconcilationProcess()"); 
	}
		 
	 
}
