예제 #1
0
        /// <summary>
        /// get the user's infomation
        /// </summary>
        /// <param name="uName">the name of the user</param>
        private async void GetPersonalInfo(string uName)
        {
            //get the domain of the web request
            string domain = this.GetString(Resource.String.domain);
            string url    = domain + "user/getuserinfo";

            IDictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("uName", uName);

            var result = await EasyWebRequest.SendGetHttpRequestBaseOnHttpWebRequest(url, dic);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")//success
            {
                string     user = data["Data"].ToString();
                JsonObject jo   = JsonObject.Parse(user) as JsonObject;

                etEmail.Text  = jo["UserEmail"];
                etName.Text   = jo["UserName"];
                tvGender.Text = jo["UserGender"];
            }
            else//fault
            {
                etEmail.Text  = "";
                etName.Text   = "";
                tvGender.Text = "";
            }
        }
        void calculatedData()
        {
            try
            {
                DateTime sd = startDatePicker.Date + startTime;
                DateTime ed = endDatePicker.Date + endTime;

                if (DateTime.Compare(sd, ed) >= 0)
                {
                    CrossHud.Current.ShowError(message: "开始时间必须早于结束时间", timeout: new TimeSpan(0, 0, 4));
                    return;
                }

                string url    = App.BaseURL + "AppFlow/ComputedFlowAllWater";
                string parama = "flowid=" + _flow.flowid + "&" + "sdt=" + sd.ToString("yyyy-MM-dd HH:mm") + "&" + "edt=" + ed.ToString("yyyy-MM-dd HH:mm") + "&" + "para1=" + entry1.Text + "&" + "para2=" + entry2.Text;

                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendOtherPOSTHttpWebRequest(url, parama);
                Console.WriteLine("请求结果:" + result);
                calculated = JsonConvert.DeserializeObject <calculatedResult>(result);
            }
            catch (Exception ex)
            {
            }
        }
예제 #3
0
        /// <summary>
        /// user registrate button click even
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RegistrateEven(object sender, EventArgs e)
        {
            txtName     = FindViewById <EditText>(Resource.Id.et_name);
            txtPwd      = FindViewById <EditText>(Resource.Id.et_pwd);
            txtEmail    = FindViewById <EditText>(Resource.Id.et_email);
            _userGender = rg.CheckedRadioButtonId == Resource.Id.rbtn_man ? "male" : "female";

            string domain = this.GetString(Resource.String.domain);
            string url    = domain + "user/register";
            IDictionary <string, string> routeParames = new Dictionary <string, string>();

            routeParames.Add("userName", DESHelper.DESEncrypt(this.txtName.Text));
            routeParames.Add("userPassword", DESHelper.DESEncrypt(HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text)));
            routeParames.Add("gender", DESHelper.DESEncrypt(this._userGender));
            routeParames.Add("email", DESHelper.DESEncrypt(this.txtEmail.Text));

            var result = await EasyWebRequest.SendPostRequestBasedOnHttpClient(url, routeParames);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Register fail", ToastLength.Long).Show();
            }
        }
예제 #4
0
        /// <summary>
        /// login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void LoginClickEven(object sender, EventArgs e)
        {
            txtName = FindViewById <EditText>(Resource.Id.txt_name);
            txtPwd  = FindViewById <EditText>(Resource.Id.txt_pwd);

            string domain = this.GetString(Resource.String.domain);
            string url    = domain + "user/login";
            IDictionary <string, string> routeParames = new Dictionary <string, string>();

            routeParames.Add("userName", DESHelper.DESEncrypt(this.txtName.Text));
            routeParames.Add("userPassword", DESHelper.DESEncrypt(HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text)));

            var test = HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text);

            var result = await EasyWebRequest.SendPostRequestBasedOnHttpClient(url, routeParames);

            //var result = await EasyWebRequest.SendPostHttpRequestBaseOnHttpWebRequest(url, routeParames);
            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                var share  = GetSharedPreferences("finance", FileCreationMode.Private);
                var editor = share.Edit();
                editor.PutString("name", txtName.Text).Commit();

                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Login fail,please check your name and password", ToastLength.Long).Show();
            }
        }
예제 #5
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppArray/GetAllArray?id=" + _arrayID + "&pageIndex=0&pageSize=30";
                Console.WriteLine(url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);
                devisResult dev = JsonConvert.DeserializeObject <devisResult>(result);
                if (pageIndex == 0)
                {
                    dataList.Clear();
                }
                if (dev.Items.Count < 20)
                {
                    haveMole = false;
                }

                for (int i = 0; i < dev.Items.Count; i++)
                {
                    DeviesModel item = dev.Items[i];

                    dataList.Add(item);
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("错误提示", ex.Message, "OK");
            }
        }
예제 #6
0
        //给后传递deviceToken
        public static async void pushDeviceTokenToServie()
        {
            string url = App.BaseURL + "AppAlarm/StartedApptoken";

            Console.WriteLine("url ==" + url);
            string parama = "apptoken=" + App.deviceToken + "&" + "apptype=" + 0;

            Console.WriteLine("parama ==" + parama);
            string result = await EasyWebRequest.sendAwaitePOSTHttpWebRequest(url, parama, "");

            Console.WriteLine("result ==" + result);
        }
예제 #7
0
        private async void GetRequest(object sender, EventArgs e)
        {
            string url = "http://192.168.1.102:8077/User/GetThing";
            IDictionary <string, string> routeParames = new Dictionary <string, string>();

            routeParames.Add("str", this.txtInput.Text);
            var result = await EasyWebRequest.SendGetRequestBasedOnHttpClient(url, routeParames);

            var data = (JsonObject)result;

            this.tv.Text = "hey," + data["Val"] + ",  i am from httpclient get";
        }
 void makeData()
 {
     try
     {
         string url = App.BaseURL + "AppFlow/GetFlowDesInfo?id=" + _flow.flowid;
         Console.WriteLine("请求接口:" + url);
         string result = EasyWebRequest.sendGetHttpWebRequest(url);
         Console.WriteLine("请求结果:" + result);
         result = result.Replace("null", "0");
         list   = JsonConvert.DeserializeObject <List <FlowDesInfo> >(result);
     }
     catch (Exception ex)
     {
     }
 }
예제 #9
0
 void makeData()
 {
     try
     {
         string url = App.BaseURL + "AppOperParam/GetAllOper?id=" + _eqId + "&pageIndex=0&pageSize=30";
         Console.WriteLine(url);
         string result = EasyWebRequest.sendGetHttpWebRequest(url);
         Console.WriteLine("请求结果:" + result);
         entlisttype ENT = JsonConvert.DeserializeObject <entlisttype>(result);
         list = ENT.Items;
     }
     catch (Exception ex)
     {
         DisplayAlert("错误提示", ex.Message, "OK");
     }
 }
예제 #10
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppAlarm/GetParamByAlarm?id=" + _alert.alarmid;
                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                list = JsonConvert.DeserializeObject <AlertInfo>(result);
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #11
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppPushAlarm/GetPush?id=" + _alertOrAlarmId;
                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                list = JsonConvert.DeserializeObject <List <PushRecordType> >(result);
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #12
0
        private void reqLogin(String account, String pwd)
        {
            CrossHud.Current.Show("登陆中。。。");
            BackgroundWorker wrk = new BackgroundWorker();

            wrk.DoWork += (sender1, e1) =>
            {
                string uri = "https://www.cloudWTO.com.cn/token";

                //string uri = "http://dev.azuratech.com:20000/token";
                string parama = "Password="******"&" + "UserName="******"&" + "grant_type=password";
                result = EasyWebRequest.sendPOSTHttpWebRequest(uri, parama);
            };
            wrk.RunWorkerCompleted += (sender1, e1) =>
            {
                if (result.Contains("400"))
                {
                    CrossHud.Current.Dismiss();
                    DependencyService.Get <Sample.IToast>().ShortAlert("账号密码有误");
                }
                else if (result.Contains("access_token"))
                {
                    haveToken model = JsonConvert.DeserializeObject <haveToken>(result);
                    App.token = "Bearer" + " " + model.access_token;
                    //CrossHud.Current.Dismiss();
                    if (App.token != null)
                    {
                        try
                        {
                            reqUserInfo();
                            DependencyService.Get <IJpushSetAlias>().setAliasWithName(account);
                        }
                        catch (Exception ex)
                        {
                            DisplayAlert("错误提示", ex.Message, "OK");
                        }
                    }
                }
                else
                {
                    CrossHud.Current.Dismiss();
                    DependencyService.Get <Sample.IToast>().ShortAlert("网络异常");
                    //Navigation.PushAsync(new EnterpriseListPage());
                }
            };
            wrk.RunWorkerAsync();
        }
예제 #13
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppFlow/GetFlowOperById?id=" + _flow.flowid;

                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                dataList = JsonConvert.DeserializeObject <ObservableCollection <WaterDataModel> >(result);
            }
            catch (Exception ex)
            {
                DisplayAlert("错误提示", ex.Message, "OK");
            }
        }
예제 #14
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppFlow/GetAllROEquipment?id=" + _flow.flowid;
                Console.WriteLine(url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                dataList = JsonConvert.DeserializeObject <ObservableCollection <ROEquipmentModel> >(result);
                CrossHud.Current.Dismiss();
            }
            catch (Exception ex)
            {
                CrossHud.Current.Dismiss();
                CrossHud.Current.ShowError(message: "网络错误", timeout: new TimeSpan(0, 0, 4));
            }
        }
예제 #15
0
        void makeData()
        {
            try
            {
                DateTime sd  = startDatePicker.Date + startTime;
                DateTime ed  = endDatePicker.Date + endTime;
                string   url = App.BaseURL + "AppOperParam/GetDataByTime?id=" + _parametId + "&startTime=" + sd.ToString("yyyy-MM-dd HH:mm") + "&endTime=" + ed.ToString("yyyy-MM-dd HH:mm");

                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);
                result     = result.Replace("null", "0");
                resultData = JsonConvert.DeserializeObject <resultParama>(result);
            }
            catch (Exception ex)
            {
                DisplayAlert("错误提示", ex.Message, "OK");
            }
        }
예제 #16
0
        /// <summary>
        /// get the detials
        /// </summary>
        /// <param name="uName">the name of the user</param>
        /// <returns></returns>
        private async Task <JsonObject> GetMoneyDetial(string uName)
        {
            string domain = this.Activity.GetString(Resource.String.domain);
            string url    = domain + "money/getmoneydetial";
            IDictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("uName", uName);
            var result = await EasyWebRequest.SendGetHttpRequestBaseOnHttpWebRequest(url, dic);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                return(data);
            }
            else
            {
                return(new JsonObject());
            }
        }
예제 #17
0
        /// <summary>
        /// get the summary data
        /// </summary>
        /// <param name="uName">the name of the user</param>
        private async void GetSummaryDate(string uName)
        {
            string domain = this.Activity.GetString(Resource.String.domain);
            string url    = domain + "money/gettotalinfo";
            IDictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("uname", string.IsNullOrEmpty(uName) ? "" : uName);
            var result = await EasyWebRequest.SendGetHttpRequestBaseOnHttpWebRequest(url, dic);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                tvIncome.Text = "Your total income is гд " + data["Income"].ToString();
                tvPay.Text    = "Your total pay is гд " + data["Pay"].ToString();
            }
            else
            {
            }
        }
예제 #18
0
        /// <summary>
        /// request the categories
        /// </summary>
        /// <returns></returns>
        private async Task <JsonObject> GetCategory()
        {
            string domain = this.Activity.GetString(Resource.String.domain);
            string url    = domain + "category/getallcategory";
            IDictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("1", "1");
            var result = await EasyWebRequest.SendGetHttpRequestBaseOnHttpWebRequest(url, dic);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                return(data);
            }
            else
            {
                return(new JsonObject());
            }
        }
예제 #19
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppFlow/GetFlowOparamter?id=" + _flow.flowid + "&equipmentid=" + _equipment.id;
                Console.WriteLine(url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果前:" + result);
                result = result.Replace("null", "0");
                Console.WriteLine("请求结果后:" + result);

                dataList = JsonConvert.DeserializeObject <ObservableCollection <FlowDesInfo> >(result);
                CrossHud.Current.Dismiss();
            }
            catch (Exception ex)
            {
                CrossHud.Current.Dismiss();
                CrossHud.Current.ShowError(message: "网络错误", timeout: new TimeSpan(0, 0, 4));
            }
        }
예제 #20
0
        private void reqGoEnt()
        {
            BackgroundWorker wrk = new BackgroundWorker();

            wrk.DoWork += (sender1, e1) =>
            {
                string url2 = App.BaseURL + "AppEnterprise/GeteEnterpriseByKey?searchKey=" + "&pageIndex=0" + "&pageSize=30";
                result = EasyWebRequest.sendGetHttpWebRequest(url2);
            };
            wrk.RunWorkerCompleted += (sender1, e1) =>
            {
                var retv   = JsonConvert.DeserializeObject <entlisttype>(result);
                var list   = retv.Items;
                var busine = new BusinessDetailsPage(list[0], 0);
                CrossHud.Current.Dismiss();
                Navigation.PushAsync(busine);
                pushDeviceTokenToServie();
            };
            wrk.RunWorkerAsync();
        }
예제 #21
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppEnterprise/GetEnterpriseDetail?id=" + _ent.id;
                Console.WriteLine(url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                var list = JsonConvert.DeserializeObject <List <BusinessDetails> >(result);

                if (list.Count > 0)
                {
                    details = list[0];
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #22
0
        void makeData()
        {
            try
            {
                DateTime end   = DateTime.Now;
                DateTime start = end.AddHours(-6);

                var endStr   = end.ToString("yyyy-MM-dd HH:mm:ss");
                var startStr = start.ToString("yyyy-MM-dd");
                startStr = startStr + " 00:00:00";
                string url = App.BaseURL + "AppAlarm/GetAlarmCountByFlowid?id=" + _flow.flowid + "&sdt=" + startStr + "&edt=" + endStr;
                Console.WriteLine(url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                aaaa = JsonConvert.DeserializeObject <List <resutlDic> >(result);
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #23
0
        private void reqUserInfo()
        {
            string           userinfoResult = "";
            BackgroundWorker wrk            = new BackgroundWorker();

            wrk.DoWork += (sender1, e1) =>
            {
                string url = App.BaseURL + "appflow/GetUserInfo";
                Console.WriteLine(url);
                userinfoResult = EasyWebRequest.sendGetHttpWebRequest(url);
            };
            wrk.RunWorkerCompleted += (sender1, e1) =>
            {
                userInfo userinfo = JsonConvert.DeserializeObject <userInfo>(userinfoResult);

                if (userinfo.userInf_roleid == null)
                {
                    return;
                }
                if (userinfo.userInf_roleid == "4")
                {//企业管理员直接进入企业
                    try
                    {
                        reqGoEnt();
                    }
                    catch (Exception ex)
                    {
                        DisplayAlert("错误提示", ex.Message, "OK");
                    }
                }
                else
                {
                    CrossHud.Current.Dismiss();
                    Navigation.PushAsync(new EnterpriseListPage());
                    pushDeviceTokenToServie();
                }
            };
            wrk.RunWorkerAsync();
        }
예제 #24
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppEnterprise/GeteEnterpriseByKey?searchKey=" + searchB.Text + "&pageIndex=" + pageIndex + "&pageSize=30";
                Console.WriteLine("请求url:" + url);

                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                var retv = JsonConvert.DeserializeObject <entlisttype>(result);
                if (retv == null)
                {
                    DisplayAlert("retv null", result, "OK");
                }
                if (pageIndex == 0)
                {
                    dataList.Clear();
                }
                for (int i = 0; i < retv.Items.Count; i++)
                {
                    Enttype item = retv.Items[i];
                    dataList.Add(item);
                }

                if (retv.Totals <= dataList.Count)
                {
                    haveMole = false;
                }
                else
                {
                    haveMole = true;
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #25
0
        /// <summary>
        /// even of the add button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddItemClickEven(object sender, EventArgs e)
        {
            //get the data
            string date     = edDate.Text;
            string category = spCategory.SelectedItem.ToString();
            string type     = (string)spType.SelectedItem;
            string money    = etMoney.Text;
            string about    = etAbout.Text;

            var shared = this.Activity.GetSharedPreferences("finance", FileCreationMode.Private);

            string uName = shared.GetString("name", "");

            string domain = this.Activity.GetString(Resource.String.domain);
            //web request
            string url = domain + "money/addmoneyrecord";
            IDictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("uName", uName);
            dic.Add("moneyType", type);
            dic.Add("categoryId", category);
            dic.Add("moneyValue", money);
            dic.Add("moneyDate", date);
            dic.Add("moneyAbout", about);

            var result = await EasyWebRequest.SendPostRequestBasedOnHttpClient(url, dic);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                Toast.MakeText(this.Activity, "OK", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this.Activity, "Fail", ToastLength.Long).Show();
            }
        }
예제 #26
0
        void haveAlertOrAlarm()
        {
            try
            {
                DateTime sd  = startDatePicker.Date + startTime;
                DateTime ed  = endDatePicker.Date + endTime;
                string   url = App.BaseURL + "AppAlarm/GetAllAlarm?id=" + _businessId + "&startTime=" + sd.ToString("yyyy-MM-dd HH:mm") + "&endTime=" + ed.ToString("yyyy-MM-dd HH:mm") + "&pageIndex=" + pageIndex +
                               "&pageSize=20" + "&flag=" + _flag;
                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                resutlDic resultList = JsonConvert.DeserializeObject <resutlDic>(result);
                if (pageIndex == 0)
                {
                    dataList.Clear();
                }
                for (int i = 0; i < resultList.Items.Count; i++)
                {
                    AlertAndAlarmt item = resultList.Items[i];

                    dataList.Add(item);
                }

                if (resultList.Totals <= dataList.Count)
                {
                    haveMole = false;
                }
                else
                {
                    haveMole = true;
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Alert", ex.Message, "OK");
            }
        }
예제 #27
0
        void makeData()
        {
            try
            {
                string url = App.BaseURL + "AppFlow/GetDataByFlow?id=" + _flow.flowid + "&searchKey=" + searchB.Text + "&pageIndex=" + pageIndex + "&pageSize=20";

                Console.WriteLine("请求接口:" + url);
                string result = EasyWebRequest.sendGetHttpWebRequest(url);
                Console.WriteLine("请求结果:" + result);

                var list = JsonConvert.DeserializeObject <entlisttype>(result);

                if (pageIndex == 0)
                {
                    dataList.Clear();
                }

                for (int i = 0; i < list.Items.Count; i++)
                {
                    Parameter item = list.Items[i];
                    dataList.Add(item);
                }
                if (dataList.Count >= list.Totals)
                {
                    haveMole = false;
                }
                else
                {
                    haveMole = true;
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("错误提示", ex.Message, "OK");
            }
        }