Subversion Repositories SmartDukaan

Rev

Rev 9515 | Rev 9517 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9515 Rev 9516
Line 713... Line 713...
713
			}
713
			}
714
			else{
714
			else{
715
				continue;
715
				continue;
716
			}
716
			}
717
		}
717
		}
-
 
718
		if(iterator > 1){
718
		FileOutputStream fileOut = null;
719
			FileOutputStream fileOut = null;
719
		fis.close();
720
			fis.close();
720
		try {
721
			try {
721
			System.out.println("Before writing file ");
722
				System.out.println("Before writing file ");
722
			fileOut = new FileOutputStream(SNAPDEAL_INVENTORY_SHEET);
723
				fileOut = new FileOutputStream(SNAPDEAL_INVENTORY_SHEET);
723
		} catch (FileNotFoundException e) {
724
			} catch (FileNotFoundException e) {
724
			// TODO Auto-generated catch block
725
				// TODO Auto-generated catch block
725
			e.printStackTrace();
726
				e.printStackTrace();
726
		}
727
			}
727
		try {
728
			try {
728
 
729
 
729
			hwb.write(fileOut);
730
				hwb.write(fileOut);
730
		} catch (IOException e) {
731
			} catch (IOException e) {
731
			// TODO Auto-generated catch block
732
				// TODO Auto-generated catch block
732
			e.printStackTrace();
733
				e.printStackTrace();
733
		}
-
 
734
		HttpClient client = new DefaultHttpClient();
-
 
735
		HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
-
 
736
		BufferedReader rd= null;
-
 
737
		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
-
 
738
		nameValuePairs.add(new BasicNameValuePair("j_username",
-
 
739
		"khushal.bhatia@saholic.com"));
-
 
740
		nameValuePairs.add(new BasicNameValuePair("j_password",
-
 
741
		"sonline"));
-
 
742
		post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
-
 
743
		HttpResponse response = null;
-
 
744
		String line;
-
 
745
		try {
-
 
746
			response = client.execute(post);
-
 
747
			rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-
 
748
			while ((line = rd.readLine()) != null) {
-
 
749
				System.out.println(line);
-
 
750
			}
734
			}
-
 
735
			HttpClient client = new DefaultHttpClient();
-
 
736
			HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
-
 
737
			BufferedReader rd= null;
-
 
738
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
-
 
739
			nameValuePairs.add(new BasicNameValuePair("j_username",
-
 
740
			"khushal.bhatia@saholic.com"));
-
 
741
			nameValuePairs.add(new BasicNameValuePair("j_password",
-
 
742
			"sonline"));
-
 
743
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
-
 
744
			HttpResponse response = null;
-
 
745
			String line;
-
 
746
			try {
-
 
747
				response = client.execute(post);
-
 
748
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-
 
749
				while ((line = rd.readLine()) != null) {
-
 
750
					System.out.println(line);
-
 
751
				}
751
 
752
 
752
		} catch (ClientProtocolException e) {
753
			} catch (ClientProtocolException e) {
753
			// TODO Auto-generated catch block
754
				// TODO Auto-generated catch block
754
			e.printStackTrace();
755
				e.printStackTrace();
755
		} catch (IOException e) {
756
			} catch (IOException e) {
756
			// TODO Auto-generated catch block
757
				// TODO Auto-generated catch block
757
			e.printStackTrace();
758
				e.printStackTrace();
758
		}
759
			}
759
		post = new HttpPost("http://seller.snapdeal.com/inventory/upload");
760
			post = new HttpPost("http://seller.snapdeal.com/inventory/upload");
760
		File file = new File("/root/code/trunk/SnapDealFeeds/SellerInventory.xls");
761
			File file = new File("/root/code/trunk/SnapDealFeeds/SellerInventory.xls");
761
		MultipartEntity mpEntity = new MultipartEntity();
762
			MultipartEntity mpEntity = new MultipartEntity();
762
	    ContentBody cbFile = new FileBody(file,"application/vnd.ms-excel");
763
			ContentBody cbFile = new FileBody(file,"application/vnd.ms-excel");
763
	    mpEntity.addPart("file", cbFile);
764
			mpEntity.addPart("file", cbFile);
764
	    post.setEntity(mpEntity);
765
			post.setEntity(mpEntity);
765
		response = client.execute(post);
766
			response = client.execute(post);
766
		try {
767
			try {
767
			rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
768
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
768
		} catch (IllegalStateException e1) {
769
			} catch (IllegalStateException e1) {
769
			// TODO Auto-generated catch block
770
				// TODO Auto-generated catch block
770
			e1.printStackTrace();
771
				e1.printStackTrace();
771
		} catch (IOException e1) {
772
			} catch (IOException e1) {
772
			// TODO Auto-generated catch block
773
				// TODO Auto-generated catch block
773
			e1.printStackTrace();
774
				e1.printStackTrace();
774
		}
775
			}
775
		line = "";
776
			line = "";
776
		String feedresponse = null;
777
			String feedresponse = null;
777
		try {
778
			try {
778
			while ((line = rd.readLine()) != null) {
779
				while ((line = rd.readLine()) != null) {
779
				System.out.println(line);
780
					System.out.println(line);
780
				feedresponse = line;
781
					feedresponse = line;
781
			}
782
				}
782
		} catch (IOException e) {
783
			} catch (IOException e) {
783
			// TODO Auto-generated catch block
784
				// TODO Auto-generated catch block
784
			e.printStackTrace();
785
				e.printStackTrace();
785
		}
786
			}
786
		in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
787
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
787
		long lastSentInventoryTime = System.currentTimeMillis();
788
			long lastSentInventoryTime = System.currentTimeMillis();
788
		try {
-
 
789
			transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
-
 
790
			transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
-
 
791
		} catch (Exception e) {
-
 
792
			try {
789
			try {
793
				transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
790
				transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
794
				transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
791
				transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
-
 
792
			} catch (Exception e) {
-
 
793
				try {
-
 
794
					transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
-
 
795
					transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
795
			} catch (Exception ex) {
796
				} catch (Exception ex) {
796
				ex.printStackTrace();
797
					ex.printStackTrace();
797
			}
798
				}
798
		}
799
			}
799
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
800
			java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
800
		String emailFromAddress = "build@shop2020.in";
801
			String emailFromAddress = "build@shop2020.in";
801
		String password = "cafe@nes";
802
			String password = "cafe@nes";
802
		GmailUtils mailer = new GmailUtils();
803
			GmailUtils mailer = new GmailUtils();
803
		String sendTo[] = new String[]{"vikram.raghav@shop2020.in","rajveer.singh@shop2020.in"};
804
			String sendTo[] = new String[]{"vikram.raghav@shop2020.in","rajveer.singh@shop2020.in"};
804
		//String sendTo[] = new String[]{"vikram.raghav@shop2020.in","kshitij.sood@shop2020.in"};
805
			//String sendTo[] = new String[]{"vikram.raghav@shop2020.in","kshitij.sood@shop2020.in"};
805
		/*String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
806
			/*String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
806
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
807
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
807
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
808
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
808
		 */
809
			 */
809
		String emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime);
810
			String emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime);
810
		String text = backInStockItems.toString();
811
			String text = backInStockItems.toString();
-
 
812
			if(text.length() > 0){
-
 
813
				try {
-
 
814
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
-
 
815
				} catch (MessagingException e) {
-
 
816
					e.printStackTrace();
-
 
817
				}
-
 
818
			}
-
 
819
			emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime);
-
 
820
			text = outOfStockItems.toString();
811
		if(text.length() > 0){
821
			if(text.length() > 0){
812
			try {
822
				try {
813
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
823
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
814
			} catch (MessagingException e) {
824
				} catch (MessagingException e) {
815
				e.printStackTrace();
825
					e.printStackTrace();
-
 
826
				}
816
			}
827
			}
817
		}
-
 
818
		emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime);
-
 
819
		text = outOfStockItems.toString();
828
			List<File> files = new ArrayList<File>();
820
		if(text.length() > 0){
829
			files.add(new File(SNAPDEAL_INVENTORY_SHEET));
821
			try {
830
			try {
822
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
831
				mailer.sendSSLMessage(sendTo,"Inventory File",feedresponse, emailFromAddress, password, files);
823
			} catch (MessagingException e) {
832
			} catch (MessagingException e) {
824
				e.printStackTrace();
833
				e.printStackTrace();
825
			}
834
			}
826
		}
835
		}
827
		List<File> files = new ArrayList<File>();
-
 
828
		files.add(new File(SNAPDEAL_INVENTORY_SHEET));
-
 
829
		try {
-
 
830
			mailer.sendSSLMessage(sendTo,"Inventory File",feedresponse, emailFromAddress, password, files);
-
 
831
		} catch (MessagingException e) {
-
 
832
			e.printStackTrace();
-
 
833
		}
-
 
834
 
836
 
835
 
837
 
836
	}
838
	}
837
 
839
 
838
}
840
}