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


TypeScript eta-lib.term類代碼示例

本文整理匯總了TypeScript中eta-lib.term的典型用法代碼示例。如果您正苦於以下問題:TypeScript term類的具體用法?TypeScript term怎麽用?TypeScript term使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: callback

 eta.student.get(req.session["userid"], (student: eta.Student) => {
     if (!student) {
         callback({ errcode: eta.http.InternalError });
         return;
     }
     if (student.sections.length == 0
         || !eta.section.hasCurrentSections(student.sections, eta.term.getCurrent().id)) {
         res.redirect("/track/index");
         return;
     }
     let sql: string = `
         SELECT
             LOWER(TIME_FORMAT(Visit.timeIn, '%l:%i %p')) AS timeIn,
             LOWER(TIME_FORMAT(Visit.timeOut, '%l:%i %p')) AS timeOut,
             ROUND(TIME_TO_SEC(TIMEDIFF(Visit.timeOut, Visit.timeIn)) / 3600, 2) AS totalHours,
             DATE_FORMAT(Visit.timeIn, '%c/%e/%Y') AS date,
             GROUP_CONCAT(DISTINCT CONCAT(Course.subject, ' ', Course.number) ORDER BY Course.subject, Course.number SEPARATOR ', ') AS courses
         FROM
             Visit
                 RIGHT JOIN Section ON
                     Visit.section REGEXP Section.id
                 RIGHT JOIN Course ON
                     Section.course = Course.id
         WHERE
             Visit.term = ? AND
             Visit.student = ?
         GROUP BY Visit.student, Visit.timeIn
         ORDER BY Visit.timeIn`;
     eta.db.query(sql, [eta.term.getCurrent().id, req.session["userid"]], (err: eta.DBError, rows: any[]) => {
         if (err) {
             eta.logger.dbError(err);
             callback({ errcode: eta.http.InternalError });
             return;
         }
         let totalHours: number = 0;
         for (let i: number = 0; i < rows.length; i++) {
             totalHours += rows[i].totalHours;
         }
         eta.person.getByID(req.session["userid"], (person: eta.Person) => {
             if (!person) {
                 callback({ errcode: eta.http.InternalError });
                 return;
             }
             callback({
                 "visits": rows,
                 "name": person.firstName + " " + person.lastName,
                 "totalHours": totalHours.toFixed(2)
             });
         });
     });
 });
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:51,代碼來源:student.ts

示例2: generateWizIQRooms

 private generateWizIQRooms(callback: (err: Error) => void): void {
     let rooms: string[] = eta.config.wiziq.rooms;
     eta.center.getHours(eta.config.wiziq.onlineCenter, eta.term.getCurrent().id, (err: Error, hours?: { [key: string]: eta.HoursOfOperation }) => {
         if (err) {
             return callback(err);
         }
         let todayHours: eta.HoursOfOperation = hours[eta.time.getCurrentDayOfWeek()];
         let start: Date = eta.time.getDateFromTime(todayHours.open);
         if (start.getTime() < new Date().getTime()) {
             start = new Date();
         }
         let end: Date = eta.time.getDateFromTime(todayHours.close);
         let sql: string = `
             INSERT INTO OnlineRoom (letter, date, url)
             VALUES (?, CURDATE(), ?)
             ON DUPLICATE KEY UPDATE url = VALUES(url)`;
         for (let i: number = 0; i < rooms.length; i++) {
             eta.wiziq.schedule(start, end, rooms[i], (err: Error, result?: any) => {
                 if (err) {
                     return eta.logger.warn("Couldn't schedule room " + rooms[i] + ": " + err.message);
                 }
                 let url: string = result.CommonAttendeeUrl;
                 eta.db.query(sql, [rooms[i], url], (err: eta.DBError, rows: any[]) => {
                     if (err) {
                         return eta.logger.dbError(err);
                     }
                 });
             });
         }
         callback(null);
     });
 }
開發者ID:crossroads-education,項目名稱:eta-sys,代碼行數:32,代碼來源:generate-wiziq.ts

示例3: callback

 eta.professor.getSections(req.session["userid"], (sections: eta.Section[]) => {
     if (!sections) {
         callback({ errcode: eta.http.InternalError });
         return;
     }
     if (sections.length > 0) {
         if (eta.section.hasCurrentSections(sections, eta.term.getCurrent().id)) {
             res.redirect("/track/professor");
             return;
         }
     }
     // falls to here if they're not a current student or professor
     eta.athlete.isDirector(req.session["userid"], (isAthleteDirector: boolean) => {
         if (isAthleteDirector === null) {
             callback({ errcode: eta.http.InternalError });
             return;
         }
         if (isAthleteDirector) {
             res.redirect("/track/athlete");
             return;
         }
         // falls to here if they're not a current student, professor or director
         callback({}); // just display the "error" page
     });
 });
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:25,代碼來源:index.ts

示例4: callback

 eta.athlete.isDirector(req.session["userid"], (isAthleteDirector: boolean) => {
     if (isAthleteDirector === null) {
         callback({ errcode: eta.http.InternalError });
         return;
     }
     if (!isAthleteDirector) {
         res.redirect("/track/index");
         return;
     }
     let isPastWeek: boolean = !!req.query.isPastWeek;
     let pastWeekSql: string = `AND DATE(Visit.timeIn) >= (CURDATE() - INTERVAL 7 DAY)`;
     let sql: string = `
         SELECT
             Person.id,
             Person.firstName,
             Person.lastName,
             VisitCount.count AS visitCount,
             VisitCount.duration AS visitDuration,
             VisitCount.timesOut AS visitTimesOut,
             VisitCount.lastTimeIn AS visitLastTimeIn
         FROM
             Athlete
                 LEFT JOIN Person ON
                     Athlete.id = Person.id
                 LEFT JOIN (
                     SELECT
                         Visit.student AS student,
                         COUNT(DISTINCT Visit.student, Visit.timeIn) AS count,
                         ROUND(SUM(TIME_TO_SEC(TIMEDIFF(Visit.timeOut, Visit.timeIn))) / 3600, 2) AS duration,
                         GROUP_CONCAT(IFNULL(Visit.timeOut, 'NULL') ORDER BY Visit.timeIn DESC SEPARATOR ', ') AS timesOut,
                         DATE(MAX(Visit.timeIn)) = CURDATE() AS lastTimeIn
                     FROM
                         Visit
                     WHERE
                         Visit.term = ?
                         ${isPastWeek ? pastWeekSql : ""}
                     GROUP BY
                         Visit.student
                 ) VisitCount ON
                     Athlete.id = VisitCount.student
         WHERE
             VisitCount.count > 0`;
     eta.db.query(sql, [eta.term.getCurrent().id], (err: eta.DBError, rows: any[]) => {
         if (err) {
             eta.logger.dbError(err);
             callback({ errcode: eta.http.InternalError });
             return;
         }
         for (let i: number = 0; i < rows.length; i++) {
             let lastTimeOut: string = rows[i].visitTimesOut.split(", ")[0];
             rows[i].isCurrent = (lastTimeOut === "NULL") && rows[i].visitLastTimeIn;
         }
         callback({
             "students": rows,
             "isPastWeek": isPastWeek
         })
     });
 });
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:58,代碼來源:athlete.ts

示例5: callback

 eta.person.getByID(req.body.student, (person: eta.Person) => {
     if (!person) {
         callback({ errcode: eta.http.InternalError });
         return;
     }
     let sectionSql: string = "AND Section.id = ?";
     let params: string[] = [req.body.student, eta.term.getCurrent().id];
     if (req.body.section) {
         params.push(req.body.section);
     }
     let sql: string = `
         SELECT
             GROUP_CONCAT(DISTINCT CONCAT(Course.subject, ' ', Course.number) ORDER BY Course.subject, Course.number SEPARATOR ', ') AS "0",
             DATE_FORMAT(Visit.timeIn, '%c/%e/%Y') AS "1",
             LOWER(TIME_FORMAT(Visit.timeIn, '%l:%i %p')) AS "2",
             IFNULL(
                 LOWER(TIME_FORMAT(Visit.timeOut, '%l:%i %p')),
                 'N/A'
             ) AS "3",
             IFNULL(
                 ROUND(TIME_TO_SEC(TIMEDIFF(Visit.timeOut, Visit.timeIn)) / 3600, 2),
                 '0.00'
             ) AS "4"
         FROM
             Visit
                 RIGHT JOIN Section ON
                     Visit.section REGEXP Section.id
                 RIGHT JOIN Course ON
                     Section.course = Course.id
         WHERE
             Visit.student = ? AND
             Visit.term = ?
             ${req.body.section ? sectionSql : ""}
         GROUP BY Visit.timeIn`;
     eta.db.query(sql, params, (err: eta.DBError, rows: any[]) => {
         if (err) {
             eta.logger.dbError(err);
             callback({ errcode: eta.http.InternalError });
             return;
         }
         callback({
             "raw": JSON.stringify({
                 "firstName": person.firstName,
                 "lastName": person.lastName,
                 "visits": rows
             })
         });
     });
 });
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:49,代碼來源:get-single.ts

示例6: processTable

 private processTable(db: oracledb.IConnection, file: string, useTerm?: string): void {
     let tableHandler: EtaTable, tableName: string;
     try {
         let handlerModule: any = require(file);
         tableName = handlerModule.default.name;
         tableHandler = new handlerModule.default(db);
     } catch (ex) {
         eta.logger.warn("Could not include Oracle table handler: " + ex.toString());
         return;
     }
     let term: string = eta.term.getCurrent().term;
     if (useTerm) {
         term = useTerm;
     }
     eta.logger.trace("Fetching " + tableName + "...");
     tableHandler.fetch(term, (err: Error, rows: any[]) => {
         if (err) {
             eta.logger.warn("Couldn't process table " + tableName + ": " + err.message);
             return;
         }
         let sql = "INSERT ";
         if (tableHandler.shouldIgnoreDuplicates()) {
             sql += "IGNORE ";
         }
         let result: eta.SqlValueResult = eta.sql.getInsertMany(rows, true);
         sql += "INTO `" + tableName + "` " + result.columns + " VALUES " + result.sql;
         let duplicateUpdateSql: string = tableHandler.getDuplicateUpdateSql();
         if (duplicateUpdateSql != "") {
             sql += " ON DUPLICATE KEY UPDATE " + duplicateUpdateSql;
         }
         eta.db.query(sql, result.params, (err: eta.DBError, rows: any[]) => {
             if (err) {
                 eta.logger.dbError(err);
                 return;
             }
             eta.logger.trace("Successfully updated table " + tableName);
         });
     });
 }
開發者ID:crossroads-education,項目名稱:eta-sys,代碼行數:39,代碼來源:update-database.ts

示例7: callback

 eta.section.getByProfessor(req.session["userid"], (rawSections: eta.Section[]) => {
     if (!rawSections) {
         callback({ errcode: eta.http.InternalError });
         return;
     }
     let sections: eta.Section[] = eta.section.removePrevious(rawSections, eta.term.getCurrent().id);
     if (sections.length === 0) { // no sections at all or no current sections
         res.redirect("/track/index");
         return;
     }
     sections.sort(eta.section.sort);
     eta.person.getByID(req.session["userid"], (person: eta.Person) => {
         if (!person) {
             callback({ errcode: eta.http.InternalError });
             return;
         }
         callback({
             "name": person.firstName + " " + person.lastName,
             "sections": sections
         });
     });
 });
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:22,代碼來源:professor.ts


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