コード例 #1
0
        /// <summary>
        /// 删除指定的收藏文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (lbx_FavoriteList.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选择要删除的书签!");
                return;
            }

            var path = favoritePath + "\\" + lbx_FavoriteList.SelectedItem;
            var type = path.Substring(path.LastIndexOf(".", StringComparison.Ordinal) + 1);

            if (type != "url")
            {
                return;
            }

            var isDelete = favoriteManager.DeleteFavorite(path);

            if (isDelete)
            {
                lbx_FavoriteList.Items.Clear();
                ScanAllFavorite(favoritePath);
            }
            else
            {
                MessageBox.Show("操作失败!");
            }
        }
コード例 #2
0
        public virtual object CancelFavorite(HttpContext context)
        {
            YZRequest      request  = new YZRequest(context);
            YZResourceType resType  = request.GetEnum <YZResourceType>("resType");
            string         resId    = request.GetString("resId");
            string         comments = request.GetString("comments", null);
            string         uid      = YZAuthHelper.LoginUserAccount;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    if (FavoriteManager.HasFavorited(provider, cn, uid, resType, resId))
                    {
                        FavoriteManager.DeleteFavorite(provider, cn, uid, resType, resId);
                    }

                    return(false);
                }
            }
        }