當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Request.on方法代碼示例

本文整理匯總了TypeScript中tedious.Request.on方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Request.on方法的具體用法?TypeScript Request.on怎麽用?TypeScript Request.on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tedious.Request的用法示例。


在下文中一共展示了Request.on方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                    Select
                        *
                    from
                        SupportRequest
                    where
                        MessageID = @requestMessageId
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.setHeader('content-type', 'application/x-www-form-urlencoded');
                            res.setHeader('Access-Control-Allow-Origin', '*');
                            res.status(200).send(result);
                        }
                    }
                );

                request.addParameter('requestMessageId', TYPES.NVarChar, requestMessageId);

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:54,代碼來源:supportResponse.ts

示例2: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                        SELECT * FROM [dbo].[InstructionResponse]
                        WHERE DeviceId = @DeviceID AND UserId = @UserId AND Requester = @Requester AND RequestedTime > CAST(GETDATE() AS DATE)
                        ORDER BY RequestedTime DESC
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.send(result);
                        }
                    }
                );

                request.addParameter('DeviceID', TYPES.NVarChar, deviceId);
                request.addParameter('UserId', TYPES.NVarChar, deviceUserId);
                request.addParameter('Requester', TYPES.NVarChar, userId);

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:51,代碼來源:instructionResponse.ts

示例3: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                        Select
                            delaybandId as ID,
                            delayBandLabel as [Band],
                            0 as [Occurences]
                        from
                           responseDelayBands 
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.send(result);
                        }
                    }
                );

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:50,代碼來源:connectivityDelayBands.ts

示例4: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                        SELECT CD.Id, CD.DeviceId, CD.UserId, CD.RouteId, CD.LastConnected, PD.IsPilot
                        FROM dbo.ConnectedDevices CD
                        LEFT JOIN [dbo].[PilotDevices] PD ON CD.DeviceId = PD.DeviceId
                        WHERE CD.LastConnected > CAST(GETDATE() AS DATE);
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.setHeader('content-type', 'application/x-www-form-urlencoded');
                            res.setHeader('Access-Control-Allow-Origin', '*');
                            res.status(200).send(result);
                        }
                    }
                );

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:50,代碼來源:connectedDevices.ts

示例5: function

        this.pool.acquire(function (err, connection) {
            if (err)
                console.error(err);
            
            var request = new tedious.Request(queryString, function(err, rowCount){
                if(err) {
                    console.error(err);
                }
                else {
                    console.log(rowCount + ' results found');    
                }
                callback(err,result);
                connection.release();    
            });
            
            request.on('row', function(columns){
                var row = {};
                    
                columns.forEach(function(column) {
                    if (column.value === null) {
                        console.log('NULL');
                    } else {
                        row[column.metadata.colName] = column.value;
                    }
                });

                result.push(row);
            });
            
            var TYPES = tedious.TYPES;

            connection.execSql(request);
            
        })    
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:34,代碼來源:dbManager.ts

示例6: join

        this.pool.acquire(function (err, connection) {
            if (err)
                console.error(err);
        
            var queryString = `
                select u.* from userconfig u inner join (select driverlogin, max(dateinserted) as lastLogin from userconfig
                group by driverlogin) ufil
                on u.driverLogin = ufil.driverlogin and u.dateinserted = ufil.lastLogin
                where u.dateinserted > dateadd(second, ` + period + `, getdate())
                order by u.driverlogin
            `;
            
            var request = new tedious.Request(queryString, function(err, rowCount){
                if(err) {
                    console.error(err);
                    callback(err);
                }
                else {
                    console.log(rowCount + ' results found');
                    callback(result);
                }
                connection.release();    
            });
            
            request.on('row', function(columns){
                var row = {};
                    
                columns.forEach(function(column) {
                    if (column.value === null) {
                        console.log('NULL');
                    } else {
                        row[column.metadata.colName] = column.value;
                    }
                });

                result.push(row);
            });
            
            var TYPES = tedious.TYPES;

            connection.execSql(request);
            
        })
開發者ID:MattGauler,項目名稱:support-portal-uat,代碼行數:43,代碼來源:driverDBManager.ts


注:本文中的tedious.Request.on方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。