示例#1
0
        public bool UpdateTracking(UpdateTrackingServiceForm project, string workflowid, string userid)
        {
            if (project == null || string.IsNullOrEmpty(project.ID))
            {
                throw new Exception("上传数据有误,缺少ID或者Form");
            }
            ISqlMapper             mapper = Common.GetMapperFromSession();
            ProjectDao             dao    = new ProjectDao(mapper);
            TrackingMortgageDao    tmdao  = new TrackingMortgageDao(mapper);
            TrackingChangeOwnerDao tcodao = new TrackingChangeOwnerDao(mapper);

            dao.Update(new ProjectUpdateForm
            {
                Entity = new Project
                {
                    LogoutAssetTime      = project.LogoutAssetTime,
                    PickNewAssetCodeTime = project.PickNewAssetCodeTime,
                    MortgageRemark       = project.MortgageRemark,
                },
                ProjectQueryForm = new ProjectQueryForm {
                    ID = project.ID
                },
            });

            //过户信息处理
            TrackingChangeOwner tco = new TrackingChangeOwner
            {
                ProjectID = project.ID,
                ChangeOwnerProfileCode = project.ChangeOwnerProfileCode,
                ChangeOwnerRemark      = project.ChangeOwnerRemark,
                ChangeOwnerProfileTime = project.ChangeOwnerProfileTime,
                NewAssetCode           = project.NewAssetCode,
                NewAssetDate           = project.NewAssetDate,
            };
            TrackingChangeOwner tcoowner = tcodao.Query(new TrackingChangeOwnerQueryForm {
                ProjectID = project.ID
            }).FirstOrDefault();

            if (tcoowner == null)
            {
                tco.Creator = project.LastUpdator;
                tcodao.Add(tco);
            }
            else
            {
                tco.LastUpdator = project.LastUpdator;
                tcodao.Update(new TrackingChangeOwnerUpdateForm
                {
                    Entity = tco,
                    TrackingChangeOwnerQueryForm = new TrackingChangeOwnerQueryForm {
                        ID = tcoowner.ID
                    },
                });
            }
            TrackingMortgage tm = new TrackingMortgage
            {
                MortgageFeedbackCode = project.MortgageFeedbackCode,
                ProjectID            = project.ID,
                MortgageOverTime     = project.MortgageOverTime,
                MortgagePredictTime  = project.MortgagePredictTime,
            };
            //借贷信息处理
            var tmmodel = tmdao.Query(new TrackingMortgageQueryForm {
                ProjectID = project.ID
            }).FirstOrDefault();

            if (tmmodel == null)
            {
                tm.Creator = project.LastUpdator;
                tmdao.Add(tm);
            }
            else
            {
                tm.LastUpdator = project.LastUpdator;
                tmdao.Update(new TrackingMortgageUpdateForm
                {
                    Entity = tm,
                    TrackingMortgageQueryForm = new TrackingMortgageQueryForm {
                        ID = tmmodel.ID
                    },
                });
            }
            WorkflowModel model = WorkflowModel.Load(workflowid);

            if (!model.CanUserProcess(userid))
            {
                return(true);
            }
            model.ProcessActivity(new Approval {
                Status = (int)ApprovalStatus.None
            }, userid, new WorkflowAuthority());
            return(true);
        }
示例#2
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);
        }