/// <summary> /// 認証トークンを取得します。ログイン処理。成功した場合、id,Tokenがthis Connectionに設定されます。 /// </summary> /// <param name="passWd">Input MD5 Passwd.</param> public async Task <string> GetToken(string id, string passWd) { try { var req = new ReqLogginJson(); req.id = id; req.passwd = passWd; req.device = Environment.MachineName; string json; DataContractJsonSerializer dc = new DataContractJsonSerializer(typeof(ReqLogginJson)); using (MemoryStream stm = new MemoryStream()) { dc.WriteObject(stm, req); stm.Position = 0; using (StreamReader read = new StreamReader(stm)) json = read.ReadToEnd(); } string resJson = await Post(REQUEST_URI + "/Account/Loggin/", json); var res = Serializer <ResponseMessageJson> .GetT(resJson); if (res.status == "success") { this.MyId = id; this.Token = res.data; return(res.data); } Debug.Error("GET Token Error. " + res.status + " > " + res.data); return(null); } catch { return(null); } }
/// <summary> /// ユーザー作成リクエストを送信します。(ログイン処理は含みません。) /// </summary> /// <returns>KVP(結果[bool],メッセージ[string])</returns> /// <param name="passwd">MD5</param> public async Task <KeyValuePair <bool, string> > CreateUser(string id, string email, string passWd) { ReqLogginJson req = new ReqLogginJson(); req.id = id; req.email = email; req.passwd = passWd; try { var json = Serializer <ReqLogginJson> .GetJson(req); var resJson = await Post(REQUEST_URI + "/Account/CreateUser/", json); var res = Serializer <ResponseMessageJson> .GetT(resJson); if (res.status == "success") { return(new KeyValuePair <bool, string>(true, "success.")); } else { return(new KeyValuePair <bool, string>(false, res.data)); } } catch { return(new KeyValuePair <bool, string>(false, "Error.")); } }