async Task <IEnumerator <Task <WorkingLogSubordinate> > > FetchSubordinateWorkingLogs(string userId, string password, string companyCode) { var html = ""; // ログオン処理 html = await LogOn(userId, password, companyCode); return(await Task.Run(() => { // ApprovalMonthlyへアクセス html = wc.Get(AttendanceProURLs.ApprovalMonthly); ResponseValidator.ValidateFetchedApprovalMonthly(html); return FetchSubordinateWorkingLogs(html); })); }
// ログイン async Task <string> LogOn(string userId, string password, string companyCode) { return(await Task.Run(() => { // トップページの取得 var html = wc.Get(AttendanceProURLs.LogOn); // ログイン実行 var query = QueryCreator.QueryForLogOnPage(html, userId, password, companyCode); html = wc.Post(AttendanceProURLs.LogOn, query); // ログインが正常に完了しているかのチェック ResponseValidator.ValidateLoggedIn(html); return html; })); }
/// <summary> /// /// </summary> /// <returns></returns> public async Task <bool> IsManagerAccount() { return(await Task.Run(() => { // ApprovalMonthlyへアクセス var html = wc.Get(AttendanceProURLs.ApprovalMonthly); try { ResponseValidator.ValidateFetchedApprovalMonthly(html); // ??? return true; } catch (AttendanceProFetchApprovalMonthlyException) { return false; } })); }
async Task <WorkingLogSubordinate> FetchSubordinateWorkingLog(string html, string targetSubordinate) { return(await Task.Run(() => { var today = DateTime.Today.Day; // まずは ApprovalMonthlyへアクセスしてURLを取得する var query = QueryCreator.QueryForApprovalMonthlyPage(html, targetSubordinate); html = wc.Post(AttendanceProURLs.ApprovalMonthly, query); // AttendanceExercisedMonthlyDetails へのアクセス var url = QueryCreator.UrlForAttendanceExercisedMonthlyDetailsPage(html); html = wc.Get(url); var doc = ResponseValidator.ValidateFetchedAttendanceExercisedMonthlyDetails(html); return new WorkingLogSubordinate(doc, today); })); }
async Task <WorkingLogOwn> Attend(string userId, string password, string companyCode, AttendanceTypes type) { // ログイン後のページ var html = await LogOn(userId, password, companyCode); await Task.Run(() => { // 既に出退勤済かどうか ResponseValidator.ValidateAlreadyAttended(html, type); // 出退勤実行 var query = QueryCreator.QueryForAttendanceTableDailyPage(html, type); html = wc.Post(AttendanceProURLs.AttendanceTableDaily, query); // 出退勤が正常に完了しているかのチェック ResponseValidator.ValidateAttended(html, type); }); // 月次勤務表の情報を取得 return(await FetchOwnWorkingLog(userId, password, companyCode, withLogOn : false)); }
async Task <WorkingLogOwn> FetchOwnWorkingLog(string userId, string password, string companyCode, bool withLogOn) { var html = ""; if (withLogOn) { // ログオン処理 html = await LogOn(userId, password, companyCode); } return(await Task.Run(() => { var today = DateTime.Today.Day; // 月次勤務表から情報を取得する html = wc.Get(AttendanceProURLs.AttendanceTableFullTime); // 月次勤務表が取得できているかのチェック var doc = ResponseValidator.ValidateFetchedTableFullTime(html); return new WorkingLogOwn(doc, today); })); }