<%@	include	file = "EgMonitorTracker.jsp" %>
<%@  page import= "java.util.Vector"%>
<%@  page import= "java.util.Hashtable"%>
<%@	page import	= "java.util.HashMap"%>
<%@	page import	= "java.util.StringTokenizer"%>
<%@  page import= "com.eg.IniFile" %>
<%@  page import= "com.eg.EgInstallInfo" %>
<%@  page import= "java.net.URLEncoder" %>
<%@  page import="com.egurkha.monitor.EgCtxUserBean" %>
<%@  page import = "com.egurkha.User" %>
<%@  page import = "com.egurkha.UserRegistry" %>
<%@  page import = "com.egurkha.EgUserRole" %>
<%@  page import = "com.egurkha.ini.IniUI" %>
<%@  page import= "com.eg.EgDateInfo" %>
<%@  page import= "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.EgMemInfo" %>
<%@  page import= "java.util.*" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@page import = "com.eg.EgURLEncoder"%>
<%@  page import= "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.monitor.VMDesktopBean"%>
<%@ page import="com.egurkha.monitor.*"%>
<%@  page import= "com.eg.EgExternalInfo" %>
<%@  page import= "com.eg.EgSpecsInfo" %>
<%@  page import= "com.eg.EgAgentInfo" %>
<%@  page import= "com.eg.EgTesterInfo" %>
<%@ page import="net.sf.json.*"%>
<%@ page import="java.text.SimpleDateFormat"%> 
<%@  page import= "com.eg.EgFormatInfo" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="dd" scope="page" class="com.egurkha.monitor.EgDiagnosisBean" />
<jsp:useBean id="trans" scope="page" class="egurkha.TransactionBean"/>
<%

		String uiFile11 = "eg_ui.ini";
		String s_iniFile_dir11 = EgInstallInfo.getInstallDir()+ "/manager/config/";
		IniFile egUI11 = new IniFile(s_iniFile_dir11 + uiFile11);  
		String[] options = {"Any","Recent","1 hour", "3 hours", "6 hours", "9 hours", "12 hours","15 hours", "18 hours","21 hours","24 hours", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month","2 months"};   
		JSONObject gridObj=new JSONObject();
		JSONArray gridData = new JSONArray();
		JSONArray columnDetails = new JSONArray();
		JSONObject rootJson = new JSONObject();
		JSONObject screenLabels = new JSONObject();
		JSONObject dateTime = new JSONObject();
		TreeMap linksMap = new TreeMap();

		EgAgentInfo agentInfo = new EgAgentInfo(EgConstants.MANAGER);
		EgTesterInfo tt = new EgTesterInfo(EgConstants.MANAGER);
		EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
		boolean ddEnabled = EgMemInfo.ddEnabled;
		EgFormatInfo formatInfo = new EgFormatInfo ("manager");
		ArrayList excludeDDTestList = formatInfo.getHideDDTestList();
		trans.createFile("eg_format.ini");
		String strVarArr[] = trans.getVariables("FORMAT");
		String dummyTestArr[] = trans.getVariables("COMMON_DD_MAPPING");
		String defaulttimelinevalue="";
		String s_timeline=request.getParameter("eg_timeline"); 
		String eg_stdate = request.getParameter("eg_stdate");
		String eg_enddate = request.getParameter("eg_enddate");
		String start_hr = request.getParameter("starthr");
		String end_hr = request.getParameter("endhr");
		String startmin_h = request.getParameter("startmin_h");
		startmin_h=(startmin_h==null || startmin_h.trim().length()==0 || startmin_h.equals("null"))?"00":startmin_h;
		String endmin_h = request.getParameter("endmin_h");
		endmin_h=(endmin_h==null || endmin_h.trim().length()==0|| endmin_h.equals("null"))?"59":endmin_h;
		String isFromLayers = request.getParameter("isFromLayers");
		String eg_tbound=request.getParameter("eg_tbound"); 
		eg_tbound = (eg_tbound==null||eg_tbound.equalsIgnoreCase("null")||eg_tbound.trim().length()==0)?"":eg_tbound;
		boolean isFromLayersFlag = false;
		isFromLayersFlag = (isFromLayers==null||isFromLayers.equalsIgnoreCase("null")||isFromLayers.trim().length()==0)?false:true;
		String currentDateFormat = egUI11.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
		String search_type = request.getParameter("searchtype"); 
		search_type = (search_type==null||search_type.equalsIgnoreCase("null")||search_type.trim().length()==0)?"":search_type;
		String search_value = request.getParameter("searchvalue");
		search_value = (search_value==null||search_value.equalsIgnoreCase("null")||search_value.trim().length()==0)?"":search_value;
		Vector csvHeaders = new Vector();
		String searchValue = request.getParameter("searchuser");
		
		if(isFromLayersFlag)
		{
			gridObj.put("isFromLayers",isFromLayersFlag);
			String comFormat = "";
			String userFormat = u_ser.getUserDateFormat();
			if(eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0)
			{
				if(DateUtil.isDate(eg_stdate,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				eg_stdate = DateUtil.changeDateFormat(eg_stdate,comFormat,userFormat);

				dateTime.put("eg_stdate",eg_stdate);
				dateTime.put("start_hr",start_hr);
			}
			if(eg_enddate!=null && !eg_enddate.equalsIgnoreCase("null") && eg_enddate.trim().length()>0)
			{
				if(DateUtil.isDate(eg_enddate,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				eg_enddate = DateUtil.changeDateFormat(eg_enddate,comFormat,userFormat);

				dateTime.put("eg_enddate",eg_enddate);
				dateTime.put("end_hr",end_hr);
			}
		}
		if(s_timeline==null)
		{
		  defaulttimelinevalue=egUI11.getValue("SEARCH_DISPLAY","Timeline");
		  s_timeline=defaulttimelinevalue;
          gridObj.put("defaulttimelinevalue",defaulttimelinevalue);
	    }
	   else
	   {
           gridObj.put("defaulttimelinevalue",s_timeline);
	   }
		columnDetails.add(mappingInfo.getTextDescription("monitor.thinclients.User/Virtual Desktops"));
		columnDetails.add(mappingInfo.getTextDescription("monitor.thinclients.Server"));
		columnDetails.add(mappingInfo.getTextDescription("monitor.thinclients.Component type"));
		columnDetails.add(mappingInfo.getTextDescription("monitor.thinclients.Last access time"));
		columnDetails.add(mappingInfo.getTextDescription("monitor.common.Graph"));
		//columnDetails.add(mappingInfo.getTextDescription("monitor.thinclients.Diagnosis"));
		columnDetails.add(mappingInfo.getTextDescription("monitor.common.DD"));
		csvHeaders.add(mappingInfo.getTextDescription("monitor.thinclients.User/Virtual Desktops"));
		csvHeaders.add(mappingInfo.getTextDescription("monitor.thinclients.Server"));
		csvHeaders.add(mappingInfo.getTextDescription("monitor.thinclients.Component type"));
		csvHeaders.add(mappingInfo.getTextDescription("monitor.thinclients.Last access time"));
		
		List listData = new LinkedList();
		String mainTitle = mappingInfo.getTextDescription("monitor.vmsearch.Search results for - "+searchValue);
		listData.add(mainTitle);
		listData.add("");
		listData.add(csvHeaders);
		ArrayList timlinelist = new ArrayList(Arrays.asList(options));
		//Collections.sort(timlinelist,String.CASE_INSENSITIVE_ORDER);
		JSONArray historyTmeLineList = new JSONArray();
		//historyTmeLineList.addAll(timlinelist);
		ListIterator itr = timlinelist.listIterator();
		String tempStr = "";
		while(itr.hasNext())
		{
			tempStr = (String)itr.next();
			JSONObject temp = new JSONObject();
			temp.put("displayField",tempStr);
			temp.put("valueField",tempStr);
			historyTmeLineList.add(temp);
		}
		String timeLineLbl = mappingInfo.getTextDescription("monitor.common.Timeline");
		String fromLbl = mappingInfo.getTextDescription("monitor.common.From");
		String toLbl = mappingInfo.getTextDescription("monitor.common.To");
		screenLabels.put("monitor.common.State",mappingInfo.getTextDescription("monitor.common.State"));
		screenLabels.put("monitor.common.Timeline",timeLineLbl);
		screenLabels.put("monitor.common.From",fromLbl);
		screenLabels.put("monitor.common.To",toLbl);
		screenLabels.put("monitor.common.Hr",mappingInfo.getTextDescription("monitor.common.Hr"));
		gridObj.put("defaulttimelineopt",mappingInfo.getTextDescription("monitor.common.1 hour"));
        try
        {   
			StringBuffer s_title = new StringBuffer();
			String ftitle="";
			s_title.append(mappingInfo.getTextDescription("monitor.search.Search results for"));
			s_title.append(" - ");
			s_title.append(mappingInfo.getTextDescription("monitor.search.user"));
			s_title.append(" ");
			EgExternalInfo egExternalInfo=new EgExternalInfo("manager");
			MonitorDAOFactory monitorDaoFactory = MonitorDAOFactory.getInstance();
			EgServerDashBoardDAO dashboardDAO=monitorDaoFactory.getServerDashBoardDAO();
			EgTablesInfo tables=new EgTablesInfo("manager");
			String uiFile = "eg_ui.ini";
			String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
			String formatFile = "eg_format.ini";
			IniFile formatIniFile = new IniFile(s_iniFile_dir + formatFile);
			IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
            String usersdetailsperpage = egUI.getValue("SEARCH_DISPLAY","UserDetails_PerPage");
			com.eg.IniFile egEx = new com.eg.IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_external.ini");

			boolean isShowInsideview=false;
			String strShownInsideview=egEx.getValue("User_VM_Search","shownInsideview");
			if(strShownInsideview!=null && strShownInsideview.trim().length()>0 && (strShownInsideview.equalsIgnoreCase("true") || strShownInsideview.equalsIgnoreCase("yes")))
			{
				isShowInsideview=true;
			}

			com.eg.IniFile egEndIni = new com.eg.IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_endUserDetails.ini");

			String strLinkFromThin ="";
			boolean isLinkFromThin=false;
			if(egEndIni!=null)
				strLinkFromThin = egEndIni.getValue("END_USER_DASHBOARD_SETTINGS","LinkFromThinClient");

			strLinkFromThin=(strLinkFromThin==null || strLinkFromThin.trim().length()==0)?"false":strLinkFromThin;
			isLinkFromThin = strLinkFromThin.equalsIgnoreCase("true")?true:false;

			boolean isLinkFromThinHistory=false;
			String strLinkFromThinHistory = egEndIni.getValue("END_USER_DASHBOARD_SETTINGS","LinkFromThinClientHistory");
			if(strLinkFromThinHistory!=null && strLinkFromThinHistory.trim().length()>0 && (strLinkFromThinHistory.equalsIgnoreCase("true") || strLinkFromThinHistory.equalsIgnoreCase("yes")))
			{
				isLinkFromThinHistory=true;
			}

			List vdiList=new LinkedList();
			List vdiUserList=new LinkedList();
			if(isLinkFromThin || isShowInsideview)
			{
				String[] iniVdiList = egEx.getVariables("Virtual_Desktops");
				if(iniVdiList!=null && iniVdiList.length>0)
				{
					vdiList = Arrays.asList(iniVdiList);
				}

				String[] iniVdiUserList = egEx.getVariables("VdiUser_Search_Types");
				if(iniVdiUserList!=null && iniVdiUserList.length>0)
				{
					vdiUserList = Arrays.asList(iniVdiUserList);
				}
			}
		
			String dispDate = null;
			String mode = null;
			com.egurkha.ini.IniUI ui = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
			//declaration Section
			ErUtils erUtils = new ErUtils();
			EgDateInfo egDt=new EgDateInfo();

			java.util.Date local_date = new java.util.Date(egDt.egetUTCDate());
			Calendar cal = Calendar.getInstance();
			cal.setTime(local_date);
			cal.setTimeZone(egDt.getRealTimeZone());

			//EgCtxUserBean user=new EgCtxUserBean(session.getId());
			String start_date="";
			String end_date="";
			String hidden="Measure";
			String s_user="";
			Vector v_data=null;
			StringBuffer printQS=new StringBuffer();
			String title="";
			Vector v_columns=new Vector();	
            s_user=request.getParameter("searchvalue");
			s_user=com.egurkha.util.StringUtils.replace(s_user,"|quots|","'");
			s_user=com.egurkha.util.StringUtils.replace(s_user,"|hash|","#");
			
			if(s_user!=null)
            {
                String s_temp_user = com.egurkha.util.StringUtils.decodeSecurityChar(s_user);
                s_title.append(s_temp_user);
				s_title.append(" ");
			} 
             
            if (s_user==null)
			   s_user="";
			Hashtable ht_server=(Hashtable)request.getAttribute("CitrixUser");
			if(ht_server!=null && ht_server.size()>0)
				session.setAttribute("CitrixUser",ht_server);
            String mHost = "";
		    String mHostForDD = "";
		    Hashtable state_hash=new Hashtable();
		    Hashtable msmt_hash=new Hashtable();
   		    if(ht_server!=null && ht_server.size()!=0)
		    {
				Iterator keys=ht_server.keySet().iterator();
				String enddateValue = "";
				if (s_timeline==null || !s_timeline.equals("Recent"))
				{
					enddateValue = (String) ht_server.get("endDateTime");
				}
				while (keys.hasNext())
			    {
					String user=(String)keys.next();
					String search_string = "";
					if(user!=null && user.equals("endDateTime"))
					{
						continue;
					}
					search_string = user;
					v_data=(Vector)ht_server.get(user);
					if(v_data!=null && v_data.size()>0)
					{
                    			String test="";
					String testForDD="";
					Collections.sort(v_data,Collections.reverseOrder());
					for(int i=0;i<v_data.size();i++)
					{
						JSONObject rowData = new JSONObject();
						Vector csvData = new Vector();
						String serverwithall=(String)v_data.get(i);
						String server="";
						String comptype="";
						String terminal_comptype="Terminal_server";
						String layer="";
						String layerForDD="";
						String powered_on=null;
						String disp_user=null;
						String real_ConnectionType=null;
						StringTokenizer st=new StringTokenizer(serverwithall,"|");
						int count_token=st.countTokens();
						String timeLineValue=st.nextToken();
						String strdateValue="";
						if (timeLineValue!=null && !timeLineValue.equals("Recent"))
						{
							strdateValue=st.nextToken();
						}						
						String strdate=st.nextToken();//serverwithall.substring(0,serverwithall.indexOf("|"));
						String serverwithcom=st.nextToken();//serverwithall.substring(serverwithall.indexOf("|")+1,serverwithall.lastIndexOf("|"));
						String connectionType=st.nextToken();//serverwithall.substring(serverwithall.lastIndexOf("|")+1);
						real_ConnectionType = connectionType;
						user=st.nextToken();
						if(real_ConnectionType!=null && real_ConnectionType.equalsIgnoreCase("CitrixXenDesktop7") && count_token>6)
						{
							disp_user=st.nextToken();
						}
						else if(count_token>6)
							powered_on=st.nextToken();

						if(user.startsWith("+"))
							user=user.substring(1);
						server=serverwithcom.substring(serverwithcom.indexOf(":")+1);
						String componentName=server;
						if (componentName.endsWith("NULL") && componentName.indexOf(":")>-1)
							componentName=componentName.substring(0,componentName.lastIndexOf(":"));
						comptype=serverwithcom.substring(0,serverwithcom.indexOf(":"));

						String measureList="";
						String ddMeasure="";

						if(comptype!=null && !comptype.trim().equals(""))
						{
							String testWithGraphMeasure = egEx.getValue("VirtualDesktops_Measure",comptype);
							String testWithDDMeasure = egEx.getValue("VirtualDesktops_Measure",comptype+":DD");

							if(connectionType!=null && connectionType.equalsIgnoreCase("Terminal") && comptype!=null && !comptype.equals(terminal_comptype))
							{
								testWithGraphMeasure = egEx.getValue("VirtualDesktops_Measure",terminal_comptype);
								testWithDDMeasure = egEx.getValue("VirtualDesktops_Measure",terminal_comptype+":DD");
							}

							if(testWithGraphMeasure!=null && !testWithGraphMeasure.trim().equals("") && testWithGraphMeasure.indexOf(":")>-1)
							{
								test = testWithGraphMeasure.substring(0,testWithGraphMeasure.indexOf(":"));
								measureList = testWithGraphMeasure.substring(testWithGraphMeasure.indexOf(":")+1);
							}
							if(testWithDDMeasure!=null && !testWithDDMeasure.trim().equals("") && testWithDDMeasure.indexOf(":")>-1)
							{
								testForDD = testWithDDMeasure.substring(0,testWithDDMeasure.indexOf(":"));
								ddMeasure = testWithDDMeasure.substring(testWithDDMeasure.indexOf(":")+1);
							}
						}
						if(test!=null && !test.trim().equals(""))
						{
								layer=tables.getLayerForTest(test);
								if(layer!=null && !layer.trim().equals("") && layer.indexOf(",")>-1)
								{
									layer=layer.substring(0,layer.indexOf(","));
								}
						 }
						 if(testForDD!=null && !testForDD.trim().equals(""))
						 {
								layerForDD=tables.getLayerForTest(testForDD);
								if(layerForDD!=null && !layerForDD.trim().equals("") && layerForDD.indexOf(",")>-1)
								{
									layerForDD=layerForDD.substring(0,layerForDD.indexOf(","));
								}
						  }
  						 String tempServerwithAll = "";
						 if(serverwithall!=null && serverwithall.indexOf("|")>-1)
						 {
								tempServerwithAll = serverwithall.substring(serverwithall.indexOf("|")+1);
								strdateValue=tempServerwithAll.substring(0,tempServerwithAll.indexOf("|"));
								tempServerwithAll=tempServerwithAll.substring(tempServerwithAll.indexOf("|")+1);
						  }
						  String startdate1="";
						  boolean use3DGraphs = false; //ui.use3DGraphs(IniUI.MONITOR);
						  if(use3DGraphs)
						  {
								mode ="3D";
						  }
						  else
								mode ="2D";
						//try
						//{

						Hashtable allMsmtHosts = new Hashtable();
						String msmt_key=comptype+":"+server;
						if(msmt_hash!=null && msmt_hash.size()>0 && msmt_hash.containsKey(msmt_key))
						{
							allMsmtHosts=(Hashtable)msmt_hash.get(msmt_key);
						}
						else
						{
							Hashtable tmp_allMsmtHosts=(Hashtable)dashboardDAO.getMsmtHostForAllTest(server,comptype,"custom");

							allMsmtHosts = new Hashtable();
							allMsmtHosts.putAll(tmp_allMsmtHosts);

							msmt_hash.put(msmt_key,(Hashtable)tmp_allMsmtHosts);
						}
						
						String starttime = "";
						String endtime = "";
						String sthr="";
						String endhr="";
						if (timeLineValue!=null && !timeLineValue.equals("Recent"))
						{
						//	Date startdateObj = new Date(strdateValue);
							Date startdateObj = new Date(strdate);
							Date dateObj=null;
							//starttime = strdateValue;
							starttime = strdate;
							Calendar cal_temp = new GregorianCalendar();
							cal_temp.setTime(startdateObj);
							cal_temp.add(Calendar.HOUR_OF_DAY,-1);
							//calendar.add(Calendar.HOUR,-4);

							dateObj = cal_temp.getTime();
							long l_starttime = dateObj.getTime();
							String startDate = egDt.egetDateUS(l_starttime);
							sthr=startDate.substring(startDate.indexOf(" ")+1,startDate.indexOf(":"));
							starttime=startDate.substring(0,startDate.indexOf(" "));

							eg_stdate=starttime;
							start_hr=sthr;
							//Date enddateObj = new Date(enddateValue);
							Date enddateObj = new Date(strdate);
							cal_temp = new GregorianCalendar();
							cal_temp.setTime(enddateObj);
							cal_temp.add(Calendar.HOUR_OF_DAY,1);
							//calendar.add(Calendar.HOUR,-4);

							dateObj = cal_temp.getTime();
							long l_endtime = dateObj.getTime();
							endtime = egDt.egetDateUS(l_endtime);
							endhr=endtime.substring(endtime.indexOf(" ")+1,endtime.indexOf(":"));
							endtime=endtime.substring(0,endtime.indexOf(" "));
							timeLineValue="Any";

							if(eg_enddate==null || eg_enddate.equals("null"))
							{
								eg_enddate=endtime;
							}

							end_hr=endhr;
						}

						List agents=new LinkedList();
						List agentsForDD=new LinkedList();
						String nick_name = server.substring(0,server.lastIndexOf(":"));
						agents=egExternalInfo.getAgentsFor(test,comptype,nick_name);
						agentsForDD=egExternalInfo.getAgentsFor(testForDD,comptype,nick_name);

						if (agents!=null && agents.size()>0)
						{
							mHost = (String) agents.get(0);
						}
						else
						{
							mHost=nick_name;
						}
						if (agentsForDD!=null && agentsForDD.size()>0)
						{
							mHostForDD = (String) agentsForDD.get(0);
						}
						else
						{
							mHostForDD=nick_name;
						}

						String searchType = "";
						searchType = request.getParameter("searchtype");

						String layerQs="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&host="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&tab=LayerModel&toDashBoardLayer=true"; 

							String tlayerQs=EgURLEncoder.encode("site|eq|NULL^qctr|eq|2^fromalarm|eq|1^fromPage|eq|vm^newWindow|eq|false^comptype|eq|"+comptype+"^host|eq|"+server+"^layer|eq|"+layer+"^test|eq|"+test+"-+"+EgURLEncoder.encode(user,"UTF-8")+"^msmt_host|eq|^isFromVmHost|eq|true^gotoLayerModel|eq|true^tab|eq|LayerModel^toDashBoardLayer|eq|true^isTotalVm|eq|null^poweredOnVMs|eq|null^tstate|eq|GOOD^priority|eq|10^searchValueandType|eq|"+search_type+" "+search_value,"UTF-8");
							
							String userlayerQs="/final/monitor/EgSiteInfraView.jsp?site=NULL&qctr=2&fromalarm=1&fromPage=vm&newWindow=false&comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"&host="+EgURLEncoder.encode(server,"UTF-8")+"&layer="+EgURLEncoder.encode(layer,"UTF-8")+"&test="+EgURLEncoder.encode(test,"UTF-8")+"-"+user+"&msmt_host=&isFromVmHost=true&gotoLayerModel=true&tab=LayerModel&toDashBoardLayer=true&isTotalVm=null&poweredOnVMs=null&tstate=GOOD&priority=10";
							
							String st_dispDate = DateUtil.changeDateFormat(starttime,"MM/dd/yyyy",currentDateFormat);
							String et_dispDate = DateUtil.changeDateFormat(endtime,"MM/dd/yyyy",currentDateFormat);

						String ddQs="/final/monitor/EgDiagnosis.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&test="+EgURLEncoder.encode(testForDD,"UTF-8")+"&info=*"+EgURLEncoder.encode(user,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHostForDD,"UTF-8")+"&from=0&newWindow=true&measure="+ddMeasure+"&firsttime=true&flag=0 &starttime="+EgURLEncoder.encode(st_dispDate,"UTF-8")+"&endtime="+EgURLEncoder.encode(et_dispDate,"UTF-8")+"&starthr="+sthr+"&endhr="+endhr+"&timeline="+timeLineValue;

						String tmp_s_timeline=timeLineValue;
						if(tmp_s_timeline!=null && tmp_s_timeline.equals("Recent"))
						{
							tmp_s_timeline = "24 hours";
						}
						String graphQs="";
						String hostname=EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8");
						String port = server.substring(server.lastIndexOf(":")+1);

						String dLink = "/final/monitor/EgDiagnosis.jsp?site=NULL&host="+hostname+"&port="+port+"&test="+testForDD+"&isPopUp=true";

						String compddLink = dLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&from=0&measure="+ddMeasure+"&flag=1&firsttime=true&comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"&timeline="+tmp_s_timeline;

						String histLink="/final/monitor/dispComponentHistory.jsp?site=NULL&info=" + EgURLEncoder.encode(user,"UTF-8") + "&test=" + test + "&component=" +EgURLEncoder.encode(server+":"+comptype,"UTF-8");

						String ddLink = response.encodeURL("/final/monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site=NULL&host="+hostname+"&port="+port+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&state=any&messy="+measureList+"&test="+test+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&clicked=dd&from=measurespage";

						

						String compgraphLink = "/final/monitor/dispComponentGraphs.jsp?site=NULL&host=" +hostname+"&port="+port+"&layer="+layer+"&test="+test+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8");


						String  graphLink = compgraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state=any"+"&timeLine="+tmp_s_timeline;

						String compsummarygraphLink ="/final/monitor/dispComponentSummaryGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");
						
						String summarygraphLink = compsummarygraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state=any";

						String comptrendgraphLink ="/final/monitor/dispComponentTrendGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String trendgraphLink = comptrendgraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state=any";

						String  aggLink="/final/monitor/dispAggComponentGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String historyLink = histLink+"&measure="+measureList;

						String feedLink="/final/monitor/dispComponentFeedback.jsp?site=NULL&trgthost="+hostname+"&port="+port+"&test="+test+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8");


						String portForMsmtTime="NULL";
						String keyValue=componentName+":"+portForMsmtTime+":"+test+":"+mHost;
						if(componentName!=null && componentName.indexOf(":")>0)
						{		
							keyValue=componentName+":"+test+":"+mHost;
						}
						String msmtTimeStr=dashboardDAO.getMeasureLastMsmtTime(keyValue,user);
						String msmtTimeStr2="";
						try
						{
							SimpleDateFormat df=new SimpleDateFormat("MM/dd/yyyy*HH:mm:ss");
							SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							if(msmtTimeStr!=null && msmtTimeStr!="")
							{							
								java.util.Date msd=sdf2.parse(msmtTimeStr);
								msmtTimeStr2 =df.format(msd);
							}
						}
						catch(Exception eexx)
						{
							System.out.println("Exception--->"+eexx.getMessage());
							eexx.printStackTrace();
						}

						String feedbackLink =  feedLink+"&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&measure="+measureList+ "&msmttime="+msmtTimeStr2 +"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8");

						String aggregateLink=aggLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state=any";

						String measureLink = response.encodeURL("/final/monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site=NULL&host="+hostname+"&port="+port+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&state=any&messy="+measureList+"&from=measurespage&dd_disp=yes&test="+test+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8");

						graphQs = measureLink; 

						ddQs = ddLink;

						String layer_for_url=egEx.getValue("VMSearch_InsideviewLayer",comptype);

						layer_for_url=(layer_for_url==null || layer_for_url.trim().length()==0)?"VIRTUAL_DESKTOP":layer_for_url;

						String insideQs="/final/monitor/egInsideviewDashboard.jsp?getFor="+ddMeasure+"&comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&Layer=VIRTUAL_DESKTOP&info="+user.trim()+"&compName="+EgURLEncoder.encode(server+comptype,"UTF-8")+"&fromThinClients=yes&componentName="+EgURLEncoder.encode(componentName,"UTF-8");

						String showInsideQs="";
						if(isShowInsideview)
						{
							showInsideQs="/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&Layer="+layer_for_url+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&compName="+EgURLEncoder.encode(server+comptype,"UTF-8")+"&searchuser="+EgURLEncoder.encode(search_type+" "+search_value,"UTF-8");
						}

						String userinfo=com.egurkha.util.StringUtils.replace(user,"\\","\\\\");

						boolean isEndDash=false;
						boolean isEndDashXenApp=false;
						if(isLinkFromThin && vdiList!=null && vdiList.size()>0 && vdiList.contains(comptype))
						{
							//String temp_url_desktopName=com.egurkha.util.StringUtils.replace(user, "\\", "\\\\");
							String temp_url_desktopName=com.egurkha.util.StringUtils.replace(user, "\\", "\\");
							insideQs = "/final/monitor/endUserDashboardDetailsData.jsp?comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&info=*"+EgURLEncoder.encode(temp_url_desktopName.trim(),"UTF-8")+"&compName="+EgURLEncoder.encode(server+":"+comptype,"UTF-8")+"&componentName="+EgURLEncoder.encode(componentName,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&user="+EgURLEncoder.encode(u_rs,"UTF-8")+"&usersearch=true&userType=VDI"+"&searchuser="+EgURLEncoder.encode(search_type+" "+search_value,"UTF-8");
							
							if((s_timeline!=null && !s_timeline.equalsIgnoreCase("null") && s_timeline.trim().length()>0) && (eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0))
							{
								insideQs = insideQs + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(eg_stdate,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(eg_enddate,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");
								if(!s_timeline.equals("Recent"))
									insideQs = insideQs + "&eg_tbound="+EgURLEncoder.encode(eg_tbound,"UTF-8");	
							}
							isEndDash=true;
						}
						else if(isLinkFromThin && vdiUserList!=null && vdiUserList.size()>0 && vdiUserList.contains(comptype))
						{
							String userType=(String)egEndIni.getValue("COMP_TYPE_TYPES",comptype);
							if(userType!=null && userType.trim().length()>0)
							{
								//if(!connectionType.equalsIgnoreCase("Terminal") && !connectionType.equalsIgnoreCase("CitrixXenDesktop7"))
								//{
									//String temp_url_desktopName=com.egurkha.util.StringUtils.replace(user, "\\", "\\\\");
									String temp_url_desktopName=com.egurkha.util.StringUtils.replace(user, "\\", "\\");

									insideQs = "/final/monitor/endUserDashboardDetailsData.jsp?comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&info=*"+EgURLEncoder.encode(temp_url_desktopName.trim(),"UTF-8")+"&compName="+EgURLEncoder.encode(server+":"+comptype,"UTF-8")+"&componentName="+EgURLEncoder.encode(componentName,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&user="+EgURLEncoder.encode(u_rs,"UTF-8")+"&usersearch=true&userType="+userType+"&searchuser="+EgURLEncoder.encode(search_type+" "+search_value,"UTF-8");
									
									if((s_timeline!=null && !s_timeline.equalsIgnoreCase("null") && s_timeline.trim().length()>0) && (eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0))
									{
										insideQs = insideQs + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(eg_stdate,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(eg_enddate,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");
										if(!s_timeline.equals("Recent"))
											insideQs = insideQs + "&eg_tbound="+EgURLEncoder.encode(eg_tbound,"UTF-8");
									}
									isEndDashXenApp=true;
								//}
							}
						}

						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"#","|hash|");
						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"%","|percent|");
						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"&","|amp|");
						// Changed by Anthonilawrance
                        String userurl="/final/monitor/eGUserDetails.jsp?comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&info=*"+EgURLEncoder.encode(userinfo, "UTF-8")+"&compName="+EgURLEncoder.encode(server+":"+comptype,"UTF-8")+"&componentName="+EgURLEncoder.encode(componentName,"UTF-8")+"&username="+EgURLEncoder.encode(s_user, "UTF-8")+"&searchval="+EgURLEncoder.encode(s_user, "UTF-8")+"&searchtype="+EgURLEncoder.encode(searchType, "UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&searchuser="+EgURLEncoder.encode(search_type+" "+search_value,"UTF-8");
						
						if((s_timeline!=null && !s_timeline.equalsIgnoreCase("null") && s_timeline.trim().length()>0) && (eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0))
						{
							//userurl = userurl + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(starttime,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(endtime,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");

							userurl = userurl + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(starttime,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(endtime,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");
							if(!s_timeline.equals("Recent"))
									userurl = userurl + "&eg_tbound="+EgURLEncoder.encode(eg_tbound,"UTF-8");
						}
//						"&eg_timeline="+EgURLEncoder.encode(timeLineValue, "UTF-8")+"&eg_tbound="+EgURLEncoder.encode(request.getParameter("eg_tbound"), "UTF-8")+"&eg_stdate_h="+EgURLEncoder.encode(starttime, "UTF-8")+"&eg_enddate_h="+EgURLEncoder.encode(endtime, "UTF-8")+"&starthr_h="+EgURLEncoder.encode(sthr.trim(), "UTF-8")+"&startmin_h="+EgURLEncoder.encode(dateObj.getMinutes()+"", "UTF-8")+"&endhr_h="+EgURLEncoder.encode(endtime, "UTF-8")+"&endmin_h="+EgURLEncoder.encode(dateObj.getMinutes()+"", "UTF-8")+"&username="+EgURLEncoder.encode(UserRegistry.getInstance().getUser(request.getSession().getId()).getLoginID(), "UTF-8");
						StringTokenizer st2=new StringTokenizer(measureList,",");
						if(measureList!=null && st2.countTokens()>0 && st2.countTokens()==1)
						{
							graphQs=graphQs+"&showRange=Range";
						}
						graphQs=graphQs+"&time=Any&gtype=0&draw=1&gformat=graph&from=test&mode=3D&qctr=5&search=&thisIs=event&showRange=Range&newWindow=true";

						dispDate = DateUtil.changeDateFormat(strdate,"MM/dd/yyyy HH:mm:ss",currentDateFormat +" HH:mm:ss");
						String orgDate = dispDate;
						EgTimeZoneConverter timeZoneConverter = new EgTimeZoneConverter(dispDate , u_ser);
						dispDate = timeZoneConverter.getDateTime();
                        boolean showDDIcon = false;
						String hostName=server.substring(0,server.lastIndexOf(":"));

						String msmtHost=null;
						if(allMsmtHosts!=null && allMsmtHosts.size()>0)
							msmtHost=(String)allMsmtHosts.get(testForDD);

						if(msmtHost == null)
							msmtHost = mHostForDD;

						String s_info_to_db = null;
						String ddWithoutInfo = formatIniFile.getValue("Tests_For_DDWithoutInfos", testForDD + ":" + ddMeasure);
						boolean lookforActualDes = false;

						if(ddWithoutInfo!=null && ddWithoutInfo.equalsIgnoreCase("yes"))
						{
							lookforActualDes = true;
							s_info_to_db = "+";
						}
						else
						{
							s_info_to_db = "+"+user;
						}

						if(ddEnabled)
						{
							Vector measures = new Vector();

							if(strVarArr!=null && strVarArr.length>0)
							{
								for(int sva=0; sva<strVarArr.length; sva++)
								{
									if(strVarArr[sva].startsWith(testForDD))
									{
										String meas = strVarArr[sva].substring(strVarArr[sva].indexOf(":")+1,strVarArr[sva].length());
										if(!measures.contains(meas))
										{
											measures.add(meas);
										}
									}
								}
							}
							
							if(dummyTestArr!=null && dummyTestArr.length>0)
							{
								for(int dta=0; dta<dummyTestArr.length; dta++)
								{
									if(dummyTestArr[dta].startsWith(testForDD))
									{
										String meas = dummyTestArr[dta].substring(dummyTestArr[dta].indexOf(":")+1,dummyTestArr[dta].length());
										if(!measures.contains(meas))
										{
											measures.add(meas);
										}
									}
								}
							}

							if(measures.contains(ddMeasure))
							{
								ArrayList DDEnabledList=tt.DefaultDDEnabledTypes();
								boolean isRemoteDetailed = false;
								if(DDEnabledList!=null && DDEnabledList.size()>0 && DDEnabledList.contains(comptype))
								{
									isRemoteDetailed=true;
								}
								else
								{
									isRemoteDetailed = tt.getRemoteDetailed();
								}

								boolean isAgentlessServer = false;
								if (!isRemoteDetailed)
										isAgentlessServer = agentInfo.isAgentlessServer(hostName, comptype);

								//Fix to hide DD icon based on Ini entry
								if(excludeDDTestList != null && excludeDDTestList.size() > 0 && excludeDDTestList.contains(testForDD))
								{
									showDDIcon = false;
								}
								else if (ui.getVirtualServerTypes().contains(comptype)|| !isAgentlessServer || specsInfo.isTestExternal(testForDD))
								{
									showDDIcon = true; //dd.ShowDDData("NULL",hostName,testForDD,ddMeasure,s_info_to_db,msmtHost);
									if(lookforActualDes && !showDDIcon)
									{
										showDDIcon = true; //dd.ShowDDData("NULL",hostName,testForDD,ddMeasure,"+"+user,msmtHost);
									}
								}
							}
						}

						ArrayList insideview_vm_list=new ArrayList();
						if((isLinkFromThin && isEndDash) || (connectionType.indexOf("VmVdi")>-1) || (isShowInsideview && vdiList!=null && vdiList.size()>0 && vdiList.contains(comptype)))
						{
							String key_for_hash=comptype+"^eg^"+server+"^eg^"+layer_for_url;

							if(state_hash!=null && state_hash.size()>0 && state_hash.containsKey(key_for_hash))
							{
								insideview_vm_list=(ArrayList)state_hash.get(key_for_hash);
							}
							else
							{
								Hashtable Valid_info=new Hashtable();

								VMDesktopBean vmdeskBean=new VMDesktopBean(comptype,server,layer_for_url);
								Valid_info=vmdeskBean.getInfoForTest();
								if(Valid_info!=null && Valid_info.size()>0)
								{
									Enumeration vm_keys=Valid_info.keys();
									while(vm_keys.hasMoreElements())
									{
										String key = (String)vm_keys.nextElement();
										insideview_vm_list.add(key.toLowerCase());
									}
								}

								if(insideview_vm_list!=null)
								{
									state_hash.put(key_for_hash,(ArrayList)insideview_vm_list);
								}
							}
						}

						String org_user_name=user;
						if(user!=null && user.indexOf("_on_")>-1)
						{
							ArrayList tokUserList = com.egurkha.util.StringUtils.egTokenizer(user, "_on_",true,false,true);//param 3-->includeEmpty,4-->unique,5-->trim
							if(tokUserList!=null && tokUserList.size()==2)
							{
								org_user_name=(String)tokUserList.get(1);
							}
						}

						String mon_link="hand";
						boolean flage=false;
						if(connectionType.equalsIgnoreCase("Citrix") || connectionType.equalsIgnoreCase("Terminal") || connectionType.equalsIgnoreCase("CitrixXenDesktop7"))
						{
							if(!isLinkFromThin || !isEndDashXenApp)
							{
								//insideQs="javascript:void(0);";
								//mon_link="default";
								insideQs = userlayerQs;
							}
						}
						else if(insideview_vm_list!=null && !insideview_vm_list.contains(user.toLowerCase()))
						{
							if(!insideview_vm_list.contains(org_user_name.toLowerCase()))
							{
								//insideQs="javascript:void(0);";
								//mon_link="default";
								insideQs = userlayerQs;
							}
						}
                        flage=true;
						if(real_ConnectionType==null || !real_ConnectionType.equalsIgnoreCase("CitrixXenDesktop7"))
						{
							disp_user=user;
						}

						JSONObject linkObj = new JSONObject();
						//linkObj.put("USER_LINK_TEXT",user);
						linkObj.put("USER_LINK_TEXT",disp_user);
						csvData.add(disp_user);
						if(powered_on!=null && powered_on.equalsIgnoreCase("on") && insideview_vm_list!=null && (insideview_vm_list.contains(user.toLowerCase()) || insideview_vm_list.contains(org_user_name.toLowerCase())))
						{
							if(isShowInsideview && showInsideQs!=null && showInsideQs.trim().length()>0)
							{
								linkObj.put("USER_LINK_URL",showInsideQs);
							}
							else
							{
								linkObj.put("USER_LINK_URL",insideQs);
							}
						}
						else if(isLinkFromThin && powered_on==null && (!connectionType.equalsIgnoreCase("Terminal") && !connectionType.equalsIgnoreCase("CitrixXenDesktop7")) && ((vdiList!=null && vdiList.size()>0 && vdiList.contains(comptype)) || (vdiUserList!=null && vdiUserList.size()>0 && vdiUserList.contains(comptype))) && insideview_vm_list!=null && (insideview_vm_list.contains(user.toLowerCase()) || insideview_vm_list.contains(org_user_name.toLowerCase())) )
						{
							if(isShowInsideview && showInsideQs!=null && showInsideQs.trim().length()>0)
							{
								linkObj.put("USER_LINK_URL",showInsideQs);
							}
							else
							{
								linkObj.put("USER_LINK_URL",insideQs);
							}
						}
						else if(isLinkFromThin && isEndDashXenApp)
						{
							linkObj.put("USER_LINK_URL",insideQs);
						}
						else
						{
							//linkObj.put("USER_LINK_URL",userlayerQs);
							if(isLinkFromThinHistory)
							{
								if(isShowInsideview && showInsideQs!=null && showInsideQs.trim().length()>0)
								{
									linkObj.put("USER_LINK_URL",showInsideQs);
								}
								else
								{
									linkObj.put("USER_LINK_URL",insideQs);
								}
							}
							else
							{
								linkObj.put("USER_LINK_URL",userurl);
							}
						}

						rowData.put("COLUMN_0",linkObj);
						if(powered_on!=null && powered_on.equalsIgnoreCase("on") && insideview_vm_list!=null && (insideview_vm_list.contains(user.toLowerCase()) || insideview_vm_list.contains(org_user_name.toLowerCase())))
					    { 
                            JSONObject compnameObj = new JSONObject();
						    compnameObj.put("USERCOMPNAME_LINK_TEXT",componentName);
						    compnameObj.put("USERCOMPNAME_LINK_URL",tlayerQs);
						    rowData.put("COLUMN_1",compnameObj);
							csvData.add(componentName);
						}
						else if(isLinkFromThin && isEndDashXenApp)
						{
							JSONObject compnameObj = new JSONObject();
						    compnameObj.put("USERCOMPNAME_LINK_TEXT",componentName);
						    compnameObj.put("USERCOMPNAME_LINK_URL",tlayerQs);
						    rowData.put("COLUMN_1",compnameObj);
							csvData.add(componentName);
						}
						else
						{
                            JSONObject compnameObj = new JSONObject();
							String tmpLayerQs = "from=list^tab=LayerModel^toDashBoardLayer=true^qctr=2^fromPage=GlobalSearchList^fromalarm=null^host="+EgURLEncoder.encode(server,"UTF-8")+"^comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"^site=NULL^searchValueandType="+EgURLEncoder.encode(searchType+" "+s_user,"UTF-8");

						    compnameObj.put("USERCOMPNAME_LINK_TEXT",componentName);
						    compnameObj.put("USERCOMPNAME_LINK_URL",tlayerQs);
						    rowData.put("COLUMN_1",compnameObj);
						    csvData.add(componentName);
						}
                        if(connectionType!=null && !connectionType.trim().equals("") && (connectionType.equalsIgnoreCase("Ctx") || connectionType.equalsIgnoreCase("CitrixXenDesktop7")))
					    {
						    connectionType = "Citrix";
							if(real_ConnectionType!=null && real_ConnectionType.equalsIgnoreCase("CitrixXenDesktop7") && (user.endsWith(":RDP") || user.equalsIgnoreCase("+RDP")))
							{
								connectionType = "Terminal";
							}
					    }
                        JSONObject comptypeObj = new JSONObject();
						comptypeObj.put("USERCOMPTYPE_LINK_TEXT",mappingInfo.getComponentTypeDescription(comptype));
						csvData.add(mappingInfo.getComponentTypeDescription(comptype));
						String tmpLayerQs = "from=list^tab=LayerModel^toDashBoardLayer=true^qctr=2^fromPage=componentList^fromalarm=null^host="+EgURLEncoder.encode(server,"UTF-8")+"^comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"^site=NULL";						
						comptypeObj.put("USERCOMPTYPE_LINK_URL",tmpLayerQs);
						rowData.put("COLUMN_2",comptypeObj);   
						rowData.put("COLUMN_3",dispDate); 
						csvData.add(dispDate);
                        JSONObject graphlinkObj = new JSONObject();
						graphlinkObj.put("USERGRAPH_LINK_IMAGE","graphicon");
						
						if(orgDate!=null && orgDate.trim().length()>0)
						{
							orgDate = orgDate.trim();
							String temDate= orgDate;

							if(orgDate.indexOf(":")>-1)
							{
								int colonCountCheck = orgDate.length() - com.egurkha.util.StringUtils.replace(orgDate,":","").length();
								if(colonCountCheck == 2)
									temDate = orgDate.substring(0,orgDate.lastIndexOf(":"));
							}

							graphQs += "&fromSearch=true&latime="+temDate;
							ddQs += "&fromSearch=true&latime="+temDate;
						}
						
						graphlinkObj.put("USERGRAPH_LINK_URL",graphQs);
                        rowData.put("COLUMN_4",graphlinkObj);     
                        

						// Rights Symbol replace
						user = com.egurkha.util.StringUtils.replace(user,"\u00AE","|rights|");
						
						if(showDDIcon)
					    { 
							linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compddlink", compddLink);
							//linksMap.put(testForDD+"#"+ddMeasure+"#*"+user+"#"+mHost+"compddlink", compddLink);
                            JSONObject ddlinkObj3 = new JSONObject();
							ddlinkObj3.put("USERDD_LINK_IMAGE","ddicon");
							ddlinkObj3.put("USERDD_LINK_URL",ddQs);
							rowData.put("COLUMN_5",ddlinkObj3);
						}  
						/*}
					    catch(Throwable e)
					    {
						  System.out.println("null pointer exception... "+e);
						  e.printStackTrace();
					    }*/
						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compfeedbacklink", aggregateLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compgraphlink", graphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compsummarygraphlink", summarygraphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"comptrendgraphlink", trendgraphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"comphistorylink", historyLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compfeedbacklink", feedbackLink);
						 gridData.add(rowData);
							listData.add(csvData);
						}
					}
					else
					{
						rootJson.put("noDataErrorMsg",mappingInfo.getTextDescription("monitor.vmsearch.No data available"));
					}
				}
				session.setAttribute("userSearchCsvData", listData);
			}
			else
			{
				rootJson.put("noDataErrorMsg",mappingInfo.getTextDescription("monitor.vmsearch.No data available"));
			}

			String mngrIProc = new IniFile(new com.eg.EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
			String htmlFileName = mngrIProc + "/final/monitor/eGUserSearchPrint.jsp;jsessionid="+session.getId()+"?";
			String csvFilePath = "/final/monitor/eGSessionDetailsPrint.jsp;jsessionid="+session.getId()+"?";
			session.setAttribute("USERSEARCH_PDF_URL",htmlFileName);
			session.setAttribute("REPORT_NAME","userSearch");
			session.setAttribute("title","User Search Details");
			session.setAttribute("frmPage","userSearch");
			
			int increment = Integer.parseInt(usersdetailsperpage);
			int optionCount = 5;
			String rowsPerPage[] = new String[optionCount];
			for(int i=0;i<optionCount;i++)
			{
				int j=i+1;
				rowsPerPage[i] = "" + j* increment;
			}
			JSONArray eventsPerPageJson = new JSONArray();
			String rowCount = request.getParameter("eventsPerPage");
			if(rowCount == null || rowCount.equals("null"))
				rowCount = rowsPerPage[0];
			for(int i=0;i<rowsPerPage.length;i++)
			{
				JSONObject eventsPerPageJsonObj = new JSONObject();
				eventsPerPageJsonObj.put("displayField",rowsPerPage[i]);
				eventsPerPageJsonObj.put("valueField",rowsPerPage[i]);
				eventsPerPageJson.add(eventsPerPageJsonObj);
			}
			gridObj.put("eventsPerPage",eventsPerPageJson);
			gridObj.put("eventsPerPageValue",rowCount);

			ftitle=s_title.toString();
			gridObj.put("searchmessage",mappingInfo.getTextDescription("monitor.vmsearch.No data available for the current search"));
			gridObj.put("searchtitle",ftitle);
			gridObj.put("searchtype","usersearch");
			gridObj.put("screenLabels",screenLabels);
			gridObj.put("usersdetailsperpage",rowCount);
			gridObj.put("timeLineList",historyTmeLineList);
			if(dateTime!=null && dateTime.size()>0)
				gridObj.put("dateTime",dateTime);
			//gridObj.put("monitor_Skin",monitor_Skin);
			gridObj.put("COLUMNS",columnDetails);
			gridObj.put("DATA",gridData);
			rootJson.put("SEARCH_DATA",gridObj);
			rootJson.put("csvFilePath",csvFilePath);
			out.println(rootJson.toString());
			session.setAttribute("Tablinks", linksMap);
		}
		catch(Exception e)
		{
			System.out.println("EXCEPTION CITRIXUSER---->"+e);
			e.printStackTrace();
		}


%>