<?xml version="1.0" encoding="euc-kr"?>
<%@ page contentType="text/xml; charset=utf-8"%>
<%@ page import="com.eactive.eai.adapter.socket2.config.MonitoringUtil"%>
<%@ page import="java.util.*,com.eactive.eai.common.util.Logger" %>
<Dataset>
	<Columns>
		<Column Name="EaiSevrInstncName"  Type="string" Size="255" />
		<Column Name="AdptrBzwkGroupName" Type="string" Size="255" />
		<Column Name="AdptrBzwkName"      Type="string" Size="255" />
		<Column Name="AdptrBzwkDesc"      Type="string" Size="255" />
		<Column Name="AdptrType"          Type="string" Size="255" />
		<Column Name="Status"             Type="string" Size="255" />
		<Column Name="Param7"             Type="string" Size="255" />
		<Column Name="Param8"             Type="string" Size="255" />
		<Column Name="Starting"           Type="string" Size="255" />
		<Column Name="KesaUseYn"          Type="string" Size="255" />
		<Column Name="TestMasterYn"          Type="string" Size="255" />
		<Column Name="AdptrNickName"          Type="string" Size="255" />
		<Column Name="CompanyCodeData"          Type="string" Size="255" />
		<Column Name="StartStop"          Type="string" Size="255" />		
	</Columns>
	<Rows>
<%!
	static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
%>	
	
<%
	//
	//  Socket2 status info


    String eaiSvrInstNm = request.getParameter("eaiSvrInstNm");
	String adapterGroupName = request.getParameter("adapterGroupName");

    if (eaiSvrInstNm == null)
      eaiSvrInstNm = "";
	
    if (adapterGroupName == null)
    	adapterGroupName = "";

    String stateColor = "";
    String stateText = "";

    String startColor = "";
    String startText = "";
    String startStop = "";
    
    
    String[][] arrList = null ;
    try {
    	if(adapterGroupName.length() > 0) {
    		arrList = MonitoringUtil.adapterStatus(adapterGroupName);
    	}
    	else {
    		arrList = MonitoringUtil.adapterList1();
    	}
    } catch ( Exception e ) {
    	if (logger.isError()){
    		logger.error(e.toString());
    	}
    }
    
    // 리턴된 arrList 가 null 이 아니면서 배열길이가 0 인 경우 Exception 발생 
    // 하지 않도록 하기 위함.  (2008-06-30)
    if( arrList == null || arrList.length == 0 ) {
%>
		<Row>
			<Data><%=eaiSvrInstNm%></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
			<Data></Data>
		</Row>
<%
	
	} else {
		int col = arrList[0].length ;
		int row = arrList.length ;
		
		for( int i = 0 ; i < row ; i++ ) {
			out.println("<Row>");
			out.println("<Data>" + eaiSvrInstNm + "</Data>");
			for( int j = 0 ; j < col ; j++ ) {
				if(j == 2) {
					out.println("<Data><![CDATA[" + arrList[i][j] + "]]></Data>");
				} else {
					out.println("<Data>" + arrList[i][j] + "</Data>");
				}
			}
			
            // 버그수정
			if(arrList[i] != null && arrList[i].length > 4 ) {
                if( "STARTED".equals(arrList[i][7]) || "STARTING".equals(arrList[i][7])) {
                    startStop = "03" ; // stop
                } else {
                    startStop = "01" ; // start
                }
			}
			
			out.println("<Data>"+ startStop +"</Data>");
			out.println("</Row>");
		}
	}
%>
	</Rows>
</Dataset>
