Esempio n. 1
0
 public WR_Rule GetModel(int id)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Rule.Where(p => p.Record_Status == 0 && p.ID == id).FirstOrDefault());
     }
 }
Esempio n. 2
0
        public bool CheckPermission(string flowId, string loginName, string deptCode)
        {
            //loginName 域账号
            //deptCode 部门ID

            bool flag = false;

            flowId = flowId + ",";

            using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
            {
                //Reject_Users
                if (db.WR_Permission.Where(p => p.Record_Status == 0 && (p.Flow_Ids + ",").Contains(flowId) && (p.Reject_Users + ",").Contains(loginName + ",")).Any())
                {
                    flag = false;
                }
                //Allow_Users
                else if (db.WR_Permission.Where(p => p.Record_Status == 0 && (p.Flow_Ids + ",").Contains(flowId) && (p.Allow_Users + ",").Contains(loginName + ",")).Any())
                {
                    flag = true;
                }
                else
                {
                    flag = CheckPermissionByDept(flowId, deptCode);
                }
            }
            return(flag);
        }
Esempio n. 3
0
 public List <WR_Setting> GetSettingByCategory(string category)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Setting.Where(p => p.Record_Status == 0).ToList());
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 判断是否流程管理员
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public bool CheckIsCagegoryAdmin(string userCode)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Category.Where(p => p.Record_Status == 0 && ((p.Category_Admin + ",").Contains(userCode + ","))).Any());
     }
 }
Esempio n. 5
0
 public bool CheckIsFocus(string type, int id, string createdBy)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Focus.Where(p => p.Record_Status == 0 && p.Rule_ID == id && p.Created_By == createdBy).Any());
     }
 }
Esempio n. 6
0
 public List <WR_Permission> GetList()
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Permission.Where(p => p.Record_Status == 0).ToList());
     }
 }
Esempio n. 7
0
 public string GetValueByName(string name)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         WR_Setting obj = db.WR_Setting.Where(p => p.Record_Status == 0 && p.Name == name).FirstOrDefault();
         return(obj != null ? obj.Value : "");
     }
 }
Esempio n. 8
0
 public void Insert(WR_Rule model)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         db.WR_Rule.InsertOnSubmit(model);
         db.SubmitChanges();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// 获取最新3个月发布的制度
 /// </summary>
 /// <returns></returns>
 public List <V_WR_Rule> GetTopRuleList()
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.V_WR_Rule
                .Where(p => p.Record_Status == 0 && p.Publish_Date.HasValue && p.Publish_Date.Value > DateTime.Now.AddMonths(-3))
                .OrderByDescending(p => p.Publish_Date.Value).ToList());
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 获取收藏制度的总数
 /// </summary>
 /// <param name="userCode"></param>
 /// <returns></returns>
 public int GetRuleFocusCount(string userCode)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.V_WR_RuleFocus
                .Where(p => p.Record_Status == 0 && p.Focus_By == userCode)
                .Count());
     }
 }
Esempio n. 11
0
 /// <summary>
 /// 获取流程分类
 /// </summary>
 /// <param name="userCode"></param>
 /// <param name="isRuleAdmin"></param>
 /// <returns></returns>
 public List <WR_Category> GetCategoryList(string userCode, bool isRuleAdmin)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.WR_Category
                .Where(p => p.Record_Status == 0)
                .Where(p => isRuleAdmin ? true : ((p.Category_Admin + ",").Contains(userCode + ","))).ToList());
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 获取收藏制度
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageCount"></param>
 /// <param name="userCode"></param>
 /// <returns></returns>
 public List <V_WR_RuleFocus> GetRuleFocusList(int pageIndex, int pageCount, string userCode)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.V_WR_RuleFocus
                .Where(p => p.Record_Status == 0 && p.Focus_By == userCode)
                .OrderByDescending(p => p.Created_On).Skip(pageCount * (pageIndex - 1)).Take(pageCount).ToList());
     }
 }
Esempio n. 13
0
 public int GetRuleCount(int categoryId, string key)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.V_WR_Rule
                .Where(p => categoryId == -1 ? true : p.Category_ID == categoryId)
                .Where(p => string.IsNullOrEmpty(key) ? true : p.Title.Contains(key))
                .Where(p => p.Record_Status == 0)
                .Count());
     }
 }
Esempio n. 14
0
 /// <summary>
 /// 获取列表分页
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageCount"></param>
 /// <param name="categoryId"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public List <V_WR_Rule> GetRuleList(int pageIndex, int pageCount, int categoryId, string key)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         return(db.V_WR_Rule
                .Where(p => categoryId == -1 ? true : p.Category_ID == categoryId)
                .Where(p => string.IsNullOrEmpty(key) ? true : p.Title.Contains(key))
                .Where(p => p.Record_Status == 0)
                .OrderByDescending(p => p.Created_On).OrderByDescending(p => p.Publish_Date).Skip(pageCount * (pageIndex - 1)).Take(pageCount).ToList());
     }
 }
Esempio n. 15
0
 public void Insert(WR_Focus model)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         bool flag = db.WR_Focus.Where(p => p.Record_Status == 0 && p.Rule_ID == model.Rule_ID && p.Created_By == model.Created_By).Any();
         if (!flag)
         {
             db.WR_Focus.InsertOnSubmit(model);
             db.SubmitChanges();
         }
     }
 }
Esempio n. 16
0
 public void Delete(string type, int id, string createdBy)
 {
     using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
     {
         WR_Focus model = db.WR_Focus.Where(p => p.Record_Status == 0 && p.Rule_ID == id && p.Created_By == createdBy).FirstOrDefault();
         if (model != null)
         {
             db.WR_Focus.DeleteOnSubmit(model);
             db.SubmitChanges();
         }
     }
 }
Esempio n. 17
0
        /// <summary>
        /// 获取列表总数
        /// </summary>
        /// <param name="userCode"></param>
        /// <param name="isRuleAdmin"></param>
        /// <param name="category_Id"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public int GetViewListCount(string userCode, bool isRuleAdmin, int categoryId, string key)
        {
            using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
            {
                string[]           categoryIds = new string[] { };
                List <WR_Category> categorys   = db.WR_Category.Where(p => p.Record_Status == 0 && (p.Category_Admin + ",").Contains(userCode + ",")).ToList();
                if (categorys != null && categorys.Count > 0)
                {
                    categoryIds = categorys.Select(p => p.ID.ToString()).ToArray();
                }

                return(db.V_WR_Rule
                       .Where(p => p.Record_Status == 0)
                       .Where(p => categoryId == -1 ? true : p.Category_ID == categoryId)
                       .Where(p => string.IsNullOrEmpty(key) ? true : p.Title.Contains(key))
                       .Where(p => isRuleAdmin ? true : categoryIds.Contains(p.Category_ID.ToString()))
                       .Count());
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 获取列表分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <param name="userCode"></param>
        /// <param name="isRuleAdmin"></param>
        /// <param name="categoryId"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public List <V_WR_Rule> GetViewList(int pageIndex, int pageCount, string userCode, bool isRuleAdmin, int categoryId, string key)
        {
            using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
            {
                string[]           categoryIds = new string[] { };
                List <WR_Category> categorys   = db.WR_Category.Where(p => p.Record_Status == 0 && (p.Category_Admin + ",").Contains(userCode + ",")).ToList();
                if (categorys != null && categorys.Count > 0)
                {
                    categoryIds = categorys.Select(p => p.ID.ToString()).ToArray();
                }

                return(db.V_WR_Rule
                       .Where(p => p.Record_Status == 0)
                       .Where(p => isRuleAdmin ? true : categoryIds.Contains(p.Category_ID.ToString()))
                       .Where(p => categoryId == -1 ? true : p.Category_ID == categoryId)
                       .Where(p => string.IsNullOrEmpty(key) ? true : p.Title.Contains(key))
                       .OrderByDescending(p => p.Created_On).OrderByDescending(p => p.Publish_Date).Skip(pageCount * (pageIndex - 1)).Take(pageCount).ToList());
            }
        }
Esempio n. 19
0
        ////递归
        bool CheckPermissionByDept(string flowId, string deptCode)
        {
            //loginName 域账号
            //deptCode 部门ID
            bool change = false;
            bool flag   = false;

            using (WorkFlowRuleDataContext db = new WorkFlowRuleDataContext())
            {
                //Reject_Depts
                if (db.WR_Permission.Where(p => p.Record_Status == 0 && (p.Flow_Ids + ",").Contains(flowId) && (p.Reject_Depts + ",").Contains(deptCode + ",")).Any())
                {
                    change = true;
                    flag   = false;
                }
                //Allow_Depts
                else if (db.WR_Permission.Where(p => p.Record_Status == 0 && (p.Flow_Ids + ",").Contains(flowId) && (p.Allow_Depts + ",").Contains(deptCode + ",")).Any())
                {
                    change = true;
                    flag   = true;
                }
            }

            if (change)
            {
                return(flag);
            }
            else
            {
                //递归
                if (deptCode.Contains('-') && !change)
                {
                    return(CheckPermissionByDept(flowId, deptCode.Substring(0, deptCode.LastIndexOf('-'))));
                }
                return(flag);
            }
        }