// DBへ登録 private void setAppKey(AccessSQLite db, ClientAppJson client) { var app = new AppKey(); app.ClientId = client.client_id; app.ClientSec = client.client_secret; db.DeleteAppKeyMaster(); db.InsertAppKeyMaster(app); }
private void setAccessToken(AccessSQLite db, AccessTokenJson token) { var tok = new AccessToken(); tok.Host = DefaultValue.MSTDN_HOST; tok.Token = token.access_token; db.DeleteAccessTokenMaster(); db.InsertAccessTokenMaster(tok); }
protected void getAccessToken() { flg = false; AccessSQLite db = new AccessSQLite(); IEnumerable <AccessToken> token = db.GetAccessTokenMaster(); foreach (AccessToken data in token) { this.pHost = data.Host; this.pToken = data.Token; flg = true; } }
protected void getAppKey() { flg = false; AccessSQLite db = new AccessSQLite(); IEnumerable <AppKey> appData = db.GetAppKeyMaster(); foreach (AppKey data in appData) { this.pClientId = data.ClientId; this.pClientSec = data.ClientSec; flg = true; } }
// SQLiteからデータを取得 protected void getUser() { flg = false; AccessSQLite db = new AccessSQLite(); IEnumerable <UserData> userMaster = db.GetUserMaster(); foreach (UserData data in userMaster) { this.pUser = data.UserId; this.pPass = data.Password; flg = true; } }
// DB更新 private void UpdateDb() { try { AccessSQLite db = new AccessSQLite(); UserData ud = new UserData(); ud.UserId = this.User.Text; ud.Password = this.Password.Text; db.DeleteUserMaster(); db.InsertUserMaster(ud); } catch (Exception e) { throw e; } }
// 起動時処理 protected async override void OnAppearing() { base.OnAppearing(); try { var db = new AccessSQLite(); getUser(); if (!flg) { MoveToLoginPage(DefaultValue.FST_SETTING_MSG); return; } // 初回のみアプリIDの取得 var access = new HttpRequest(); getAppKey(); if (!flg) { try { var client = await access.getClientAppJson(DefaultValue.MSTDN_HOST); setAppKey(db, client); } catch (Exception ex) { MoveToLoginPage(DefaultValue.ERR_SETTING_MSG); return; } getAppKey(); } // 起動時にアクセストークンを取得する try { var token = await access.getTokenJson(DefaultValue.MSTDN_HOST, pClientId, pClientSec, pUser, pPass); setAccessToken(db, token); } catch (Exception ex) { MoveToLoginPage(DefaultValue.ERR_SETTING_MSG); return; } } catch (Exception exception) { ErrorProc(exception); } moveMain(); }