o2oa api: x-游戏厅捕鱼达人

source

var global_items=function(){var t=[];for(var e in this)t.push(e);return t}();!function(){this.mootools={version:"1.5.0dev",build:"%build%"};var t=this.typeof=function(t){if(null==t)return"null";if(null!=t.$family)return t.$family();if(t.nodename){if(1==t.nodetype)return"element";if(3==t.nodetype)return/\s/.test(t.nodevalue)?"textnode":"whitespace"}else if("number"==typeof t.length){if(t.callee)return"arguments";if("item"in t)return"collection"}return typeof t},e=(this.instanceof=function(t,e){if(null==t)return!1;for(var n=t.$constructor||t.constructor;n;){if(n===e)return!0;n=n.parent}return!!t.hasownproperty&&t instanceof e},this.function),n=!0;for(var r in{tostring:1})n=null;n&&(n=["hasownproperty","valueof","isprototypeof","propertyisenumerable","tolocalestring","tostring","constructor"]),e.prototype.overloadsetter=function(t){var e=this;return function(r,i){if(null==r)return this;if(t||"string"!=typeof r){for(var a in r)e.call(this,a,r[a]);if(n)for(var o=n.length;o--;)a=n[o],r.hasownproperty(a)&&e.call(this,a,r[a])}else e.call(this,r,i);return this}},e.prototype.overloadgetter=function(t){var e=this;return function(n){var r,i;if("string"!=typeof n?r=n:arguments.length>1?r=arguments:t&&(r=[n]),r){i={};for(var a=0;a>>0;n>>0;i>>0,r=e<0?math.max(0,n e):e||0;r>>0,r=array(n),i=0;i>>0;n-1:string(this).indexof(t)>-1},trim:function(){return string(this).replace(/^\s |\s $/g,"")},clean:function(){return string(this).replace(/\s /g," ").trim()},camelcase:function(){return string(this).replace(/-\d/g,(function(t){return t.charat(1).touppercase()}))},hyphenate:function(){return string(this).replace(/[a-z]/g,(function(t){return"-" t.charat(0).tolowercase()}))},capitalize:function(){return string(this).replace(/\b[a-z]/g,(function(t){return t.touppercase()}))},escaperegexp:function(){return string(this).replace(/([-.* ?^${}()|[\]\/\\])/g,"\\$1")},toint:function(t){return parseint(this,t||10)},tofloat:function(){return parsefloat(this)},hextorgb:function(t){var e=string(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return e?e.slice(1).hextorgb(t):null},rgbtohex:function(t){var e=string(this).match(/\d{1,3}/g);return e?e.rgbtohex(t):null},substitute:function(t,e){return string(this).replace(e||/\\?\{([^{}] )\}/g,(function(e,n){return"\\"==e.charat(0)?e.slice(1):null!=t[n]?t[n]:""}))}}),function.extend({attempt:function(){for(var t=0,e=arguments.length;t1?array.slice(arguments,1):null,r=function(){},i=function(){var a=t,o=arguments.length;this instanceof i&&(r.prototype=e.prototype,a=new r);var s=n||o?e.apply(a,n&&o?n.concat(array.slice(arguments)):n||arguments):e.call(a);return a==t?s:a};return i},pass:function(t,e){var n=this;return null!=t&&(t=array.from(t)),function(){return n.apply(e,t||arguments)}},delay:function(t,e,n){return settimeout(this.pass(null==n?[]:n,e),t)},periodical:function(t,e,n){return setinterval(this.pass(null==n?[]:n,e),t)}}),number.implement({limit:function(t,e){return math.min(e,math.max(t,this))},round:function(t){return t=math.pow(10,t||0).tofixed(t<0?-t:0),math.round(this*t)/t},times:function(t,e){for(var n=0;n3&&t<21?"th":["th","st","nd","rd","th"][math.min(t,4)]},lessthanminuteago:"less than a minute ago",minuteago:"about a minute ago",minutesago:"{delta} minutes ago",hourago:"about an hour ago",hoursago:"about {delta} hours ago",dayago:"1 day ago",daysago:"{delta} days ago",weekago:"1 week ago",weeksago:"{delta} weeks ago",monthago:"1 month ago",monthsago:"{delta} months ago",yearago:"1 year ago",yearsago:"{delta} years ago",lessthanminuteuntil:"less than a minute from now",minuteuntil:"about a minute from now",minutesuntil:"{delta} minutes from now",houruntil:"about an hour from now",hoursuntil:"about {delta} hours from now",dayuntil:"1 day from now",daysuntil:"{delta} days from now",weekuntil:"1 week from now",weeksuntil:"{delta} weeks from now",monthuntil:"1 month from now",monthsuntil:"{delta} months from now",yearuntil:"1 year from now",yearsuntil:"{delta} years from now"}),function(){var t=this.date,e=t.methods={ms:"milliseconds",year:"fullyear",min:"minutes",mo:"month",sec:"seconds",hr:"hours"};["date","day","fullyear","hours","milliseconds","minutes","month","seconds","time","timezoneoffset","week","timezone","gmtoffset","dayofyear","lastmonth","lastdayofmonth","utcdate","utcday","utcfullyear","ampm","ordinal","utchours","utcmilliseconds","utcminutes","utcmonth","utcseconds","utcmilliseconds"].each((function(e){t.methods[e.tolowercase()]=e}));var n=function(t,e,r){return 1==e?t:t28)return 1;0==o&&s<-2&&(r=new t(r).decrement("day",i),i=0),(n=new t(r.get("year"),0,1).get("day")||7)>4&&(a=-7)}else n=new t(r.get("year"),0,1).get("day");return a =r.get("dayofyear"),a =6-i,(a =(7 n-e)%7)/7},getordinal:function(e){return t.getmsg("ordinal",e||this.get("date"))},gettimezone:function(){return this.tostring().replace(/^.*? ([a-z]{3}).[0-9]{4}.*$/,"$1").replace(/^.*?\(([a-z])[a-z]  ([a-z])[a-z]  ([a-z])[a-z] \)$/,"$1$2$3")},getgmtoffset:function(){var t=this.get("timezoneoffset");return(t>0?"-":" ") n((t.abs()/60).floor(),2) n(t`,2)},setampm:function(t){t=t.touppercase();var e=this.get("hr");return e>11&&"am"==t?this.decrement("hour",12):e<12&&"pm"==t?this.increment("hour",12):this},getampm:function(){return this.get("hr")<12?"am":"pm"},parse:function(e){return this.set("time",t.parse(e)),this},isvalid:function(t){return t||(t=this),"date"==typeof(t)&&!isnan(t.valueof())},format:function(e){if(!this.isvalid())return"invalid date";if(e||(e="%x %x"),"string"==typeof e&&(e=a[e.tolowercase()]||e),"function"==typeof e)return e(this);var r=this;return e.replace(/%([a-z%])/gi,(function(e,i){switch(i){case"a":return t.getmsg("days_abbr")[r.get("day")];case"a":return t.getmsg("days")[r.get("day")];case"b":return t.getmsg("months_abbr")[r.get("month")];case"b":return t.getmsg("months")[r.get("month")];case"c":return r.format("%a %b %d %h:%m:%s %y");case"d":return n(r.get("date"),2);case"e":return n(r.get("date"),2," ");case"h":return n(r.get("hr"),2);case"i":return n(r.get("hr")||12,2);case"j":return n(r.get("dayofyear"),3);case"k":return n(r.get("hr"),2," ");case"l":return n(r.get("hr")||12,2," ");case"l":return n(r.get("ms"),3);case"m":return n(r.get("mo") 1,2);case"m":return n(r.get("min"),2);case"o":return r.get("ordinal");case"p":return t.getmsg(r.get("ampm"));case"s":return math.round(r/1e3);case"s":return n(r.get("seconds"),2);case"t":return r.format("%h:%m:%s");case"u":return n(r.get("week"),2);case"w":return r.get("day");case"x":return r.format(t.getmsg("shortdate"));case"x":return r.format(t.getmsg("shorttime"));case"y":return r.get("year").tostring().substr(2);case"y":return r.get("year");case"z":return r.get("gmtoffset");case"z":return r.get("timezone")}return i}))},toisostring:function(){return this.format("iso8601")}}).alias({tojson:"toisostring",compare:"diff",strftime:"format"});var r=["sun","mon","tue","wed","thu","fri","sat"],i=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],a={db:"%y-%m-%d %h:%m:%s",compact:"%y%m%dt%h%m%s",short:"%d %b %h:%m",long:"%b %d, %y %h:%m",rfc822:function(t){return r[t.get("day")] t.format(", %d ") i[t.get("month")] t.format(" %y %h:%m:%s %z")},rfc2822:function(t){return r[t.get("day")] t.format(", %d ") i[t.get("month")] t.format(" %y %h:%m:%s %z")},iso8601:function(t){return t.getutcfullyear() "-" n(t.getutcmonth() 1,2) "-" n(t.getutcdate(),2) "t" n(t.getutchours(),2) ":" n(t.getutcminutes(),2) ":" n(t.getutcseconds(),2) "." n(t.getutcmilliseconds(),3) "z"}},o=[],s=t.parse,u=function(e,n,r){var i=-1,a=t.getmsg(e "s");switch(typeof(n)){case"object":i=a[n.get(e)];break;case"number":if(!(i=a[n]))throw new error("invalid " e " index: " n);break;case"string":var o=a.filter((function(t){return this.test(t)}),new regexp("^" n,"i"));if(!o.length)throw new error("invalid " e " string");if(o.length>1)throw new error("ambiguous " e);i=o[0]}return r?a.indexof(i):i},c=1900,l=70;t.extend({getmsg:function(t,e){return locale.get("date." t,e)},units:{ms:function.convert(1),second:function.convert(1e3),minute:function.convert(6e4),hour:function.convert(36e5),day:function.convert(864e5),week:function.convert(6084e5),month:function(e,n){var r=new t;return 864e5*t.daysinmonth(null!=e?e:r.get("mo"),null!=n?n:r.get("year"))},year:function(e){return e=e||(new t).get("year"),t.isleapyear(e)?316224e5:31536e6}},daysinmonth:function(e,n){return[31,t.isleapyear(n)?29:28,31,30,31,30,31,31,30,31,30,31][e]},isleapyear:function(t){return t%4==0&&t0!=0||t@0==0},parse:function(e){var n,r=typeof(e);return"number"==r?new t(e):"string"!=r?e:(e=e.clean()).length?(o.some((function(t){var r=t.re.exec(e);return!!r&&(n=t.handler(r))})),n&&n.isvalid()||(n=new t(s(e)))&&n.isvalid()||(n=new t(e.toint())),n):null},parseday:function(t,e){return u("day",t,e)},parsemonth:function(t,e){return u("month",t,e)},parseutc:function(e){var n=new t(e),r=t.utc(n.get("year"),n.get("mo"),n.get("date"),n.get("hr"),n.get("min"),n.get("sec"),n.get("ms"));return new t(r)},orderindex:function(e){return t.getmsg("dateorder").indexof(e) 1},defineformat:function(t,e){return a[t]=e,this},defineparser:function(t){return o.push(t.re&&t.handler?t:g(t)),this},defineparsers:function(){return array.flatten(arguments).each(t.defineparser),this},define2digityearstart:function(t){return c=t-(l=t0),this}}).extend({defineformats:t.defineformat.overloadsetter()});var h,f=function(e){return new regexp("(?:" t.getmsg(e).map((function(t){return t.substr(0,3)})).join("|") ")[a-z]*")},d={d:/[0-2]?[0-9]|3[01]/,h:/[01]?[0-9]|2[0-3]/,i:/0?[1-9]|1[0-2]/,m:/[0-5]?\d/,s:/\d /,o:/[a-z]*/,p:/[ap]\.?m\.?/,y:/\d{2}|\d{4}/,y:/\d{4}/,z:/z|[ -]\d{2}(?::?\d{2})?/};d.m=d.i,d.s=d.m;var g=function(e){if(!h)return{format:e};var n=[],r=(e.source||e).replace(/%([a-z])/gi,(function(e,n){return function(e){switch(e){case"t":return"%h:%m:%s";case"x":return(1==t.orderindex("month")?"%m[-./]%d":"%d[-./]%m") "([-./]%y)?";case"x":return"%h([.:]%m)?([.:]%s([.:]%s)?)? ?%p? ?%z?"}return null}(n)||e})).replace(/\((?!\?)/g,"(?:").replace(/ (?!\?|\*)/g,",? ").replace(/%([a-z%])/gi,(function(t,e){var r=d[e];return r?(n.push(e),"(" r.source ")"):e})).replace(/\[a-z\]/gi,"[a-z\\u00c0-\\uffff;&]");return{format:e,re:new regexp("^" r "$","i"),handler:function(e){e=e.slice(1).associate(n);var r=(new t).cleartime(),i=e.y||e.y;for(var a in null!=i&&p.call(r,"y",i),"d"in e&&p.call(r,"d",1),("m"in e||e.b||e.b)&&p.call(r,"m",1),e)p.call(r,a,e[a]);return r}}},p=function(e,n){if(!n)return this;switch(e){case"a":case"a":return this.set("day",t.parseday(n,!0));case"b":case"b":return this.set("mo",t.parsemonth(n,!0));case"d":return this.set("date",n);case"h":case"i":return this.set("hr",n);case"m":return this.set("mo",n-1);case"m":return this.set("min",n);case"p":return this.set("ampm",n.replace(/\./g,""));case"s":return this.set("sec",n);case"s":return this.set("ms",1e3*("0." n));case"w":return this.set("day",n);case"y":return this.set("year",n);case"y":return(n= n)<100&&(n =c (n>> 0;
                for (var i = (from < 0) ? math.max(0, length   from) : from || 0; i < length; i  ){
                    if (this[i] === item) return i;
                }
                return -1;
            }
        }};
    library.defineproperties(array.prototype, o);
})();
bind.library = library;
//print 重载, console, error
if (!bind.oprint) bind.oprint = print;
var print = function(str, type){
    var d = new date();
    var t = (type || "print").touppercase();
    var l = "[script]";
    bind.oprint(d.format("db") "." d.getmilliseconds() " " t " " l " " str);
}
var _parseprint = function(str){
    if (!str && str!==0 && str!==false) return str;
    var text = (typeof(str)!=="string") ? str.tostring() : str;
    try{
        var i = 1;
        while (text.indexof("%s")!==-1 && i  i) ? functionarguments[i] : null;
                failure = (n>  i) ? functionarguments[i] : null;
                parameters.each(function(p, x){
                    parameter[p] = (n>  i) ? functionarguments[i] : null;
                });
                if (service.method && (service.method.tolowercase()==="post" || service.method.tolowercase()==="put")){
                    data = (n>  i) ? functionarguments[i] : null;
                }
            }else{
                parameters.each(function(p, x){
                    parameter[p] = (n>x) ? functionarguments[x] : null;
                });
                if (service.method && (service.method.tolowercase()==="post" || service.method.tolowercase()==="put")){
                    data = (n>  i) ? functionarguments[i] : null;
                }
                success = (n>  i) ? functionarguments[i] : null;
                failure = (n>  i) ? functionarguments[i] : null;
            }
            return _self.invoke({"name": key, "data": data, "parameter": parameter, "success": success, "failure": failure});
        };
    };
    var createmethod = function(service, key){
        var jaxrsuri = service.uri;
        var re = new regexp("\{. ?\}", "g");
        var replacewords = jaxrsuri.match(re);
        var parameters = [];
        if (replacewords) parameters = replacewords.map(function(s){
            return s.substring(1,s.length-1);
        });
        this[key] = invokefunction.call(this, service, parameters, key);
    };
    object.keys(this.actions).foreach(function(key){
        var service = this.actions[key];
        if (service.uri) if (!this[key]) createmethod.call(this, service, key);
    }, this);
    this.invoke = function(option){
        if (this.actions[option.name]){
            var uri = this.actions[option.name].uri;
            var method = this.actions[option.name].method || "get";
            if (option.parameter){
                object.keys(option.parameter).foreach(function(key){
                    var v = option.parameter[key];
                    uri = uri.replace("{" key "}", v);
                });
            }
            var res = null;
            try{
                switch (method.tolowercase()){
                    case "get":
                        res = bind.applications.getquery(this.root, uri);
                        break;
                    case "post":
                        res = bind.applications.postquery(this.root, uri, json.stringify(option.data));
                        break;
                    case "put":
                        res = bind.applications.putquery(this.root, uri, json.stringify(option.data));
                        break;
                    case "delete":
                        res = bind.applications.deletequery(this.root, uri);
                        break;
                    default:
                        res = bind.applications.getquery(this.root, uri);
                }
                if (res && res.gettype().tostring()==="success"){
                    var json = json.parse(res.tostring());
                    if (option.success) option.success(json);
                }else{
                    if (option.failure) option.failure(((res) ? json.parse(res.tostring()) : null));
                }
                return res;
            }catch(e){
                if (option.failure) option.failure(e);
            }
        }
    };
}
bind.action.applications = bind.applications;
bind.actions = {
    "loadedactions": {},
    "load": function(root){
        if (this.loadedactions[root]) return this.loadedactions[root];
        var jaxrsstring = bind.applications.describeapi(root);
        var json = json.parse(jaxrsstring.tostring());
        if (json && json.jaxrs){
            var actionobj = {};
            json.jaxrs.each(function(o){
                if (o.methods && o.methods.length){
                    var actions = {};
                    o.methods.each(function(m){
                        var o = {"uri": "/" m.uri};
                        if (m.method) o.method = m.method;
                        if (m.enctype) o.enctype = m.enctype;
                        actions[m.name] = o;
                    }.bind(this));
                    actionobj[o.name] = new bind.action(root, actions);
                }
            }.bind(this));
            this.loadedactions[root] = actionobj;
            return actionobj;
        }
        return null;
    }
};
//组织相关
var getnameflag = function(name){
    var t = library.typeof(name);
    if (t==="array"){
        var v = [];
        name.foreach(function(id){
            v.push((library.typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id);
        });
        return v;
    }else{
        return [(t==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name];
    }
};
bind.org = {
    "group": function() { return this.ogroup},
    "identity": function() { return this.oidentity},
    "person": function() { return this.operson},
    "personattribute": function() { return this.opersonattribute},
    "role": function() { return this.orole},
    "unit": function() { return this.ounit},
    "unitattribute": function() { return this.ounitattribute},
    "unitduty": function() { return this.ounitduty},
    "getobject": function(o, v){
        var arr = [];
        if (!v || !v.length){
            return null;
        }else{
            for (var i=0; i -1){
        if (callback) callback.apply(this);
        return;
    }
    var scriptaction;
    var scriptdata;
    switch ( type ){
        case "portal" :
            bind.portalactions.getscript( application, name, {"importedlist":includedscripts[application]}, function(json){
                if (json.data){
                    includedscripts[application] = includedscripts[application].concat(json.data.importedlist);
                    scriptdata = json.data;
                }
            }.bind(this));
            break;
        case "process" :
            bind.processactions.getscript( name, application, {"importedlist":includedscripts[application]}, function(json){
                if (json.data){
                    includedscripts[application] = includedscripts[application].concat(json.data.importedlist);
                    scriptdata = json.data;
                }
            }.bind(this));
            break;
        case "cms" :
            bind.cmsactions.getscript(name, application, {"importedlist":includedscripts[application]}, function(json){
                if (json.data){
                    includedscripts[application] = includedscripts[application].concat(json.data.importedlist);
                    scriptdata = json.data;
                }
            }.bind(this));
            break;
        case "service" :
            bind.serviceactions.getscript(name, {"importedlist":includedscripts[application]}, function(json){
                if (json.data){
                    includedscripts[application] = includedscripts[application].concat(json.data.importedlist);
                    scriptdata = json.data;
                }
            }.bind(this));
            break;
    }
    includedscripts[application].push(name);
    if (scriptdata && scriptdata.text){
        exec(scriptdata.text, this);
        if (callback) callback.apply(this);
    }
};
//optionsorname : {
//  type : "", //默认为process, 可以为  process  cms
//  application : "", //流程/cms的名称/别名/id, 默认为当前应用
//  name : "", // 数据字典名称/别名/id
//  enableanonymous : false //允许在未登录的情况下读取cms的数据字典
//}
//或者name: "" // 数据字典名称/别名/id
bind.dict = function(optionsorname){
    var options = optionsorname;
    if( typeof( options ) == "string" ){
        options = { name : options };
    }
    var name = this.name = options.name;
    var type;
    if( options.type === "service"){
        type = options.type;
    }else{
        type = ( options.type && options.application ) ?  options.type : "service";
    }
    var applicationid = options.application;
    var enableanonymous = options.enableanonymous || false;
    //mwf.require("mwf.xscript.actions.dictactions", null, false);
    var action;
    if( type == "cms" ){
        action = bind.cmsactions;
    }else if( type == "service" ){
        action = bind.serviceactions;
    }else if( type == "portal" ){
        action = bind.portalactions;
    }else{
        action = bind.processactions;
    }
    var encodepath = function( path ){
        var arr = path.split(/\./g);
        var ar = arr.map(function(v){
            return encodeuricomponent(v);
        });
        return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/");
    };
    this.get = function(path, success, failure){
        var value = null;
        if( type === "service" ){
            if (path){
                var p = encodepath( path );
                action.getdictdata(encodeuricomponent(this.name), p, function(json){
                    value = json.data;
                    if (success) success(json.data);
                }, function(xhr, text, error){
                    if (failure) failure(xhr, text, error);
                });
            }else{
                action.getdictroot(encodeuricomponent(this.name), function(json){
                    value = json.data;
                    if (success) success(json.data);
                }, function(xhr, text, error){
                    if (failure) failure(xhr, text, error);
                }, false);
            }
        }else{
            if (path){
                var p = encodepath( path );
                action[(enableanonymous && type == "cms") ? "getdictdataanonymous" : "getdictdata"](encodeuricomponent(this.name), applicationid, p, function(json){
                    value = json.data;
                    if (success) success(json.data);
                }, function(xhr, text, error){
                    if (failure) failure(xhr, text, error);
                });
            }else{
                action[(enableanonymous && type == "cms") ? "getdictrootanonymous" : "getdictroot"](encodeuricomponent(this.name), applicationid, function(json){
                    value = json.data;
                    if (success) success(json.data);
                }, function(xhr, text, error){
                    if (failure) failure(xhr, text, error);
                }, false);
            }
        }
        return value;
    };
    this.set = function(path, value, success, failure){
        var p = encodepath( path );
        //var p = path.replace(/\./g, "/");
        if( type === "service" ){
            action.setdictdata(encodeuricomponent(this.name), p, value, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }else{
            action.setdictdata(encodeuricomponent(this.name), applicationid, p, value, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }
    };
    this.add = function(path, value, success, failure){
        var p = encodepath( path );
        //var p = path.replace(/\./g, "/");
        if( type === "service" ) {
            action.adddictdata(encodeuricomponent(this.name), p, value, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }else{
            action.adddictdata(encodeuricomponent(this.name), applicationid, p, value, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }
    };
    this["delete"] = function(path, success, failure){
        var p = encodepath( path );
        //var p = path.replace(/\./g, "/");
        if( type === "service" ) {
            action.deletedictdata(encodeuricomponent(this.name), p, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }else{
            action.deletedictdata(encodeuricomponent(this.name), applicationid, p, function(json){
                if (success) success(json.data);
            }, function(xhr, text, error){
                if (failure) failure(xhr, text, error);
            }, false, false);
        }
    };
    this.destory = this["delete"];
};
bind.table = function(name){
    this.name = name;
    this.action = actions.load("x_query_assemble_surface").tableaction;
    this.listrownext = function(id, count, success, error, async){
        this.action.listrownext(this.name, id, count, success, error, async);
    };
    this.listrowprev = function(id, count, success, error, async){
        this.action.listrowprev(this.name, id, count, success, error, async);
    };
    this.listrowselect = function(where, orderby, size, success, error, async){
        this.action.listrowselect(this.name, {"where": where, "orderby": orderby, "size": size || ""}, success, error, async);
    };
    this.listrowselectwhere = function(where, success, error, async){
        this.action.listrowselectwhere(this.name, where, success, error, async);
    };
    this.rowcountwhere = function(where, success, error, async){
        this.action.rowcountwhere(this.name, where, success, error, async);
    };
    this.deleterow = function(id, success, error, async){
        this.action.rowdelete(this.name, id, success, error, async);
    };
    this.deleteallrow = function(success, error, async){
        this.action.rowdeleteall(this.name, success, error, async);
    };
    this.getrow = function(id, success, error, async){
        this.action.rowget(this.name, id, success, error, async);
    };
    this.insertrow = function(data, success, error, async){
        this.action.rowinsert(this.name, data, success, error, async);
    };
    this.addrow = function(data, success, error, async){
        this.action.rowinsertone(this.name, data, success, error, async);
    };
    this.updaterow = function(id, data, success, error, async){
        this.action.rowupdate(this.name, id, data, success, error, async);
    };
}
bind.statement = {
        execute: function (obj, callback) {
        if( obj.format ){
            return this._execute(obj, callback, obj.format);
        }else{
            if( this.needcheckformat(obj) ){
                var value;
                var _self = this;
                bind.actions.load("x_query_assemble_surface").statementaction.getformat(obj.name, function(json){
                    value = _self._execute(obj, callback, json.data.format);
                });
                return value;
            }else{
                return this._execute(obj, callback, "");
            }
        }
    },
    needcheckformat: function(s){
        if( s.format )return false;
        if( typeof(s.parameter) === "object" ){
            for( var p in s.parameter ){
                if( typeof( s.parameter[p] ) === "date" )return true;
            }
        }
        if( typeof(s.filter) === "array" ){
            for( var i=0; i< s.filter.length; i  ){
                var ftype = s.filter[i].formattype;
                if( ["datetimevalue", "datetimevalue", "datevalue", "timevalue"].indexof( ftype ) > -1 )return true;
            }
        }
        return false;
    },
    _execute: function (statement, callback, format) {
        var parameter = this.parseparameter(statement.parameter, format);
        var filterlist = this.parsefilter(statement.filter, parameter, format);
        var obj = {
            "filterlist": filterlist,
            "parameter" : parameter
        };
        var value;
        bind.actions.load("x_query_assemble_surface").statementaction.executev2(
            statement.name, statement.mode || "data", statement.page || 1, statement.pagesize || 20, obj,
            function (json) {
                if (callback) callback(json);
                value = json;
            }
        );
        return value;
    },
    parsefilter : function( filter, parameter, format ){
        if( typeof(filter) !== "array" )return [];
        if( !parameter )parameter = {};
        var filterlist = [];
        ( filter || [] ).each( function (d) {
            //var parametername = d.path.replace(/\./g, "_");
            var pname = d.path.replace(/\./g, "_");
            var parametername = pname;
            var suffix = 1;
            while( parameter[parametername] ){
                parametername = pname   "_"   suffix;
                suffix  ;
            }
            var value = d.value;
            if( d.comparison === "like" || d.comparison === "notlike" ){
                if( value.substr(0, 1) !== "%" )value = "%" value;
                if( value.substr(value.length-1,1) !== "%" )value = value "%";
                parameter[ parametername ] = value; //"%" value "%";
            }else{
                if( ["sql", "sqlscript"].contains(format) ) {
                    if (d.formattype === "numbervalue") {
                        value = parsefloat(value);
                    }
                }else{
                    if (d.formattype === "datetimevalue" || d.formattype === "datetimevalue") {
                        value = "{ts '"   value   "'}"
                    } else if (d.formattype === "datevalue") {
                        value = "{d '"   value   "'}"
                    } else if (d.formattype === "timevalue") {
                        value = "{t '"   value   "'}"
                    } else if (d.formattype === "numbervalue") {
                        value = parsefloat(value);
                    }
                }
                parameter[ parametername ] = value;
            }
            d.value = parametername;
            filterlist.push( d );
        });
        return filterlist;
    },
    parseparameter : function( obj, format ){
        if( typeof(obj) !== "object" )return {};
        var parameter = {};
        //传入的参数
        for( var p in obj ){
            var value = obj[p];
            if( typeof( value ) === "date" ){
                if( ["sql", "sqlscript"].contains(format) ){
                            value = value.format("db");
                        }else{
                            value = "{ts '" value.format("db") "'}"
                        }
            }
            parameter[ p ] = value;
        }
        return parameter;
    },
    "select": function () {}
};
bind.view = {
    "lookup": function(view, callback){
        var filterlist = {"filterlist": (view.filter || null)};
        var value;
        bind.actions.load("x_query_assemble_surface").viewaction.executewithquery(view.view, view.application, filterlist, function(json){
            var data = {
                "grid": json.data.grid || json.data.groupgrid,
                "groupgrid": json.data.groupgrid
            };
            if (callback) callback(data);
            value = data;
        });
        return value;
    },
    "select": function(view, callback, options){}
};
bind.service = {
    restful: function(method, url, headers, body, connecttimeout, readtimeout){
        var service = bind.java_resources.getwebservicesclient();
        var bodydata = ((typeof body)==="object") ? json.stringify(body) : (body||"");
        var res = service.restful(method, url, (headers||null), bodydata, (connecttimeout||2000), (readtimeout||300000));
        var o = {
            "responsecode" : res.responsecode,
            "headers" : res.headers,
            "body": res.body
        }
        try {
            o.json = json.parse(res.body);
        }catch(e){}
        return o;
    },
    "get": function(url, headers, connecttimeout, readtimeout){
        return this.restful("get", url, headers, "", connecttimeout, readtimeout);
    },
    "post": function(url, headers, body, connecttimeout, readtimeout){
        return this.restful("post", url, headers, body, connecttimeout, readtimeout);
    },
    soap: function(wsdl, method, pars){
        var service = bind.java_resources.getwebservicesclient();
        return service.soap(wsdl, method, pars);
    },
    soapxml: function(wsdl, xml){
        var service = bind.java_resources.getwebservicesclient();
        return service.jaxwsxml(wsdl, xml);
    }
}
//----------------------------------------------------------
//java对象:  invoke
//java_resources: getcontext(); getapplications(); getorganization(); getwebservicesclient();  ok
//java_effectiveperson ;
//java_customresponse
//java_requesttext;
//java_request
//agent
//java_resources: getcontext(); getapplications(); getorganization(); getwebservicesclient();  ok
//jpql
//java_resources: getcontext(); getapplications(); getorganization(); getwebservicesclient();  ok
//java_effectiveperson ;
//java_parameters;
//接口响应对象
/**
 * 用于服务管理的接口脚本,描述服务的响应对象。
* @o2range 服务管理-接口 * @o2cn 服务的响应对象 * @module server.service.response * @o2category server.service * @o2ordernumber 245 * @o2syntax * var res = this.response; */ var response = { /** * @summary 服务返回一个303跳转。 * @method seeother * @methodof service.service.module:response * @static * @param {string} [url] 跳转的url。 * @o2syntax * this.response.seeother(url); */ seeother: function(url){ bind.java_customresponse.seeother(url); }, /** * @summary 服务返回一个301跳转。 * @method redirect * @methodof service.service.module:response * @static * @param {string} [url] 跳转的url。 * @o2syntax * this.response.redirect(url); */ redirect: function(url){ bind.java_customresponse.temporaryredirect(url); }, /** * @summary 服务返回一个301跳转。 * @method setbody * @methodof service.service.module:response * @static * @param {string|object} [body] 响应内容,文本或json对象。 * @param {string} [contenttype] 响应头的content-type。 * @o2syntax * this.response.setbody(body, contenttype); * @example * //设置json格式的响应内容 * this.response.setbody({ * "key1": "value1", * "key2": "value2" * }, "application/json"); */ setbody: function(body, contenttype){ var o = body; if (typeof(o)==="object"){ o = json.stringify(o); } bind.java_customresponse.setbody(o, contenttype || ""); } } library.defineproperties(response, { "customresponse": { "configurable": true, "get": function(){ return bind.java_customresponse || null } } }); function _get(key, java_data){ if (!bind["o" key]) bind["o" key] = json.parse(java_data); return bind["o" key]; } var o= { "entitymanager": { "configurable": true, "get": function(){return null;} }, "context": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getcontext() : null)} }, "applications": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getapplications() : null)} }, "organization": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getorganization() : null)} }, //"service": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getwebservicesclient() : null)} }, /** * 获取当前用户的全称。 * @module server.currentperson * @o2cn 当前用户全称 * @o2category server.common * @o2ordernumber 250 * @o2syntax * var user = this.currentperson; */ "currentperson": { "configurable": true, "get": function(){return (bind.java_effectiveperson || null)} }, "effectiveperson": { "configurable": true, "get": function(){return (bind.java_effectiveperson || null)} }, /** * 用于数据中心查询语句的脚本中,可获取语句参数。json对象,在调用此语句的时候传入
* @o2range 数据中心-查询配置-通过脚本创建查询语句 * @o2cn 数据中心查询语句参数 * @module server.service.parameters * @o2category server.service * @o2ordernumber 255 * @o2syntax * var pars = this.parameters; * @example * * 通过this.statement.execute调用一个名为“task”的查询配置,并传入parameters,代码如下: *
//用一个名为“task”的查询配置,并传入parameters
     * this.statement.execute({
     *  "name": "task",
     *  "mode" : "all",
     *  "parameter" : {
     *     "person" : "xxx@xxx@p",  //传入人员参数
     *     "starttime" : (new date("2020-01-01")) //传入时间参数
     *  }
     * }, function(json){
     *  var count = json.count; //总数语句执行后返回的数字
     *  var list = json.data; //查询语句后返回的数组
     *   //......
     * });
     *     
* * 在task查询配置的脚本中,parameters对象就可获取到执行查询时传入的parameters对象,以便于动态创建查询语句 * * //动态生成查询指定用户,在指定时间之后的所有待办数据 * var user = this.parameters.person; * var starttime = (new date(this.parameters.starttime)).format("db"); //格式化为yyyy-mm-dd hh:mm:ss * return "select o from task o where o.person='" user "' and o.starttime>{ts '" starttime "'}" */ "parameters": { "configurable": true, "get": function(){return ((bind.java_parameters) ? _get("parameters", bind.java_parameters) : null)} }, /** * 调用接口时传入的请求消息体的文本内容。 * @o2range 服务管理-接口 * @module server.requesttext * @o2cn 传入的服务消息体文本 * @o2category server.service * @o2ordernumber 250 * @o2syntax * var text = this.requesttext; * @example * var text = this.requesttext; //传入的服务消息体文本 * var object = json.parse(text); //转成对象 */ "requesttext": { "configurable": true, "get": function(){return bind.java_requesttext || null; } }, "request": { "configurable": true, "get": function(){return bind.java_request || null; } }, "resources": { "configurable": true, "get": function(){return (bind.java_resources || null)} }, "customresponse": { "configurable": true, "get": function(){return (bind.java_customresponse || null)} }, "message": { "configurable": true, "get": function(){return (bind.java_message) ? _get("message", bind.java_message) : null;} } } library.defineproperties(bind, o); /* 清除 engine */ this.engine = null;
网站地图