Exemple #1
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(MCatalog obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "MCatalog.Insert";
     return SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
 }
Exemple #2
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(MCatalog obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "MCatalog.Update";
     int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
     return result > 0 ? true : false;
 }
Exemple #3
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(MCatalog obj)
 {
     return dal.Insert(obj);
 }
Exemple #4
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(MCatalog obj)
 {
     return dal.Update(obj);
 }
Exemple #5
0
        public void DoMydoc(string opType, string folderName, string docIds, int applyFolderId, int folderType)
        {
            try
            {
                UserService us = Context.GetService<UserService>();
                U_UserInfo u = base.GetUser();
                switch (opType.ToLower())
                {
                    #region 新增文件夹
                    case "addfolder":
                        MCatalog mc = new MCatalog() {
                            CateText = folderName,
                            CatalogType = folderType,
                            CreateTime = DateTime.Now,
                            DocCount = 0,
                            UserId = u.UserId
                        };
                        us.MCatalogBll.Insert(mc);

                        break;
                    #endregion
                    #region 删除文件夹
                    case "deletefolder":
                        MCatalog dmc = us.MCatalogBll.Get(applyFolderId, u.UserId);
                        if (dmc != null)
                        {
                            us.MCatalogBll.Delete(dmc.CateId);
                            us.DocInfoBll.UpdateUserCatalog(u.UserId, dmc.CateId);
                        }
                        else {
                            throw new Exception("操作失败");
                        }
                        break;
                    #endregion
                    #region 重命名文件夹
                    case "updatefolder":
                        MCatalog dmc2 = us.MCatalogBll.Get(applyFolderId, u.UserId);
                        if (dmc2 != null)
                        {
                            dmc2.CateText = folderName;
                            us.MCatalogBll.Update(dmc2);
                        }
                        else
                        {
                            throw new Exception("操作失败");
                        }
                        break;
                    #endregion
                    #region 多选删除
                    case "deleteall":
                        string[] strDocIds = docIds.Split(',');
                        strDocIds.ToList().ForEach(s => {
                            DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId);
                            if (d != null)
                            {
                                us.DocInfoBll.Delete(d.DocId);
                                if (d.UserCateId != 0)
                                {
                                    //文件夹文档数量减一
                                    MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId);
                                    dsmc.DocCount -= 1;
                                    us.MCatalogBll.Update(dsmc);
                                }
                            }
                            else
                                throw new Exception("可能删除了不是自己的文档");
                        });
                        break;
                    #endregion
                    #region 移动到文件夹
                    case "moveall":
                        string[] strDocIds2 = docIds.Split(',');
                        strDocIds2.ToList().ForEach(s => {
                            us.DocInfoBll.MoveFolder(int.Parse(s), applyFolderId);
                        });
                        break;
                    #endregion
                    #region 单个删除
                    case "deletesingle":
                        string[] strDocIds3 = docIds.Split(',');
                        strDocIds3.ToList().ForEach(s => {
                            DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId);
                            if (d != null)
                            {
                                us.DocInfoBll.Delete(d.DocId);
                                if (d.UserCateId != 0) {
                                    //文件夹文档数量减一
                                    MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId);
                                    dsmc.DocCount -= 1;
                                    us.MCatalogBll.Update(dsmc);
                                }
                            }
                            else
                                throw new Exception("可能删除了不是自己的文档");
                        });
                        break;
                    #endregion
                    #region 移动到收藏夹
                    case "moveallfav":
                        string[] strDocIds4 = docIds.Split(',');
                        strDocIds4.ToList().ForEach(s =>
                        {
                            us.MFavoriteBll.MoveFolder(int.Parse(s), applyFolderId);
                        });
                        break;
                    #endregion
                    #region 删除收藏
                    case "deleteallfav":
                        string[] strDocIds5 = docIds.Split(',');
                        strDocIds5.ToList().ForEach(s =>
                        {
                            us.MFavoriteBll.Delete(int.Parse(s));
                        });
                        break;
                    #endregion
                }
                AddSuccess("操作成功");
            }
            catch(Exception ex) {
                Utils.Log4Net.Error(ex);
                AddError("操作失败");
            }
            RedirectToReferrer();
        }