﻿ExchangeRate = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'ExchangeRate',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},


    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        if (AG.ClientAPI.checkRequest(that, requestName)) {
            var strConditions = AG.ClientAPI.getConditions(that, requestName);
            $.ajax({
                url: '/Handler/WS.Spider/SearchExchangeRate.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'xml',
                cache: true,
                async: false,
                success: function (data) {
                    var jsonData = AGFSLib.xmlToJson($('Document', data));
                    if (typeof (jsonData.length) == "undefined" && typeof (jsonData.ExchangeRate) != "undefined")
                        jsonData = [jsonData.ExchangeRate];
                    that.data[requestName] = [];

                    var position = 0;
                    for (var i = 0; i < jsonData.length; i++) {

                        position = that.data[requestName].push(jsonData[i]) - 1;

                    }
                    that.pkConditions[requestName].isRun = true;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return false;
                }
            })
        }
    }
};ExchangeUnit = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'ExchangeUnit',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},


    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        if (AG.ClientAPI.checkRequest(that, requestName)) {
            var strConditions = AG.ClientAPI.getConditions(that, requestName);
            $.ajax({
                url: '/Handler/WS.Spider/SearchExchangeUnit.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'xml',
                cache: true,
                async: false,
                success: function (data) {
                    var jsonData = AGFSLib.xmlToJson($('Document', data));
                    if (typeof (jsonData.length) == "undefined" && typeof (jsonData.ExchangeUnit) != "undefined")
                        jsonData = [jsonData.ExchangeUnit];
                    that.data[requestName] = [];

                    var position = 0;
                    for (var i = 0; i < jsonData.length; i++) {

                        position = that.data[requestName].push(jsonData[i]) - 1;

                    }
                    that.pkConditions[requestName].isRun = true;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return false;
                }
            })
        }
    }
};
WorldIndex = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'WorldIndex',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},


    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        if (AG.ClientAPI.checkRequest(that, requestName)) {
            var strConditions = AG.ClientAPI.getConditions(that, requestName);
            $.ajax({
                url: '/Handler/WS.Spider/SearchWorldIndex.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'xml',
                cache: true,
                async: false,
                success: function (data) {
                    var jsonData = AGFSLib.xmlToJson($('Document', data));
                    if (typeof (jsonData.length) == "undefined" && typeof (jsonData.WorldIndex) != "undefined")
                        jsonData = [jsonData.WorldIndex];
                    that.data[requestName] = [];

                    var position = 0;
                    for (var i = 0; i < jsonData.length; i++) {

                        position = that.data[requestName].push(jsonData[i]) - 1;


                    }
                    that.pkConditions[requestName].isRun = true;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return false;
                }
            })
        }
    }
};
