//上传 private void UploadBtn_Click(object sender, RoutedEventArgs e) { if (System.Windows.MessageBox.Show("是否上传检测记录?", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { string activityId = Uid; List <StudentCheckData> studentCheckDatas = dbUtill.GetUploadDatasByActivityId(activityId); if (studentCheckDatas.Count > 0) { MyCustomControlLibrary.MMessageBox.ShowLoading(MyCustomControlLibrary.MMessageBox.LoadType.Circle, "正在上传", new Point(0, 0), new Size(0, 0), "", System.Windows.Controls.Orientation.Vertical, "#ffffff", 3); string url = dbUtill.GetImageUrl(); string uploadUrl = ConfigurationManager.AppSettings["UploadUrl"]; string schoolId = ConfigurationManager.AppSettings["schoolId"]; Activity activity = dbUtill.GetActivitieInfoByID(ActivityId); foreach (StudentCheckData student in studentCheckDatas) { string res = dbUtill.GetStudentInfoByStudentId(student.studentId); string studentName = dbUtill.GetStudentNameByID(student.studentId); string[] resArray = res.Split(','); string gradeName = resArray[1]; string className = resArray[0]; string path = @url + "\\" + ActivityName + "\\" + gradeName + "\\" + className + "\\" + student.studentId + "_" + studentName + ".jpg"; if (!File.Exists(path)) { ImageInfo imageInfo = CommonUtill.ImageFileInfo(path); if (student.jsonContent.Trim().Length > 1) { string param = "{\"student_educode\":\"" + student.NID + "\",\"activity_code\":\"" + activityId + "\",\"student_number\":\"" + student.studentId + "\",\"image\":[{\"image_size\":" + imageInfo.image_size + ",\"image_code\":" + imageInfo.image_code + ",\"fileName\":" + imageInfo.fileName + ",\"image_time\":" + imageInfo.image_time + "}],\"target_code\":\"7\", \"school_code\": \"" + schoolId + "\",\"datas\": { \"age\": " + student.studentAge + ",\"height\": " + student.studentHeight + ",\"checkDate\": \"" + student.checkDate + "\",\"checkResult\":\"" + student.jsonContent + "\"}},\"activityName\": \"" + activity.ActivityName + "\",\"activityDate\": \"" + activity.activityDate + "\"}"; string Res = requestUtill.PostRequestClient(uploadUrl, param); } } else { rp.checkData = student; rp.CreateMC780_boy(); ImageInfo imageInfo = CommonUtill.ImageFileInfo(path); if (student.jsonContent.Trim().Length > 1) { string param = "{\"student_educode\":\"" + student.NID + "\",\"activity_code\":\"" + activityId + "\",\"student_number\":\"" + student.studentId + "\",\"image\":[{\"image_size\":" + imageInfo.image_size + ",\"image_code\":" + imageInfo.image_code + ",\"fileName\":" + imageInfo.fileName + ",\"image_time\":" + imageInfo.image_time + "}],\"target_code\":\"7\", \"school_code\": \"" + schoolId + "\",\"datas\": { \"age\": " + student.studentAge + ",\"height\": " + student.studentHeight + ",\"checkDate\": \"" + student.checkDate + "\",\"checkResult\":\"" + student.jsonContent + "\"}},\"activityName\": \"" + activity.ActivityName + "\",\"activityDate\": \"" + activity.activityDate + "\"}"; string Res = requestUtill.PostRequestClient(uploadUrl, param); Console.WriteLine(Res); } } } MyCustomControlLibrary.MMessageBox.MClosed(); System.Windows.MessageBox.Show("上传完毕", "提示"); } else { System.Windows.MessageBox.Show("该活动不存在已检测的数据,请检测后再试", "提示"); } } }
// private void OkBtn_Click(object sender, RoutedEventArgs e) { string memberName = MemberName.Text.Trim(); string memberId = dbUtill.GetTeacherIDByName(memberName); if (memberName.Length > 0 && memberId.Length <= 1) { MessageBox.Show("不存在该用户,请核对后再试", "提示"); } else { string url = dbUtill.GetImageUrl(); string memberSex = ""; string IsUpload = ""; Time1.SelectedDateFormat = DatePickerFormat.Short; Time2.SelectedDateFormat = DatePickerFormat.Short; string time1 = Time1.SelectedDate.ToString(); string time2 = Time2.SelectedDate.ToString(); if (MenberSex.SelectedItem is ComboBoxItem item) { string membersex = item.Content.ToString(); if (membersex.Equals("男")) { memberSex = "0"; } else { memberSex = "1"; } } if (Isupload.SelectedItem is ComboBoxItem item2) { string isUpload = item2.Content.ToString(); if (isUpload.Equals("否")) { IsUpload = "0"; } else { IsUpload = "1"; } } Report rp = new Report(); List <TeacherCheckData> teachers = dbUtill.GetTeacherCheckDataList(memberId, time1, time2, memberSex, IsUpload); if (teachers.Count > 0) { for (int i = 0; i < teachers.Count; i++) { rp.teacherCheckData = teachers[i]; rp.CreateTeacherPrint(i); } MessageBox.Show("已保存至" + url, "提示"); } else { MessageBox.Show("没有符合条件的检测记录", "提示"); } } }
//保存报告图片 public void CreateMC780_boy() { Dictionary <string, string> dic = checkDataUtill.GetDicByBackStr(checkData.jsonContent); Font font = new Font("宋体", 11f); Font font1 = new Font("宋体", 7f); Font font2 = new Font("宋体", 9f); Font font3 = new Font("宋体", 6f); int num = 0x317; int num1 = 0x45f; Image image = Image.FromFile(@"Resources/780_boy.jpg"); Image image2 = new Bitmap(num1, num); Graphics g = Graphics.FromImage(image2); g.DrawImage(image, 0, 0, num1, num); string studentName = dbUtill.GetStudentNameByID(checkData.studentId); string studentId = checkData.studentId; string activityId = checkData.activityId; try { g.DrawString(studentName, font, Brushes.Black, new Point(75, 72)); //姓名 g.DrawString(dic["AG"], font, Brushes.Black, new Point(200, 72)); //年龄 g.DrawString(dic["Da"], new Font("宋体", 11f), Brushes.Black, new Point(300, 72)); //日期 string sex = dic["GE"]; if (sex.Equals("1")) { g.DrawString("√", font, Brushes.Black, new Point(476, 72)); //性别 } else { g.DrawString("√", font, Brushes.Black, new Point(511, 72)); } g.DrawString(studentId, new Font("宋体", 11f), Brushes.Black, new Point(75, 103)); //Id g.DrawString(dic["Pt"], font, Brushes.Black, new Point(240, 103)); //着衣重量 g.DrawString(dic["Hm"], font, Brushes.Black, new Point(330, 103)); //身高 string bodytype = dic["Bt"]; if (bodytype.Equals("0")) { g.DrawString("√", font, Brushes.Black, new Point(437, 104)); //身体类型 } else { g.DrawString("√", font, Brushes.Black, new Point(457, 104)); } g.DrawString(dic["Wk"], font, Brushes.Black, new Point(80, 191)); //体重 g.DrawString(dic["FW"], font, Brushes.Black, new Point(80, 218)); //体脂率 g.DrawString(dic["fW"], font, Brushes.Black, new Point(80, 245)); //体脂量 g.DrawString(dic["MW"], font, Brushes.Black, new Point(80, 271)); //去脂体重 g.DrawString(dic["wW"], font, Brushes.Black, new Point(80, 297)); //体水份量 g.DrawString(dic["MI"], font, Brushes.Black, new Point(80, 325)); //BMI //参考值 g.DrawString("30.22~38.11", font3, Brushes.Black, new Point(152, 193)); //体重 g.DrawString("10~25.9", font3, Brushes.Black, new Point(152, 220)); //体脂率 g.DrawString("2.84~8.95", font3, Brushes.Black, new Point(152, 247)); //体脂量 g.DrawString("27.38~29.16", font3, Brushes.Black, new Point(152, 273)); //去脂体重 g.DrawString("17.1~18.525", font3, Brushes.Black, new Point(152, 299)); //体水份量 g.DrawString("13.6~18.6", font3, Brushes.Black, new Point(152, 327)); //BMI // g.DrawString(dic["mW"], font, Brushes.Black, new Point(130, 365)); //肌肉量 g.DrawString(dic["bW"], font, Brushes.Black, new Point(130, 398)); //推定骨量 g.DrawString(dic["rB"], font, Brushes.Black, new Point(79, 450)); // 基础代谢率 g.DrawString(dic["ml"], font1, Brushes.Black, new Point(60, 630)); //左上肢 g.DrawString(dic["mr"], font1, Brushes.Black, new Point(220, 630)); //BMI g.DrawString(dic["mL"], font1, Brushes.Black, new Point(60, 710)); //BMI g.DrawString(dic["mR"], font1, Brushes.Black, new Point(220, 710)); //BMI g.DrawString(dic["mT"], font1, Brushes.Black, new Point(220, 680)); //躯干 //肌肉平衡 g.DrawString(dic["mr"], font1, Brushes.Black, new Point(330, 420)); //左上肢 g.DrawString(dic["Mr"], font1, Brushes.Black, new Point(490, 420)); //BMI g.DrawString(dic["mR"], font1, Brushes.Black, new Point(330, 480)); //BMI g.DrawString(dic["MR"], font1, Brushes.Black, new Point(490, 480)); //BMI //各部分脂肪 g.DrawString(dic["Fr"], font1, Brushes.Black, new Point(510, 622)); //右上肢 g.DrawString(dic["fr"], font1, Brushes.Black, new Point(510, 634)); // g.DrawString(dic["Fl"], font1, Brushes.Black, new Point(340, 625)); //左上肢 g.DrawString(dic["fl"], font1, Brushes.Black, new Point(340, 637)); // g.DrawString(dic["FR"], font1, Brushes.Black, new Point(518, 712)); //右下肢 g.DrawString(dic["fR"], font1, Brushes.Black, new Point(518, 724)); // g.DrawString(dic["FL"], font1, Brushes.Black, new Point(335, 708)); //左下肢 g.DrawString(dic["fL"], font1, Brushes.Black, new Point(335, 720)); // g.DrawString(dic["FT"], font1, Brushes.Black, new Point(515, 679)); //躯干部 g.DrawString(dic["fT"], font1, Brushes.Black, new Point(515, 691)); // // g.DrawString(dic["fW"], font1, Brushes.Black, new Point(380, 175)); //体脂量 g.DrawString(dic["bW"], font1, Brushes.Black, new Point(440, 175)); //推定骨量 g.DrawString(dic["Wk"], font1, Brushes.Black, new Point(318, 330)); //体重 g.DrawString(dic["MW"], font1, Brushes.Black, new Point(378, 330)); //非脂肪量 g.DrawString(dic["mW"], font1, Brushes.Black, new Point(438, 330)); //肌肉量 g.DrawString(dic["wW"], font1, Brushes.Black, new Point(500, 330)); //体水份量 int age = int.Parse(dic["AG"]); double weight = double.Parse(dic["Wk"]) * 3.2; double height = double.Parse(dic["Hm"]) * 2.08; int weight1 = Convert.ToInt32(weight); int height1 = Convert.ToInt32(height); if (sex.Equals("0")) { g.DrawString("•", font, Brushes.Red, new Point(591 + age * 11, 512 - weight1)); //体重 g.DrawString("体重", font, Brushes.Black, new Point(593 + age * 11, 505 - weight1)); //体重 g.DrawString(dic["Wk"], font, Brushes.Black, new Point(625 + age * 11, 505 - height1)); // g.DrawString("•", font, Brushes.Blue, new Point(591 + age * 11, 512 - height1)); g.DrawString("身高", font, Brushes.Black, new Point(593 + age * 11, 505 - height1)); g.DrawString(dic["Hm"], font, Brushes.Black, new Point(625 + age * 11, 505 - height1)); // } else { g.DrawString("•", font, Brushes.Red, new Point(851 + age * 11, 512 - weight1)); g.DrawString("体重", font, Brushes.Black, new Point(855 + age * 11, 505 - weight1)); //体重 g.DrawString(dic["Wk"], font, Brushes.Black, new Point(895 + age * 11, 505 - weight1)); //体重 g.DrawString("•", font, Brushes.Blue, new Point(851 + age * 11, 512 - height1)); g.DrawString("身高", font, Brushes.Black, new Point(855 + age * 11, 505 - height1)); //身高 g.DrawString(dic["Hm"], font, Brushes.Black, new Point(895 + age * 11, 505 - height1)); // } g.DrawString(dic["MI"], font, Brushes.Black, new Point(79, 500)); // 肥胖指数 double bmi = double.Parse(dic["MI"]); int bmi_i = (int)bmi; int b = 10 * (bmi_i - 16); Rectangle rectangle = new Rectangle(125, 495, 80 + b, 10); g.FillRectangle(Brushes.Black, rectangle); //建议 Comment comment = dbUtill.GetComment(); if (bmi < 18.5) { g.DrawString(comment.low, font2, Brushes.Black, new Point(575, 610)); } else if (bmi < 22.5) { g.DrawString(comment.mid, font2, Brushes.Black, new Point(575, 610)); } else { g.DrawString(comment.hight, font2, Brushes.Black, new Point(575, 610)); } string url = dbUtill.GetImageUrl(); string activityName = dbUtill.GetActivitieNameByID(checkData.activityId); string res = dbUtill.GetStudentInfoByStudentId(checkData.studentId); string[] resArray = res.Split(','); string gradeName = resArray[1]; string className = resArray[0]; if (!Directory.Exists(@url + "\\" + activityName + "\\" + gradeName + "\\" + className + "\\")) { Directory.CreateDirectory(@url + "\\" + activityName + "\\" + gradeName + "\\" + className + "\\"); } image2.Save(@url + "\\" + activityName + "\\" + gradeName + "\\" + className + "\\" + studentId + "_" + studentName + ".jpg"); } catch (Exception ex) { MessageBox.Show("错误,因为" + ex.Message, "提示"); } }
public void Init() { string imageUrlText = dbUtill.GetImageUrl(); imageUrl.Content = imageUrlText; }