public TrainRecord GetTrainRecord() { if (currentControl != null) { endTicks = DateTime.Now.Ticks; TrainRecord record = new TrainRecord(); record.MaxAngle = MaxAngle; record.MinAngle = MinAngle; record.PushRodValue = PushRodAngle; record.Force = Force; record.Speed = Speed; record.Times = Times * GroupNum; record.ModeId = (int)currentControl.Mode; record.ActionId = (int)currentControl.Action; record.FactTimes = currentControl.CurrentTimes; record.IsFit = 0; record.StartTime = new DateTime(startTicks); record.EndTime = new DateTime(endTicks); record.ExMinutes = (int)((endTicks - startTicks) / (10000 * 1000)); record.ExerciseDate = record.StartTime.Date; record.TargetLine = targetLine; record.MaxForce = maxForce; record.RealMinAngle = actionMinAngle; record.RealMaxAngle = actionMaxAngle; record.GroupNum = GroupNum; if (GroupRecordList != null) { record.GroupRecords = GroupRecordList.ToArray(); } if (sumForceNum > 0) { record.AvgForce = (float)(sumForce / sumForceNum); } if (RealLine != null) { record.RealLine = RealLine.ToArray(); } if (ForceLine != null) { record.ForceLine = ForceLine.ToArray(); } return record; } return null; }
private void SaveTrainRecord(TrainRecord record) { Application.Current.Dispatcher.Invoke(new Action(() => { try { if (record.ModeId == (int)ModeEnum.Fit) return; if (record != null) { Exerciserecord er = new Exerciserecord(); er.Id = Guid.NewGuid().ToString("N"); er.ActionId = record.ActionId; er.EndTime = record.EndTime; er.ExerciseDate = record.ExerciseDate; er.ExMinutes = record.ExMinutes; er.Times = record.Times; er.FactTimes = record.FactTimes; er.RobotForce = record.Force; er.IsFit = record.IsFit; er.MaxAngle = record.MaxAngle; er.MinAngle = record.MinAngle; er.ModeId = record.ModeId; er.PatientId = ModuleConstant.PatientId; er.Speed = record.Speed; er.StartTime = record.StartTime; er.Maxforce = record.MaxForce; er.AvgForce = record.AvgForce; er.RealMinAngle = record.RealMinAngle; er.RealMaxAngle = record.RealMaxAngle; er.GroupNum = record.GroupNum; er.PushRodValue = record.PushRodValue; StringBuilder sb = new StringBuilder(); if (record.TargetLine != null) { for (int i = 0; i < record.TargetLine.Length; i++) { if (i == 0) { sb.Append(record.TargetLine[i].ToString("#0.00")); } else { sb.Append("|").Append(record.TargetLine[i].ToString("#0.00")); } } er.Record1 = sb.ToString(); } sb = new StringBuilder(); if (record.RealLine != null) { for (int i = 0; i < record.RealLine.Length; i++) { if (i == 0) { sb.Append(record.RealLine[i].ToString("#0.00")); } else { sb.Append("|").Append(record.RealLine[i].ToString("#0.00")); } } er.Record2 = sb.ToString(); } sb = new StringBuilder(); if (record.ForceLine != null) { for (int i = 0; i < record.ForceLine.Length; i++) { if (i == 0) { sb.Append(record.ForceLine[i].ToString("#0.00")); } else { sb.Append("|").Append(record.ForceLine[i].ToString("#0.00")); } } er.Record3 = sb.ToString(); } sb = new StringBuilder(); if (record.GroupRecords != null) { for (int i = 0; i < record.GroupRecords.Length; i++) { if (i > 0) { sb.Append("|"); } sb.Append(record.GroupRecords[i].GroupNum).Append(",") .Append(record.GroupRecords[i].Min.ToString("#0.00")).Append(",") .Append(record.GroupRecords[i].Max.ToString("#0.00")); } er.GroupRecord = sb.ToString(); } MySession.Session.Save(er); MySession.Session.Flush(); } } catch {} })); }