/********************************************************
	Title 	 : AutoPmtPrcSch
	Date  	 : 20/FEB/15
	Developer: Priyanka Shinde
 ********************************************************/
package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule;
//import java.rmi.RemoteException;
import java.util.*;
import java.util.Date;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.*;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.utility.E12GenericUtility;
import ibase.utility.CommonConstants;
import java.text.SimpleDateFormat;

public class AutoPmtPrcSch implements Schedule
{
	//GenericUtility genericUtility = GenericUtility.getInstance();
	Calendar calendar = Calendar.getInstance();		
	E12GenericUtility e12GenericUtility = new E12GenericUtility();
	String startDateStr = null;
	FileOutputStream fos1 = null;
	java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
	@Override
	public String schedule(String scheduleParamXML)throws Exception
	{

		int childNodeListLength = 0;
		String childNodeName = null;
		String tranId="",loginSiteCode="";
		ibase.utility.UserInfoBean userInfo = null;
		int noOfParam=0;
		String sysDate ="";
		String retString="";
				
		String xtraParams = "",siteCode="",sundryType="",sundryCode="";
		String actualLoginSiteCode="";
	    String getString="";
		String due_date_from="",wfStatus="";
		
		try
		{
			System.out.println("In try@@@@@@@########@@@");
			System.out.println("************ ["+scheduleParamXML+"]");
			Document dom = null;					
			userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
			loginSiteCode = userInfo.getSiteCode();			
			xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode();
			
			System.out.println("XTRAPARAMS@@@@@@@@@@@######:"+xtraParams);
			GenericUtility genericUtility=GenericUtility.getInstance();
			System.out.println("scheduleParamXML-----"+scheduleParamXML);
			dom=genericUtility.parseString(scheduleParamXML);
			
			java.util.Date today=new java.util.Date();
			Calendar c = Calendar.getInstance(); 
			c.setTime(today); 
			today = c.getTime();
			SimpleDateFormat sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
			sysDate=sdf.format(today);
			
			NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
            noOfParam = paramList.getLength();            
            NodeList parentNodeList = null,childNodeList = null;
			Node parentNode = null,childNode = null;			
						
			parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");

			parentNode = parentNodeList.item(0);
			childNodeList = parentNode.getChildNodes();
			childNodeListLength = childNodeList.getLength();
			System.out.println("childNodeListLength  !!!!!"+childNodeListLength);
			for(int ctr = 0; ctr < childNodeListLength; ctr++)
			{
				childNode = childNodeList.item(ctr);
				childNodeName = childNode.getNodeName();
							
				if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
				{
					if(ctr==0)
					{
						actualLoginSiteCode = childNode.getFirstChild().getNodeValue();
						System.out.println("actualLoginSiteCode======"+actualLoginSiteCode);
					}
					if(ctr==1)
					{
						due_date_from = childNode.getFirstChild().getNodeValue();
						System.out.println("due_date_from======"+due_date_from);
					}
					if(ctr==2)
					{
						wfStatus = childNode.getFirstChild().getNodeValue();
						System.out.println("status======"+wfStatus);
					}
					if(ctr==3)
					{
						sundryType = childNode.getFirstChild().getNodeValue();
						System.out.println("sundryType======"+sundryType);
					}
					
					if(ctr==4)
					{
						sundryCode = childNode.getFirstChild().getNodeValue();
						System.out.println("sundryCode======"+sundryCode);
					}
								
				}
			}
			
			
			System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
			getString=  autoPayment(actualLoginSiteCode,sundryType,due_date_from,wfStatus,sundryCode,scheduleParamXML);
			
		}
				
		catch(Exception e)
		{
			System.out.println(">>>>>>>>>>>>>In catch:");
			System.out.println(e);
		}
		
		System.out.println("");
		return retString;

	}

	@Override
	public String schedule(HashMap arg0) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String schedulePriority(String arg0) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	public String autoPayment(String  siteCode,String sundryType,String dueDateFrom,String wfStatus,String sundryCodeParam,String scheduleParamXML ) throws Exception
	{
		
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		//PreparedStatement pstmt1 = null;
		//ResultSet rs1 = null;
		boolean isError = false;
		String retString="";
		String sql="";
		String sundryFieldName="",sundryTableName="",sundryCode="";
		String tranId="",loginSiteCode="",xtraParams = "";
		String vouchurNo="";
		String miscPaytranDate="",effDate="",billNo="",billDate="",currCode="",exchRate="",acctrCode="",cctrCode="";
		String dueOn="",finEntity="",siteCd="",totAmt="",sundryTyp="",bankCode="",payMode="";	
		String advAmt="",tranSer="",adjAmt="",holdAmt="",userName="",payAmt="",sundryName="",netPay="";
		String xmlString4="", retString1="";
		String bankName = "",refNo="",refNoupto="";
		String sysDate ="";
		String trantype="";
		String strToWrite = "";
		String endDateStr = null;
		String errString ="";
		
		boolean flag=false;
		
		java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
		java.util.Date endDate = new java.util.Date(System.currentTimeMillis());
		ArrayList<String> sundryCodeList = new ArrayList<String>();
		AutoPmtGenPrc aPayPrc=new AutoPmtGenPrc();
		FinCommon fin =new FinCommon();
		try
		{
			ConnDriver connDriver = new ConnDriver();
			conn = connDriver.getConnectDB("DriverITM");
			connDriver = null;
			conn.setAutoCommit(false);
			ibase.utility.UserInfoBean userInfo = null;
			userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
			loginSiteCode = userInfo.getSiteCode();
			String windowName="w_miscpay_auto,";
			xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode();
			
			java.util.Date today=new java.util.Date();
			Calendar c = Calendar.getInstance(); 
			c.setTime(today); 
			today = c.getTime();
			SimpleDateFormat sdf=new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
			sysDate=sdf.format(today);
			
			 Date currentDate = new Date(); 
			 SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());  
			
			System.out.println("XTRAPARAMS@@@@@@@@@@@######:"+xtraParams);
			
			sql="select bank_code from site where site_code = ? ";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1,siteCode);
			rs = pstmt.executeQuery();
			if(rs.next())
			{
				bankCode=rs.getString("bank_code");
			}
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;
			
			
			sql = "SELECT BANK_NAME,chq1,chq3 FROM BANK WHERE BANK_CODE = ?";			
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1,bankCode);
			rs = pstmt.executeQuery();
			if (rs.next())
			{
				bankName= checkNull(rs.getString(1));		
				refNo= checkNull(rs.getString(2));		
				refNoupto= checkNull(rs.getString(3));					
			}	
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;
			
			sql="select fin_entity from site where site_code = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1,siteCode);
			rs = pstmt.executeQuery();
			if(rs.next())
			{
				finEntity=rs.getString("fin_entity");
			}
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;			
			System.out.println("finEntity========="+finEntity);
			
			sql="select curr_code   from finent where fin_entity = ?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1,finEntity);
			rs = pstmt.executeQuery();
			if(rs.next())
			{
				currCode=rs.getString("curr_code");
			}
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;
			
			System.out.println("currCode========="+currCode);
			
			trantype=fin.getFinparams("999999", "TRAN_TYPE_AUTO_PAY", conn);
			System.out.println("trantype========="+trantype);
			if(trantype==null||trantype.trim().length()==0||trantype.equalsIgnoreCase("NULLFOUND"))
			{
			trantype="O";
			}			
			
			if(sundryType!=null && sundryType.trim().length()>0 &&("C".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="customer";
				sundryFieldName="cust_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("S".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="supplier";
				sundryFieldName="supp_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("B".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="bank";
				sundryFieldName="bank_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("T".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="transporter";
				sundryFieldName="tran_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("E".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="employee";
				sundryFieldName="emp_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("L".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="loanparty";
				sundryFieldName="party_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("P".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="sales_pers";
				sundryFieldName="sales_pers";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("R".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="strg_customer";
				sundryFieldName="sc_code";
			}
			else if(sundryType!=null && sundryType.trim().length()>0 &&("X".equalsIgnoreCase(sundryType)))
			{
				sundryTableName="tax_authority";
				sundryFieldName="tauth_code";
			}		
			if(("null".equals(sundryCodeParam) || sundryCodeParam.trim().length() == 0  ))
			{
				sql="select "+sundryFieldName+" from "+sundryTableName;
				pstmt = conn.prepareStatement(sql);
				rs = pstmt.executeQuery();
				while (rs.next())
				{
					sundryCode = rs.getString(1);
					//System.out.println("sundryCode>>..>>>>>"+sundryCode);
					sundryCodeList.add(sundryCode);
				}
			}
			else
			{
				String[] arrStr =sundryCodeParam.split(",");
				int len =arrStr.length;
				for(int i =0;i<len;i++)
				{
					sundryCode =arrStr[i];
					//	System.out.println("sundryCode>>>>>>>>"+sundryCode);
						sundryCodeList.add(sundryCode);						
				}				
			}
			
			System.out.println("list Size========="+sundryCodeList.size());
			int itr=0;
			while(itr < sundryCodeList.size())
			{
				sundryCode = sundryCodeList.get(itr);
				System.out.println("------------->sundryCode" +sundryCode);						
				payMode="%";
				String xmlString1=" <Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"+
						"<date__pay><![CDATA["+sdf1.format(currentDate).toString()+"]]></date__pay>" +
						"<vouch_no__fr><![CDATA[]]></vouch_no__fr>" +
						"<vouch_no__to><![CDATA[]]></vouch_no__to>" +
						"<date__fr><![CDATA["+dueDateFrom+"]]></date__fr>" +
						"<date__to><![CDATA["+sysDate+"]]></date__to>" +
						"<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" +
						"<bank_code><![CDATA["+bankCode+"]]></bank_code>" +
						"<ref_no><![CDATA["+refNo+"]]></ref_no>" +
						"<post><![CDATA[]]></post>" +
						"<bank_name><![CDATA[]]></bank_name>" +
						"<sundry_type><![CDATA["+sundryType+"]]></sundry_type>" +
						"<sundry_code><![CDATA["+sundryCode+"]]></sundry_code>" +
						"<ref_no__upto><![CDATA["+refNoupto+"]]></ref_no__upto>" +
						"<pay_mode><![CDATA["+payMode+"]]></pay_mode>" +
						"<entry_batch_no><![CDATA[]]></entry_batch_no>" +
						"<chq_split><![CDATA[]]></chq_split>" +
						"<bank_code__add><![CDATA[]]></bank_code__add>" +
						"<bank_name__add><![CDATA[]]></bank_name__add>" +
						"<exch_rate><![CDATA[]]></exch_rate>" +
						"<noof_confirmed><![CDATA[]]></noof_confirmed>" +
						"<noof_rejected><![CDATA[]]></noof_rejected>" +
						"<tax_env><![CDATA[]]></tax_env>" +
						"<tran_type><![CDATA["+trantype+"]]></tran_type>" +
						"<curr_code><![CDATA["+currCode+"]]></curr_code>" +
						"<bank_flag><![CDATA[]]></bank_flag>"+
						"<wf_status><![CDATA["+wfStatus+"]]></wf_status></Detail1>";
				
				String xmlString2="<DocumentRoot><description>Datawindow Root</description><group0><description>Group0 description</description><Header0><description>Header0 members</description>" +
						"<Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"+
						"<date__pay><![CDATA["+sdf1.format(currentDate).toString()+"]]></date__pay>" +
								"<vouch_no__fr><![CDATA[]]></vouch_no__fr>" +
								"<vouch_no__to><![CDATA[]]></vouch_no__to>" +
								"<date__fr><![CDATA["+sysDate+"]]></date__fr>" +
								"<date__to><![CDATA["+sysDate+"]]></date__to>" +
								"<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" +
								"<bank_code><![CDATA["+bankCode+"]]></bank_code>" +
								"<ref_no><![CDATA["+refNo+"]]></ref_no>" +
								"<post><![CDATA[]]></post>" +
								"<bank_name><![CDATA[]]></bank_name>" +
								"<sundry_type><![CDATA["+sundryType+"]]></sundry_type>" +
								"<sundry_code><![CDATA["+sundryCode+"]]></sundry_code>" +
								"<ref_no__upto><![CDATA["+refNoupto+"]]></ref_no__upto>" +
								"<pay_mode><![CDATA["+payMode+"]]></pay_mode>" +
								"<entry_batch_no><![CDATA[]]></entry_batch_no>" +
								"<chq_split><![CDATA[]]></chq_split>" +
								"<bank_code__add><![CDATA[]]></bank_code__add>" +
								"<bank_name__add><![CDATA[]]></bank_name__add>" +
								"<exch_rate><![CDATA[]]></exch_rate>" +
								"<noof_confirmed><![CDATA[]]></noof_confirmed>" +
								"<noof_rejected><![CDATA[]]></noof_rejected>" +
								"<tax_env><![CDATA[]]></tax_env>" +
								"<tran_type><![CDATA["+trantype+"]]></tran_type>" +
								"<curr_code><![CDATA["+currCode+"]]></curr_code>" +								
								"<bank_flag><![CDATA[]]></bank_flag></Detail1></Header0></group0></DocumentRoot>";
				
				
				System.out.println("xmlString1@@@@@@@@@@@@@@@@:"+xmlString1);
				System.out.println("xmlString2@@@@@@@@@@@@@@@@:"+xmlString2);
				
				System.out.println("Calling getData() Method@@@@@@@@@@@");
				retString=aPayPrc.getData(xmlString1, xmlString2, windowName, xtraParams);
				System.out.println("ResultString....." + retString);
				
				/**
				 * Check for Null return
				 * */
				if(retString!=null && retString.trim().length()>0)
				{
					// Start Process
					System.out.println("Processing DATA *****");
					startDate = new java.util.Date(System.currentTimeMillis());
					calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
					startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
					strToWrite=strToWrite+startDateStr+",";

					System.out.println("STARTING DATE"+startDateStr +"STRING TO WRITE"+strToWrite);
					
					System.out.println("getData Method Finished@@@@@@@@@@@2");
					
					xmlString4="<DocumentRoot><description>Datawindow Root</description><group0><description>Group0 description</description><Header0><description>Header0 members</description>";
					String lineArr[]=retString.split("\n");
					
					for(int ctr=0;ctr<lineArr.length;ctr++)
					{
						String arr[]=lineArr[ctr].split("\t");	
						
							vouchurNo=arr[0];
					    	miscPaytranDate=arr[1];
							effDate=arr[2];
							billNo=arr[3];
							billDate=arr[4];
							currCode=arr[5];
							exchRate=arr[6];
							sundryCode=arr[7];
							acctrCode=arr[8];
							cctrCode=arr[9];
							dueOn=arr[10];
							siteCd=arr[11];
							finEntity=arr[12];
							totAmt=arr[13];
							sundryTyp=arr[14];
							bankCode=arr[15];
							payMode=arr[16];
							advAmt=arr[17];
							tranId=arr[18];						
							tranSer=arr[19];
							adjAmt=arr[20];
							holdAmt=arr[21];
							userName=arr[22];						
							payAmt=arr[23];					
							sundryName=arr[24];
							netPay=arr[25];
												
							xmlString4=xmlString4+"<Detail2 dbID=\"\" domID='"+ctr+"' objContext=\"2\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>null"+
							"<ref_no><![CDATA["+vouchurNo+"]]></ref_no>"+
							"<tran_date><![CDATA["+miscPaytranDate+"]]></tran_date>"+
							"<ref_date><![CDATA["+effDate+"]]></ref_date>"+
							"<bill_no><![CDATA["+billNo+"]]></bill_no>"+
							"<bill_date><![CDATA["+billDate+"]]></bill_date>"+
							"<curr_code><![CDATA["+currCode+"]]></curr_code>"+
							"<exch_rate><![CDATA["+exchRate+"]]></exch_rate>"+
							"<sundry_code><![CDATA["+sundryCode+"]]></sundry_code>"+
							"<acct_code><![CDATA["+acctrCode+"]]></acct_code>"+
							"<cctr_code><![CDATA["+cctrCode+"]]></cctr_code>"+
							"<due_date><![CDATA["+dueOn+"]]></due_date>"+
							"<site_code><![CDATA["+siteCode+"]]></site_code>"+
							"<fin_entity><![CDATA["+finEntity+"]]></fin_entity>"+
							"<tot_amt><![CDATA["+totAmt+"]]></tot_amt>"+						
							"<sundry_type><![CDATA["+sundryTyp+"]]></sundry_type>"+
							"<bank_code><![CDATA["+bankCode+"]]></bank_code>"+
							"<pay_mode><![CDATA["+payMode+"]]></pay_mode>"+
							"<adv_amt><![CDATA["+advAmt+"]]></adv_amt>"+
							"<tran_id><![CDATA["+tranId+"]]></tran_id>"+
							"<tran_ser><![CDATA["+tranSer+"]]></tran_ser>"+
							"<adj_amt><![CDATA["+adjAmt+"]]></adj_amt>"+						
							"<hold_amt><![CDATA["+holdAmt+"]]></hold_amt>"+
							"<username><![CDATA["+userName+"]]></username>"+
							"<pay_amt><![CDATA["+payAmt+"]]></pay_amt>"+
							"<sundry_name><![CDATA["+sundryName+"]]></sundry_name>"+
							"<net_payable><![CDATA["+netPay+"]]></net_payable>"+								
							"</Detail2>";
							
					}
					xmlString4=xmlString4+"</Header0></group0></DocumentRoot>";
					
					System.out.println("xmlString4@@@@@@@@@@@@@@@@:"+xmlString4);
					
					System.out.println("Calling process() Method@@@@@@@@@@@@");
					
				retString1 = aPayPrc.process(xmlString1, xmlString4, windowName, xtraParams);				
				endDate = new java.util.Date(System.currentTimeMillis());
				calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
				endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			
				strToWrite=strToWrite+endDateStr+",";
				strToWrite = strToWrite + retString+"\r\n\r\n"+xmlString1+"\r\n\r\n"+xmlString4+"\r\n\r\n"+retString1+"\r\n\r\n";
				fos1.write(strToWrite.getBytes());
				
				System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
				System.out.println("ResultString1....." + retString1);
				System.out.println("-----Process() called successfully-------");
				strToWrite="";
				
				//Increment itr
				itr++;
				}
				else
				{
					//Increment itr
					System.out.println("*******No data found GOING ahead*******");
					itr++;
					endDate = new java.util.Date(System.currentTimeMillis());
					calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
					endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			
					strToWrite=strToWrite+endDateStr+",";
					strToWrite = strToWrite + "No Data Found"+"\r\n\r\n"+xmlString1+"\r\n\r\n";
					fos1.write(strToWrite.getBytes());
					
					System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
					System.out.println("ResultString1....." + retString1);
					System.out.println("-----No data found------");
					strToWrite="";
				}
				
				System.out.println("Iteration COUNT :- ["+itr+"]");
			}
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;
		}
		
		catch(SQLException se)
		{
			isError = true;
			System.out.println("Exception :  : AutoPmtPrcSch" +se.getMessage());
			try
			{
				conn.rollback();
			}
			catch(Exception se1){}
			throw new ITMException(se);
		}finally
		{
				if(conn != null)
				{
					if(pstmt!=null)
					{
						pstmt.close();
						pstmt=null;
					}
					
					if(rs!=null)
					{
						rs.close();
						rs=null;
					}
				
					conn.close();
					conn= null;
				}
		}
		
		
		return retString;
	}
	private String checkNull(String str)
	{
		if(str == null)
		{
			return "";
		}
		else
		{
			return str ;
		}

	}
	
	private String intializingLog(String fileName)
	{
		String log="intializingLog_Failed";
		String strToWrite = "";
		String currTime = null;
		try{
			SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
			try
			{
				currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
				currTime = currTime.replaceAll("-","");
				calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
				fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
				fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
			}
			catch(Exception e)
			{
				System.out.println("Exception []::"+e.getMessage());
				e.printStackTrace();
			}
			startDate = new java.util.Date(System.currentTimeMillis());
			calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
			startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes());

		}
		catch(Exception e)
		{
			System.out.println("Exception []::"+e.getMessage());
			e.printStackTrace();
		}

		log ="intializingLog_Successesfull";
		return log;
	}

}
