public async static Task <List <InformationListModel> > GetInformationListByUserNameAsync(int pageIndex, int pageSize, string userName) { try { HttpService http = new HttpService(); string response = await http.SendGetRequest( InterfaceUrl.GetInformationListByUserName(pageIndex, pageSize, userName)); if (response != string.Empty) { JArray jsonArray = JArray.Parse(response); List <InformationListModel> lstInformationList = new List <InformationListModel>(); foreach (var json in jsonArray) { InformationListModel model = new InformationListModel(); model.informationId = json["informationId"].ToString(); model.userId = json["userId"].ToString(); model.avatorUri = json["avatorUri"].ToString(); model.userName = json["userName"].ToString(); model.title = json["title"].ToString(); model.summary = json["summary"].ToString(); model.viewCount = json["viewCount"].ToString(); model.publishTime = json["publishTime"].ToString(); model.publishAddress = json["publishAddress"].ToString(); lstInformationList.Add(model); } return(lstInformationList); } return(null); } catch { return(null); } }
public async static Task <InformationModel> GetInformationByIdAsync(string id) { try { HttpService http = new HttpService(); string response = await http.SendGetRequest(InterfaceUrl.GetInformationById(id)); if (response != string.Empty) { JObject jsonObject = JObject.Parse(response); InformationModel model = new InformationModel(); model.id = jsonObject["id"].ToString(); model.userName = jsonObject["userName"].ToString(); model.wage = jsonObject["wage"].ToString(); model.title = jsonObject["title"].ToString(); model.viewCount = jsonObject["viewCount"].ToString(); model.content = jsonObject["content"].ToString(); model.isAcceptOrder = jsonObject["isAcceptOrder"].ToString(); model.getOrderUserName = jsonObject["getOrderUserName"].ToString(); model.addTime = jsonObject["addTime"].ToString(); model.address = jsonObject["address"].ToString(); return(model); } } catch { } return(null); }
/// <summary> /// 此方法获取坐标对应的地理名,将城镇明储存在同步存储中,返回全称 /// </summary> /// <param name="pos">Geoposition 类型的地理坐标</param> /// <returns>城市全称</returns> private async Task <string> UpdateLocationData(Geoposition pos) { try { if (pos == null) { //this.tbMessage.Text += "\nNo data."; return(string.Empty); } else { string longitude = pos.Coordinate.Point.Position.Longitude.ToString(); //精度 string latitude = pos.Coordinate.Point.Position.Latitude.ToString(); //纬度 //this.tbMessage.Text += $"\n经度为{longitude},纬度为{latitude}"; HttpService http = new HttpService(); string response = await http.SendGetRequest(InterfaceUrl.GetRegeoUrl(longitude, latitude)); if (response != string.Empty) { string city = GetCityAndDistrict(response); roamingSettings.Values[Constants.SettingName.Location] = city; string formattedAddress = GetFormattedAddress(response); return(formattedAddress); //tbMessage.Text += $"\n城市为{city},全位置为{formattedAddress}"; } } } catch { } return(string.Empty); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var item = DataSource as ContentItem; if (item == null) { return; } if (string.IsNullOrEmpty(InterfaceUrl)) { this.NavigateUrl = N2.Context.Current.GetContentAdapter <NodeAdapter>(item).GetPreviewUrl(item); } else { this.NavigateUrl = InterfaceUrl.ResolveUrlTokens().ToUrl().AppendSelection(item); } if (!ShowIcon) { Text = item.Title; } else if (string.IsNullOrEmpty(item.IconUrl)) { Text = string.Format("<b class='{0}'></b> {1}", item.IconClass, item.Title); } else { Text = string.Format("<img src='{0}' alt='{1}' /> {2}", item.IconUrl.ResolveUrlTokens(), item.GetContentType().Name, string.IsNullOrEmpty(item.Title) ? "(untitled)" : item.Title); } }
public async static Task DeleteInfo(string infoId) { try { HttpService http = new HttpService(); await http.SendDeleteRequest(InterfaceUrl.DeleteInformation(infoId)); } catch { } }
public async static Task UpdateInfo(string infoId, InformationModel model) { try { HttpService http = new HttpService(); string jsonContent = JsonHelper.ObjectToJson(model); await http.SendPutRequest(InterfaceUrl.UpdateInformation(infoId), jsonContent); } catch { } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var item = DataSource as ContentItem; if (item == null) { var version = DataSource as ContentVersion; if (version != null) { item = version.GetVersionInfo(N2.Context.Current.Resolve <ContentVersionRepository>()).Content; } return; } if (string.IsNullOrEmpty(InterfaceUrl)) { this.NavigateUrl = N2.Context.Current.GetContentAdapter <NodeAdapter>(item).GetPreviewUrl(item); } else { this.NavigateUrl = InterfaceUrl.ResolveUrlTokens().ToUrl().AppendSelection(item); } if (!string.IsNullOrEmpty(ParentQueryString)) { this.NavigateUrl = string.Format("{0}{1}{2}", this.NavigateUrl, this.NavigateUrl.Contains("?") ? "&" : "?", ParentQueryString); } var title = string.IsNullOrEmpty(item.Title) ? N2.Context.Current.Definitions.GetDefinition(item).Title : item.Title; if (!ShowIcon) { Text = title; } else if (string.IsNullOrEmpty(item.IconUrl)) { Text = string.Format("<b class='{0}'></b> {1}", item.IconClass, title); } else { Text = string.Format("<img src='{0}' alt='{1}' /> {2}", item.IconUrl.ResolveUrlTokens(), item.GetContentType().Name, title); } Attributes.Add("title", title); }
public async static Task <ContactModel> GetInfoAuthorDetails(string authorName) { try { HttpService http = new HttpService(); string response = await http.SendGetRequest(InterfaceUrl.UserLogin(authorName)); if (response != string.Empty) { ContactModel authorDetail = new ContactModel(); JObject jsonObject = JObject.Parse(response); authorDetail.toUserName = jsonObject["UserName"].ToString(); authorDetail.toEmailAddress = jsonObject["Email"].ToString(); authorDetail.toPhoneNumber = jsonObject["PhoneNumber"].ToString(); return(authorDetail); } } catch { } return(null); }
/// <summary> /// 登录服务 /// </summary> /// <param name="userName">用户名</param> /// <param name="password">密码</param> /// <returns>登录成功返回true,反之返回false</returns> public static async Task <bool> Login(string userName, string password) { HttpService http = new HttpService(); string response = await http.SendGetRequest(InterfaceUrl.UserLogin(userName)); if (response != string.Empty) { try { JObject jsonObject = JObject.Parse(response); if (EncriptHelper.ToMd5(password) == jsonObject["password"].ToString()) { roamdingSettings.Values[Constants.SettingName.Token] = jsonObject["token"].ToString(); roamdingSettings.Values[Constants.SettingName.EmailAddress] = jsonObject["Email"].ToString(); roamdingSettings.Values[Constants.SettingName.PhoneNumber] = jsonObject["PhoneNumber"].ToString(); return(true); } } catch { } } return(false); }