﻿BondBiding = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'BondBiding',
    //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.StockReport/SearchBondBiding.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.BondBiding) != "undefined")
                        jsonData = [jsonData.BondBiding];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockReport/CountBondBiding.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountBondBiding.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockReport/CountBondBiding.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockReport/CountBondBiding.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/BondBiding.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; BondDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'BondDaily',
    //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.StockReport/SearchBondDaily.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.BondDaily) != "undefined")
                        jsonData = [jsonData.BondDaily];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockReport/CountBondDaily.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountBondDaily.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockReport/CountBondDaily.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockReport/CountBondDaily.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/BondDaily.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; BondExchangeDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'BondExchangeDaily',
    //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.StockReport/SearchBondExchangeDaily.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.BondExchangeDaily) != "undefined")
                        jsonData = [jsonData.BondExchangeDaily];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockReport/CountBondExchangeDaily.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountBondExchangeDaily.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockReport/CountBondExchangeDaily.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockReport/CountBondExchangeDaily.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/BondExchangeDaily.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; BondExchangeRealtime = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'BondExchangeRealtime',
    //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.StockReport/SearchBondExchangeRealtime.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.BondExchangeRealtime) != "undefined")
                        jsonData = [jsonData.BondExchangeRealtime];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockReport/CountBondExchangeRealtime.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountBondExchangeRealtime.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockData/CountBondExchangeRealtime.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockData/CountBondExchangeRealtime.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/BondExchangeRealtime.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; BondRealtime = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'BondRealtime',
    //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.StockReport/SearchBondRealtime.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'POST',
                dataType: 'xml',
                cache: true,
                async: false,
                success: function (data) {
                    var jsonData = AGFSLib.xmlToJson($('Document', data));
                    if (typeof (jsonData.length) == "undefined" && typeof (jsonData.BondRealtime) != "undefined")
                        jsonData = [jsonData.BondRealtime];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockData/CountBondRealtime.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountBondRealtime.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockData/CountBondRealtime.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockData/CountBondRealtime.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/BondRealtime.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
};CompanyDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'CompanyDaily',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},
    //Primaky key

    //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.StockReport/SearchCompanyDaily.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.CompanyDaily) != "undefined")
                        jsonData = [jsonData.CompanyDaily];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyDaily.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountCompanyDaily.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyDaily.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyDaily.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable, header, column) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        if (fileName == "PriceQuery") {
            document.location.href = '/Handler/StockReportToExcel/StockExchange.PriceQuery.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
        }
        else {
            document.location.href = '/Handler/StockReportToExcel/CompanyDaily.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
        }
    }
};    CompanyRealtime = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'CompanyRealtime',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},
    //Primaky key    
    pkData: {},
    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        var strConditions = AG.ClientAPI.getConditions(that, requestName);
        $.ajax({
            url: '/Handler/WS.StockReport/SearchCompanyRealtime.ashx',
            data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
            type: 'POST',
            dataType: 'xml',
            cache: true,
            async: false,
            success: function (data) {
                var jsonData = AGFSLib.xmlToJson($('Document', data));
                if (typeof (jsonData.length) == "undefined" && typeof (jsonData.CompanyRealtime) != "undefined")
                    jsonData = [jsonData.CompanyRealtime];
                if (typeof (that.data[requestName]) == 'undefined') that.data[requestName] = [];
                if (typeof (that.pkData[requestName]) == "undefined") that.pkData[requestName] = {};
                var position = 0;
                for (var i = 0; i < jsonData.length; i++) {
                    position = AG.ClientAPI.findData(jsonData[i], that.pkData[requestName], 'Id');
                    if (position < 0) {
                        position = that.data[requestName].push(jsonData[i]) - 1;
                        that.pkData[requestName][jsonData[i].Id] = {};
                        that.pkData[requestName][jsonData[i].Id].position = position;
                    }
                    else {
                        for (key in jsonData[i]) {
                            if (key != "length" && typeof (jsonData[i][key]) != "undefined" && typeof (that.data[requestName][position]) != "undefined") {
                                that.data[requestName][position][key] = jsonData[i][key];
                            }
                        }
                    }
                    if (typeof (jsonData[i].Modified) != 'undefined') {
                        if (typeof (that.version[requestName]) != 'undefined')
                            that.version[requestName] = (jsonData[i].Modified > that.version[requestName]) ? jsonData[i].Modified : that.version[requestName];
                        else
                            that.version[requestName] = jsonData[i].Modified;
                    }
                }
                that.pkConditions[requestName].isRun = true;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                return false;
            }
        })
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable,undefined,false);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyRealtime.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountCompanyRealtime.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'POST',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyRealtime.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockData/CountCompanyRealtime.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/CompanyRealtime.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; IndustryDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'IndustryDaily',
    //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.StockReport/SearchIndustryDaily.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.IndustryDaily) != "undefined")
                        jsonData = [jsonData.IndustryDaily];
                    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;
                }
            })
        }
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockData/CountIndustryDaily.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountIndustryDaily.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockData/CountIndustryDaily.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockData/CountIndustryDaily.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/IndustryDaily.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; IndustryRealtime = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'IndustryRealtime',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},


    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        var strConditions = AG.ClientAPI.getConditions(that, requestName);
        $.ajax({
            url: '/Handler/WS.StockReport/SearchIndustryRealtime.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.IndustryRealtime) != "undefined")
                    jsonData = [jsonData.IndustryRealtime];
                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;
            }
        })
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        if (AG.ClientAPI.data['/Handler/WS.StockReport/CountIndustryRealtime.ashx' + 'Conditions=' + strConditions] == undefined) {
            $.ajax({
                url: '/Handler/WS.StockReport/CountIndustryRealtime.ashx',
                data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
                type: 'GET',
                dataType: 'text',
                cache: true,
                async: false,
                success: function (data) {
                    result = data;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    return 0;
                }
            });
            AG.ClientAPI.data['/Handler/WS.StockReport/CountIndustryRealtime.ashx' + 'Conditions=' + strConditions] = result;
        }
        else {
            result = AG.ClientAPI.data['/Handler/WS.StockReport/CountIndustryRealtime.ashx' + 'Conditions=' + strConditions];
        }
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable); ;
        document.location.href = '/Handler/StockReportToExcel/IndustryRealtime.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; StockExchangeDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'StockExchangeDaily',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},


    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        var strConditions = AG.ClientAPI.getConditions(that, requestName);
        $.ajax({
            url: '/Handler/WS.StockReport/SearchStockExchangeDaily.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.StockExchangeDaily) != "undefined")
                    jsonData = [jsonData.StockExchangeDaily];
                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;
            }
        })
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;
        $.ajax({
            url: '/Handler/WS.StockReport/CountStockExchangeDaily.ashx',
            data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
            type: 'GET',
            dataType: 'text',
            cache: true,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                return 0;
            }
        });
        AG.ClientAPI.data['/Handler/WS.StockReport/CountStockExchangeDaily.ashx' + 'Conditions=' + strConditions] = result;
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/StockExchangeDaily.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; StockExchangeRealtime = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'StockExchangeRealtime',
    //Conditions
    conditions: [],
    //key condition
    pkConditions: {},
    //Output Document
    data: {},
    //Primaky key    
    pkData: {},
    //methos
    //loadData
    loadData: function (requestName) {
        var that = this;
        var strConditions = AG.ClientAPI.getConditions(that, requestName);
        $.ajax({
            url: '/Handler/WS.StockReport/SearchStockExchangeRealtime.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.StockExchangeRealtime) != "undefined")
                    jsonData = [jsonData.StockExchangeRealtime];
                if (typeof (that.data[requestName]) == 'undefined') that.data[requestName] = [];
                if (typeof (that.pkData[requestName]) == "undefined") that.pkData[requestName] = {};
                var position = 0;
                for (var i = 0; i < jsonData.length; i++) {
                    position = AG.ClientAPI.findData(jsonData[i], that.pkData[requestName], 'Id');
                    if (position < 0) {
                        position = that.data[requestName].push(jsonData[i]) - 1;
                        that.pkData[requestName][jsonData[i].Id] = {};
                        that.pkData[requestName][jsonData[i].Id].position = position;
                    }
                    else {
                        for (key in jsonData[i]) {
                            if (key != "length" && typeof (jsonData[i][key]) != "undefined" && typeof (that.data[requestName][position]) != "undefined") {
                                that.data[requestName][position][key] = jsonData[i][key];
                            }
                        }
                    }
                    if (typeof (jsonData[i].Created) != 'undefined') {
                        if (typeof (that.version[requestName]) != 'undefined')
                            that.version[requestName] = (jsonData[i].Modified > that.version[requestName]) ? jsonData[i].Modified : that.version[requestName];
                        else
                            that.version[requestName] = jsonData[i].Modified;
                    }
                    if (typeof (jsonData[i].Modified) != 'undefined') {
                        if (typeof (that.version[requestName]) != 'undefined')
                            that.version[requestName] = (jsonData[i].Modified > that.version[requestName]) ? jsonData[i].Modified : that.version[requestName];
                        else
                            that.version[requestName] = jsonData[i].Modified;
                    }
                }
                that.pkConditions[requestName].isRun = true;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                return false;
            }
        })
    },
    getCount: function (data, getFields, order, filters, joinTable) {
        var that = this;
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        var result;

        $.ajax({
            url: '/Handler/WS.StockReport/CountStockExchangeRealtime.ashx',
            data: 'Conditions=' + strConditions + '&t=' + that.sessionDate,
            type: 'GET',
            dataType: 'text',
            cache: true,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                return 0;
            }
        });
        AG.ClientAPI.data['/Handler/WS.StockReport/CountStockExchangeRealtime.ashx' + 'Conditions=' + strConditions] = result;
        return result;
    },
    toExcel: function (fileName, data, getFields, order, filters, joinTable) {
        var strConditions = AG.ClientAPI.getCondition(data, getFields, order, filters, joinTable);
        document.location.href = '/Handler/StockReportToExcel/StockExchangeRealtime.aspx' + '?Conditions=' + strConditions + '&FileName=' + fileName;
    }
}; PutThroughDaily = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'PutThroughDaily',
    //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.StockReport/SearchPutThroughDaily.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.PutThroughDaily) != "undefined")
                        jsonData = [jsonData.PutThroughDaily];
                    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;
                }
            })
        }
    }
};
