コード例 #1
0
        public async Task <GeneralStringResponse> PluginGeneralAction(ActionBoundary actionBoundary, string requestURI)
        {
            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(requestURI,
                                                      new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(actionBoundary), Encoding.UTF8,
                                                                        "application/json"));


                string responseBody = await response.Content.ReadAsStringAsync();

                GeneralStringResponse generalStringResponse = null;
                try
                {
                    generalStringResponse = new JavaScriptSerializer().Deserialize <GeneralStringResponse>(responseBody);
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
                if (!response.IsSuccessStatusCode)
                {
                    JObject jObject = JObject.Parse(responseBody);
                    generalStringResponse.result = (string)jObject["message"];
                }
                return(generalStringResponse);
            }
        }
コード例 #2
0
        private async Task CheckInOrOut(string typeOfAction)
        {
            string                URLAdress             = ConfigurationManager.ConnectionStrings[ACTION_URL].ToString();
            ActionBoundary        action                = CreateActionBoundary(typeOfAction);
            GeneralStringResponse generalStringResponse = await _proxy.PluginGeneralAction(action, URLAdress);

            Message_From_Server = string.Copy(generalStringResponse.result);
            Message_For_User(Message_From_Server);
            //    Msg_For_User.Text = Message_From_Server;
        }