/*
 * Web服务路径
 */
var $Path_IdentityService = "http://" + document.location.hostname + "/webservice/identityservice/identityservice.asmx?WSDL";   // document.location.hostname

var $Path_PlantGroupStatService = "http://" + document.location.hostname + "/webservice/PlantGroupStatService/StatService.asmx?WSDL";   // document.location.hostname

var $Path_GroupDataService = "http://" + document.location.hostname + "/webservice/PowerGroupDataService/GroupDataService.asmx?WSDL";

var $Path_EnterpriseDataService = "http://" + document.location.hostname + "/webservice/PowerGroupDataService/EnterpriseDataService.asmx?WSDL"

var $Path_InputLog = "http://" + document.location.hostname + "/webservice/PlantGroupStatService/InputLog.asmx?WSDL"

var $Path_StatService = "http://" + document.location.hostname + "/webservice/PlantGroupStatService/StatService.asmx?WSDL"

var $Path_ClassService = "http://" + document.location.hostname + "/webservice/ClassService/Service.asmx?WSDL"

var $Path_ClassAttributeService = "http://" + document.location.hostname + "/webservice/ClassAttributeService/Service.asmx?WSDL"

var $Path_ClassIndicatorService = "http://" + document.location.hostname + "/webservice/ClassIndicatorService/Service.asmx?WSDL"

var $Path_BClass = "http://" + document.location.hostname + "/webservice/ClassService/Service.asmx?WSDL"

var $Path_Object = "http://" + document.location.hostname + "/webservice/ObjectService/Service.asmx?WSDL"

/*
 * Web服务执行异步方法时，返回方法ID
 */
var intCallID = null;
/*
 * Web服务执行异步方法时，返回方法ID对应的功能号
 */	
var intCallIDDic = new ActiveXObject("Scripting.Dictionary");
/*
 * Web服务结果数据返回事件
 */
function webService_Result()
{
	if (event.result.error) 
	{
		if(event.result.errorDetail.string == "Unknown server error")
			return false;
		else if(event.result.errorDetail.string == "HTC internal error")
				return false;		
		else
			alert(event.result.errorDetail.string);
	}						
	else
	{
		var instanceIntCallID = event.result.id;			

		if (intCallIDDic.Exists(instanceIntCallID)) // 存在
		{
			var instanceFunction = intCallIDDic.Item(instanceIntCallID);								
			
			try{
				eval("callbackResult('" + instanceFunction + "')");
			}
			catch(ex){}
			
			intCallIDDic.Remove(instanceIntCallID);	
		}
	}
}
/*
 * 加载数据到数据岛
 */
function loadXMLToDataIsland(dataIslandUid, xmlValue)
{
    var xmlDoc = null;
    	
    if (arguments.length == 3)  // 不在同一个页面 第三个参数是新窗口对象
        xmlDoc = arguments[2].document.all(dataIslandUid).XMLDocument;
    else 
	    xmlDoc = document.all(dataIslandUid).XMLDocument;
			
	xmlDoc.async = false;
	xmlDoc.loadXML(xmlValue);
	
	// loadResult number=0是true
	return	{
				number: xmlDoc.parseError.errorCode, 
			
				description: xmlDoc.parseError.reason
			};
}
// ----------------------------电厂集团统计服务------------------------------------------------
/*
 * 注册服务
 */
function registerPlantGroupStatService()
{
    ServiceBehavior.useService($Path_PlantGroupStatService, "PlantGroupStatService");
}
function registerGroupDataService()
{
    ServiceBehavior.useService($Path_GroupDataService, "GroupDataService");
}
function registerEnterpriseDataService()
{
    ServiceBehavior.useService($Path_EnterpriseDataService, "EnterpriseDataService");
}

// 获取企业天数据
function PlantGroupStatService_GetEnterpriseDayStatData(sFunction, ClassName, StartTime, EndTime, sWhere)
{
	intCallID = ServiceBehavior.PlantGroupStatService.callService("GetEnterpriseDayStatData", ClassName, StartTime, EndTime, sWhere);

	intCallIDDic.Add(intCallID, sFunction);
}
// 获取企业月数据
function PlantGroupStatService_GetEnterpriseMonthStatData(sFunction, ClassName, StartTime, EndTime, sWhere)
{
	intCallID = ServiceBehavior.PlantGroupStatService.callService("GetEnterpriseMonthStatData", ClassName, StartTime, EndTime, sWhere);

	intCallIDDic.Add(intCallID, sFunction);
}
// 保存企业天数据
function PlantGroupStatService_SaveEnterpriseDayStatData(sFunction, docData)
{
	intCallID = ServiceBehavior.PlantGroupStatService.callService("SaveEnterpriseDayStatData", docData);

	intCallIDDic.Add(intCallID, sFunction);
}
// 保存企业天数据
function PlantGroupStatService_SaveEnterpriseDayStatDataInXmlString(sFunction, docData)
{
	intCallID = ServiceBehavior.PlantGroupStatService.callService("SaveEnterpriseDayStatDataInXmlString", docData);

	intCallIDDic.Add(intCallID, sFunction);
}


//企业统计数据列表
function PlantGroupStatService_EnterpriseStatList(sFunction, fieldRange,rowRange,orderby)
{
	intCallID = ServiceBehavior.GroupDataService.callService("EnterpriseStatList", fieldRange,rowRange,orderby);

	intCallIDDic.Add(intCallID, sFunction);
}
//机组统计数据列表
function PlantGroupStatService_UnitStatList(sFunction, fieldRange,rowRange,orderby)
{
	intCallID = ServiceBehavior.GroupDataService.callService("UnitStatList", fieldRange,rowRange,orderby);

	intCallIDDic.Add(intCallID, sFunction);
}
//多个企业多机组统计接口
function PlantGroupStatService_EnterpriseUnitStatList(sFunction, fieldRange,rowRange,orderby)
{
	rowRange = rowRange.replace(">", "&gt;");
	rowRange = rowRange.replace("<", "&lt;");
	//alert(rowRange);
	intCallID = ServiceBehavior.GroupDataService.callService("EnterpriseUnitStatList", fieldRange,rowRange,orderby);

	intCallIDDic.Add(intCallID, sFunction);
}
//多个企业多机组日接口
function PlantGroupStatService_EnterpriseUnitDayList(sFunction, fieldRange,rowRange,orderby)
{
	intCallID = ServiceBehavior.GroupDataService.callService("EnterpriseUnitDayList", fieldRange,rowRange,orderby);

	intCallIDDic.Add(intCallID, sFunction);
}
//单个企业日数据查询接口
function PlantGroupStatService_EnterpriseDayStat(sFunction,Enterprise_ID,StartTime, EndTime)
{
	intCallID = ServiceBehavior.EnterpriseDataService.callService("EnterpriseDayStat", Enterprise_ID,StartTime, EndTime);

	intCallIDDic.Add(intCallID, sFunction);
}
//单个企业统计查询
function PlantGroupStatService_EnterpriseStat(sFunction,Enterprise_ID,StartTime, EndTime)
{
	intCallID = ServiceBehavior.EnterpriseDataService.callService("EnterpriseStat", Enterprise_ID,StartTime, EndTime);

	intCallIDDic.Add(intCallID, sFunction);
}
//部门日志查询界面
function LogService_GroupQuery(sFunction,username,month,rowrange)
{
	intCallID = ServiceBehavior.InputLog.callService("GroupQuery", username,month,rowrange);

	intCallIDDic.Add(intCallID, sFunction);
}
//企业日志查询界面
function LogService_EnterpriseQuery(sFunction,enterpriseID,month)
{
	intCallID = ServiceBehavior.LogService.callService("EnterpriseQuery", enterpriseID,month);

	intCallIDDic.Add(intCallID, sFunction);
}

//服务
function registerLogService()
{
    ServiceBehavior.useService($Path_InputLog, "InputLog");
}
//企业日志查询
function InputLog_EnterpriseQuery(sFunction,enterpriseID,month)
{
	intCallID = ServiceBehavior.InputLog.callService("EnterpriseQuery", enterpriseID,month);

	intCallIDDic.Add(intCallID, sFunction);
}
//服务
function registerStatService()
{
    ServiceBehavior.useService($Path_StatService, "StatService");
}
//企业日数据入库
function StatService_SaveEnterpriseDayStatData(sFunction,xmlDoc)
{
	intCallID = ServiceBehavior.StatService.callService("SaveEnterpriseDayStatData", xmlDoc);

	intCallIDDic.Add(intCallID, sFunction);
}
//保存企业日志（数据保存成功后调用） 
function StatService_SaveEnterpriseDayData(sFunction,sUserName, sPassword, enterpriseID,date)
{
	intCallID = ServiceBehavior.StatService.callService("SaveEnterpriseDayData",sUserName, sPassword, enterpriseID,date);

	intCallIDDic.Add(intCallID, sFunction);
}
//提交 
function StatService_EnterpriseDayDataForeward(sFunction,sUserName, sPassword, enterpriseID,date)
{
	intCallID = ServiceBehavior.StatService.callService("EnterpriseDayDataForeward",sUserName, sPassword, enterpriseID,date);

	intCallIDDic.Add(intCallID, sFunction);
}
//回退
function StatService_EnterpriseDayDataBackward(sFunction,sUserName, sPassword, enterpriseID,date)
{
	intCallID = ServiceBehavior.StatService.callService("EnterpriseDayDataBackward",sUserName, sPassword, enterpriseID,date);

	intCallIDDic.Add(intCallID, sFunction);
}
// ----------------------------验证登陆服务------------------------------------------------
/*
 * 注册服务
 */
function registerIdentityService()
{
    ServiceBehavior.useService($Path_IdentityService, "IdentityService");
}
/*
 * 提交服务验证是否存在该用户
 */
function getValidate(sFunctionType, sUserName, sPassword)
{ 
    intCallID = ServiceBehavior.IdentityService.callService("identityService", sUserName, sPassword); 

    intCallIDDic.Add(intCallID, sFunctionType);
}	
/*
 * 提交服务验证是否存在该用户
 */
function getSystemValidate(sFunctionType, sUserName, sPassword)
{ 
    intCallID = ServiceBehavior.IdentityService.callService("SystemidentityService", sUserName, sPassword); 

    intCallIDDic.Add(intCallID, sFunctionType);
}
//-----------------------------维护----------------------------------------------------------
/*
 * 类维护
 */
function registerClassService()
{
	 ServiceBehavior.useService($Path_ClassService, "ClassService");
}
function registerClassAttributeService()
{
	ServiceBehavior.useService($Path_ClassAttributeService, "ClassAttributeService");
}
function registerClassIndicatorService()
{
	ServiceBehavior.useService($Path_ClassIndicatorService, "ClassIndicatorService");
}
/*
 * 类维护
 */
function registerBClass()
{
	 ServiceBehavior.useService($Path_BClass, "BClass");
}
function BClass_GetSubClass(sFunction,BClass_ID)
{
	intCallID = ServiceBehavior.BClass.callService("GetSubClass",BClass_ID);

	intCallIDDic.Add(intCallID, sFunction);
}
function ClassAttributeService_Query(sFunction,BClass_ID)
{
	intCallID = ServiceBehavior.ClassAttributeService.callService("Query",BClass_ID);
	
	intCallIDDic.Add(intCallID, sFunction);
}
function ClassAttributeService_GetAttributes(sFunction,BClass_ID)
{
	intCallID = ServiceBehavior.ClassAttributeService.callService("GetAttributes",BClass_ID);
	
	intCallIDDic.Add(intCallID, sFunction);
}
//-------------
function registerObject()
{
	ServiceBehavior.useService($Path_Object, "ObjectService");
}

function Object_GetSubObject(sFunction,BClass_ID,BObject_ID,BClass_IDOfSub)
{
	intCallID = ServiceBehavior.ObjectService.callService("GetSubObject",BClass_ID,BObject_ID,BClass_IDOfSub);

	intCallIDDic.Add(intCallID, sFunction);
}