Subversion Repositories SmartDukaan

Rev

Rev 745 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 745 Rev 762
Line 34... Line 34...
34
import in.shop2020.model.v1.user.Line;
34
import in.shop2020.model.v1.user.Line;
35
import in.shop2020.model.v1.user.Address;
35
import in.shop2020.model.v1.user.Address;
36
import in.shop2020.model.v1.user.User;
36
import in.shop2020.model.v1.user.User;
37
import in.shop2020.model.v1.user.RatingType;
37
import in.shop2020.model.v1.user.RatingType;
38
import in.shop2020.model.v1.user.RatingsWidget;
38
import in.shop2020.model.v1.user.RatingsWidget;
-
 
39
import in.shop2020.model.v1.user.UserContextException;
39
import in.shop2020.model.v1.user.Widget;
40
import in.shop2020.model.v1.user.Widget;
40
import in.shop2020.model.v1.user.WidgetItem;
41
import in.shop2020.model.v1.user.WidgetItem;
41
import in.shop2020.model.v1.user.WidgetType;
42
import in.shop2020.model.v1.user.WidgetType;
42
import in.shop2020.serving.utils.*;
43
import in.shop2020.serving.utils.*;
43
import in.shop2020.thrift.clients.CatalogServiceClient;
44
import in.shop2020.thrift.clients.CatalogServiceClient;
Line 109... Line 110...
109
			context.put("itemList", itemList);
110
			context.put("itemList", itemList);
110
			
111
			
111
		} catch(Exception e){
112
		} catch(Exception e){
112
			
113
			
113
		}
114
		}
-
 
115
		/*
-
 
116
		finally{
-
 
117
			catalogServiceClient.closeConnection();
-
 
118
		}
-
 
119
		*/
114
 
120
 
115
		
121
		
116
		htmlString = getHtmlFromVelocity(templateFile, context);
122
		htmlString = getHtmlFromVelocity(templateFile, context);
117
		return htmlString;	
123
		return htmlString;	
118
	}
124
	}
Line 136... Line 142...
136
			}
142
			}
137
			context.put("itemList", itemList);
143
			context.put("itemList", itemList);
138
			
144
			
139
		} catch(Exception e){
145
		} catch(Exception e){
140
			
146
			
-
 
147
		}finally{
-
 
148
			catalogServiceClient.closeConnection();
141
		}
149
		}
142
 
-
 
143
		
150
		
144
		htmlString = getHtmlFromVelocity(templateFile, context);
151
		htmlString = getHtmlFromVelocity(templateFile, context);
145
		return htmlString;
152
		return htmlString;
146
	}
153
	}
147
 
154
 
Line 164... Line 171...
164
			}
171
			}
165
			context.put("itemList", itemList);
172
			context.put("itemList", itemList);
166
			
173
			
167
		} catch(Exception e){
174
		} catch(Exception e){
168
			
175
			
-
 
176
		}finally{
-
 
177
			catalogServiceClient.closeConnection();
169
		}
178
		}
170
		
179
		
171
		htmlString = getHtmlFromVelocity(templateFile, context);
180
		htmlString = getHtmlFromVelocity(templateFile, context);
172
		return htmlString;
181
		return htmlString;
173
	}
182
	}
Line 381... Line 390...
381
			userServiceClient = new UserContextServiceClient();
390
			userServiceClient = new UserContextServiceClient();
382
			client = userServiceClient.getClient();
391
			client = userServiceClient.getClient();
383
			widget = client.getWidget(widgetType, userId, true);
392
			widget = client.getWidget(widgetType, userId, true);
384
		} catch (Exception e) {
393
		} catch (Exception e) {
385
			e.printStackTrace();
394
			e.printStackTrace();
-
 
395
		}finally{
-
 
396
			userServiceClient.closeConnection();
386
		}
397
		}
387
 
398
 
388
 
399
 
389
		List<Map<String, String>> itemDetails = null;
400
		List<Map<String, String>> itemDetails = null;
390
		
401
		
Line 466... Line 477...
466
		}catch (Exception e){
477
		}catch (Exception e){
467
			
478
			
468
		}
479
		}
469
		List<String> orderDate = new ArrayList<String>();
480
		List<String> orderDate = new ArrayList<String>();
470
		SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
481
		SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
-
 
482
		if(orders==null || orders.isEmpty()){
471
		for(Order order: orders){
483
			for(Order order: orders){
472
			Date orderedOn = new Date(order.getCreated_timestamp());
484
				Date orderedOn = new Date(order.getCreated_timestamp());
473
			orderDate.add(dateformat.format(orderedOn));
485
				orderDate.add(dateformat.format(orderedOn));
-
 
486
			}
474
		}
487
		}
475
		context.put("orders", orders);
488
		context.put("orders", orders);
476
		context.put("orderDate", orderDate);
489
		context.put("orderDate", orderDate);
477
		context.put("providerNames", providerNames);
490
		context.put("providerNames", providerNames);
478
		htmlString = getHtmlFromVelocity(templateFile, context);
491
		htmlString = getHtmlFromVelocity(templateFile, context);
Line 484... Line 497...
484
		String htmlString = "";
497
		String htmlString = "";
485
		VelocityContext context = new VelocityContext();
498
		VelocityContext context = new VelocityContext();
486
		String templateFile = "templates/logindetails.vm";
499
		String templateFile = "templates/logindetails.vm";
487
		String email = "";
500
		String email = "";
488
		try{
501
		try{
489
			email = in.shop2020.serving.utils.Utils.getEmailId(userId);
502
			email = getEmailId(userId);
490
		}catch (Exception e){
503
		}catch (Exception e){
491
			
504
			
492
		}
505
		}
493
		context.put("email", email);
506
		context.put("email", email);
494
		htmlString = getHtmlFromVelocity(templateFile, context);
507
		htmlString = getHtmlFromVelocity(templateFile, context);
495
		return htmlString;
508
		return htmlString;
496
	}
509
	}
497
	
510
	
-
 
511
	public String getEmailId(long userId){
-
 
512
		String email = " ";
-
 
513
		
-
 
514
		try {
-
 
515
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
-
 
516
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
517
			if(userClient.getUserById(userId).getEmail() != null){
-
 
518
				email = userClient.getUserById(userId).getEmail();
-
 
519
			}
-
 
520
		} catch (UserContextException e) {
-
 
521
			e.printStackTrace();
-
 
522
		} catch (TException e) {
-
 
523
			e.printStackTrace();
-
 
524
		} catch (Exception e) {
-
 
525
			e.printStackTrace();
-
 
526
		}
-
 
527
		return email; 
-
 
528
	}
-
 
529
 
-
 
530
	
498
	public String getPersonalDetailsHtml(long userId) {
531
	public String getPersonalDetailsHtml(long userId) {
499
		String htmlString = "";
532
		String htmlString = "";
500
		VelocityContext context = new VelocityContext();
533
		VelocityContext context = new VelocityContext();
501
		String templateFile = "templates/personaldetails.vm";
534
		String templateFile = "templates/personaldetails.vm";
502
		String email = "";
535
		String email = "";
Line 725... Line 758...
725
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
758
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
726
		Properties p = new Properties();
759
		Properties p = new Properties();
727
		p.setProperty("resource.loader", "class");
760
		p.setProperty("resource.loader", "class");
728
		p.setProperty("class.resource.loader.class",
761
		p.setProperty("class.resource.loader.class",
729
		"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
762
		"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
-
 
763
		p.setProperty("file.resource.loader.path",
-
 
764
		"/home/FTP-shared/upload/");
730
		
765
 
731
		try {
766
		try {
732
			Velocity.init(p);
767
			Velocity.init(p);
-
 
768
			//Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, value)
733
			Template template = Velocity.getTemplate(templateFile);
769
			Template template = Velocity.getTemplate(templateFile);
734
			if(template != null) {
770
			if(template != null) {
735
				StringWriter writer = new StringWriter();
771
				StringWriter writer = new StringWriter();
736
				template.merge(context, writer);
772
				template.merge(context, writer);
737
				writer.flush();
773
				writer.flush();