Ejemplo n.º 1
0
        public List <InitApprovalResultForm> QueryMyApply(QueryMyApplyServiceForm form)
        {
            List <InitApprovalResultForm> list = new List <InitApprovalResultForm>();
            ISqlMapper  mapper     = Common.GetMapperFromSession();
            UserBLL     userbll    = new UserBLL();
            WorkflowDao wfdao      = new WorkflowDao(mapper);
            ProjectDao  projectdao = new ProjectDao(mapper);

            switch (form.Status)
            {
            case 4:    //已终审(经理审批)
                form.ManagerAppvoal = true;
                break;

            case 5:    //审批不通过
                form.Disagree = true;
                break;

            case 1:
            case 2:
            case 3:
                form.WorkflowStatus = form.Status;
                break;

            case 6:
                form.Tracking = true;
                break;
            }
            var users      = TableCacheHelper.GetDataFromCache <User>(typeof(UserDao));
            var projects   = projectdao.QueryMyApply(form);
            var projectids = (from w in projects select w.ID).Distinct().ToList();

            return(Query(projectids, null, form.UserID));
        }
        public void GetDataFromCacheTest()
        {
            var list = TableCacheHelper.GetDataFromCache <Workflow>(typeof(WorkflowDao));

            if (list.Count == 0)
            {
                return;
            }
            WorkflowDao            dao         = new WorkflowDao();
            string                 key         = typeof(Workflow).FullName;
            var                    item        = cache.GetItem(key);
            CacheEntity <Workflow> cacheentity = item.Value as CacheEntity <Workflow>;

            Assert.IsNotNull(item);
            Assert.AreEqual(list, cacheentity.List);
            DateTime dt = DateTime.Now;

            dao.Update(new WorkflowUpdateForm
            {
                Entity = new Workflow {
                    LastUpdateTime = dt
                },
                WorkflowQueryForm = new WorkflowQueryForm {
                    ID = list[0].ID
                }
            });
            list        = TableCacheHelper.GetDataFromCache <Workflow>(typeof(WorkflowDao));
            item        = cache.GetItem(key);
            cacheentity = item.Value as CacheEntity <Workflow>;
            Assert.AreEqual(dt.ToString("yyyyMMddHHmmss"), cacheentity.LastUpdateTime.Value.ToString("yyyyMMddHHmmss"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获得角色子级下的所有角色
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public List <Role> GetAllSubRoles(string roleid)
        {
            var         allroles = TableCacheHelper.GetDataFromCache <Role>(typeof(RoleDao));
            List <Role> list     = new List <Role>();
            var         role     = allroles.Find(t => t.ID == roleid);

            GetSubRole_Resc(role, allroles, list);
            return(list);
        }
Ejemplo n.º 4
0
        public List <Menu> GetAllMenu()
        {
            ISqlMapper mapper = Common.GetMapperFromSession();
            MenuDao    dao    = new MenuDao(mapper);

            List <Menu> list = TableCacheHelper.GetDataFromCache <Menu>(typeof(MenuDao));

            return(list);
        }
Ejemplo n.º 5
0
        public int CheckAuth(List <Role> roles)
        {
            //验证有没有权限访问
            var attr = ServiceSession.Current.Method.GetCustomAttribute <BaseActionAttribute>(true);

            if (attr != null)
            {
                ISqlMapper mapper       = Common.GetMapperFromSession();
                string     actionName   = attr.Action;
                var        servicelayer = ServiceSession.Current.Method.DeclaringType.GetCustomAttribute <ServiceLayer>(true);
                if (servicelayer != null)
                {
                    string moduleName         = servicelayer.Module;
                    var    modules            = TableCacheHelper.GetDataFromCache <Module>(typeof(ModuleDao));
                    var    actions            = TableCacheHelper.GetDataFromCache <RiskMgr.Model.Action>(typeof(ActionDao));
                    Role_Module_ActionDao dao = new Role_Module_ActionDao(mapper);
                    var module = modules.Find(t => t.Name == moduleName);
                    var action = actions.Find(t => t.Name == actionName);
                    if (module == null || action == null)
                    {
                        return(-1);
                    }
                    string actionID = action.ID;
                    string moduleID = module.ID;
                    Role_Module_ActionQueryForm query = new Role_Module_ActionQueryForm
                    {
                        ActionID = actionID,
                        ModuleID = moduleID
                    };
                    //MonitorCache.GetInstance().PushMessage(new CacheMessage { Message = "action id:" + actionID + ";module id:" + moduleID }, SOAFramework.Library.CacheEnum.FormMonitor);
                    var  role_module_action = dao.Query(query);
                    bool hasRight           = false;
                    foreach (var item in role_module_action)
                    {
                        if (roles != null && roles.Exists(t => t.ID == item.RoleID))
                        {
                            hasRight = true;
                            break;
                        }
                    }
                    if (!hasRight)
                    {
                        return(4);
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 6
0
 private void AddRoleAuth(ISqlMapper mapper, AddRoleServiceForm form, string roleid)
 {
     #region 权限新增
     //权限操作
     Role_Module_ActionDao rmadao  = new Role_Module_ActionDao(mapper);
     List <Module>         modules = TableCacheHelper.GetDataFromCache <Module>(typeof(ModuleDao));
     List <Model.Action>   actions = TableCacheHelper.GetDataFromCache <Model.Action>(typeof(ActionDao));
     AuthorityMapping      mapping = XMLHelper.DeserializeFromFile <AuthorityMapping>(Common.AuthorityMappingFile);
     foreach (var auth in form.Authority)
     {
         if (!auth.Checked)
         {
             continue;
         }
         var authonode = mapping.AuthNode.Find(t => t.ID.Equals(auth.ID));
         if (authonode == null)
         {
             continue;
         }
         AddAuth(authonode.Item, roleid, rmadao);
     }
     #endregion
 }
Ejemplo n.º 7
0
        public List <InitApprovalResultForm> Query(List <string> projectids, List <string> taskids, string currentuserid)
        {
            #region init dao
            List <InitApprovalResultForm> result = new List <InitApprovalResultForm>();
            if (projectids == null || projectids.Count == 0)
            {
                return(new List <InitApprovalResultForm>());
            }

            ISqlMapper             mapper      = Common.GetMapperFromSession();
            ProjectDao             dao         = new ProjectDao(mapper);
            Customer_ProjectDao    cpdao       = new Customer_ProjectDao(mapper);
            Customer_AssetDao      cadao       = new Customer_AssetDao(mapper);
            Asset_ProjectDao       apdao       = new Asset_ProjectDao(mapper);
            WorkflowDao            workflowdao = new WorkflowDao(mapper);
            ActivityDao            activitydao = new ActivityDao(mapper);
            ApprovalDao            appvoraldao = new ApprovalDao(mapper);
            TaskDao                taskdao     = new TaskDao(mapper);
            UserInfoDao            uidao       = new UserInfoDao(mapper);
            User_RoleDao           urdao       = new User_RoleDao(mapper);
            TrackingChangeOwnerDao tcodao      = new TrackingChangeOwnerDao(mapper);
            TrackingMortgageDao    tmdao       = new TrackingMortgageDao(mapper);
            LinkDao                linkdao     = new LinkDao(mapper);
            Role_Module_ActionDao  rmadao      = new Role_Module_ActionDao(mapper);
            ReturnBackConfirmDao   rbcdao      = new ReturnBackConfirmDao(mapper);
            CreditReceiverInfoDao  cridao      = new CreditReceiverInfoDao(mapper);
            #endregion

            #region 查询数据
            List <Customer_Project>    cps                 = new List <Customer_Project>();
            List <Customer_Asset>      cas                 = new List <Customer_Asset>();
            List <Asset_Project>       aps                 = new List <Asset_Project>();
            List <Activity>            activities          = new List <Activity>();
            List <Approval>            approvals           = new List <Approval>();
            List <Task>                tasks               = new List <Task>();
            List <TrackingChangeOwner> tco                 = new List <TrackingChangeOwner>();
            List <TrackingMortgage>    tm                  = new List <TrackingMortgage>();
            List <string>              projectidlist       = new List <string>();
            List <string>              workflowids         = new List <string>();
            List <CreditReceiverInfo>  criList             = new List <CreditReceiverInfo>();
            List <Link>                links               = new List <Link>();
            List <ReturnBackConfirm>   returnBackMoneyInfo = new List <ReturnBackConfirm>();
            List <Workflow>            workflows           = null;
            List <Project>             list                = null;
            var rma = rmadao.Query(new Role_Module_ActionQueryForm {
            });
            if (taskids != null && taskids.Count > 0)
            {
                tasks = taskdao.Query(new TaskQueryForm {
                    IDs = taskids
                });
                workflowids = (from t in tasks
                               select t.WorkflowID).Distinct().ToList();
                workflows = workflowdao.Query(new WorkflowQueryForm {
                    IDs = workflowids
                });
                activities = activitydao.Query(new ActivityQueryForm {
                    WorkflowIDs = workflowids
                });
                approvals = appvoraldao.Query(new ApprovalQueryForm {
                    WorkflowIDs = workflowids
                });
                projectidlist = (from w in workflows
                                 select w.ProcessID).ToList();
                list = dao.Query(new ProjectQueryForm {
                    IDs = projectidlist
                });
            }
            else if (projectids != null && projectids.Count > 0)
            {
                list = dao.Query(new ProjectQueryForm {
                    IDs = projectids
                });
                projectidlist = (from p in list
                                 select p.ID).ToList();
                workflows = workflowdao.Query(new WorkflowQueryForm {
                    ProcessIDs = projectidlist
                });
                workflowids = (from w in workflows
                               select w.ID).ToList();
                if (workflowids.Count > 0)
                {
                    activities = activitydao.Query(new ActivityQueryForm {
                        WorkflowIDs = workflowids
                    });
                    approvals = appvoraldao.Query(new ApprovalQueryForm {
                        WorkflowIDs = workflowids
                    });
                    tasks = taskdao.Query(new TaskQueryForm {
                        WorkflowIDs = workflowids
                    });
                }
            }
            else
            {
                return(result);
            }

            if (projectidlist.Count > 0)
            {
                cps = cpdao.Query(new Customer_ProjectQueryForm {
                    ProjectIDs = projectidlist
                });
                cas = cadao.Query(new Customer_AssetQueryForm {
                    ProjectIDs = projectidlist
                });
                aps = apdao.Query(new Asset_ProjectQueryForm {
                    ProjectIDs = projectidlist
                });
            }

            var users     = uidao.Query(new UserInfoQueryForm {
            });
            var userroles = urdao.Query(new User_RoleQueryForm {
            });
            criList = cridao.Query(new CreditReceiverInfoQueryForm {
                ProjectIDs = projectids
            });
            tco = tcodao.Query(new TrackingChangeOwnerQueryForm {
                ProjectIDs = projectidlist
            });
            tm = tmdao.Query(new TrackingMortgageQueryForm {
                ProjectIDs = projectidlist
            });
            returnBackMoneyInfo = rbcdao.Query(new ReturnBackConfirmQueryForm {
                ProjectIDs = projectidlist
            });

            //从缓存中取得
            var customers = TableCacheHelper.GetDataFromCache <Customer>(typeof(CustomerDao));
            var assets    = TableCacheHelper.GetDataFromCache <Asset>(typeof(AssetDao));
            #endregion

            #region 处理废单权限

            //处理废单权限
            var hasDisplayDiscard = (from ur in userroles
                                     join r in rma on ur.RoleID equals r.RoleID
                                     where r.ModuleID == "4" && r.ActionID == "4" && ur.UserID == currentuserid
                                     select r).FirstOrDefault();
            #endregion

            foreach (Project project in list)
            {
                var data = QueryDetail(project, customers, assets, cps, cas, aps, workflows, activities, approvals, tasks, users, userroles,
                                       tco, tm, returnBackMoneyInfo, criList, currentuserid);
                if (hasDisplayDiscard != null)
                {
                    data.DisplayDiscard = true;
                }
                result.Add(data);
            }
            return(result);
        }
Ejemplo n.º 8
0
 private void button3_Click(object sender, EventArgs e)
 {
     var list = TableCacheHelper.GetDataFromCache <Workflow>(typeof(WorkflowDao));
 }