private void Button_SaveClick(object sender, RoutedEventArgs e)
        {
            //获取文本框的值
            string     Name       = GroupName.Text;
            CustomData CustomData = CustomDataDAO.GetListByTypeIDAndName(CustomDataEnum.Group, Name);

            if (CustomData != null)
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("小组名称已存在", "Group already exists"));
            }
            string value = this.GroupName.Text;

            selectedGroup.CD_CustomName = value;
            DynamicParameters Parameters = new DynamicParameters();

            Parameters.Add("user_groupname", value);
            Parameters.Add("old", OldGroupName);
            using (var conn = DbUtil.getConn())
            {
                conn.Execute("update bdl_customdata set CD_CustomName=@CD_CustomName where Pk_CD_Id=@Pk_CD_Id", selectedGroup);
                //插入至上传表
                UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();
                uploadManagementDao1.Insert(new UploadManagement(selectedGroup.Pk_CD_Id, "bdl_customdata", 1));
                string query = "update bdl_user SET user_groupname = @user_groupname where user_groupname=@old";

                conn.Execute(query, Parameters);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao1.Insert(new UploadManagement(Parameters.Get <int>("old"), "bdl_user", 1));
            }
            this.Close();
        }
        /// <summary>
        /// 批量插入训练活动
        /// </summary>
        /// <param name="activities"></param>
        /// <returns></returns>
        public long BatchSaveActivity(List <ActivityEntity> activities)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                UploadManagementDAO uploadManagementDao2 = new UploadManagementDAO();
                long result = 0;
                //判断登陆用户,是教练自己锻炼。还是教练为用户进行设置。决定传哪个参数
                string currentMemberPK = CommUtil.GetSettingString("memberPrimarykey");
                string currentCoachId  = CommUtil.GetSettingString("coachId");
                if ((currentMemberPK == null || currentMemberPK == "") && (currentCoachId != null && currentCoachId != ""))
                {
                    //无用户登陆。教练单独登陆时对教练进行设置
                    foreach (var activity in activities)
                    {
                        activity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                        activity.Member_id             = CommUtil.GetSettingString("memberId");
                        activity.Fk_member_id          = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("coachId"));
                        activity.Fk_training_course_id = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId"));
                        activity.Gmt_create            = System.DateTime.Now;
                        activity.Is_complete           = false;
                        activity.current_turn_number   = 0;
                        //插入至上传表
                        uploadManagementDao2.Insert(new UploadManagement(activity.Id, "bdl_activity", 0));
                    }
                    //批量插入训练活动
                    result = activityDAO.BatchInsert(activities);
                    //根据训练活动批量插入个人设置记录 传入教练的主键id
                    personalSettingService.SavePersonalSettings(ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("coachId")));
                }
                else
                {
                    //只要用户登录,为用户进行设置
                    foreach (var activity in activities)
                    {
                        activity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                        activity.Member_id             = CommUtil.GetSettingString("memberId");
                        activity.Fk_member_id          = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("memberPrimarykey"));
                        activity.Fk_training_course_id = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId"));
                        activity.Gmt_create            = System.DateTime.Now;
                        activity.Is_complete           = false;
                        activity.current_turn_number   = 0;
                        //插入至上传表

                        uploadManagementDao2.Insert(new UploadManagement(activity.Id, "bdl_activity", 0));
                    }

                    //批量插入训练活动
                    result = activityDAO.BatchInsert(activities);
                    //根据训练活动批量插入个人设置记录 传入会员的主键id
                    personalSettingService.SavePersonalSettings(ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("memberPrimarykey")));
                }

                ts.Complete();
                return(result);
            }
        }
Example #3
0
        /// <summary>
        ///  插入一个新用户,业务层添加,同时增加上传表中数据
        /// </summary>
        public void InsertUser(User user)
        {
            user.Gmt_Create   = DateTime.Now;
            user.Gmt_Modified = DateTime.Now;
            user.Is_Deleted   = 0;
            userDAO.Insert(user);
            //插入大数据上传表
            var result = SelectByCondition(user);

            foreach (var i in result)
            {
                UploadManagement uploadManagement = new UploadManagement(i.Pk_User_Id, "bdl_user", 0);
                uploadManagementDAO.Insert(uploadManagement);
            }
        }
Example #4
0
        public void updateTest()
        {
            using (TransactionScope ts = new TransactionScope())//使整个代码块成为事务性代码

            {
                AuthDAO dao = new AuthDAO();
                Auther  a   = dao.Load(2);
                a.Auth_UserName = "******";
                dao.UpdateByPrimaryKey(a);
                //插入至上传表
                UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();
                uploadManagementDao1.Insert(new UploadManagement(a.Pk_Auth_Id, "bdl_auth", 1));

                Auther b = new Auther();
                b.Auth_UserName = "******";
                dao.Insert(b);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(b.Pk_Auth_Id, "bdl_auth", 0));

                int p = 0;
                //int l = 8 / p;

                ts.Complete();
            }
        }
Example #5
0
        /// <summary>
        /// 添加训练结果,设备上报上来的结果
        /// </summary>
        /// <param name="idCard"></param>
        /// <param name="result"></param>
        public void AddPrescriptionResult(string idCard, PrescriptionResult result, DeviceType deviceType)
        {
            using (TransactionScope ts = new TransactionScope()) //使整个代码块成为事务性代码
            {
                DevicePrescription p = GetDevicePrescriptionByIdCardDeviceType(idCard, deviceType, (byte)DevicePrescription.UNDO);
                if (p == null)
                {
                    return;
                }
                //插入训练结果
                result.Fk_DP_Id = p.Pk_DP_Id;
                if (p.Gmt_Modified != null && result.Gmt_Create != null)
                {
                    TimeSpan ts0 = (DateTime)result.Gmt_Create - (DateTime)p.Gmt_Modified;
                    result.PR_Time2 = ts0.TotalSeconds;
                }

                prescriptionResultDAO.Insert(result);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(result.Fk_DP_Id, "bdl_prescriptionresult", 0));
                //查询是否还有没完成的训练处方,如果都完成了就更新TrinInfo
                var unDoItemList = devicePrescriptionDAO.ListUnDoByTIId(p.Fk_TI_Id);
                if (unDoItemList.Count == 1)
                {
                    if (unDoItemList[0].Pk_DP_Id == p.Pk_DP_Id)//未完成的项目恰好是一个且为上报上来的这个项目就说明该大处方已经完成了,更新状态
                    {
                        var t = trainInfoDao.Load(p.Fk_TI_Id);
                        t.Pk_TI_Id = p.Fk_TI_Id;
                        t.Status   = (byte)TrainInfoStatus.Finish;
                        trainInfoDao.UpdateByPrimaryKey(t);
                        //插入至上传表
                        UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();
                        uploadManagementDao.Insert(new UploadManagement(t.FK_User_Id, "bdl_traininfo", 1));
                    }
                }

                //更新该设备处方已完成状态
                p.Dp_status = DevicePrescription.DOWN;
                devicePrescriptionDAO.UpdateByPrimaryKey(p);
                //插入至上传表
                UploadManagementDAO uploadManagementDao2 = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(p.Pk_DP_Id, "bdl_deviceprescription", 1));

                ts.Complete();
            }
        }
Example #6
0
        /// <summary>
        /// 激活时插入setter
        /// </summary>
        public void InsertSetter(Setter setter)
        {
            setterDAO.Insert(setter);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(setter.Pk_Set_Id, "bdl_set", 0));
        }
        ///zfc
        /// <summary>
        /// 根据训练课程id更新训练活动记录 完成状态
        /// </summary>
        /// <param name="fk_training_course_id"></param>
        /// <param name="complete"></param>
        public void UpdateRecordCompleteFinish(int trainingcourseid, int complete)
        {
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            trainingActivityRecordDAO.UpdateCompleteFinish(trainingcourseid, complete);
            //数据上传
            uploadManagementDao.Insert(new UploadManagement(trainingcourseid, "bdl_training_activity_record", 1));
        }
Example #8
0
        /// <summary>
        /// 更新会员的登陆时间
        /// </summary>
        public void UpdateLastLoginDate(MemberEntity memberEntity)
        {
            memberDAO.UpdateByPrimaryKey(memberEntity);
            //将更新信息插入至上传表
            UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();

            uploadManagementDao1.Insert(new UploadManagement(memberEntity.Id, "bdl_member", 1));
        }
Example #9
0
        public void UpdateDataCode(DataCode dataCode)
        {
            dataCodeDAO.UpdateByPrimaryKey(dataCode);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(dataCode.Pk_Code_Id, "bdl_datacode", 1));
        }
Example #10
0
        /// <summary>
        /// 如果传上来的用户ID在数据库中不存在,则创建默认用户,并创建默认的训练计划、课程活动、个人设置
        /// </summary>
        /// <returns></returns>
        public long AutoInsertUser(string memberId)
        {
            //使整个代码块成为事务性代码
            using (TransactionScope ts = new TransactionScope())
            {
                MemberEntity memberEntity = new MemberEntity();
                //会员UID
                memberEntity.Member_id = memberId;
                //自动创建的用户数据使用默认值
                //姓氏
                memberEntity.Member_familyName = memberId.Substring(0, 1);
                //名字
                if (memberId.Length == 6)
                {
                    memberEntity.Member_firstName = memberId.Substring(1, 1);
                }
                else if (memberId.Length == 7)
                {
                    memberEntity.Member_firstName = memberId.Substring(1, 2);
                }
                else
                {
                    memberEntity.Member_firstName = memberId.Substring(1, 2);
                }

                //计算最大心率 = 220 - 年龄,此处因为无数据使用默认值
                memberEntity.Max_heart_rate = 190;
                //计算最宜心率 = (最大心率 * 76.5%)然后四舍五入为整数
                memberEntity.Suitable_heart_rate = (int?)Math.Round(memberEntity.Max_heart_rate.Value * 0.765);
                //设置主键id
                memberEntity.Id = KeyGenerator.GetNextKeyValueLong("bdl_member");
                //设置创建时间
                memberEntity.Gmt_create = System.DateTime.Now;
                //默认不开启减脂
                memberEntity.Is_open_fat_reduction = false;
                //角色为会员
                memberEntity.Role_id = 1;
                //训练目的标签
                memberEntity.Label_name = "塑形,";
                //体重使用默认值
                memberEntity.Weight = 80;
                //身高默认
                memberEntity.Height = 170;

                //使用基类插入新会员
                long resultCode = memberDAO.Insert(memberEntity);
                //将插入信息插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(memberEntity.Id, "bdl_member", 0));
                //创建模板训练计划 使用力量耐力循环模板
                planService.AutoSaveNewPlan(memberEntity, PlanTemplate.StrengthEnduranceCycle);

                ts.Complete();
                //使用基类插入新会员
                return(resultCode);
            }
        }
Example #11
0
        /// <summary>
        /// 添加训练结果,返回主键,lj
        /// </summary>
        public void AddPrescriptionResultTwo(object siId, TrainInfo trainInfo,
                                             Dictionary <NewDevicePrescription, PrescriptionResultTwo> prescriptionDic)
        {
            UploadManagementDAO      uploadManagementDao   = new UploadManagementDAO();
            NewDevicePrescriptionDAO devicePrescriptionDao = new NewDevicePrescriptionDAO();
            NewPrescriptionResultDAO prescriptionResultDao = new NewPrescriptionResultDAO();

            using (TransactionScope ts = new TransactionScope()) //使整个代码块成为事务性代码
            {
                //插入训练信息和上传表
                int tiId = (int)new TrainInfoDAO().Insert(trainInfo);
                uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 0));
                if (siId != null)
                {
                    //改变症状表外键关联
                    var symptomInfo = symptomInfoDao.Load((int)siId);
                    symptomInfo.Fk_TI_Id = tiId;
                    symptomInfoDao.UpdateByPrimaryKey(symptomInfo);
                    //将更新信息插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 1));
                }
                if (prescriptionDic != null)
                {
                    int dpId;
                    int prId;
                    foreach (KeyValuePair <NewDevicePrescription, PrescriptionResultTwo> prescription in prescriptionDic)
                    {
                        NewDevicePrescription devicePrescription = prescription.Key;
                        PrescriptionResultTwo prescriptionResult = prescription.Value;
                        //插入设备处方、上传表
                        devicePrescription.Fk_ti_id = tiId;
                        dpId = (int)devicePrescriptionDao.Insert(devicePrescription);
                        uploadManagementDao.Insert(new UploadManagement(dpId, "bdl_deviceprescription", 0));

                        //插入设备处方结果、上传表
                        prescriptionResult.Fk_dp_id = dpId;
                        prId = (int)prescriptionResultDao.Insert(prescriptionResult);
                        uploadManagementDao.Insert(new UploadManagement(prId, "bdl_prescriptionresult", 0));
                    }
                }

                ts.Complete();
            }
        }
Example #12
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="user"></param>
        public void DeleteUser(User user)
        {
            //数据库更新
            user.Is_Deleted = 1;
            userDAO.UpdateByPrimaryKey(user);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(user.Pk_User_Id, "bdl_user", 1));
            //关联图片删除
        }
        /// <summary>
        /// 插入自定义类型数据
        /// </summary>
        /// <param name="customDataEnum">自定义枚举类型</param>
        /// <param name="value">插入的值</param>
        public void InsertCustomData(CustomDataEnum customDataEnum, string value)
        {
            CustomData customData = new CustomData();

            customData.CD_Type       = (byte)customDataEnum;
            customData.CD_CustomName = value;
            customDataDAO.Insert(customData);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(customData.Pk_CD_Id, "bdl_customdata", 0));
        }
Example #14
0
        public void DeleteCustomDataByPrimaryKey(int ID)
        {
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(ID, "bdl_customdata", 1));
            using (var conn = DbUtil.getConn())
            {
                const string query = "update bdl_customdata set is_deleted=1 where Pk_CD_Id = @Pk_CD_Id";

                conn.Query <CustomData>(query, new { Pk_CD_Id = ID });
            }
        }
Example #15
0
        /// <summary>
        /// 更新减脂模式
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="enable"></param>
        public void UpdateDeFatState(string memberId, bool enable)
        {
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
            List <long>         listId = new List <long>();

            //通过memberId获取主键id
            listId = memberDAO.ListIdByMemberId(memberId);
            foreach (var id in listId)
            {
                //数据上传
                uploadManagementDao.Insert(new UploadManagement(id, "bdl_member", 1));
            }
            memberDAO.UpdateDeFatState(memberId, enable);
        }
Example #16
0
        /// <summary>
        /// 新增编码
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="dValue"></param>
        /// <param name="sValue"></param>
        /// <param name="state"></param>
        public void AddDataCode(DataCodeTypeEnum typeId, string dValue, string sValue, Boolean state)
        {
            DataCode dataCode = new DataCode();

            //
            dataCode.Code_Xh      = dataCodeDAO.GetMaxXh(typeId.ToString()) + 1;
            dataCode.Code_D_Value = dValue;
            dataCode.Code_S_Value = sValue;
            dataCodeDAO.Insert(dataCode);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(dataCode.Pk_Code_Id, "bdl_datacode", 0));
        }
Example #17
0
        /**
         * 添加症状信息
         */
        public void AddSymptomnInfo(SymptomInfo symptomInfo)
        {
            using (TransactionScope ts = new TransactionScope())//使整个代码块成为事务性代码
            {
                //插入症状信息返回主键
                int id = (int)new SymptomInfoDao().Insert(symptomInfo);

                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(id, "bdl_symptominfo", 0));

                ts.Complete();
            }
        }
Example #18
0
        /// <summary>
        /// 添加症状信息和子表
        /// </summary>
        public void UpdateSymptomnInfo(SymptomInfo symptomInfo)
        {
            using (TransactionScope ts = new TransactionScope())//使整个代码块成为事务性代码
            {
                //插入症状信息返回主键
                new SymptomInfoDao().UpdateByPrimaryKey(symptomInfo);

                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(symptomInfo.Pk_SI_Id, "bdl_symptominfo", 1));

                ts.Complete();
            }
        }
        ///zfc
        /// <summary>
        /// 根据外键训练课程id完成训练活动,把is_complete标志位置为0,current_turn_number置为0
        /// </summary>
        /// <param name="trainingcourseid"></param>
        /// <param name="complete"></param>
        /// <returns></returns>
        public int UpdateCompleteFinish(int trainingcourseid, int complete)
        {
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
            List <long>         listId = new List <long>();

            //通过memberId获取主键id
            listId = activityDAO.ListIdByfkTrainingCourseId(trainingcourseid);
            foreach (var id in listId)
            {
                //数据上传
                uploadManagementDao.Insert(new UploadManagement(id, "bdl_activity", 1));
            }
            return(activityDAO.UpdateCompleteFinish(trainingcourseid, complete));
        }
Example #20
0
        /// <summary>
        /// 插入体力评价报告
        /// </summary>
        /// <param name="physicalPower"></param>
        public int AddPhysicalPower(PhysicalPower physicalPower)
        {
            int row = new PhysicalPowerDAO().AddPhysicalPower(physicalPower);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(new PhysicalPowerDAO().getIdByGmtCreate(physicalPower.Gmt_Create), "bdl_physicalpower", 0));
            if (row == 1)
            {
                int pk_pp_id = new PhysicalPowerDAO().getIdByGmtCreate(physicalPower.Gmt_Create);
                Console.WriteLine(pk_pp_id);
            }

            return(row);
        }
Example #21
0
        /// <summary>
        /// 自动创建模板训练课程
        /// </summary>
        /// <param name="trainingCourseEntity"></param>
        /// <returns></returns>
        public void AutoSaveNewTemplateCourse(TrainingPlanEntity trainingPlan, PlanTemplate planTemplate)
        {
            //使整个代码块成为事务性代码
            using (TransactionScope ts = new TransactionScope())
            {
                TrainingCourseEntity trainingCourseEntity = new TrainingCourseEntity();

                //主键id
                trainingCourseEntity.Id = KeyGenerator.GetNextKeyValueLong("bdl_training_course");
                //设置外键训练计划id
                trainingCourseEntity.Fk_training_plan_id = trainingPlan.Id;
                //设置会员卡号
                trainingCourseEntity.Member_id = trainingPlan.Member_id;
                //当前创建时间
                trainingCourseEntity.Gmt_create = System.DateTime.Now;
                //6.创建一个默认的训练课程
                //  课程开始时间 = 训练计划的开始时间
                trainingCourseEntity.Start_date = trainingPlan.Start_date;
                //  默认暂停时间是2天
                trainingCourseEntity.Rest_days = 2;
                //  默认课程天数是16天
                trainingCourseEntity.Target_course_count = 16;
                //  当前计数默认0
                trainingCourseEntity.Current_course_count = 0;
                //  默认结束日期 = 开始日期 + (暂停时间*(课程天数 - 1))  减一是因为当天算第一天
                trainingCourseEntity.End_date = trainingCourseEntity.Start_date.Value.AddDays(trainingCourseEntity.Rest_days.Value * (trainingCourseEntity.Target_course_count.Value - 1));
                //  状态未完成
                trainingCourseEntity.Is_complete = false;

                //  保存课程
                //这个插入基类有BUG 明明插入进入了 但是返回的结果为0,所以不要返回值了。反正如果插入失败也报异常,返回值也没啥用
                trainingCourseDAO.Insert(trainingCourseEntity);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement((int)trainingCourseEntity.Id, "bdl_training_course", 0));
                //更新配置中的课程id
                CommUtil.UpdateSettingString("trainingCourseId", (trainingCourseEntity.Id).ToString());
                //训练课程目标天数
                CommUtil.UpdateSettingString("targetCourseCount", (trainingCourseEntity.Target_course_count).ToString());
                //调用创建模板训练活动
                trainingActivityService.AutoSaveActivityTemplate(trainingCourseEntity, trainingPlan.Fk_member_id.Value, planTemplate);
                ts.Complete();
            }
        }
Example #22
0
        /// <summary>
        /// 根据web传来的心跳信息,做操作
        /// </summary>
        /// <param name="httpHeartBeat"></param>
        public void SolveHeartbeat(HttpHeartBeat httpHeartBeat)
        {
            AuthDAO authDAO = new AuthDAO();
            Auther  auther  = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);

            if (httpHeartBeat.authStatus == 0)
            {
                //0权限操作位  不作处理,属于正常心跳
                //解锁
                auther.User_Status = Auther.USER_STATUS_GENERAL;
            }
            else if (httpHeartBeat.authStatus == 1)
            {
                //锁定
                auther.User_Status = Auther.USER_STATUS_FREEZE;
            }
            else if (httpHeartBeat.authStatus == 2)
            {
                //解锁
                auther.User_Status = Auther.USER_STATUS_GENERAL;
            }
            else if (httpHeartBeat.authStatus == 3)
            {
                //永久离线至9999年
                auther.User_Status      = Auther.USER_STATUS_FREE;
                auther.Auth_OfflineTime = Auther.Auth_OFFLINETIMEFREE;
            }
            else if (httpHeartBeat.authStatus == 4)
            {
                //删除用户,做冻结处理
                auther.User_Status = Auther.USER_STATUS_FREEZE;
            }

            authDAO.UpdateByPrimaryKey(auther);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(auther.Pk_Auth_Id, "bdl_auth", 1));
        }
Example #23
0
        /// <summary>
        /// 添加训练课程
        /// </summary>
        /// <param name="trainingCourseEntity"></param>
        /// <returns></returns>
        public void SaveTrainingCourse(DateTime?startDate)
        {
            TrainingCourseEntity trainingCourseEntity = new TrainingCourseEntity();

            //主键id
            trainingCourseEntity.Id = KeyGenerator.GetNextKeyValueLong("bdl_training_course");
            //设置外键训练计划id
            trainingCourseEntity.Fk_training_plan_id = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingPlanId"));
            //设置会员卡号
            trainingCourseEntity.Member_id = CommUtil.GetSettingString("memberId");
            //当前创建时间
            trainingCourseEntity.Gmt_create = System.DateTime.Now;
            //6.创建一个默认的训练课程
            //  课程开始时间 = 训练计划的开始时间
            trainingCourseEntity.Start_date = startDate;
            //  默认暂停时间是4天
            trainingCourseEntity.Rest_days = 2;
            //  默认课程天数是16天
            trainingCourseEntity.Target_course_count = 16;
            //  默认结束日期 = 开始日期 + (暂停时间*(课程天数 - 1))  减一是因为当天算第一天
            trainingCourseEntity.End_date = trainingCourseEntity.Start_date.Value.AddDays(trainingCourseEntity.Rest_days.Value * (trainingCourseEntity.Target_course_count.Value - 1));
            //  状态未完成
            trainingCourseEntity.Is_complete = false;
            //  当前计数默认0
            trainingCourseEntity.Current_course_count = 0;
            //  保存课程


            //这个插入基类有BUG 明明插入进入了 但是返回的结果为0,所以不要返回值了。反正如果插入失败也报异常,返回值也没啥用
            trainingCourseDAO.Insert(trainingCourseEntity);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(trainingCourseEntity.Id, "bdl_training_course", 0));
            //更新配置中的课程id
            CommUtil.UpdateSettingString("trainingCourseId", (trainingCourseEntity.Id).ToString());
            //训练课程目标天数
            CommUtil.UpdateSettingString("targetCourseCount", (trainingCourseEntity.Target_course_count).ToString());
        }
Example #24
0
        /// <summary>
        /// 处理错上传请求
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ErrorInfoResponse HandleErrorInfoRequest(ErrorInfoRequest request)
        {
            ErrorInfoResponse response = new ErrorInfoResponse
            {
                Uid        = request.Uid,
                DeviceType = request.DeviceType,
                TrainMode  = request.TrainMode,
                Success    = false
            };

            try
            {
                Error error = new Error();
                error.device_type = (int)request.DeviceType;
                error.error_info  = request.Error;
                error.fk_user_id  = Convert.ToInt32(request.Uid);
                error.train_mode  = (int)request.TrainMode;
                error.error_time  = request.ErrorStartTime;
                errorDao.Insert(error);
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(errorDao.GetErrorLastId(), "bdl_error", 0));
            }
            catch (Exception e)
            {
                logger.Error("错误信息插入失败。");
            }

            logger.Error("当前出现错误时间," + request.ErrorStartTime
                         + ",用户id" + request.Uid
                         + ",设备类型" + (int)request.DeviceType
                         + ",训练模式" + (int)request.TrainMode
                         + ",错误信息" + request.Error
                         );
            response.Success = true;
            return(response);
        }
        /// <summary>
        /// 添加新的训练计划,需要先删除旧的训练计划
        /// </summary>
        /// <param name="trainingPlan"></param>
        /// <returns></returns>
        public void SaveNewTrainingPlan(TrainingPlanEntity trainingPlan)
        {
            //使整个代码块成为事务性代码
            using (TransactionScope ts = new TransactionScope())
            {
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                //会员卡号ID
                string memberId = CommUtil.GetSettingString("memberId");
                //1.删除旧的训练计划
                trainingPlanDAO.DeletePlanByMemberId(memberId);
                //2.完成旧的训练课程
                trainingCourseDAO.UpdateCompleteState(memberId, true);
                List <long> listId1 = new List <long>();
                listId1 = trainingCourseDAO.ListIdByMemeberId(memberId);
                foreach (var id in listId1)
                {
                    //数据上传
                    uploadManagementDao.Insert(new UploadManagement(id, "bdl_training_course", 1));
                }
                //3.完成旧的训练活动
                activityDAO.UpdateCompleteState(memberId, true);
                List <long> listId = new List <long>();
                //通过memberId获取主键id
                listId = activityDAO.ListIdByMemeberId(memberId);
                foreach (var id in listId)
                {
                    //数据上传
                    uploadManagementDao.Insert(new UploadManagement(id, "bdl_activity", 1));
                }
                //4.新增训练计划
                trainingPlan.Id = KeyGenerator.GetNextKeyValueLong("bdl_training_plan");

                //判断登陆用户,是教练自己锻炼。还是教练为用户进行设置。决定传哪个主键设置
                string currentMemberPK = CommUtil.GetSettingString("memberPrimarykey");
                string currentCoachId  = CommUtil.GetSettingString("coachId");
                if ((currentMemberPK == null || currentMemberPK == "") && (currentCoachId != null && currentCoachId != ""))
                {
                    //无用户登陆。教练单独登陆时
                    //  从app.config中取id,转成int赋值
                    trainingPlan.Fk_member_id = ParseIntegerUtil.ParseInt(currentCoachId);
                }
                else
                {
                    //只要用户登录,就是为用户进行设置
                    //  从app.config中取id,转成int赋值
                    trainingPlan.Fk_member_id = ParseIntegerUtil.ParseInt(currentMemberPK);
                }


                //  设置会员卡号
                trainingPlan.Member_id = CommUtil.GetSettingString("memberId");
                //  设置状态为未删除
                trainingPlan.Is_deleted = false;
                //  创建时间
                trainingPlan.Gmt_create = System.DateTime.Now;
                //  插入新训练计划
                trainingPlanDAO.Insert(trainingPlan);
                //插入至上传表
                uploadManagementDao.Insert(new UploadManagement(trainingPlan.Id, "bdl_training_plan", 0));
                //5.更新App.config中训练计划id
                CommUtil.UpdateSettingString("trainingPlanId", (trainingPlan.Id).ToString());

                //插入默认训练课程 课程开始时间 = 训练计划开始时间
                trainingCourseService.SaveTrainingCourse(trainingPlan.Start_date);
                ts.Complete();
            }
        }
        /// <summary>
        /// 根据模板自动创建训练活动 传入的是用户的数据库主键id
        /// </summary>
        /// <param name="trainingCourseEntity"></param>
        /// <param name="memberPkId"></param>
        /// <param name="planTemplate"></param>
        /// <returns></returns>
        public long AutoSaveActivityTemplate(TrainingCourseEntity trainingCourseEntity, long memberPkId, PlanTemplate planTemplate)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                long result = 0;

                List <ActivityEntity> activities = new List <ActivityEntity>();
                //力量循环活动
                ActivityEntity strengthActivity = new ActivityEntity();
                //耐力循环活动
                ActivityEntity enduranceActivity = new ActivityEntity();
                //上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

                //根据不同模板创建不同的活动
                switch (planTemplate)
                {
                case PlanTemplate.StrengthCycle:    //力量循环
                    strengthActivity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                    strengthActivity.Member_id             = trainingCourseEntity.Member_id;
                    strengthActivity.Fk_member_id          = memberPkId;
                    strengthActivity.Fk_training_course_id = trainingCourseEntity.Id;
                    strengthActivity.Gmt_create            = System.DateTime.Now;
                    strengthActivity.Is_complete           = false;
                    //模板创建默认两轮
                    strengthActivity.Target_turn_number  = 2;
                    strengthActivity.current_turn_number = 0;
                    //0:力量循环
                    strengthActivity.Activity_type = "0";

                    activities.Add(strengthActivity);
                    // 插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(strengthActivity.Id, "bdl_activity", 0));
                    break;

                case PlanTemplate.EnduranceCycle:    //耐力循环
                    enduranceActivity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                    enduranceActivity.Member_id             = trainingCourseEntity.Member_id;
                    enduranceActivity.Fk_member_id          = memberPkId;
                    enduranceActivity.Fk_training_course_id = trainingCourseEntity.Id;
                    enduranceActivity.Gmt_create            = System.DateTime.Now;
                    enduranceActivity.Is_complete           = false;
                    //模板创建默认两轮
                    enduranceActivity.Target_turn_number  = 2;
                    enduranceActivity.current_turn_number = 0;
                    //1:耐力循环
                    enduranceActivity.Activity_type = "1";

                    activities.Add(enduranceActivity);
                    //插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(enduranceActivity.Id, "bdl_activity", 0));
                    break;

                case PlanTemplate.StrengthEnduranceCycle:
                    //创建力量循环活动
                    strengthActivity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                    strengthActivity.Member_id             = trainingCourseEntity.Member_id;
                    strengthActivity.Fk_member_id          = memberPkId;
                    strengthActivity.Fk_training_course_id = trainingCourseEntity.Id;
                    strengthActivity.Gmt_create            = System.DateTime.Now;
                    strengthActivity.Is_complete           = false;
                    //模板创建默认两轮
                    strengthActivity.Target_turn_number  = 2;
                    strengthActivity.current_turn_number = 0;
                    //0:力量循环
                    strengthActivity.Activity_type = "0";

                    activities.Add(strengthActivity);
                    //插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(strengthActivity.Id, "bdl_activity", 0));
                    //创建耐力循环活动
                    enduranceActivity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                    enduranceActivity.Member_id             = trainingCourseEntity.Member_id;
                    enduranceActivity.Fk_member_id          = memberPkId;
                    enduranceActivity.Fk_training_course_id = trainingCourseEntity.Id;
                    enduranceActivity.Gmt_create            = System.DateTime.Now;
                    enduranceActivity.Is_complete           = false;
                    //模板创建默认两轮
                    enduranceActivity.Target_turn_number  = 2;
                    enduranceActivity.current_turn_number = 0;
                    //1:耐力循环
                    enduranceActivity.Activity_type = "1";

                    activities.Add(enduranceActivity);
                    //插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(enduranceActivity.Id, "bdl_activity", 0));
                    break;

                default:
                    break;
                }

                //批量插入训练活动
                result = activityDAO.BatchInsert(activities);


                //根据训练活动批量插入个人设置记录 传入用户主键id
                personalSettingService.AutoSavePersonalSettings(memberPkId, trainingCourseEntity.Id, trainingCourseEntity.Member_id);


                ts.Complete();
                return(result);
            }
        }
        /// <summary>
        /// 保存或更新在线信息,没有该ID则保存,有则更新时间
        /// </summary>
        /// <param name="frameBean"></param>
        public void SavaOrUpdateOnlineInfo(TcpFrameBean frameBean)
        {
            var onlineDevice = onlineDeviceDAO.GetByClientId(frameBean.TerminalId);

            if (onlineDevice == null)//插入
            {
                onlineDevice = new OnlineDevice();

                string name_zh = "";
                string name_en = "";

                //设置设备中英文设备名称
                switch (frameBean.DeviceType)
                {
                case DeviceType.P00:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.Rowing");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.Rowing");
                    break;

                case DeviceType.P01:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.ChestPress");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.ChestPress");
                    break;

                case DeviceType.P02:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.HorizontalLegPress");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.HorizontalLegPress");
                    break;

                case DeviceType.P03:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.AbdominalMuscleTraining");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.AbdominalMuscleTraining");
                    break;

                case DeviceType.P04:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.TricepsTraining");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.TricepsTraining");
                    break;

                case DeviceType.P05:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.LegAbduction");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.LegAbduction");
                    break;

                case DeviceType.P06:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.LegInturn");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.LegInturn");
                    break;

                case DeviceType.P07:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.ButterflyMachine");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.ButterflyMachine");
                    break;

                case DeviceType.P08:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.ReverseButterflyMachine");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.ReverseButterflyMachine");
                    break;

                case DeviceType.P09:
                    name_en = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.EN, "NewDev.SittingBackExtender");
                    name_zh = LanguageUtils.GetLanuageStrByLanguageAndKey(LanguageUtils.ZH, "NewDev.SittingBackExtender");
                    break;

                default:
                    break;
                }

                onlineDevice.od_gmt_modified  = DateTime.Now;
                onlineDevice.od_clientid      = frameBean.TerminalId;
                onlineDevice.od_clientname_en = name_en;
                onlineDevice.od_clientname_ch = name_zh;
                //插入记录
                onlineDeviceDAO.Insert(onlineDevice);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(onlineDevice.pk_od_id, "bdl_onlinedevice", 0));
            }
            else//更新
            {
                //更新心跳时间
                onlineDeviceDAO.UpdateOnlineTime(onlineDevice.pk_od_id, DateTime.Now);
                //插入至上传表
                UploadManagementDAO uploadManagementDao = new UploadManagementDAO();
                uploadManagementDao.Insert(new UploadManagement(onlineDevice.pk_od_id, "bdl_onlinedevice", 1));
            }
        }
        /// <summary>
        /// 添加训练活动后,自动根据数据库中的训练活动记录,往个人设置表插入记录
        /// </summary>
        /// <returns></returns>
        public bool SavePersonalSettings(long userPK)
        {
            //上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            //使整个代码块成为事务性代码
            using (TransactionScope ts = new TransactionScope())
            {
                //1.先查询当前训练课程对应的训练活动集合
                List <ActivityEntity> activities = activityDAO.ListActivitysByCourseId(ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId")));
                //遍历每一条活动
                foreach (var activity in activities)
                {
                    //先查询判断个人设置表是否有该会员ID,该活动类型的记录,传入会员id和活动类型
                    string memberID = CommUtil.GetSettingString("memberId");
                    List <PersonalSettingEntity> personalSettingEntities = personalSettingDAO.ListSettingByMemberIdActivityType(memberID, activity.Activity_type);

                    //若个人设置表无该会员该训练活动的记录,则每个设备往个人设置表插入一条记录
                    if (personalSettingEntities.Count == 0)
                    {
                        //查询出每个活动类型对应着哪些设备
                        List <DatacodeEntity> datacodeEntities = datacodeDao.ListByTypeIdAndExtValue("DEVICE", activity.Activity_type);
                        //批量插入 构建集合
                        var personalSettingList = new List <PersonalSettingEntity>();
                        foreach (var item in datacodeEntities)
                        {
                            var personalSetting = new PersonalSettingEntity();
                            personalSetting.Id            = KeyGenerator.GetNextKeyValueLong("bdl_personal_setting");
                            personalSetting.Activity_type = activity.Activity_type;
                            //默认标准模式
                            personalSetting.Training_mode       = "0";
                            personalSetting.Device_code         = item.Code_s_value;
                            personalSetting.Device_order_number = item.Code_xh;
                            //主键设置为传入的主键,因为传入前判断是登陆的教练单独训练还是有用户登录
                            personalSetting.Fk_member_id = userPK;
                            personalSetting.Member_id    = CommUtil.GetSettingString("memberId");
                            personalSetting.Gmt_create   = System.DateTime.Now;
                            //这个外键id用于展示的时候联查活动表和设置表。能够根据当前存在的训练活动查出相应的设置。根据活动id联查是最简单的方法。
                            //否则如果根据会员卡号查有可能出现没选这个训练活动却因为以前添加过设置查出来了。如果再根据类型判断查询也很麻烦。添加活动的时候更新个人设置里这个外键活动id是最好的办法。
                            personalSetting.Fk_training_activity_id = activity.Id;

                            //分别设置力度和功率 单车跑步机只设置功率 其他设置力度
                            if ("12".Equals(item.Code_s_value) || "16".Equals(item.Code_s_value))
                            {
                                personalSetting.Power = 30;
                            }
                            else
                            {
                                //设置各个属性的默认值
                                personalSetting.Consequent_force = 21;  //顺向力
                                personalSetting.Reverse_force    = 21;  //反向力
                                personalSetting.Front_limit      = 100; //前方限制
                                personalSetting.Back_limit       = 0;   //后方限制
                            }

                            //添加进集合
                            personalSettingList.Add(personalSetting);

                            //插入至上传表
                            uploadManagementDao.Insert(new UploadManagement(personalSetting.Id, "bdl_personal_setting", 0));
                        }
                        //使用基本DAO 批量插入数据库
                        personalSettingDAO.BatchInsert(personalSettingList);
                    }
                    //如果有记录就更新记录的外键活动id
                    else if (personalSettingEntities.Count > 0)
                    {
                        PersonalSettingEntity personalSetting = new PersonalSettingEntity();
                        personalSetting.Fk_training_activity_id = activity.Id;
                        personalSetting.Member_id     = CommUtil.GetSettingString("memberId");
                        personalSetting.Activity_type = activity.Activity_type;
                        personalSettingDAO.UpdateSettingActivityId(personalSetting);
                    }
                }


                ts.Complete();
            }
            return(true);
        }
Example #29
0
        /// <summary>
        /// 保存训练信息
        /// DevicePrescription
        /// </summary>
        /// <param name="trainInfo"></param>
        /// <param name="devicePrescriptions"></param>
        public void SaveTraininfo(object siId, TrainInfo trainInfo, List <NewDevicePrescription> devicePrescriptions)
        {
            using (TransactionScope ts = new TransactionScope()) //使整个代码块成为事务性代码
            {
                TrainInfo trainInfoFromDB = GetTrainInfoByUserIdAndStatus(trainInfo.FK_User_Id, trainInfo.Status);
                if (trainInfoFromDB != null)
                {
                    switch (trainInfo.Status)
                    {
                    case (int)TrainInfoStatus.Save:
                        //如果保存处方,删除原来的记录和关联的处方
                        trainInfoDao.DeleteByPrimaryKey(trainInfoFromDB);
                        devicePrescriptionDao.DeleteByTiId(trainInfoFromDB.Pk_TI_Id);
                        break;

                    case (int)TrainInfoStatus.Normal:
                        //如果是写卡后的插入,废弃原来的记录
                        trainInfoDao.UpdateStatusByUserId(trainInfo.FK_User_Id);


                        break;

                    case (int)TrainInfoStatus.Temp:
                        //如果是暂存状态的数据,废弃之前的该用户的暂存训练信息。在此处并不废弃已经有的nomal状态的信息,写卡成功了,才会废弃。
                        trainInfoDao.AbandonAllTempTrainInfo(trainInfo.FK_User_Id);

                        break;
                    }
                }

                //插入训练信息表
                int tiId = (int)trainInfoDao.Insert(trainInfo);
                //插入上传表
                uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 0));
                //插入症状信息,如果有症状信息的话
                if (trainInfo.Status == (int)TrainInfoStatus.Normal && siId != null)
                {
                    //如果是写卡,并且选了症状记录,改变症状表外键关联
                    var symptomInfo = symptomInfoDao.Load((int)siId);
                    symptomInfo.Fk_TI_Id = tiId;
                    symptomInfoDao.UpdateByPrimaryKey(symptomInfo);
                    //插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(symptomInfo.Pk_SI_Id, "bdl_symptominfo", 1));
                }

                int dpId;
                //插入设备处方
                if (devicePrescriptions != null)
                {
                    foreach (NewDevicePrescription devicePrescription in devicePrescriptions)
                    {
                        devicePrescription.Fk_ti_id = tiId;
                        dpId = (int)devicePrescriptionDao.Insert(devicePrescription);
                        //插入至上传表
                        uploadManagementDao.Insert(new UploadManagement(dpId, "bdl_deviceprescription", 0));
                    }
                }

                ts.Complete();
            }
        }
        /// <summary>
        /// 自动创建模板训练计划 2019.3.27
        /// </summary>
        /// <param name="memberId"></param>
        public void AutoSaveNewPlan(MemberEntity memberEntity, PlanTemplate planTemplate)
        {
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            //使整个代码块成为事务性代码
            using (TransactionScope ts = new TransactionScope())
            {
                TrainingPlanEntity trainingPlan = new TrainingPlanEntity();

                //会员卡号ID
                string memberId = memberEntity.Member_id;

                //1.删除旧的训练计划
                trainingPlanDAO.DeletePlanByMemberId(memberId);
                //2.完成旧的训练课程
                trainingCourseDAO.UpdateCompleteState(memberId, true);
                List <long> listId1 = new List <long>();
                listId1 = trainingCourseDAO.ListIdByMemeberId(memberId);
                foreach (var id in listId1)
                {
                    //数据上传
                    uploadManagementDao.Insert(new UploadManagement(id, "bdl_training_course", 1));
                }

                //3.完成旧的训练活动
                activityDAO.UpdateCompleteState(memberId, true);

                List <long> listId = new List <long>();
                //通过memberId获取主键id
                listId = activityDAO.ListIdByMemeberId(memberId);
                foreach (var id in listId)
                {
                    //数据上传
                    uploadManagementDao.Insert(new UploadManagement(id, "bdl_activity", 1));
                }
                //4.新增训练计划
                trainingPlan.Id = KeyGenerator.GetNextKeyValueLong("bdl_training_plan");
                //外键用户主键id
                trainingPlan.Fk_member_id = memberEntity.Id;
                //  设置会员卡号
                trainingPlan.Member_id = memberEntity.Member_id;
                // 开始时间
                trainingPlan.Start_date = System.DateTime.Now;
                //  设置状态为未删除
                trainingPlan.Is_deleted = false;
                //  创建时间
                trainingPlan.Gmt_create = System.DateTime.Now;
                //训练计划标题
                switch (planTemplate)
                {
                case PlanTemplate.StrengthCycle:
                    trainingPlan.Title = "力量循环";
                    break;

                case PlanTemplate.EnduranceCycle:
                    trainingPlan.Title = "力量耐力循环";
                    break;

                case PlanTemplate.StrengthEnduranceCycle:
                    trainingPlan.Title = "力量循环与力量耐力循环";
                    break;

                default:
                    break;
                }

                trainingPlan.Training_target = "塑形";
                //  插入新训练计划
                trainingPlanDAO.Insert(trainingPlan);
                uploadManagementDao.Insert(new UploadManagement(trainingPlan.Id, "bdl_training_plan", 0));
                //5.更新App.config中训练计划id
                CommUtil.UpdateSettingString("trainingPlanId", (trainingPlan.Id).ToString());
                //自动创建模板课程
                trainingCourseService.AutoSaveNewTemplateCourse(trainingPlan, planTemplate);
                ts.Complete();
            }
        }