module.exports.judge_lib_recomended_1st = function(){
//function judge_lib_recomended_1st( ){
    
    if(DEBUG)   console.log("judge_lib_recomended_1st START");
    dfd_flag = 0;
    
    //judge_lib_recomended_with_arg( booklist[0], Setting );
    
    dfd_flag =0;
    

    
    if(DEBUG){
        console.log("=========================================");
        console.log("judge_lib_recomended_1st START");
        console.log("=========================================");
        if((order_check >= ORDER_1st_END) && ( order_check <= ORDER_2nd_END)){
            console.log("ORDER = " + order_check);
        }else{
            console.log("ORDER ERROR !!! judge_lib_recomended_1st: " + order_check);
        }
        if( order_check != ORDER_2nd_END)   order_check++;  //ongoing;
    }
    
    lib_recomended_set_cache( Setting );
    
    if( dfd_flag == 0 ){
        console.log("judge_lib_recomended_1st promise");
        return dfd_librecom.promise();
    }
    
//}
};
Example #2
0
                    readFile = function(filename, charset){

                        var _dfd = new $.Deferred(),
                            _charset = charset || 'utf8';

                        fs.readFile(filename, _charset, function(err, data) {
                            if(err) { _dfd.reject('FileNotFound', 'cant load [' + filename + '] file!'); }
                            _dfd.resolve(data);
                        });
                        return _dfd.promise();

                    },
Example #3
0
                    writeFile = function(filename, data, chmod){

                        var _dfd    = new $.Deferred(),
                            _data  = data  || ' ',
                            _chmod = chmod || '0777';

                        fs.writeFile(filename, _data, function (err) {
                            if(err) { _dfd.reject('FileCouldNotWrite', 'cant write [' + filename + '] file!'); }
                            fs.chmod(filename, _chmod, function(){
                                _dfd.reject('PermissionDenied', 'cant set chmod [' + _chmod + ']');
                            });
                            _dfd.resolve(200);
                        });
                        return _dfd.promise();
                    };
Example #4
0
                    match = function(pattern, data, slice_start, slice_end){

                        var _dfd = new $.Deferred(),
                            match, container=[], tmpContainer=[];

                        while(match!==null){
                            match = pattern.exec(data);
                            if(match!==null){
                                tmpContainer=[];
                                for(var i= ( slice_start || 0 ), length=( slice_end || match.length ); i<length; i++){
                                    tmpContainer.push(match[i]);
                                }
                                container.push(tmpContainer);
                            }
                        }
                        _dfd.resolve(container);
                        return _dfd.promise();
                    },
exports.judge_school_recomended = function(){
    var i;
    
    if(DEBUG){
        console.log("=========================================");
        console.log("judge_school_recomended START. Booklist.len="+booklist.length);
        console.log("=========================================");
        
        if((order_check >= ORDER_1st_END) && ( order_check <= ORDER_2nd_END)){
            console.log("ORDER = " + order_check);
        }else{
            console.log("ORDER ERROR !!! judge_lib_recomended_1st: " + order_check);
        }
        if( order_check != ORDER_2nd_END) order_check++;  //ongoing;
    }
    
    
    get_school_recommendation_books();  //DBから読み込み
    
    return dfd_schoolrecom.promise();
    
};
module.exports.get_bookinfo_about_lib = function(){   //★★★★NODEJS時はこちら
//function get_bookinfo_about_lib(){                  //★★★★NODEJS使わずに通常javascriptはこちら

    if(DEBUG=1){
        console.log("=========================================");
        console.log("get_bookinfo_about_lib START");
        console.log("=========================================");
        
        if((order_check >= ORDER_1st_END) && ( order_check <= ORDER_2nd_END)){
            console.log("ORDER = " + order_check);
        }else{
            console.log("ORDER ERROR !!! judge_lib_recomended_1st: " + order_check);
        }
        if( order_check != ORDER_2nd_END) order_check++;  //ongoing;
    }
    
    var i;

////////
    //booklist[0].Isbn = "9784864104449";
    //booklist[1].Isbn = "9784834022995";
    //dfd_calil = new $.Deferred;
    //var book_status = get_bookinfo_about_lib_with_arg( booklist[0], Setting, FLAG_1st_CALL );
        
    //calil_books_status[0] = book_status;
    //return dfd_calil.promise();
    
////////
    
    //これだと1件目要求出しただけでreturnして2件目にいかない。。。
    /*
    for (i = 0; i<booklist.length; i++)
        return( get_bookinfo_about_lib_with_arg( booklist[i], Setting, FLAG_1st_CALL ));
    */
    
    
    dfd_calil = new $.Deferred;
    
    
    //var book_status;    // ①init/sending/retry_waiting/retry_sending/done のstatusと②Sessionidのarray
    
    
    init_calil_books_status( booklist );
    calil_session_status = CALIL_STATUS_INIT;
    calil_sessionid = "";
        
    //book_status = get_bookinfo_about_lib_with_arg( booklist[i], Setting, FLAG_1st_CALL );
    get_bookinfo_about_lib_with_arg( booklist, Setting, FLAG_1st_CALL );
        
    //calil_books_status[i] = book_status;
        
        
        
        /*
        if(DEBUG){
            console.log(
                "calil_books_status["+i+"]: "
                + " Isbn=" + book_status.isbn 
                + " status=" + book_status.status
                + " SessionId=" + book_status.SessionId
            );
        }
        */
    
    return dfd_calil.promise();
    
//}
};