예제 #1
0
        public void Post([FromUri] Pfile items)
        {
            //    Encryption.Encrypt
            try
            {
                result = falseresult("ข้อมูลไม่ถูกต้อง");
                CustomerMapDao map = new CustomerMapDao();
                int            _id = MobileEncryption.Decrypt(items.ID.UrlDescriptHttp()).Toint();
                string         Key = MobileEncryption.Decrypt(items.UserKeys.UrlDescriptHttp());
                var            Obj = map.FindByActive().Where(o => o.ID == _id && o.Keygen == Key).FirstOrDefault();
                if (Obj != null)
                {
                    SaveAccount.UpdateUser(Obj.ID, items.TitleID, items.Fname, items.Lname, items.DateOfBirth, items.OccupationID, items.SalaryID, items.Address, items.ProvinceID, items.PrefectureID, items.DistrictID, items.ZipCode,
                                           items.Tel, items.Tel_ext, items.Mobile, items.Fax, items.Email);
                    result = Trueresult("แก้ไขข้อมูลเรียบร้อย");
                }
                else
                {
                    result = falseresult("ข้อมูลไม่ถูกต้อง");
                }
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }

            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
예제 #2
0
        public String getTitle()
        {
            String     title  = "";
            HttpClient client = new HttpClient()
            {
                BaseAddress = new Uri(Profile.ServerSetting.ApiUrl)
            };

            JObject main    = new JObject();
            JObject mParams = new JObject();

            main.Add("rpcId", "APP_GENFILE");
            mParams.Add("APPID", "FLOW01");
            main.Add("params", mParams);
            HttpContent         contentPost = new StringContent(main.ToString(), Encoding.UTF8, "application/json");
            HttpResponseMessage response    = client.PostAsync("", contentPost).GetAwaiter().GetResult();

            Pfile pfile = JsonConvert.DeserializeObject <Pfile>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());//反序列化

            return(pfile.result[0].PFILE);
        }