protected override void OnFlowEnd(T_Trainmanagement_TrainplanApproval entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(entity.RelateID))
            {
                entity.RelateID = entity.ID;
            }


            var detailList = entity.T_Trainmanagement_TrainplanApproval_Trainplan.ToList();

            if (detailList.Count == 0)
            {
                return;
            }

            HRSQLDB.ExecuteNonQuery("delete from S_Train_CompPlan where FormID ='" + entity.RelateID + "'");

            foreach (var item in detailList)
            {
                S_Train_CompPlan plan = new S_Train_CompPlan();
                plan.ID     = Formula.FormulaHelper.CreateGuid();
                plan.FormID = entity.RelateID;
                BusinessEntities.Set <S_Train_CompPlan>().Add(plan);
                plan.InOrOut = "In";

                //将表单主表数据更新至结果表
                UpdateEntity <S_Train_CompPlan>(plan, entity.ToDic());
                //将表单子表数据更新至结果表
                UpdateEntity <S_Train_CompPlan>(plan, item.ToDic());
            }
            entity.IsNewVersion = "True";
            string sql = string.Format("update T_Trainmanagement_TrainplanApproval set IsNewVersion = 'False' where RelateID='{0}' and ID <>'{1}'", entity.RelateID, entity.ID);

            HRSQLDB.ExecuteNonQuery(sql);

            BusinessEntities.SaveChanges();
        }
        protected override void OnFlowEnd(T_Trainmanagement_Companytrainresults entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity == null)
            {
                return;
            }

            var compPlan = BusinessEntities.Set <S_Train_CompPlan>().Find(entity.Trainproject);

            if (compPlan == null)
            {
                //生成计划外培训数据
                compPlan                   = new S_Train_CompPlan();
                compPlan.ID                = Formula.FormulaHelper.CreateGuid();
                compPlan.Trainyear         = entity.Trainyears;
                compPlan.Fillname          = entity.Fillname;
                compPlan.FillnameName      = entity.FillnameName;
                compPlan.Trainproject      = entity.TrainprojectName;
                compPlan.InOrOut           = "Out";//计划外
                compPlan.Undertakedept     = entity.Udertakedept;
                compPlan.UndertakedeptName = entity.UdertakedeptName;

                BusinessEntities.Set <S_Train_CompPlan>().Add(compPlan);

                entity.Trainproject = compPlan.ID;
            }

            //累计学时
            if (compPlan.Accumulathours == null)
            {
                compPlan.Accumulathours = 0;
            }
            compPlan.Accumulathours += entity.Trainhours;
            //进度=100 标记为完成
            if (entity.Progress == 100)
            {
                compPlan.IsComplete = "True";
            }

            BusinessEntities.SaveChanges();
        }