public async void OnClick(View v) { switch (v.Id) { case Resource.Id.headerAvatar: var token = UserShared.GetAccessToken(this); var user = await SQLiteUtils.Instance().QueryUser(); if (user == null || token == null || token.access_token == "") { StartActivityForResult(new Intent(this, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode); } else { if (string.IsNullOrEmpty(user.BlogApp)) { Toast.MakeText(this, "未开通博客", ToastLength.Short).Show(); } else { BlogActivity.Start(this, user.BlogApp); } } break; } }
public static void import(DataTable dt) { SQLiteConnection connection = null; SQLiteTransaction transaction = null; try { connection = SQLiteUtils.getConnection(); connection.Open(); transaction = connection.BeginTransaction(); List <SQLiteParameter> paramList = new List <SQLiteParameter>(); foreach (DataRow dr in dt.Rows) { paramList.Add(new SQLiteParameter("@name", dr["name"])); paramList.Add(new SQLiteParameter("@value", dr["value"])); SQLiteUtils.execute("update t_config set value = @value where name = @name", paramList, connection); configMap[dr["name"]] = dr["value"]; } transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { if (connection != null) { connection.Close(); } } }
public async void PostBookmark() { //是否登录 var user = UserShared.GetAccessToken(this); if (user.access_token == "" || user.RefreshTime.AddSeconds(user.expires_in) < DateTime.Now) { //未登录或清空Token失效 //清空Token UserShared.Update(this, new AccessToken()); await SQLiteUtils.Instance().DeleteUserAll(); Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(this); dialog.SetMessage(Resources.GetString(Resource.String.need_login_tip)); dialog.SetPositiveButton(Resources.GetString(Resource.String.confirm), delegate { StartActivityForResult(new Intent(this, typeof(LoginActivity)), (int)RequestCode.LoginCode); dialog.Dispose(); }); dialog.SetNegativeButton(Resources.GetString(Resource.String.cancel), delegate { dialog.Dispose(); }); dialog.Create().Show(); } else { var linkurl = txtLinkUrl.Text; var title = txtTitle.Text; var tags = txtTags.Text; var content = txtContent.Text; if (linkurl.Length == 0) { Toast.MakeText(this, "请输入网址", ToastLength.Short).Show(); } else if (linkurl.Length < 3) { Toast.MakeText(this, "网址的内容太少了,至少3个字吧", ToastLength.Short).Show(); } else if (title.Length == 0) { Toast.MakeText(this, "请输入标题", ToastLength.Short).Show(); } else if (title.Length < 3) { Toast.MakeText(this, "标题的内容太少了,至少3个字吧", ToastLength.Short).Show(); } else { dialog.SetMessage(Resources.GetString(Resource.String.addstatusing)); dialog.Show(); bookmark.LinkUrl = linkurl; bookmark.Summary = content; bookmark.Tags = tags.Split(',').ToList(); bookmark.Title = title; bookmarkPresenter.BookmarkAdd(user, bookmark); } } }
public override void OnCreate() { base.OnCreate(); UMShareAPI.Get(this); SQLiteUtils.Instance(); PlatformConfig.SetWeixin("wxdad334f38b612cc7", "6dfd3bc792c8fc51f6f6f0bbe037bbfd"); }
public async Task GetServiceNews(AccessToken token, int id) { try { var result = await OkHttpUtils.Instance(token).GetAsyn(string.Format(ApiUtils.NewsBody, id)); if (result.IsError) { newsView.GetServiceNewsFail(result.Message); } else { await SQLiteUtils.Instance().QueryNew(id).ContinueWith(async(response) => { var news = response.Result; news.Body = result.Message; await SQLiteUtils.Instance().UpdateNew(news); newsView.GetServiceNewsSuccess(news); }); } } catch (Exception ex) { newsView.GetServiceNewsFail(ex.Message); } }
public async void OnDelete(int id) { //是否登录 var user = UserShared.GetAccessToken(this.Activity); if (user.access_token == "" || user.RefreshTime.AddSeconds(user.expires_in) < DateTime.Now) { //未登录或清空Token失效 //清空Token UserShared.Update(this.Activity, new AccessToken()); await SQLiteUtils.Instance().DeleteUserAll(); Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(this.Activity); dialog.SetMessage(Resources.GetString(Resource.String.need_login_tip)); dialog.SetPositiveButton(Resources.GetString(Resource.String.confirm), delegate { StartActivityForResult(new Intent(this.Activity, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode); dialog.Dispose(); }); dialog.SetNegativeButton(Resources.GetString(Resource.String.cancel), delegate { dialog.Dispose(); }); dialog.Create().Show(); } else { var item = adapter.GetData().Where(a => a.Id == id).FirstOrDefault(); var child = recyclerView.FindViewWithTag(item.Id); child.FindViewById(Resource.Id.imgDelete).Visibility = ViewStates.Gone; child.FindViewById(Resource.Id.progressBar).Visibility = ViewStates.Visible; statusesPresenter.DeleteStatus(user, item.Id); } }
public async Task GetServiceArticles(AccessToken token, int position, int pageIndex = 1) { try { var url = ""; switch (position) { case 0: url = string.Format(ApiUtils.ArticleHome, pageIndex, pageSize); break; case 1: url = string.Format(ApiUtils.ArticleHot, pageIndex, pageSize); break; } var result = await OkHttpUtils.Instance(token).GetAsyn(url); if (result.IsError) { articlesView.GetServiceArticlesFail(result.Message); } else { var articles = JsonConvert.DeserializeObject <List <ArticlesModel> >(result.Message); await SQLiteUtils.Instance().UpdateArticles(articles); articlesView.GetServiceArticlesSuccess(articles); } } catch (Exception ex) { articlesView.GetServiceArticlesFail(ex.Message); } }
public List <String> import(DataTable dataTable) { SQLiteConnection connection = null; SQLiteTransaction transaction = null; List <String> unImportList = new List <String>(); try { connection = SQLiteUtils.getConnection(); connection.Open(); transaction = connection.BeginTransaction(); foreach (DataRow dr in dataTable.Rows) { List <SQLiteParameter> paramList = new List <SQLiteParameter>(); paramList.Add(new SQLiteParameter("@mail_address", Convert.ToString(dr["mail_address"]))); paramList.Add(new SQLiteParameter("@type", Convert.ToString(dr["type"]))); DataTable result = SQLiteUtils.query("select count(*) as cnt from t_mail_address where mail_address = @mail_address and type = @type", paramList, connection); long rowCnt = (long)result.Rows[0]["cnt"]; if (rowCnt == 0) { String create_date = dr.Table.Columns["create_date"] == null ? "" : Convert.ToString(dr["create_date"]); paramList.Add(new SQLiteParameter("@create_date", create_date)); String create_type = dr.Table.Columns["create_type"] == null ? "1" : Convert.ToString(dr["create_type"]); paramList.Add(new SQLiteParameter("@create_type", create_type)); String send_cnt = dr.Table.Columns["send_cnt"] == null ? "0" : Convert.ToString(dr["send_cnt"]); paramList.Add(new SQLiteParameter("@send_cnt", send_cnt)); String send_date = dr.Table.Columns["send_date"] == null ? "" : Convert.ToString(dr["send_date"]); paramList.Add(new SQLiteParameter("@send_date", send_date)); SQLiteUtils.execute("insert into t_mail_address(mail_address, type, send_cnt, create_date, send_date, create_type) values(@mail_address, @type, @send_cnt, @create_date, @send_date, @create_type)", paramList, connection); } else { unImportList.Add(Convert.ToString(dr["mail_address"])); } } transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { if (connection != null) { connection.Close(); } } return(unImportList); }
public async Task GetServiceKbArticle(AccessToken token, int id) { try { var result = await OkHttpUtils.Instance(token).GetAsyn(string.Format(ApiUtils.KbArticlesBody, id)); if (result.IsError) { kbarticleView.GetServiceKbArticleFail(result.Message); } else { await SQLiteUtils.Instance().QueryKbArticle(id).ContinueWith(async(response) => { var article = response.Result; article.Body = result.Message; await SQLiteUtils.Instance().UpdateKbArticle(article); kbarticleView.GetServiceKbArticleSuccess(article); }); } } catch (Exception ex) { kbarticleView.GetServiceKbArticleFail(ex.Message); } }
public void add(String url, String mailAddress, String type) { mailAddress = mailAddress.ToLower().Trim(); List <SQLiteParameter> paramList = new List <SQLiteParameter>(); paramList.Add(new SQLiteParameter("@mail_address", mailAddress)); paramList.Add(new SQLiteParameter("@type", type)); DataTable dt = SQLiteUtils.query("select count(mail_address) as cnt from t_mail_address where mail_address = @mail_address and type = @type", paramList); long rowCnt = (long)dt.Rows[0]["cnt"]; if (rowCnt == 0) { //同站点mail解析超过系统设定数,则不再添加mail if (url == null || runtimeSerivce.get(url).addMainCnt()) { paramList.Add(new SQLiteParameter("@create_date", DateUtils.getSysDate())); paramList.Add(new SQLiteParameter("@send_cnt", "0")); //如果手动录入,则为1;自动抓取的为0 paramList.Add(new SQLiteParameter("@create_type", url != null ? "0" : "1")); SQLiteUtils.execute("insert into t_mail_address(mail_address,send_cnt,type,create_date,create_type) values(@mail_address,@send_cnt,@type,@create_date,@create_type)", paramList); } } }
protected override async void OnResume() { base.OnResume(); if (ClientId != "" && ClientSercret != "") { var token = TokenShared.GetAccessToken(this); if (token.access_token == "" || token.RefreshTime.AddSeconds(token.expires_in) < DateTime.Now) { var basic = Square.OkHttp3.Credentials.Basic(Resources.GetString(Resource.String.ClientId), Resources.GetString(Resource.String.ClientSercret)); splashPresenter.GetAccessToken(TokenShared.GetAccessToken(this), basic); } else { var user = UserShared.GetAccessToken(this); if (user.access_token != "" && user.RefreshTime.AddSeconds(user.expires_in) < DateTime.Now) { Toast.MakeText(this, Resources.GetString(Resource.String.access_token_out_of_date), ToastLength.Long).Show(); } if (user.access_token == "" || user.RefreshTime.AddSeconds(user.expires_in) < DateTime.Now) { UserShared.Update(this, new AccessToken()); await SQLiteUtils.Instance().DeleteUserAll(); } StartMain(); } } }
public void remove(String id) { List <SQLiteParameter> paramList = new List <SQLiteParameter>(); paramList.Add(new SQLiteParameter("@id", id)); SQLiteUtils.execute("delete from t_mail_address where id = @id", paramList); }
private void save_Click(object sender, EventArgs e) { var p = CodeCreatorUtils.FormToData <Project>(this); SQLiteUtils.UpdateData(p); LoadProjectList(); GlobalVariable.WorkingProject = p; }
public void remove(Int32 id) { List <SQLiteParameter> paramList = new List <SQLiteParameter>(); paramList.Add(new SQLiteParameter("@id", id)); SQLiteUtils.execute("delete from t_mail_sender where id = @id", paramList); initClient(); }
public void update(String id, String mailAddress) { List <SQLiteParameter> paramList = new List <SQLiteParameter>(); paramList.Add(new SQLiteParameter("@id", id)); paramList.Add(new SQLiteParameter("@mail_address", mailAddress.ToLower().Trim())); paramList.Add(new SQLiteParameter("@create_type", "1")); SQLiteUtils.execute("update t_mail_address set mail_address = @mail_address, create_type = @create_type where id = @id", paramList); }
public async void NotifyItemChanged(int id, int position) { var bookmarks = adapter.GetData(); var index = bookmarks.IndexOf(adapter.GetItem(position)); bookmarks[index] = await SQLiteUtils.Instance().QueryBookmark(id); adapter.NotifyItemChanged(position); }
private void add_Click(object sender, EventArgs e) { var p = CodeCreatorUtils.FormToData <Project>(this); p.Id = Guid.NewGuid().ToString(); SQLiteUtils.InsertData(p); LoadProjectList(); GlobalVariable.WorkingProject = p; }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Id = Intent.GetIntExtra("id", 0); statusPresenter = new StatusPresenter(this); commentPresenter = new StatusCommentsPresenter(this); handler = new Handler(); StatusBarCompat.SetOrdinaryToolBar(this); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbar.SetNavigationOnClickListener(this); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); userName = FindViewById <TextView>(Resource.Id.txtUserName); imgUserUrl = FindViewById <ImageView>(Resource.Id.imgUserUrl); imgPrivate = FindViewById <ImageView>(Resource.Id.imgPrivate); imgDelete = FindViewById <ImageButton>(Resource.Id.imgDelete); txtPostdate = FindViewById <TextView>(Resource.Id.txtPostdate); txtBody = FindViewById <TextView>(Resource.Id.txtBody); commentCount = FindViewById <TextView>(Resource.Id.txtCommentCount); txtContent = FindViewById <TextView>(Resource.Id.txtContent); proLoading = FindViewById <ProgressBar>(Resource.Id.proLoading); btnComment = FindViewById <TextView>(Resource.Id.btnComment); btnComment.SetOnClickListener(this); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.SetLayoutManager(new LinearLayoutManager(this)); recyclerView.NestedScrollingEnabled = false; adapter = new StatusCommentsAdapter(); adapter.OnDeleteClickListener = this; adapter.User = await SQLiteUtils.Instance().QueryUser(); recyclerView.SetAdapter(adapter); notDataView = this.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false); notDataView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; errorView = this.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false); errorView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; recyclerView.Post(async() => { await statusPresenter.GetClientStatus(Id); OnRefresh(); }); }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); try { this.HasOptionsMenu = true; swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); var manager = new LinearLayoutManager(this.Activity); recyclerView.SetLayoutManager(manager); adapter = new StatusAdapter(); adapter.SetOnLoadMoreListener(this); adapter.OnDeleteClickListener = this; adapter.User = await SQLiteUtils.Instance().QueryUser(); recyclerView.SetAdapter(adapter); nologinView = this.Activity.LayoutInflater.Inflate(Resource.Layout.nologin_view, (ViewGroup)recyclerView.Parent, false); nologinView.Click += delegate(object sender, EventArgs e) { StartActivityForResult(new Intent(this.Activity, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode); }; notDataView = this.Activity.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false); notDataView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; errorView = this.Activity.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false); errorView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; recyclerView.Post(async() => { if (position == 0) { await statusesPresenter.GetClientStatus(); } else if (!LoginUtils.Instance(this.Activity).GetLoginStatus()) { recyclerView.Post(() => { adapter.SetEmptyView(nologinView); }); } }); } catch (Exception ex) { MobclickAgent.ReportError(Context, ex.Message + ex.StackTrace); } }
public static DialogInfo getDialogInfo(string dialogScript, int dialogId) { SQLiteUtils sqlUtils = new SQLiteUtils(); SqliteDataReader reader = sqlUtils.findSql(dialogScript, dialogId); reader.Read(); DialogInfo dialogInfo = dataToObject(reader); return(dialogInfo); }
public static DialogInfo getDialogInfo(SessionInfo sessionInfo) { SQLiteUtils sqlUtils = new SQLiteUtils(); SqliteDataReader reader = sqlUtils.findSql(sessionInfo.dialogScript, sessionInfo.dialogId); reader.Read(); DialogInfo dialogInfo = dataToObject(reader); return(dialogInfo); }
public async Task LoginAsync(AccessToken token, string basic, string account, string password) { try { var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("grant_type", "password"), new OkHttpUtils.Param("username", account), new OkHttpUtils.Param("password", password) }; OkHttpUtils.Instance(token).Post(ApiUtils.Token, basic, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.OK) { token = JsonConvert.DeserializeObject <AccessToken>(body); token.RefreshTime = DateTime.Now; var result = await OkHttpUtils.Instance(token).GetAsyn(ApiUtils.Users); if (result.IsError) { loginView.LoginFail(result.Message); } else { var user = JsonConvert.DeserializeObject <UserModel>(result.Message); await SQLiteUtils.Instance().UpdateUser(user); loginView.LoginSuccess(token, user); } } else { try { var error = JsonConvert.DeserializeObject <LoginErrorMessage>(body); if (error != null && error.Error != null) { loginView.LoginFail("µÇ¼ʧ°Ü,Óû§Ãû»òÃÜÂë´íÎó"); } } catch (Exception e) { loginView.LoginFail(e.Message); } } }, (call, ex) => { loginView.LoginFail(ex.Message); }); } catch (Exception ex) { loginView.LoginFail(ex.Message); } }
public void PostComment(AccessToken token, int questionId, int answerId, string content) { try { var url = string.Format(ApiUtils.QuestionsAnswerCommentsAdd, questionId, answerId.ToString()); var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("ParentCommentId", "0"), new OkHttpUtils.Param("Content", content), }; OkHttpUtils.Instance(token).Post(url, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.OK) { var user = await SQLiteUtils.Instance().QueryUser(); QuestionCommentsModel news = new QuestionCommentsModel(); news.PostUserInfo = new QuestionUserInfoModel() { UserID = user.SpaceUserId, IconName = user.Face, UCUserID = user.UserId, UserName = user.DisplayName, QScore = user.Score }; news.Content = content; news.DateAdded = DateTime.Now; news.CommentID = answerId; commentsView.PostCommentSuccess(news); } else { try { var error = JsonConvert.DeserializeObject <ErrorMessage>(body); commentsView.PostCommentFail(error.Message); } catch (Exception e) { commentsView.PostCommentFail(e.Message); } } }, (call, ex) => { commentsView.PostCommentFail(ex.Message); }); } catch (Exception e) { commentsView.PostCommentFail(e.Message); } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); blogApp = Intent.GetStringExtra("blogApp"); blogPresenter = new BlogPresenter(this); handler = new Handler(); coordinatorLayout = FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout); appBarLayout = FindViewById <AppBarLayout>(Resource.Id.appbar); linearLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbar.SetNavigationOnClickListener(this); StatusBarCompat.SetCollapsingToolbar(this, coordinatorLayout, appBarLayout, linearLayout, toolbar); imgAvatar = FindViewById <ImageView>(Resource.Id.avatar); txtTitle = FindViewById <TextView>(Resource.Id.txtTitle); txtSubTitle = FindViewById <TextView>(Resource.Id.txtSubTitle); user = await SQLiteUtils.Instance().QueryUser(); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); var manager = new LinearLayoutManager(this); recyclerView.SetLayoutManager(manager); adapter = new ArticlesAdapter(); adapter.SetOnLoadMoreListener(this); recyclerView.SetAdapter(adapter); notDataView = this.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false); notDataView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; errorView = this.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false); errorView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; recyclerView.Post(async() => { await blogPresenter.GetClientBlog(blogApp); OnRefresh(); }); }
public async Task GetClientDailyExtra(int id) { try { dailyView.GetDailyExtraSuccess(await SQLiteUtils.Instance().QueryDailyExtra(id)); } catch (Exception ex) { dailyView.GetServiceDailyFail(ex.Message); } }
public async void PostQuestion() { //是否登录 var user = UserShared.GetAccessToken(this); if (user.access_token == "" || user.RefreshTime.AddSeconds(user.expires_in) < DateTime.Now) { //未登录或清空Token失效 //清空Token UserShared.Update(this, new AccessToken()); await SQLiteUtils.Instance().DeleteUserAll(); Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(this); dialog.SetMessage(Resources.GetString(Resource.String.need_login_tip)); dialog.SetPositiveButton(Resources.GetString(Resource.String.confirm), delegate { StartActivityForResult(new Intent(this, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode); dialog.Dispose(); }); dialog.SetNegativeButton(Resources.GetString(Resource.String.cancel), delegate { dialog.Dispose(); }); dialog.Create().Show(); } else { var title = txtTitle.Text; var tags = txtTags.Text; var content = txtContent.Text; if (title.Length == 0) { Toast.MakeText(this, "请输入标题", ToastLength.Short).Show(); } else if (title.Length < 3) { Toast.MakeText(this, "标题的内容太少了,至少3个字吧", ToastLength.Short).Show(); } else if (content.Length == 0) { Toast.MakeText(this, "请输入提问内容", ToastLength.Short).Show(); } else if (content.Length < 3) { Toast.MakeText(this, "提问内容太少了,至少3个字吧", ToastLength.Short).Show(); } else { dialog.SetMessage(Resources.GetString(Resource.String.addstatusing)); dialog.Show(); questionPresenter.QuestionAdd(user, title, content, tags, 1); } } }
public async Task GetClientArticles() { try { articlesView.GetArticlesSuccess(await SQLiteUtils.Instance().QueryArticles(limit)); } catch (Exception ex) { articlesView.GetArticlesFail(ex.Message); } }
protected async override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == (int)RequestCode.LoginCode && resultCode == Result.Ok) { adapter.User = await SQLiteUtils.Instance().QueryUser(); adapter.NotifyDataSetChanged(); PostComment(); } }
public void PostComment(AccessToken token, int id, string content) { try { var url = string.Format(ApiUtils.NewsCommentAdd, id.ToString()); var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("ParentId", "0"), new OkHttpUtils.Param("Content", content), }; OkHttpUtils.Instance(token).Post(url, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.Created) { var user = await SQLiteUtils.Instance().QueryUser(); NewsCommentModel news = new NewsCommentModel(); news.UserName = user.DisplayName; news.FaceUrl = user.Face; news.CommentContent = content; news.DateAdded = DateTime.Now; news.Floor = 0; news.CommentID = Convert.ToInt32(body); news.AgreeCount = 0; news.AntiCount = 0; news.ContentID = 0; news.UserGuid = user.UserId; commentView.PostCommentSuccess(news); } else { try { var error = JsonConvert.DeserializeObject <ErrorMessage>(body); commentView.PostCommentFail(error.Message); } catch (Exception e) { commentView.PostCommentFail(e.Message); } } }, (call, ex) => { commentView.PostCommentFail(ex.Message); }); } catch (Exception e) { commentView.PostCommentFail(e.Message); } }
public async Task GetClientArticle(int slug) { try { articleView.GetClientArticleSuccess(await SQLiteUtils.Instance().QueryArticle(slug)); } catch (Exception ex) { articleView.GetArticleFail(ex.Message); } }