Beispiel #1
0
        /// <summary>
        /// 签到,查询
        /// <param name="queryOnly">true:查询 false:签到</param>
        /// </summary>
        /// <returns></returns>
        public async Task <DoSignResponseData> DoSign(string queryOnly)
        {
            DoSignRequestParams sParams = new DoSignRequestParams();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            sParams.queryOny = queryOnly;
            HttpSerializeData <DoSignRequestParams> httpSerializeData = new HttpSerializeData <DoSignRequestParams>("doSign.html", sParams);
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            resultJson     = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));

            HttpDeserializeData <DoSignResponseData> sData = JsonAnalysis.Deserialize <HttpDeserializeData <DoSignResponseData> >(resultJson);

            if (queryOnly.Equals("false"))
            {
            }
            if (sData.result.error == "00")// 签到成功
            {
                return(sData.result);
            }
            else if (sData.status.code.Equals("0000"))
            {
                return(sData.result);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        private async void GetHttpRequest_Click(object sender, RoutedEventArgs e)
        {
            string url = "http://baike.baidu.com/cms/global/lemma_config.json";

            byte[] bytes = null;
            string str   = null;


            NetworkRequest request = NetworkRequest.CreateHttp("http://baike.baidu.com/cms/global/lemma_config.json?cl=2&rn=20&tn=news");

            bytes = request.Get();

            request = NetworkRequest.CreateHttp("http://p5.sinaimg.cn/2776321060/180/73181353913818");
            bytes   = await request.GetAsync();

            str             = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
            this.img.Source = await ToolsLib.Utility.GetBitmapImageAsync(bytes);

            request      = NetworkRequest.CreateHttp(url);
            request.Body = "name=123";
            bytes        = request.Post();

            request = NetworkRequest.CreateHttp(url);
            bytes   = await request.PostAsync();

            str = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            this.result_tbk.Text = str;
        }
Beispiel #3
0
        public async Task <bool> GetUserInfo()
        {
            GetUserInforRequestParams sParams = new GetUserInforRequestParams();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            HttpSerializeData <GetUserInforRequestParams> httpSerializeData = new HttpSerializeData <GetUserInforRequestParams>("getUserInfo.html", sParams);
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            resultJson     = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));

            if (!string.IsNullOrEmpty(resultJson))
            {
                HttpDeserializeData <GetUserInforResponseData> sData = JsonAnalysis.Deserialize <HttpDeserializeData <GetUserInforResponseData> >(resultJson);

                if (sData.result.error == "01")   // 未绑定账户
                {
                    //todo:跳转到绑定页面,进行用户绑定
                    (Window.Current.Content as Frame).Navigate(typeof(BindDevicePage));
                }
                else if (sData.status.code.Equals("0000"))
                {
                    //todo:跳转到签到页面
                    (Window.Current.Content as Frame).Navigate(typeof(SignPage));
                }
                else
                {
                }
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        private async void BindDevice()
        {
            BindDeviceRequest sParams = new BindDeviceRequest();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            sParams.userName = "******";

            HttpSerializeData <BindDeviceRequest> httpSerializeData = new HttpSerializeData <BindDeviceRequest>("bindDevice.html", sParams);
            string         url            = httpSerializeData.GetURL();
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            result         = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));
        }
Beispiel #5
0
        /// <summary>
        /// 签到,查询
        /// <param name="queryOnly">true:查询 false:签到</param>
        /// </summary>
        /// <returns></returns>
        public async Task <DoSignResponseData> DoSign(string queryOnly)
        {
            DoSignRequestParams sParams = new DoSignRequestParams();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            sParams.queryOny = queryOnly;
            HttpSerializeData <DoSignRequestParams> httpSerializeData = new HttpSerializeData <DoSignRequestParams>("doSign.html", sParams);
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            resultJson     = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));

            HttpDeserializeData <DoSignResponseData> sData = JsonAnalysis.Deserialize <HttpDeserializeData <DoSignResponseData> >(resultJson);

            if (sData == null)
            {
                //todo:报错
                var res = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    var msg = new MessageDialog("网络请求错误!").ShowAsync();
                });
            }
            if (queryOnly.Equals("false"))
            {
            }
            if (sData.result.error == "00")// 签到成功
            {
                this.SystemTime  = sData.result.sysTime;
                this.SignInTime  = sData.result.signInTime;
                this.SignOutTime = sData.result.signOutTime;
                this.UserName    = sData.result.realName;
                return(sData.result);
            }
            else if (sData.status.code.Equals("0000"))
            {
                this.SystemTime  = sData.result.sysTime;
                this.SignInTime  = sData.result.signInTime;
                this.SignOutTime = sData.result.signOutTime;
                this.UserName    = sData.result.realName;
                if (queryOnly.Equals("false"))
                {
                    //todo:报错
                    var res = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var msg = new MessageDialog(sData.result.errorMsg).ShowAsync();
                    });
                }
                return(sData.result);
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
        private async void PostHttpRequest_Async_Click(object sender, RoutedEventArgs e)
        {
            string url = "http://baike.baidu.com/cms/global/lemma_config.json";

            byte[]         bytes   = null;
            string         str     = null;
            NetworkRequest request = NetworkRequest.CreateHttp(url);

            bytes = await request.PostAsync();

            str = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
            this.result_tbk.Text = str;
        }
Beispiel #7
0
        public async Task <string> BindDevice(string userName)
        {
            BindDeviceRequest sParams = new BindDeviceRequest();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            sParams.userName = userName;

            HttpSerializeData <BindDeviceRequest> httpSerializeData = new HttpSerializeData <BindDeviceRequest>("bindDevice.html", sParams);
            string         url            = httpSerializeData.GetURL();
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            result         = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));

            return(result);
        }
Beispiel #8
0
        private async void GetUserInfo()
        {
            GetUserInforRequestParams sParams = new GetUserInforRequestParams();

            sParams.deviceId = Configuration.GetDeviceUniqueId();
            HttpSerializeData <GetUserInforRequestParams> httpSerializeData = new HttpSerializeData <GetUserInforRequestParams>("getUserInfo.html", sParams);
            NetworkRequest networkRequest = NetworkRequest.CreateHttp(httpSerializeData.GetURL());
            var            resultJson     = await networkRequest.PostAsync <string>(JsonAnalysis.Serialize(httpSerializeData));

            HttpDeserializeData <GetUserInforResponseData> sData = JsonAnalysis.Deserialize <HttpDeserializeData <GetUserInforResponseData> >(resultJson);

            if (sData.result.error == "01")   // 未绑定账户
            {
                //todo:跳转到绑定页面,进行用户绑定
            }
            else if (sData.status.code.Equals("0000"))
            {
                //todo:跳转到签到页面
            }
            else
            {
            }
        }