<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "java.text.ParseException" %>
<%@ page import ="com.eg.ErDbServer"%>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import = "com.eg.EgDbaseInfo" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import ="com.eg.IniFile"%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="com.eg.EgDateInfo" %>
<%@ page import="com.eg.EgGroupInfo" %>
<%@ page import="com.eg.EgReportInfo" %>
<%@ page import = "com.egurkha.*" %>
<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "java.net.*" %>
<%@ page import="com.eg.EgThresholdInfo" %>
<%@ page import="com.eg.EgTablesInfo" %>
<%@ page import="com.eg.EgMappingInfo" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "java.text.*" %>
<%@ page import="net.sf.json.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "java.util.Date" %>

<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>


<%
try
{
	String rowIndex=request.getParameter("index");
	String er_Duration=request.getParameter("er_Duration");
	String showFrom=request.getParameter("showFrom");
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	EgMappingInfo intlmap=new EgMappingInfo(thisuser.getLanguage());
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
 	JSONObject rootJson=new JSONObject();
	JSONArray gridDataArray=new JSONArray();
	JSONArray headerObject = new JSONArray();
	JSONArray appMemoryDataSet = new JSONArray();
	JSONArray appCpuDataSet = new JSONArray();
	JSONArray appIODataSet = new JSONArray();
	JSONArray sessionDataSet = new JSONArray();
	JSONObject memoryApplicationGraph=new JSONObject();
	JSONObject cpuApplicationGraph=new JSONObject();
	JSONObject ioApplicationGraph=new JSONObject();
   	ErUtils erUtils = new ErUtils();
	com.eg.EgDbInfo dbInfo = new com.eg.EgDbInfo("manager");
	ErChart chrt=new ErChart();
	JSONArray tmpObj=null;
	int idx=0;
	HashMap Report_data=null;
	ArrayList  Rep_data=(ArrayList)session.getAttribute("sessionUserView");
	int index=Integer.parseInt(rowIndex);
	Object v1 =null;
	if(Rep_data != null && Rep_data.size()>0)
	{
		v1 = (Object)Rep_data.get(index);
		if(v1 instanceof HashMap)
			Report_data = (HashMap)v1;
	}
	String userName="";
	if(Report_data != null )
	{
		userName=(String)Report_data.get("user");
		rootJson.put("PanelTitle",userName);
	}
	String strUserNameValue=null;
	String currentDateFormat="";
	if(thisuser!=null)
	{
		strUserNameValue = thisuser.getLoginID();
		currentDateFormat = thisuser.getUserDateFormat();
	}
	if(Rep_data != null && er_Duration != null && !er_Duration.equalsIgnoreCase("null")){
		double durtnVal=Double.parseDouble(er_Duration);
		if(durtnVal > 0){
			for(int i=0;i<Rep_data.size();i++){
				 v1 = (Object)Rep_data.get(i);
				if(v1 instanceof HashMap)
					Report_data = (HashMap)v1;
				String duration=(String)Report_data.get("duration");
				if(duration != null ){
					double durtnValChk=Double.parseDouble(duration);
					if(durtnValChk <= durtnVal && (durtnValChk+1) >= durtnVal){
						break;
					}
					else if(durtnValChk >= durtnVal && (durtnValChk-1) <= durtnVal){
						break;
					}
				}
			}
		}
	}
	if(Report_data != null &&  Report_data.size() > 0){
		EgReportInfo reportInfo = new EgReportInfo("manager");
		String compType="";
		ErSessionDetailView es=new ErSessionDetailView(Report_data,strUserNameValue);
		if(Report_data.containsKey("multipleLogin")){
			rootJson.put("fromMultipleLogins","true");
			ArrayList loginLst=(ArrayList)Report_data.get("multipleLogin");
			if(loginLst != null && loginLst.size() > 0){
				String columnsVal = reportInfo.getValue("CITIX_USER_SESSION_VIEW","multilpleLoginSummary");
				ArrayList measureLst=ErUtils.egTokenizer(columnsVal, ",");
				JSONObject summaryObj=es.getLoginSummaryTable(loginLst,measureLst,currentDateFormat);
				rootJson.put("multipleLoginsData",summaryObj);
			}
		}
		else
			rootJson.put("fromMultipleLogins","false");
		String cmpType=(String)Report_data.get("CompnentType");
		boolean isVmComp=false;
		if(cmpType != null )
			isVmComp=reportInfo.isVmComponent(cmpType);
		es.setShowFromComboValue(showFrom);
		ErSessionInfoBean sessionInfobean=es.getAppResourceInfo();
		JSONArray seqRow=new JSONArray();
		JSONArray memeoryRow=new JSONArray();
		JSONArray cpuRow=new JSONArray();
		List appInfoList=sessionInfobean.getAppInfoList();
		JSONObject browserActivtyObj=sessionInfobean.getBrowserDetailsObj();
		ArrayList timeLst=new ArrayList();
		String ChartColrs = reportInfo.getChartColor("CITIX_USER_SESSION_VIEW");
		ArrayList colr=ErUtils.egTokenizer(ChartColrs, ",");
		String ChartColrsPie = reportInfo.getValue("CITIX_USER_SESSION_VIEW","PieChartColor");
		ArrayList piecolr=ErUtils.egTokenizer(ChartColrsPie, ",");
		String chartType=reportInfo.getValue("CITIX_USER_SESSION_VIEW","ApplicationChartType");
		if(chartType == null || chartType.length()==0)
			chartType="line";
		HashMap reMap=new HashMap();
		String parentId="";
		String tmpParentId="";
		HashMap parentIdMap=new HashMap();
		HashMap childMap=new HashMap();
		String childId="";
		JSONArray gridDataSubArray=new JSONArray();
		if(appInfoList!=null)
		{
			for(int k=0;k<appInfoList.size();k++)
			{
				ErApplicationInfoBean appInfoBean=(ErApplicationInfoBean)appInfoList.get(k);
				parentId=appInfoBean.getParentPid();
				childId=appInfoBean.getPid();
				double appCpuUtil=appInfoBean.getAppCpuUtil();
				double appMemoryUtil=appInfoBean.getAppMemoryUtil();
				String memeory = Double.toString(appMemoryUtil);
				String cpu = Double.toString(appCpuUtil);
				if(false)
				{
					ErApplicationInfoBean tmpBean=(ErApplicationInfoBean)reMap.get(parentId);
					ArrayList al=tmpBean.getMemoryLst();
					al.add(memeory);
					tmpBean.setMemoryLst(al);
					ArrayList cl=tmpBean.getCpuLst();
					cl.add(cpu);
					tmpBean.setCpuLst(cl);
					parentIdMap.put(parentId,tmpBean);
				}
				else
				{
					reMap.put(parentId,appInfoBean);
				}
				childMap.put(childId,parentId);
				tmpParentId=parentId;
			}
		}
		HashMap childParentMap=new HashMap();

		if(appInfoList!=null)
		{
			for(int k=0;k<appInfoList.size();k++)
			{
				ErApplicationInfoBean appInfoBean=(ErApplicationInfoBean)appInfoList.get(k);
				parentId=appInfoBean.getParentPid();
				childId=appInfoBean.getPid();
				double appCpuUtil=appInfoBean.getAppCpuUtil();
				double appMemoryUtil=appInfoBean.getAppMemoryUtil();
				String memeory = Double.toString(appMemoryUtil);
				String cpu = Double.toString(appCpuUtil);
				String desktopName=appInfoBean.getDeskTopName();
				if(desktopName == null){
					continue;
				}
				if(parentId!=null && childMap.containsKey(parentId))
				{
					ErApplicationInfoBean tmpBean=(ErApplicationInfoBean)reMap.get(parentId);
					if(tmpBean!=null)
					{
						ArrayList al=tmpBean.getMemoryLst();
						if(al==null || al.size()==0)
						al.add(Double.toString(tmpBean.getAppMemoryUtil()));
						al.add(memeory);
						tmpBean.setMemoryLst(al);
						ArrayList cl=tmpBean.getCpuLst();
						cl.add(cpu);
						tmpBean.setCpuLst(cl);
						parentIdMap.put(parentId,tmpBean);
						childParentMap.put(parentId,parentId);
					}
				}
				else if(parentId!=null && childMap.containsKey(childId))
				{
					ErApplicationInfoBean tmpBean=(ErApplicationInfoBean)reMap.get(childId);
					if(tmpBean!=null)
					{
						ArrayList al=tmpBean.getMemoryLst();
						if(al==null || al.size()==0)
						al.add(Double.toString(tmpBean.getAppMemoryUtil()));
						al.add(memeory);
						tmpBean.setMemoryLst(al);
						ArrayList cl=tmpBean.getCpuLst();
						cl.add(cpu);
						tmpBean.setCpuLst(cl);
						parentIdMap.put(parentId,tmpBean);
						childParentMap.put(parentId,parentId);
					}
				}
			}
		}

		parentId="";
		String subRow="";
		boolean isParentFound=false;
		HashMap hmTmp=new HashMap();
		HashMap idxTmp=new HashMap();
		boolean showLaunchDuratnCol=sessionInfobean.getApplaunchColumnState();;
		boolean enableApplnDurationColumn=false;
		boolean isAppIODetailsFound=sessionInfobean.getAppIOOperationState();
		if(appInfoList != null)
			enableApplnDurationColumn=es.getApplicationDurationDetails(appInfoList,currentDateFormat);
		if(appInfoList!=null)
		{
			boolean checkBrowsrActivty=false;
			String needBrowserDetailsForVMComp=reportInfo.getValue("CITIX_USER_SESSION_VIEW","needBrowserDetailsForVMComp");
			if(needBrowserDetailsForVMComp != null && needBrowserDetailsForVMComp.equalsIgnoreCase("yes") &&isVmComp && browserActivtyObj != null && browserActivtyObj.size() > 0){
				checkBrowsrActivty=true;
			}
			compType=sessionInfobean.getComponentType();
			String supportedBrowsers=reportInfo.getValue("CITIX_USER_SESSION_VIEW","SupportedBrowsers");
			String browserDetails = reportInfo.getValue("CITIX_USER_SESSION_VIEW","browserDetails");
			String measuresForGrid="WEBSITEURL,WEBSITETITLE";
			if(browserDetails != null && browserDetails.length() > 0){
				measuresForGrid=browserDetails;
			}
			ArrayList measrLst=erUtils.egTokenizer(measuresForGrid, ",");
			SimpleDateFormat applnDateFormat = new SimpleDateFormat(currentDateFormat+" HH:mm:ss");
			SimpleDateFormat browsrDteFrmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			EgTimeZoneConverter converterTimeZone = new EgTimeZoneConverter();
			for(int k=0;k<appInfoList.size();k++)
			{
				ErApplicationInfoBean appInfoBean=(ErApplicationInfoBean)appInfoList.get(k);
				String appName=appInfoBean.getAppName();
				String appLaunchTime=appInfoBean.getAppLaunchTime();
				String appEndTtime=appInfoBean.getAppEndTime();
				//TimeZone Conversion
				if(appLaunchTime!=null)
				{
					converterTimeZone.convertProcess(appLaunchTime,thisuser,false);
					appLaunchTime = converterTimeZone.getDateTime();
				}
				if(appEndTtime!=null)
				{
					converterTimeZone.convertProcess(appEndTtime,thisuser,false);
					appEndTtime = converterTimeZone.getDateTime();
				}
				double appCpuUtil=appInfoBean.getAppCpuUtil();
				double appMemoryUtil=appInfoBean.getAppMemoryUtil();
				String launchDuration=appInfoBean.getAppLaunchDuration();
				if(launchDuration!=null && launchDuration.length()>0 && !launchDuration.equals("-"))
				{
					launchDuration = erUtils.round(Double.parseDouble(launchDuration),4)+"";
				}
				else
				{
					launchDuration = "-";	
				}
				double appIoOperationsUtil=appInfoBean.getIoOperations();
				SimpleDateFormat frmt = new SimpleDateFormat(currentDateFormat+" HH:mm:ss");
				long diff =1;
				long diffMinutes =1;
				try{
					Date dte=frmt.parse(appLaunchTime);
				}catch(Exception e){
					frmt = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss");
				}
				try {
					Date d1=frmt.parse(appLaunchTime);
					Date d2=frmt.parse(appEndTtime);
					diff = d2.getTime() - d1.getTime();
					diffMinutes = Math.abs(diff / (60 * 1000));
				}
				catch (Exception e) {}
				parentId=appInfoBean.getParentPid();
				childId=appInfoBean.getPid();
				if((parentIdMap!=null && parentIdMap.containsKey(parentId))||( childParentMap.containsKey(childId)))
				{
					if(!isParentFound && !hmTmp.containsKey(parentId) && !hmTmp.containsKey(childId))
					{
						ErApplicationInfoBean parentBean=null;
						if(parentIdMap.containsKey(parentId))
						{
							parentBean=(ErApplicationInfoBean)parentIdMap.get(parentId);
						}
						else
						{
							if(childParentMap!=null)
							{
								String pId=(String)childParentMap.get(childId);
								parentBean=(ErApplicationInfoBean)parentIdMap.get(pId);
							}
						}
						gridDataSubArray.add(parentBean.getDeskTopName());
						gridDataSubArray.add(parentBean.getAppLaunchTime());
						if(enableApplnDurationColumn){
							if(diffMinutes <= 0){
								gridDataSubArray.add("-");
								gridDataSubArray.add("-");
							}else{
								gridDataSubArray.add(parentBean.getAppEndTime());
								gridDataSubArray.add(diffMinutes);
							}
						}
						String memoryAvg=erUtils.calculateAvg(parentBean.getMemoryLst());
						String cpuAvg=erUtils.calculateAvg(parentBean.getCpuLst());
						if(showLaunchDuratnCol)
							gridDataSubArray.add(launchDuration);
						gridDataSubArray.add(cpuAvg);
						gridDataSubArray.add(memoryAvg);
						if(isAppIODetailsFound)
							gridDataSubArray.add(appIoOperationsUtil);
					}
					isParentFound=true;
					if(subRow.length()!=0)
						subRow+="#";
					if(showLaunchDuratnCol)
						subRow+=appName+"$"+appLaunchTime+"$"+appEndTtime+"$"+diffMinutes+"$"+launchDuration+"$"+erUtils.round(appCpuUtil,4)+"$"+erUtils.round(appMemoryUtil,4);
					else
						subRow+=appName+"$"+appLaunchTime+"$"+appEndTtime+"$"+diffMinutes+"$"+erUtils.round(appCpuUtil,4)+"$"+erUtils.round(appMemoryUtil,4);
					if(isAppIODetailsFound)
						subRow+="$"+erUtils.round(appIoOperationsUtil,4);
					hmTmp.put(parentId,subRow);
					continue;
				}
				else if( !hmTmp.containsKey(parentId) && !hmTmp.containsKey(childId))
				{		
					if(isParentFound)
					{
						gridDataSubArray.add(subRow);
						if(gridDataSubArray!=null && gridDataSubArray.size()>0)
						{
							gridDataArray.add(gridDataSubArray);
							idxTmp.put(parentId,idx);
							idx++;
						}
						gridDataSubArray=new JSONArray();
						gridDataSubArray.add(appName);
							gridDataSubArray.add(appLaunchTime);
						if(enableApplnDurationColumn){
							if(diffMinutes <= 0){
								gridDataSubArray.add("-");
								gridDataSubArray.add("-");
							}else{
								gridDataSubArray.add(appEndTtime);
								gridDataSubArray.add(diffMinutes);
							}
						}
						if(showLaunchDuratnCol)
							gridDataSubArray.add(launchDuration);
						gridDataSubArray.add(appCpuUtil);
						gridDataSubArray.add(appMemoryUtil);
						if(isAppIODetailsFound)
						gridDataSubArray.add(appIoOperationsUtil);
						if(gridDataSubArray!=null && gridDataSubArray.size()>0)
						{
							gridDataArray.add(gridDataSubArray);
							idx++;
						}
					}
					else
					{
						gridDataSubArray.add(appName);
						gridDataSubArray.add(appLaunchTime);
						if(enableApplnDurationColumn){
							if(diffMinutes <= 0){
								gridDataSubArray.add("-");
								gridDataSubArray.add("-");
							}else{
								gridDataSubArray.add(appEndTtime);
								gridDataSubArray.add(diffMinutes);
							}
						}
						if(showLaunchDuratnCol)
							gridDataSubArray.add(launchDuration);
						gridDataSubArray.add(appCpuUtil);
						gridDataSubArray.add(appMemoryUtil);
						if(isAppIODetailsFound)
							gridDataSubArray.add(appIoOperationsUtil);

						if(checkBrowsrActivty)
						{
							if(appName!=null && appName.indexOf("Google Chrome")>-1)
								appName = "Chrome";

							if(((supportedBrowsers.toLowerCase()).indexOf(appName.toLowerCase())) > -1){
								String keyId=childId;
								if(keyId != null && keyId.indexOf(".") > -1)
									keyId=keyId.substring(0,keyId.indexOf("."));
								String tmpkey=appName;
	//							String tmpkey=appName+"#"+keyId;
								if(browserActivtyObj.containsKey(tmpkey)){
									JSONObject tmpObject=(JSONObject)browserActivtyObj.get(tmpkey);
									if(tmpObject != null && tmpObject.size() > 0){
										JSONObject addtnlDat=es.getApplicationDetails(tmpObject,appLaunchTime,appEndTtime,measrLst,applnDateFormat,browsrDteFrmt);
										gridDataSubArray.add(addtnlDat);
									}
								}
							}
						}
						if(gridDataSubArray!=null && gridDataSubArray.size()>0)
						{
							gridDataArray.add(gridDataSubArray);
							idx++;
						}
					}
				}
				subRow="";
				isParentFound=false;
				gridDataSubArray=new JSONArray();
			}
		}
		if(idxTmp.size()==0)
		{
			if(isParentFound)
			{
				gridDataSubArray.add(subRow);
			}
			if(gridDataSubArray!=null && gridDataSubArray.size()>0)
			{
				gridDataArray.add(gridDataSubArray);
			}
		}
		Set ky=	hmTmp.keySet();
		Iterator iky=ky.iterator();
		while(iky.hasNext())
		{
			String str=(String)iky.next();
			String val=(String)hmTmp.get(str);
			if(idxTmp.containsKey(str))
			{
				Integer indexx=(Integer)idxTmp.get(str);
				JSONArray tmpArr=(JSONArray)	gridDataArray.get(indexx);
				if(tmpArr!=null)
				{
					String strTmp=(String)tmpArr.get(5);
					strTmp+="#";
					strTmp+=val;
					tmpArr.set(5,strTmp);
					gridDataArray.set(indexx,tmpArr);
				}
			}
		}

		if(appInfoList!=null){
			compType=sessionInfobean.getComponentType();
			headerObject.add("Name");
			headerObject.add("Start Time");
			if(enableApplnDurationColumn){
				headerObject.add("End Time");
				headerObject.add("<div>Duration</div><div style='text-align:center'>(Mins)</div>");
			}
			if(showLaunchDuratnCol)
				headerObject.add("<div>Launch Time</div><div style='text-align:center'>(Secs)</div>");
			headerObject.add("<div>Cpu Util</div><div style='text-align:center'>(%)</div>");
			if(isVmComp)
				headerObject.add("<div>Memory Util</div><div style='text-align:center'>(MB)</div>");
			else
				headerObject.add("<div>Memory Util</div><div style='text-align:center'>(%)</div>");
			if(isAppIODetailsFound)
				headerObject.add("<div>IO Operations</div><div style='text-align:center'>(KB/Sec)</div>");
			rootJson.put("dataArray",gridDataArray);
			rootJson.put("columns",headerObject);
		}
		if(appInfoList!=null)
		{
			int colrcnt=0;
			for(int k=0;k<appInfoList.size();k++)
			{
				if(colrcnt == colr.size()-1){
					colrcnt=0;
				}
				ErApplicationInfoBean appInfoBean=(ErApplicationInfoBean)appInfoList.get(k);
				String appName=appInfoBean.getAppName();
				String appLaunchTime=appInfoBean.getAppLaunchTime();
				String appEndTtime=appInfoBean.getAppEndTime();
				double appCpuUtil=appInfoBean.getAppCpuUtil();
				double appMemoryUtil=appInfoBean.getAppMemoryUtil();
				String launchDuration=appInfoBean.getAppLaunchDuration();
				if(launchDuration!=null && launchDuration.length()>0 && !launchDuration.equals("-"))
				{
					launchDuration = erUtils.round(Double.parseDouble(launchDuration),4)+"";
				}
				else
				{
					launchDuration = "-";	
				}
				double appIoOperationsUtil=appInfoBean.getIoOperations();
				parentId=appInfoBean.getParentPid();
				seqRow=new JSONArray();
				memeoryRow=new JSONArray();
				cpuRow=new JSONArray();
				HashMap applicationResourceMap=appInfoBean.getResourceMapforGraph();
				TreeMap tmpMap=null;
				if(applicationResourceMap != null && applicationResourceMap.size() > 0)
				{
					JSONObject timeValueMap=(JSONObject)applicationResourceMap.get("MEMORY");
					tmpMap=new TreeMap(timeValueMap);
					Iterator itr = tmpMap.keySet().iterator();
					while(itr.hasNext()){
						JSONArray rowData=new JSONArray();
						String msmt_time = (String) itr.next();
						String value=(String)timeValueMap.get(msmt_time);
						if(value != null && value.indexOf("#") > -1){
							String sumVal=value.substring(0,value.indexOf("#"));
							String sumCnt=value.substring(value.indexOf("#")+1);
							double sumvalue=Double.parseDouble(sumVal);
							int sumcount=Integer.parseInt(sumCnt);
							if(sumcount > 0)
								sumvalue=sumvalue/sumcount;
							value=String.valueOf(sumvalue);
						}
						Date tempDate = sdf.parse(msmt_time);
						rowData.add(tempDate.getTime());
						rowData.add(Double.valueOf(value));
						seqRow.add(rowData);
						timeLst.add(tempDate.getTime());
					}
					JSONObject s1=new JSONObject();
					s1.put("name",appName);
					s1.put("data",seqRow);
					s1.put("color",(String)colr.get(colrcnt));
					appMemoryDataSet.add(s1);
					memeoryRow=seqRow;
					seqRow=new JSONArray();
					timeValueMap=(JSONObject)applicationResourceMap.get("CPU");
					tmpMap=new TreeMap(timeValueMap);
					if(timeValueMap!=null  &&  timeValueMap.size() > 0){
						itr = tmpMap.keySet().iterator();
						while(itr.hasNext())
						{
							JSONArray rowData=new JSONArray();
							String msmt_time = (String) itr.next();
							String value=(String)timeValueMap.get(msmt_time);
							if(value != null && value.indexOf("#") > -1){
								String sumVal=value.substring(0,value.indexOf("#"));
								String sumCnt=value.substring(value.indexOf("#")+1);
								double sumvalue=Double.parseDouble(sumVal);
								int sumcount=Integer.parseInt(sumCnt);
								if(sumcount > 0)
									sumvalue=sumvalue/sumcount;
								value=String.valueOf(sumvalue);
							}
							Date tempDate = sdf.parse(msmt_time);
							rowData.add(tempDate.getTime());
							rowData.add(Double.valueOf(value));
							seqRow.add(rowData);
							timeLst.add(tempDate.getTime());
						}
						JSONObject s2=new JSONObject();
						s2.put("name",appName);
						s2.put("data",seqRow);
						s2.put("color",(String)colr.get(colrcnt));
						appCpuDataSet.add(s2);
						cpuRow=seqRow;
					}
					seqRow=new JSONArray();	
					timeValueMap=(JSONObject)applicationResourceMap.get("IO");
					if(timeValueMap!=null &&  timeValueMap.size() > 0)
					{
						tmpMap=new TreeMap(timeValueMap);
						itr = tmpMap.keySet().iterator();
						while(itr.hasNext())
						{
							JSONArray rowData=new JSONArray();
							String msmt_time = (String) itr.next();
							String value=(String)timeValueMap.get(msmt_time);
							if(value != null && value.indexOf("#") > -1){
								String sumVal=value.substring(0,value.indexOf("#"));
								String sumCnt=value.substring(value.indexOf("#")+1);
								double sumvalue=Double.parseDouble(sumVal);
								int sumcount=Integer.parseInt(sumCnt);
								if(sumcount > 0)
									sumvalue=sumvalue/sumcount;
								value=String.valueOf(sumvalue);
							}
							Date tempDate = sdf.parse(msmt_time);
							rowData.add(tempDate.getTime());
							rowData.add(Double.valueOf(value));
							seqRow.add(rowData);
							timeLst.add(tempDate.getTime());
						}
						JSONObject s3=new JSONObject();
						s3.put("name",appName);
						s3.put("data",seqRow);
						s3.put("color",(String)colr.get(colrcnt));
						appIODataSet.add(s3);
						rootJson.put("ioGraphenabled","true");
					}
					else{
						rootJson.put("ioGraphenabled","false");
					}
				}
				colrcnt++;	
			}
			String strLineWidth = "2";
			int AppCount =0;
			try
			{
				AppCount = Integer.parseInt(sessionInfobean.getUniqueApplicationsCnt());
			}
			catch(Exception e){}
			if(sessionInfobean!=null &&  AppCount>5)
				strLineWidth = "1";
			if(appMemoryDataSet!=null && appMemoryDataSet.size()>0)
			{
				memoryApplicationGraph.put("DataSet",appMemoryDataSet);	
				memoryApplicationGraph.put("chartType",chartType);
				memoryApplicationGraph.put("LegendPosition","top");
				memoryApplicationGraph.put("LineWidth",strLineWidth);
				memoryApplicationGraph.put("showLegends","true");
				memoryApplicationGraph.put("lowerLimit",Collections.min(timeLst));
				memoryApplicationGraph.put("higherLimit",Collections.max(timeLst));
				memoryApplicationGraph.put("TimeFormatOut","HH:mm");
				memoryApplicationGraph.put("timeScale","30");
				memoryApplicationGraph.put("yAxisLabelYval","21");
				memoryApplicationGraph.put("showdisconnectedline","Yes");
				memoryApplicationGraph.put("legend",true);
				memoryApplicationGraph.put("legend","true");
				memoryApplicationGraph.put("showLegend",true);
				memoryApplicationGraph.put("reflow",false);
				memoryApplicationGraph.put("showLegend","true");
				memoryApplicationGraph.put("showLegendsEnable",true);
				memoryApplicationGraph.put("legendFontSize","true");
				memoryApplicationGraph.put("showLegendsEnable","11");
				memoryApplicationGraph.put("yLabel","%");
//				memoryApplicationGraph.put("xLabel","Hours");
				memoryApplicationGraph.put("disbleSpacing","true");
				tmpObj=chrt.getChartLegendDatas(memoryApplicationGraph);
				memoryApplicationGraph.put("ShowLegendinTableFormatforUIData",tmpObj);
				memoryApplicationGraph.put("ShowLegendinTableFormatforUI","yes");
				rootJson.put("memoryApplicationGraph",memoryApplicationGraph);
				rootJson.put("memoryGraphDataFound","true");
			}
			else
			{
				rootJson.put("memoryGraphDataFound","false");
			}
			if(appCpuDataSet!=null && appCpuDataSet.size()>0)
			{
				cpuApplicationGraph.put("DataSet",appCpuDataSet);
				cpuApplicationGraph.put("LegendPosition","top");
				cpuApplicationGraph.put("chartType",chartType);
				cpuApplicationGraph.put("showLegends","true");
				cpuApplicationGraph.put("LineWidth",strLineWidth);
				cpuApplicationGraph.put("lowerLimit",Collections.min(timeLst));
				cpuApplicationGraph.put("higherLimit",Collections.max(timeLst));
				cpuApplicationGraph.put("TimeFormatOut","HH:mm");
				cpuApplicationGraph.put("timeScale","30");
				cpuApplicationGraph.put("reflow",false);
				cpuApplicationGraph.put("yAxisLabelYval","21");
				cpuApplicationGraph.put("showdisconnectedline","Yes");
//				cpuApplicationGraph.put("xLabel","Hours");
				cpuApplicationGraph.put("yLabel","%");
				cpuApplicationGraph.put("disbleSpacing","true");
				tmpObj=chrt.getChartLegendDatas(cpuApplicationGraph);
				cpuApplicationGraph.put("ShowLegendinTableFormatforUIData",tmpObj);
				cpuApplicationGraph.put("ShowLegendinTableFormatforUI","yes");
				rootJson.put("cpuApplicationGraph",cpuApplicationGraph);
				rootJson.put("cpuGraphDataFound","true");
			}
			else
			{
				rootJson.put("cpuGraphDataFound","false");
			}
			if(appIODataSet!=null && appIODataSet.size()>0)
			{
				ioApplicationGraph.put("DataSet",appIODataSet);
				ioApplicationGraph.put("LegendPosition","top");
				ioApplicationGraph.put("chartType",chartType);
				ioApplicationGraph.put("showLegends","true");
				ioApplicationGraph.put("LineWidth",strLineWidth);
				ioApplicationGraph.put("lowerLimit",Collections.min(timeLst));
				ioApplicationGraph.put("higherLimit",Collections.max(timeLst));
				ioApplicationGraph.put("TimeFormatOut","HH:mm");
				ioApplicationGraph.put("timeScale","30");
				ioApplicationGraph.put("reflow",false);
				ioApplicationGraph.put("yAxisLabelYval","21");
				ioApplicationGraph.put("showdisconnectedline","Yes");
				ioApplicationGraph.put("yLabel","KB/Sec");
//				ioApplicationGraph.put("xLabel","Hours");
				tmpObj=chrt.getChartLegendDatas(ioApplicationGraph);
				ioApplicationGraph.put("ShowLegendinTableFormatforUIData",tmpObj);
				ioApplicationGraph.put("ShowLegendinTableFormatforUI","yes");
				rootJson.put("ioApplicationGraph",ioApplicationGraph);
				rootJson.put("ioGraphDataFound","true");
			}
			else
			{
				rootJson.put("ioGraphDataFound","false");
			}
		}
		rootJson.put("IsVm",new Boolean(isVmComp));
		session.setAttribute("DRILLDOWN_PDF_URL", mngrIProc+"/final/reporter/ErUsersessionReportPrint.jsp;jsessionid="+session.getId());
		session.setAttribute("DRILLDOWN_MAIL_URL", mngrIProc+"/final/reporter/ErUsersessionReportPrint.jsp;jsessionid="+session.getId()+"?index="+index+"&pdf=yes&er_RmDispName=UserSessionDetails");
		HashMap pdfFileName =new HashMap();
		pdfFileName.put("fileName","User_Session_Details");
		session.setAttribute("parameters", pdfFileName);
		
		boolean showActiveIdleGraph=false;
		String enableActiveIdleGraph=reportInfo.getValue("CITIX_USER_SESSION_VIEW","enableActiveIdleGraph");
		if(enableActiveIdleGraph != null && enableActiveIdleGraph.equalsIgnoreCase("yes"))
		{
			JSONObject sessionidleTime=sessionInfobean.getSessionTimeMap();

			if(sessionidleTime != null && sessionidleTime.size() > 0){
				Iterator resoucrItr = sessionidleTime.keySet().iterator();
				JSONArray datasetArr=new JSONArray();
				JSONArray tmpdatasetArr=new JSONArray();
				ArrayList Xlabl=new ArrayList();
				ArrayList timeLstChk=new ArrayList();
				JSONObject obj=new JSONObject();

				while(resoucrItr.hasNext())
				{
					String key = (String) resoucrItr.next();
					int yVal=0;
					if(key != null && key.equalsIgnoreCase("ActiveTime"))
						yVal=1;
					JSONArray rMap=(JSONArray)sessionidleTime.get(key);
					if(rMap != null && rMap.size() % 2 == 0){
						for(int l=0;l<rMap.size();l+=2){
							SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							java.util.Date dt = formatter.parse((String)rMap.get(l));
							java.util.Date dt2 = formatter.parse((String)rMap.get(l+1));

							if(!timeLstChk.contains(dt))
								timeLstChk.add(dt);
							if(!timeLstChk.contains(dt2))
								timeLstChk.add(dt2);

							obj=new JSONObject();
							obj.put("x",(new Long(dt.getTime())));
							obj.put("x2",(new Long(dt2.getTime())));
							obj.put("y",yVal);
							if(yVal == 1)
								obj.put("color","#69c7b3");
							else
								obj.put("color","#f49242");

							obj.put("partialFill",new Integer(0));
							datasetArr.add(obj);
						}
					}
				}
				if(datasetArr != null && datasetArr.size() > 0){
					JSONObject activeIdleGraph=new JSONObject();
					if(timeLstChk != null && timeLstChk.size() > 0){
						Collections.sort(timeLstChk);
						long diffMinutes=0; 
						try{
							Date stDatee=(Date)timeLstChk.get(0);
							Date enDatee=(Date)timeLstChk.get(timeLstChk.size()-1);
							long diff = enDatee.getTime() - stDatee.getTime();
							diffMinutes = Math.abs(diff / (60 * 1000));
						}
						catch (Exception e) {
							e.printStackTrace();
						}
						if(diffMinutes > 0 && diffMinutes <= 180){
							long intrvlVal=(diffMinutes/10);
							int tickIntrval=(int)intrvlVal;
							if(intrvlVal >= 3&& intrvlVal <=5 )
								 tickIntrval=5;
							else if(intrvlVal > 5 && intrvlVal <=10 )
								tickIntrval=10;
							else  if(intrvlVal > 10&& intrvlVal <=15 )
								tickIntrval=15;
							else if(intrvlVal > 15)
								tickIntrval=20;
							activeIdleGraph.put("tickIntervalValue",(tickIntrval*60000));
						}
					}
					Xlabl.add("Idle");
					Xlabl.add("Active");
					obj=new JSONObject();
					obj.put("data",datasetArr);
					obj.put("pointWidth",new Integer(20));
					tmpdatasetArr.add(obj);
					activeIdleGraph.put("xRangeArry",Xlabl);
					activeIdleGraph.put("DataSet",tmpdatasetArr);
					activeIdleGraph.put("chartType","xrange");
					rootJson.put("XRange_Graph",activeIdleGraph);
					showActiveIdleGraph=true;
				}
			}
		}
		rootJson.put("showActiveIdleGraph",showActiveIdleGraph);
		HashMap resourceMapTmp=sessionInfobean.getSessionResourceMap();
		String fromPage="JSON";
		JSONArray resourceGraphDatas=es.getResourceGraphData(resourceMapTmp,compType,reportInfo,fromPage,null);
		rootJson.put("resourceGraphArrayNEW",resourceGraphDatas);


		boolean isSessionDataFound=false;
		JSONObject logonDetailInfos=sessionInfobean.getLogonDataMap();
		JSONObject logonDetailInfo=sessionInfobean.getLogonDataMapforPie();
		JSONArray logonGPDetailInfo=sessionInfobean.getGPLogonDetails();
		String compontType=sessionInfobean.getComponentType();
		if(logonGPDetailInfo != null && logonGPDetailInfo.size() > 0){
			String strTestName=sessionInfobean.getTestName();
			JSONArray headerArray=new JSONArray();
			if(strTestName != null && strTestName.length() > 0){
				if(strTestName != null){
					if(strTestName.indexOf("_DDD") == -1)
						strTestName=strTestName+"_DDD";
					String measrData=reportInfo.getValue("CITIX_USER_SESSION_VIEW",strTestName+"_GPDuration_Splitup");
					if(measrData != null && measrData.length() > 0){
						ArrayList colmnLst=ErUtils.egTokenizer(measrData, ",");
						for(int z=0;z<colmnLst.size();z++){
							String strTmp=(String)colmnLst.get(z);
							if(strTmp != null && strTmp.indexOf("#") > -1)
								strTmp=strTmp.substring(strTmp.indexOf("#")+1);
							headerArray.add(strTmp);
						}
					}
				}
			}
			JSONObject obj=new JSONObject();
			obj.put("header",headerArray);
			obj.put("dataArray",logonGPDetailInfo);
			rootJson.put("GPDetails",obj);
		}
	// user logon graph 
		String logonBrkdwnTabl=reportInfo.getValue("CITIX_USER_SESSION_VIEW","LogonDetailsBreakdown");
		String logonBrkdwnData=reportInfo.getValue("CITIX_USER_SESSION_VIEW","Details:"+logonBrkdwnTabl);
		String logonBrkdwnInnerData=reportInfo.getValue("CITIX_USER_SESSION_VIEW","Details:"+logonBrkdwnTabl+":innerMeasure");
		JSONObject userLogonGraphObj=new JSONObject();
		JSONArray logonArr=new JSONArray();
		int colrcunt=0;
		HashMap legMap=new HashMap();
		ArrayList legTmpArray=null;
		ArrayList innerMeasrKeysList=null;
		if(logonBrkdwnInnerData != null && logonBrkdwnInnerData.length() > 0){
			StringTokenizer strtk=new StringTokenizer(logonBrkdwnInnerData,"$");
			innerMeasrKeysList=new ArrayList();
			while(strtk.hasMoreTokens()){
				String strTmp=(String)strtk.nextToken();
				String innrMeasr = "";
				if(strTmp != null && strTmp.indexOf("^eG^") > -1){
					innrMeasr=strTmp.substring(0,strTmp.indexOf("^eG^"));
					strTmp=strTmp.substring(strTmp.indexOf("^eG^")+4);
					legTmpArray=ErUtils.egTokenizer(strTmp, ",");
					if(legTmpArray != null && legTmpArray.size() > 0){
						innerMeasrKeysList.addAll(legTmpArray);
						legMap.put(innrMeasr,legTmpArray);
					}
				}
			}
		}
		boolean islegCheckneeded=false;
		if(legMap != null && legMap.size() > 0)
			islegCheckneeded=true;

		if(logonDetailInfo != null && logonDetailInfo.size() > 0 && logonBrkdwnData != null && logonBrkdwnData.length() > 0)
		{
			ArrayList logonBrkdwnDataLst=ErUtils.egTokenizer(logonBrkdwnData, ",");
			JSONObject obj=null;
			ArrayList innerMeasrKeys=new ArrayList();
			if(logonBrkdwnDataLst != null && logonBrkdwnDataLst.size() > 0){
				for(int k=0;k<logonBrkdwnDataLst.size();k++){
					if(colrcunt == piecolr.size()-1){
						colrcunt=0;
					}
					String tmpStr=(String)logonBrkdwnDataLst.get(k);
					if(innerMeasrKeysList != null && innerMeasrKeysList.contains(tmpStr)){
						continue;
					}
					boolean needtoAddInnerMeasure=false;
					ArrayList tmpList=null;
					if(islegCheckneeded && legMap.containsKey(tmpStr)){
						tmpList=(ArrayList)legMap.get(tmpStr);
						if(tmpList != null && tmpList.size() > 0)
							needtoAddInnerMeasure=true;
					}
					String strDisp=tmpStr;
					if(tmpStr != null && tmpStr.indexOf("#") > -1){
						strDisp=tmpStr.substring(tmpStr.indexOf("#")+1);
						tmpStr=tmpStr.substring(0,tmpStr.indexOf("#"));
					}else if(logonBrkdwnTabl != null && logonBrkdwnTabl.length() > 0){
						strDisp=intlmap.getMeasureDescription(logonBrkdwnTabl,tmpStr);
					}
					if(tmpStr!=null && (tmpStr.equalsIgnoreCase("Logon duration") || tmpStr.equalsIgnoreCase("Logon_duration")))
						continue;
					String value="0";
					if(logonDetailInfo.containsKey(tmpStr))
						value=(String)logonDetailInfo.get(tmpStr);

					obj=new JSONObject();
					obj.put("name",strDisp);
					obj.put("y",Double.parseDouble(value));
					obj.put("color",(String)piecolr.get(colrcunt));
					if(needtoAddInnerMeasure){
						JSONArray innerArray=new JSONArray();
						JSONObject innerObj=null;
						for(int l=0;l<tmpList.size();l++){
							tmpStr=(String)tmpList.get(l);
							if(innerMeasrKeys != null && !innerMeasrKeys.contains(tmpStr))
								innerMeasrKeys.add(tmpStr);
							strDisp=tmpStr;
							if(tmpStr != null && tmpStr.indexOf("#") > -1){
								strDisp=tmpStr.substring(tmpStr.indexOf("#")+1);
								tmpStr=tmpStr.substring(0,tmpStr.indexOf("#"));
							}else if(logonBrkdwnTabl != null && logonBrkdwnTabl.length() > 0){
								strDisp=intlmap.getMeasureDescription(logonBrkdwnTabl,tmpStr);
							}
							if(tmpStr!=null && (tmpStr.equalsIgnoreCase("Logon duration") || tmpStr.equalsIgnoreCase("Logon_duration")))
								continue;
							value="0";
							if(logonDetailInfo.containsKey(tmpStr))
								value=(String)logonDetailInfo.get(tmpStr);
							innerObj=new JSONObject();
							innerObj.put("name",strDisp);
							innerObj.put("y",Double.parseDouble(value));
							innerArray.add(innerObj);
						}
						if(innerArray != null && innerArray.size() > 0)
							obj.put("innerArray",innerArray);
					}
					logonArr.add(obj);
					colrcunt++;
				}
			}
		}
		JSONObject dataObj=new JSONObject();
		dataObj.put("data",logonArr);
		JSONArray dataSetArr=new JSONArray();
		dataSetArr.add(dataObj);
		userLogonGraphObj.put("chartTitle","Distribution of Logon Duration");
		userLogonGraphObj.put("chartType","donut");
		userLogonGraphObj.put("chartHeight","200");
		userLogonGraphObj.put("chartWidth","200");
		userLogonGraphObj.put("pieSize","100%");
		userLogonGraphObj.put("innerSize","55%");
		userLogonGraphObj.put("legend",false);
//		userLogonGraphObj.put("pieLabels",pieLabels);
//		userLogonGraphObj.put("pieColors",pieColors);
		userLogonGraphObj.put("title","<div align='center'><div style='font-size:23px;font-family:Roboto;'>"+sessionInfobean.getLogonTime()+"</div><div style='margin-top: -5px;font-size:11px;font-family:Roboto;'>Secs</div></div>");
		userLogonGraphObj.put("isDataLabelEnabled",false);
		if(logonArr!=null && logonArr.size()==0)
		{
			userLogonGraphObj.put("NoDataFound","true");
			rootJson.put("isSummaryDataFound","false");
		}
		else
		{
			userLogonGraphObj.put("NoDataFound","false");
			userLogonGraphObj.put("DataSet",dataSetArr);
			rootJson.put("isSummaryDataFound","true");
		}
		if(logonDetailInfos == null || logonDetailInfos.size() == 0){
			rootJson.put("islogonDetailInfofound","false");
		}else{
			rootJson.put("islogonDetailInfofound","true");
		}
		
		if(logonDetailInfos != null && logonDetailInfos.size() > 0) {
			String tstName=sessionInfobean.getTestName();

			String loginTime=(String)Report_data.get("login_time");
			String logoutTime=(String)Report_data.get("msmttime");
			String trgt_host=(String)Report_data.get("trgt_host");
			String port="NULL";
			if(trgt_host != null && trgt_host.indexOf(":") > -1){
				port=trgt_host.substring(trgt_host.indexOf(":")+1);
				trgt_host=trgt_host.substring(0,trgt_host.indexOf(":"));
			}
//				String currentDateFormat = strUserDateFormat;
			SimpleDateFormat sdf3=new SimpleDateFormat(currentDateFormat);
	//			String tmpStartTime =login_time;
			logoutTime = DateUtil.changeDateFormat(logoutTime,"dd-MM-yyyy HH:mm:ss","MM/dd/yyyy HH:mm:ss");
			Date tempDate = new Date(loginTime);


			String strt_Time=sdf3.format(tempDate);
			int strt_Min=tempDate.getMinutes();
			int strt_Hr=tempDate.getHours();
			tempDate = new Date(logoutTime);
			String end_Time=sdf3.format(tempDate);
			int end_Min=tempDate.getMinutes();
			int end_Hr=tempDate.getHours();
			if(strt_Time != null )
				strt_Time=com.eg.EgURLEncoder.encode(strt_Time,"UTF-8");
			if(end_Time != null )
				end_Time=com.eg.EgURLEncoder.encode(end_Time,"UTF-8");
			String infName="*"+userName;
			if(isVmComp)
				infName+="_on_"+sessionInfobean.getDesktopName();
			String dispMeasr=reportInfo.getValue("CITIX_USER_SESSION_VIEW",tstName);

			// need to change measureDisp,start & end Time  & (test) based on request
			rootJson.put("gpDurationQuery","/final/monitor/componentMeasureTabSet.jsp?type="+compType+"&site=NULL&host="+trgt_host+"&port="+port+"&info="+com.eg.EgURLEncoder.encode(infName,"UTF-8")+"&starttime="+strt_Time+"&endtime="+end_Time+"&starthr="+strt_Hr+"&endhr="+end_Hr+"&startmin="+strt_Min+"&endmin="+end_Min+"&userID="+usr_Id+"&test="+tstName+"&comptype="+compType+"&measureDisp="+dispMeasr+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=UserSessionDetails");
		}
		if(logonDetailInfos != null && logonDetailInfos.size() > 0){
			rootJson.put("logonDetailInfo",logonDetailInfos);
		}

		rootJson.put("userLogonGraphObj",userLogonGraphObj);
		String logonDuration=sessionInfobean.getLogonDuration();
		if(logonDuration == null || logonDuration.equalsIgnoreCase("")){
			logonDuration="-";
		}
		else{
			logonDuration=logonDuration+"<span class='newFont_normal11'>&nbsp;secs</span>";
		}

		// session info
		
		EgTimeZoneConverter time_converter = new EgTimeZoneConverter();
		String start_time = (String)sessionInfobean.getSessionStartTime();

		time_converter.convertProcess(start_time,thisuser,false);
		start_time = time_converter.getDateTime();
		
		JSONObject sInfo=new JSONObject();
		sInfo.put("trgtHost",sessionInfobean.getTrgtHost());
		sInfo.put("sessionStartTime",start_time);
		sInfo.put("clientIp",sessionInfobean.getClientIp());
		sInfo.put("clientName",sessionInfobean.getClientName());
		sInfo.put("sessionDuration",sessionInfobean.getSessionDuration());
		sInfo.put("idleTime",sessionInfobean.getIdleTimeinDayWise());
		sInfo.put("totalDuraion",sessionInfobean.getSessionDurationinDaywise());
		sInfo.put("activeTime",sessionInfobean.getActiveTimeinDayWise());
		sInfo.put("uniqueApplicationsCnt",sessionInfobean.getUniqueApplicationsCnt());
		sInfo.put("uniqueApplications",sessionInfobean.getUniqueApplications());
		sInfo.put("logonDuraion",logonDuration);
		sInfo.put("ComponentType",sessionInfobean.getComponentType());
		sInfo.put("DesktopName",sessionInfobean.getDesktopName());
		String strTestName=sessionInfobean.getTestName();
		ArrayList tableColumnsLst=new ArrayList(Arrays.asList(dbInfo.getMeasurementsForTest(strTestName)));
		String logTit="Session Start-up Duration";
		if(tableColumnsLst != null && tableColumnsLst.contains("Logon_duration")){
			logTit=intlmap.getMeasureDescription(strTestName,"Logon_duration");
		}
		sInfo.put("logonTitle",logTit);
		rootJson.put("sessionInfo",sInfo);
		JSONArray logonArray=new JSONArray();
		JSONObject objct=new JSONObject();
		
		int idleTime=Integer.parseInt((String)sessionInfobean.getIdleTime());
		objct.put("name","idleTime");
		objct.put("y",idleTime);
		objct.put("color","#f49242");
		logonArray.add(objct);
		objct=new JSONObject();
		int actveTime=Integer.parseInt((String)sessionInfobean.getActiveTime());
		objct.put("name","activeTime");
		objct.put("y",actveTime);
		objct.put("color","#69c7b3");
		logonArray.add(objct);

		JSONObject dataObject=new JSONObject();
		dataObject.put("data",logonArray);
		JSONArray dataSetArray=new JSONArray();
		dataSetArray.add(dataObject);
		
		JSONObject sessionTimeGraph=new JSONObject();	 
		sessionTimeGraph.put("DataSet",dataSetArray);
		sessionTimeGraph.put("legend",true);
		sessionTimeGraph.put("type","bar");
		String strTitle="<div class='donutChartTitleOuter'><div class='donutChartTitleMiddle'>"+sessionInfobean.getSessionDuration()+"</div><div class='newFont_normal13' style='margin-top:-2px'>Duration</div><div class='newFont_normal10'>(mins)</div></div>";
		sessionTimeGraph.put("title",strTitle);
		sessionTimeGraph.put("pieSize","120%");
		sessionTimeGraph.put("innerSize","65%");
		sessionTimeGraph.put("chartHeight", "160");
		sessionTimeGraph.put("chartWidth", "200");
		sessionTimeGraph.put("isShadowEnable",false);
		sessionTimeGraph.put("chartType","donut");
		
		rootJson.put("sessionTimeGraph",sessionTimeGraph);
		rootJson.put("noDataFound","false");
	}
	else{
		rootJson.put("noDataFound","true");
	}
	out.println(rootJson.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
%>