示例#1
0
        public void InitExam(InitExamModel data)
        {
            workflowTeamRepo.Delete(m => m.ProcessName == data.ProcessName);
            var list = new List<WorkflowTeamRelation>();
            WorkflowTeamRelation wtr;
            foreach (NodeTeamModel nodeTeam in data.NodeTeams)
            {
                wtr = new WorkflowTeamRelation
                {
                    InDate = DateTime.Now,
                    InUser = data.User.UserID,
                    NodeName = nodeTeam.NodeName,
                    ProcessName = data.ProcessName,
                    TeamName = nodeTeam.TeamName
                };
                list.Add(wtr);
            }

            workflowTeamRepo.Insert(list);
        }
示例#2
0
        public void CreateTiKu(TiKuMasterModel master)
        {
            if (master != null)
            {
                var parameter = new SqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "@TiKuName",
                    Value = master.TiKuName
                };
                adonetWrapper.ExecuteSqlCommand(
                        @"declare @masterSysNo int
                          select @masterSysNo = SysNo FROM dbo.TiKuMaster where TiKuName=@TiKuName
                          delete from dbo.TiKuMaster where SysNo = @masterSysNo;
                          delete from dbo.TiKuDetail where MasterSysNo = @masterSysNo"
                        , parameter);

                var insertCount = tiKuRepo.Insert(PublicFunc.EntityMap<TiKuMasterModel, TiKuMaster>(master));
                if (insertCount > 0)
                {
                    var masterSysNo = tiKuRepo.Entities.FirstOrDefault(m => m.TiKuName == master.TiKuName).SysNo;
                    var details = PublicFunc.EntityMap<List<TiKuDetailModel>, List<TiKuDetail>>(master.Details);
                    if (details != null)
                    {
                        details.ForEach((detail) =>
                        {
                            detail.MasterSysNo = masterSysNo;
                        });

                        tiKuDetailRepo.Insert(details);

                        var names = details.Select(m => m.ProcessName).Distinct().ToList();
                        foreach (var name in names)
                        {
                            var matchDetails = details.Where(m => m.ProcessName == name);
                            if (matchDetails != null)
                            {
                                var initExam = new InitExamModel();
                                initExam.User = master.User;
                                initExam.ProcessName = name;
                                initExam.NodeTeams = new List<NodeTeamModel>();

                                foreach (var mDetail in matchDetails)
                                {
                                    initExam.NodeTeams.Add(new NodeTeamModel()
                                    {
                                        NodeName = mDetail.NodeName,
                                        TeamName = mDetail.TeamName
                                    });
                                }
                                taskService.InitExam(initExam);
                            }
                        }
                    }
                }
            }
        }