﻿Attachment = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'Attachment',
    //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.Data/SearchAttachment.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.Attachment) != "undefined")
                        jsonData = [jsonData.Attachment];
                    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;
                }
            })
        }
    }
};Config = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'Config',
    //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.Data/SearchConfig.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.Config) != "undefined")
                        jsonData = [jsonData.Config];
                    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;
                }
            })
        }
    }
};Field = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'Field',
    //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.Data/SearchField.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.Field) != "undefined")
                        jsonData = [jsonData.Field];
                    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;
                }
            })
        }
    },
    searchField: function (requestName, data) {
        var that = this;
        AG.ClientAPI.addCondition(that, requestName, data);
        if (AG.ClientAPI.checkRequest(that, requestName)) {
            var strConditions = AG.ClientAPI.getConditions(that, requestName);
            $.ajax({
                url: '/Handler/WS.StockReport/SearchField.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.Field) != "undefined")
                        jsonData = [jsonData.Field];
                    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;
                }
            });
        }
        return that.data[requestName];
    }
};FieldCategory = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'FieldCategory',
    //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.StockData/SearchFieldCategory.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.FieldCategory) != "undefined")
                        jsonData = [jsonData.FieldCategory];
                    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;
                }
            })
        }
    }
};Region = {
    //private property
    sessionDate: new Date().getTime(),
    interval: false,
    version: [],
    name: 'Region',
    //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/SearchRegion.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.Region) != "undefined")
                        jsonData = [jsonData.Region];
                    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;
                }
            })
        }
    }
};
