private void AddMessage() { if (string.IsNullOrEmpty(CallWebApiMain._accToken)) { ViewData["result"] = "请先登录!"; return; } //CallWebApiMain.Login(TxtUserName, TxtPassWord); //"OMSG对象Json + MSG1对象Json"; AddMessageModel msgObj = new AddMessageModel { MSG1 = ModelHelper.GetMSG1Model(), OMSG = ModelHelper.GetOmsgModel(), }; //添加消息 string result = CallWebApiMain.AddMessage(msgObj); APIReturnModel model = null; JavaScriptSerializer js = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(result)) { model = js.Deserialize <APIReturnModel>(result); } ViewData["result"] = model != null ? model.SequenceId : "Error"; }
public IActionResult Post([FromBody] SystemUserModel model) { try { if (!string.IsNullOrEmpty(model.Id)) { //Check Empty Guid Guid userid = new Guid(model.Id); if (userid != Guid.Empty) { //Update APIReturnModel update = SystemUserService.UpdateSystemUsers(model); return(Ok(new { data = update.Value, status = StatusMessages.Get(update.Status) })); } else { //Passed User ID is empty guid return(Ok(new { data = string.Empty, status = StatusMessages.Error_UserUpdateFailed_GUID })); } } else { //Insert APIReturnModel create = SystemUserService.CreateSystemUsers(model); return(Ok(new { data = create.Value, status = StatusMessages.Get(create.Status) })); } } catch { } return(Ok(new { data = string.Empty, status = StatusMessages.Error_Failed })); }
public IActionResult SystemUserRemove(string id) { try { if (!string.IsNullOrEmpty(id)) { //Check Empty Guid Guid userid = new Guid(id); if (userid != Guid.Empty) { //Delete APIReturnModel delete = SystemUserService.DeleteSystemUsers(id); return(Ok(new { data = delete.Value, status = StatusMessages.Get(delete.Status) })); } else { //Passed User ID is empty guid return(Ok(new { data = string.Empty, status = StatusMessages.Error_UserDeleteFailed_GUID })); } } else { //Passed User ID is empty guid return(Ok(new { data = string.Empty, status = StatusMessages.Error_UserDeleteFailed_GUID })); } } catch { } return(Ok(new { data = string.Empty, status = StatusMessages.Error_Failed })); }
protected void BtnAddMessage_Click(object sender, EventArgs e) { //"OMSG对象Json + MSG1对象Json"; AddMessageModel msgObj = new AddMessageModel { Omsg1Model = ModelHelper.GetMSG1Model(), OmsgModel = ModelHelper.GetOmsgModel(), }; string result = InterfaceController.AddMessage(msgObj); APIReturnModel model = null; try { JavaScriptSerializer js = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(result)) { model = js.Deserialize <APIReturnModel>(result); } } catch (Exception ex) { Console.WriteLine(ex); } Response.Write(JsonHelper.DataContractJsonSerialize <APIReturnModel>(model)); }
public APIReturnModel CallTripAdvisorAPI() { APIReturnModel returnModel = new APIReturnModel(); try { string TAkey = TripAdvisorSettings.TripAdvisorKey; using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); foreach (var locationID in TripAdvisorSettings.TripAdvisorLocationIDs.Split('|')) { foreach (var language in TripAdvisorSettings.TripAdvisorLanguages.Split('|')) { LocationModel model = new LocationModel(); model.LocationID = locationID; model.Language = language; if (TripAdvisorSettings.TripAdvisorLocationURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorLocationURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; LocationRootObject locationrootObject = JsonConvert.DeserializeObject <LocationRootObject>(response.Content.ReadAsStringAsync().Result); model.LocationDetails = locationrootObject; } if (TripAdvisorSettings.TripAdvisorActivityURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorActivityURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; ActivityRootObject activitiesrootObject = JsonConvert.DeserializeObject <ActivityRootObject>(response.Content.ReadAsStringAsync().Result); model.ActivitiesDetails = activitiesrootObject; } if (TripAdvisorSettings.TripAdvisorAttractionsURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorAttractionsURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; AttractionRootObject attractionsrootObject = JsonConvert.DeserializeObject <AttractionRootObject>(response.Content.ReadAsStringAsync().Result); model.AttractionDetails = attractionsrootObject; } if (TripAdvisorSettings.TripAdvisorHotelsURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorHotelsURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; HotelRootObject hotelsrootObject = JsonConvert.DeserializeObject <HotelRootObject>(response.Content.ReadAsStringAsync().Result); model.HotelDetails = hotelsrootObject; } if (TripAdvisorSettings.TripAdvisorRestaurantsURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorRestaurantsURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; RestaurantRootObject restaurantrootObject = JsonConvert.DeserializeObject <RestaurantRootObject>(response.Content.ReadAsStringAsync().Result); model.RestaurantDetails = restaurantrootObject; } if (TripAdvisorSettings.TripAdvisorReviewsURL != null) { string url = string.Format(TripAdvisorSettings.TripAdvisorReviewsURL, locationID, TAkey, language); var response = httpClient.GetAsync(url).Result; ReviewRootObject reviewrootObject = JsonConvert.DeserializeObject <ReviewRootObject>(response.Content.ReadAsStringAsync().Result); model.ReviewDetails = reviewrootObject; } returnModel.locationModels.Add(model); } } } } catch (Exception ex) { throw; } return(returnModel); }