<%@page contentType="text/html;  charset=UTF-8;" pageEncoding="UTF-8"  %>

<%@page import="java.io.ByteArrayInputStream" %>
<%@page import="java.io.ByteArrayOutputStream" %>
<%@page import="java.io.File" %>
<%@page import="java.io.IOException" %>
<%@page import="java.io.InputStream" %>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %>
<%@page import="org.apache.commons.fileupload.FileItemFactory" %>
<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
<%@page import="org.apache.commons.fileupload.FileItem" %>
<%@page import="com.csc.library.session.*" %>
<%@page import="com.csc.library.utilities.*,com.csc.library.database.DataSet,java.util.*" %>
<%@page import="com.csc.library.database.CscConnection" %>
<%@page import="com.csc.library.fpprocess.*" %>
<%@page import="com.csc.library.fputility.*" %>
<%@page import="com.google.gson.Gson" %>
<%@page import="com.google.gson.GsonBuilder" %>

<%
		UProfile up = new UProfile(); 
		up.setDbName("DBSYS");
		up.setSchemaName("dbo");
		up.setUserName("MYHRADMIN");
		up.set("companyid", "100");
		up.set("employeeid", "1262");
		up.set("lang", "eng");
		up.set("appname", "ANDROID");


		ThaiUtilities util = new ThaiUtilities();
		

		String SQL = "SELECT EMPLOYEEID,COMPANYID,FPID,FILENAME,STATUS FROM MEMPL_FP ";
		String strJSON = "";

		Gson gson = new Gson();
		Gson gs = new GsonBuilder().serializeNulls().create();
		MempFP empfp = null;
		ArrayList<MempFP> arr = new ArrayList<MempFP>();

		System.out.print("!! updempfp has been called !!");
		try{
	
			DataSet ds = new DataSet(SQL,up.get("dbname"),"Mempl_fp");
			ds.initConnection(up);
			while(ds.next()){	
				try {
					empfp = new MempFP();
					empfp.setEmpId(ds.getString("employeeid"));
					empfp.setCompanyid(ds.getString("companyid"));
					empfp.setFpid(Integer.parseInt(ds.getString("fpid")));
					empfp.setFilename(ds.getString("filename"));
					empfp.setStatus(ds.getString("status"));
					
					arr.add(empfp);
					System.out.print("--> upd empid : " + ds.getString("employeeid"));
					System.out.print("--> upd fpid : " + ds.getString("fpid"));
					System.out.print("--> upd fptemplate : " + ds.getString("filename"));
				}catch(Exception e){
					System.out.print(" error while saving template !!! ");
					e.printStackTrace();
				}
			}
		}catch(Exception e){				
			e.printStackTrace();
		}	

		String json = "";
		try {

			System.out.print("******* create package data size [" + arr.size() + "]");
			String COMCODE = "2";	/* 2 : comcode for update employeeid fingerprint */
			MsgPackage msgpack = new MsgPackage(COMCODE);	
			msgpack.setUpdEmpFp(arr);

			json = gson.toJson(msgpack);

		}catch(Exception e){
			e.printStackTrace();
		}
		
%>


<%=json%>

