/// <summary> /// 测试获得自定义类型的list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_11(object sender, RoutedEventArgs e) { CustomDataDAO customDataDAO = new CustomDataDAO(); Console.WriteLine(CustomDataEnum.Disease.ToString()); MessageBox.Show(JsonTools.Obj2JSONStrNew(customDataDAO.GetListByTypeID(CustomDataEnum.Diagiosis))); }
/// <summary> /// 获取当前心跳 /// </summary> /// <returns></returns> public static HeartbeatRequest GetHeartBeatByCurrent() { HeartbeatRequest sendHeartBeat = new HeartbeatRequest(); SystemSettingService systemSettingService = new SystemSettingService(); var result = systemSettingService.GetSystemSetting(); if (result == null) { return(null); } //机器码mac地址从数据库取 sendHeartBeat.UniqueId = result.Set_Unique_Id; //bdl_system_setting表装换成json,赋值 sendHeartBeat.SettingJSON = JsonTools.Obj2JSONStrNew <SystemSettingEntity>(result); //项目名 智能健身赋值 sendHeartBeat.ProductName = "智能健身"; //使用期限 sendHeartBeat.UseDeadTime = result.Auth_OfflineTime.ToString().Replace("/", "-"); //冻结 if (result.User_Status == SystemSettingEntity.USER_STATUS_FREEZE) { //是否为冻结状态的心跳,这里不能从数据库取,否则,云通知本地锁死,本地改状态后,会再次通知云锁死本机,陷入死循环 //状态 正常0和锁定1 sendHeartBeat.Status = 1.ToString(); } //正常 else if (result.User_Status == SystemSettingEntity.USER_STATUS_GENERAL) { //状态 正常0和锁定1 //默认为正常心跳 sendHeartBeat.Status = 0.ToString(); } return(sendHeartBeat); }
private void Button_Click_20(object sender, RoutedEventArgs e) { AuthDAO authDAO = new AuthDAO(); var result = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER); MessageBox.Show(JsonTools.Obj2JSONStrNew(result)); }
// 重写基类的方法,当消息到达时触发,这里收到消息后,在控制台输出收到的内容,并原样返回了客户端 public override void ChannelRead(IChannelHandlerContext context, object message) { var buffer = message as BodyStrongMessage; Console.WriteLine("收到数据:" + JsonTools.Obj2JSONStrNew(buffer)); //BodyStrongMessage response = new BodyStrongMessage(); //response.Sequence = buffer.Sequence > Int32.MaxValue - 1 ? 0 : buffer.Sequence + 1; if (buffer.MessageType != BodyStrongMessage.Types.MessageType.Heaerbeatresp) { return; } Console.WriteLine("回复的消息:" + buffer.MessageType.ToString()); switch (buffer.HeartbeatResponse.ResponseType) { //延长使用时间,注意区分9999和一般时间 case HeartbeatResponse.Types.ResponseType.Addusetime: TcpHeartBeatUtils.AddUseTime(buffer.HeartbeatResponse); break; //正常心跳不做处理 case HeartbeatResponse.Types.ResponseType.Nomal: break; //上锁 case HeartbeatResponse.Types.ResponseType.Lock: TcpHeartBeatUtils.LockUse(buffer.HeartbeatResponse); break; //解锁 case HeartbeatResponse.Types.ResponseType.Unlock: TcpHeartBeatUtils.UnLockUse(buffer.HeartbeatResponse); break; } }
private void Button_Click_7(object sender, RoutedEventArgs e) { UserService userService = new UserService(); string pingJsonStr = JsonTools.Obj2JSONStrNew(userService.GetAllUsers()); MessageBox.Show(pingJsonStr); }
private void Button_Click_3(object sender, RoutedEventArgs e) { AuthDAO authDAO = new AuthDAO(); Auther auther = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_ADMIN); string pingJsonStr = JsonTools.Obj2JSONStrNew(auther); MessageBox.Show(pingJsonStr); }
private void Button_Click_5(object sender, RoutedEventArgs e) { AuthDAO authDAO = new AuthDAO(); Auther auther = authDAO.Login("123", "123"); string pingJsonStr = JsonTools.Obj2JSONStrNew(auther); MessageBox.Show(pingJsonStr); }
private void Button_Click_2(object sender, RoutedEventArgs e) { AutherDTO autherDTO = new AutherDTO(); autherDTO.username = "******"; string pingJsonStr = JsonTools.Obj2JSONStrNew(autherDTO); MessageBox.Show(pingJsonStr); }
private void Button_Click_9(object sender, RoutedEventArgs e) { UserService userService = new UserService(); User user = userService.GetByIdCard("438"); List <User> queryResult = userService.SelectByCondition(user); foreach (var i in queryResult) { MessageBox.Show(JsonTools.Obj2JSONStrNew(i)); } }
private void Buttonlz_Click_2(object sender, RoutedEventArgs e) { entity.Setter setter = new entity.Setter(); setter.Pk_Set_Id = 1; setter.Set_Language = entity.Setter.SET_LANGUAGE_CHINA; setter.Set_OrganizationName = "1"; setter.Set_OrganizationPhone = "2"; setter.Set_OrganizationSort = "3"; setter.Set_PhotoLocation = "4"; //自封装 //string str = JsonTools.Obj2JSONStr<entity.Setter>(setter); //blog string str = JsonTools.Obj2JSONStrNew(setter); System.Windows.MessageBox.Show(str); }
/// <summary> /// 获取当前心跳 /// </summary> /// <returns></returns> public static HeartbeatRequest GetHeartBeatByCurrent() { HeartbeatRequest sendHeartBeat = new HeartbeatRequest(); //不属于未注册状态 SetterDAO setterDAO = new SetterDAO(); Setter setter = setterDAO.getSetter(); if (setterDAO.ListAll().Count != 1) { //设置表没有唯一标识,直接返回 return(null); } AuthDAO authDAO = new AuthDAO(); var result = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER); if (result == null) { return(null); } //机器码mac地址从本地拿 sendHeartBeat.UniqueId = setter.Set_Unique_Id; //setting表装换成json,赋值 sendHeartBeat.SettingJSON = JsonTools.Obj2JSONStrNew <Setter>(setter); //项目名 医疗康复赋值 sendHeartBeat.ProductName = "医疗康复"; //使用期限 sendHeartBeat.UseDeadTime = result.Auth_OfflineTime.ToString().Replace("/", "-"); //地理位置 //sendHeartBeat.Address = setter.Set_Organizationaddress; //冻结 if (result.User_Status == Auther.USER_STATUS_FREEZE) { //是否为冻结状态的心跳,这里不能从数据库取,否则,云通知本地锁死,本地改状态后,会再次通知云锁死本机,陷入死循环 //状态 正常0和锁定1 sendHeartBeat.Status = 1.ToString(); } //正常 else if (result.User_Status == Auther.USER_STATUS_GENERAL) { //状态 正常0和锁定1 //默认为正常心跳 sendHeartBeat.Status = 0.ToString(); } return(sendHeartBeat); }
/// <summary> /// /// </summary> /// <param name="uploadManagement">传入上传管理者实体</param> /// <returns>返回可以用来上传的辅助对象</returns> public ServiceResult GetServiceResult(UploadManagement uploadManagement) { //service返回结果对象 ServiceResult serviceResult = new ServiceResult(); //提前载入唯一Setter SetterDAO setterDAO = new SetterDAO(); Setter setter = setterDAO.getSetter(); //需要加入解密逻辑 TODO string mac = ""; //try //{ // byte[] deBytes = AesUtil.Decrypt(Encoding.GetEncoding("GBK").GetBytes(setter.Set_Unique_Id), // ProtocolConstant.USB_DOG_PASSWORD); // mac = Encoding.GetEncoding("GBK").GetString(deBytes); //} //catch (Exception ex) //{ // mac = setter.Set_Unique_Id.Replace(":", ""); //} byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id); byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD); mac = Encoding.GetEncoding("GBK").GetString(b).Replace(":", "-"); ///if识别出表,设置发送路径,select出实体,转化至DTO,json打成string,返回 //识别是否是权限用户添加 if (uploadManagement.UM_DataTable == "bdl_auth") { AuthDAO authDAO = new AuthDAO(); Auther auther = authDAO.Load(uploadManagement.UM_DataId); if (auther == null) { return(null); } AutherDTO autherDTO = new AutherDTO(setter, auther, mac); //serviceResult.URL = "clientController/addClient.action"; serviceResult.Data = JsonTools.Obj2JSONStrNew <AutherDTO>(autherDTO); } //bdl_customdata表 else if (uploadManagement.UM_DataTable == "bdl_customdata") { CustomDataDAO customDataDAO = new CustomDataDAO(); CustomData customData = customDataDAO.Load(uploadManagement.UM_DataId); if (customData == null) { return(null); } CustomDataDTO customDataDTO = new CustomDataDTO(customData, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <CustomDataDTO>(customDataDTO); } //bdl_datacode表 else if (uploadManagement.UM_DataTable == "bdl_datacode") { DataCodeDAO dataCodedao = new DataCodeDAO(); DataCode dataCode = dataCodedao.Load(uploadManagement.UM_DataId); if (dataCode == null) { return(null); } DataCodeDTO dataCodeDTO = new DataCodeDTO(dataCode, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <DataCodeDTO>(dataCodeDTO); } //bdl_deviceset表 else if (uploadManagement.UM_DataTable == "bdl_deviceset") { DeviceSetDAO deviceSetDAO = new DeviceSetDAO(); DeviceSet deviceSet = deviceSetDAO.Load(uploadManagement.UM_DataId); if (deviceSet == null) { return(null); } DeviceSetDTO deviceSetDTO = new DeviceSetDTO(deviceSet, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSetDTO>(deviceSetDTO); } //bdl_devicesort表 else if (uploadManagement.UM_DataTable == "bdl_devicesort") { DeviceSortDAO deviceSortDAO = new DeviceSortDAO(); DeviceSort deviceSort = deviceSortDAO.Load(uploadManagement.UM_DataId); if (deviceSort == null) { return(null); } DeviceSortDTO deviceSortDTO = new DeviceSortDTO(deviceSort, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSortDTO>(deviceSortDTO); } //bdl_onlinedevice表 else if (uploadManagement.UM_DataTable == "bdl_onlinedevice") { OnlineDeviceDAO onlineDeviceDAO = new OnlineDeviceDAO(); OnlineDevice onlineDevice = onlineDeviceDAO.Load(uploadManagement.UM_DataId); if (onlineDevice == null) { return(null); } OnlineDeviceDTO onlineDeviceDTO = new OnlineDeviceDTO(onlineDevice, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <OnlineDeviceDTO>(onlineDeviceDTO); } //bdl_set表 else if (uploadManagement.UM_DataTable == "bdl_set") { SetterDAO setterDAO1 = new SetterDAO(); Setter setter1 = setterDAO1.Load(uploadManagement.UM_DataId); if (setter1 == null) { return(null); } SetterDTO setterDTO = new SetterDTO(setter1, mac); serviceResult.Data = JsonTools.Obj2JSONStrNew <SetterDTO>(setterDTO); } //病人表 else if (uploadManagement.UM_DataTable == "bdl_user") { UserDAO userDAO = new UserDAO(); User user = userDAO.Load(uploadManagement.UM_DataId); if (user == null) { return(null); } UserDTO userDTO = new UserDTO(user, mac); //serviceResult.URL = "bigData/bodyStrongUser"; serviceResult.Data = JsonTools.Obj2JSONStrNew <UserDTO>(userDTO); } //症状表 else if (uploadManagement.UM_DataTable == "bdl_symptominfo") { SymptomInfoDao symptomInfoDao = new SymptomInfoDao(); var result = symptomInfoDao.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } SymptomInfoDTO symptomInfoDTO = new SymptomInfoDTO(result, mac); //serviceResult.URL = "bigData/symptomInfo"; serviceResult.Data = JsonTools.Obj2JSONStrNew <SymptomInfoDTO>(symptomInfoDTO); } //训练处方总表 else if (uploadManagement.UM_DataTable == "bdl_traininfo") { TrainInfoDAO trainInfoDAO = new TrainInfoDAO(); var result = trainInfoDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } TrainInfoDTO trainInfoDTO = new TrainInfoDTO(result, mac); //serviceResult.URL = "bigData/trainInfo"; serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainInfoDTO>(trainInfoDTO); } //总表中的一条数据对某台设备的具体处方 else if (uploadManagement.UM_DataTable == "bdl_deviceprescription") { DevicePrescriptionDAO devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = devicePrescriptionDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } DevicePrescriptionDTO devicePrescriptionDTO = new DevicePrescriptionDTO(result, mac); //serviceResult.URL = "bigData/devicePrescription"; serviceResult.Data = JsonTools.Obj2JSONStrNew <DevicePrescriptionDTO>(devicePrescriptionDTO); } //具体处方的具体反馈 else if (uploadManagement.UM_DataTable == "bdl_prescriptionresult") { PrescriptionResultDAO prescriptionResultDAO = new PrescriptionResultDAO(); var result = prescriptionResultDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } PrescriptionResultDTO prescriptionResultDTO = new PrescriptionResultDTO(result, mac); //serviceResult.URL = "bigData/prescriptionResult"; serviceResult.Data = JsonTools.Obj2JSONStrNew <PrescriptionResultDTO>(prescriptionResultDTO); } else if (uploadManagement.UM_DataTable == "bdl_physicalpower") { PhysicalPowerDAO physicalPowerDAO = new PhysicalPowerDAO(); var result = physicalPowerDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } PhysicalPowerDTO physicalPowerDTO = new PhysicalPowerDTO(result, mac); //serviceResult.URL = "bigData/physicalPower"; serviceResult.Data = JsonTools.Obj2JSONStrNew <PhysicalPowerDTO>(physicalPowerDTO); } else if (uploadManagement.UM_DataTable == "bdl_error") { ErrorDao errorDao = new ErrorDao(); var result = errorDao.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } ErrorDTO errorDTO = new ErrorDTO(result, mac); //serviceResult.URL = "bigData/physicalPower"; serviceResult.Data = JsonTools.Obj2JSONStrNew <ErrorDTO>(errorDTO); } return(serviceResult); }
/// <summary> /// 测试自定义模糊查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_12(object sender, RoutedEventArgs e) { CustomDataDAO customDataDAO = new CustomDataDAO(); MessageBox.Show(JsonTools.Obj2JSONStrNew(customDataDAO.GetExistByValue(CustomDataEnum.Group, "C"))); }
//定时器轮询方法 public void Run() { /* * if (setterDao.ListAll() == null) * { * //网路不通 或 未注册 不上传 * return; * }*/ //Console.WriteLine("大数据线程实例化run方法-执行:"); var result = uploadManagementService.ListLimit20(); if (result == null) { ;//Console.WriteLine("大数据线程RUN方法-result==null"); } foreach (var uploadManagementone in result) { SendMsgDTO sendMsgDto = new SendMsgDTO(); UploadManagement uploadManagement = new UploadManagement(); uploadManagement = uploadManagementone; //选择是那一个类,将类名进行赋值 switch (uploadManagement.UM_DataTable) { case "bdl_activity": sendMsgDto.dataType = "ActivityEntity"; break; case "bdl_member": sendMsgDto.dataType = "MemberEntity"; break; case "bdl_personal_setting": sendMsgDto.dataType = "PersonalSettingEntity"; break; case "bdl_skeleton_length": sendMsgDto.dataType = "SkeletonLengthEntity"; break; case "bdl_system_setting": sendMsgDto.dataType = "SystemSettingEntity"; break; case "bdl_training_activity_record": sendMsgDto.dataType = "TrainingActivityRecordEntity"; break; case "bdl_training_course": sendMsgDto.dataType = "TrainingCourseEntity"; break; case "bdl_training_device_record": sendMsgDto.dataType = "TrainingDeviceRecordEntity"; break; case "bdl_training_plan": sendMsgDto.dataType = "TrainingPlanEntity"; break; default: Console.WriteLine("没有这个表"); Console.WriteLine(uploadManagement.UM_DataTable); break; } //sendMsgDto.dataType = "TrainingCourseEntity"; sendMsgDto.dataExec = uploadManagement.UM_Exec; sendMsgDto.dataId = uploadManagement.UM_DataId; sendMsgDto.belongProduct = "aisport"; //sendMsgDto.content = JsonTools.Obj2JSONStrNew <TrainingCourseEntity> // Console.WriteLine("大数据线程实例化Upload方法-table:" + uploadManagement.UM_DataTable); //1.查询 ServiceResult serviceResult = uploadManagementService.GetServiceResult(uploadManagement); sendMsgDto.content = serviceResult.Data; int i = 1; Console.WriteLine("这里是上传表的每一条内容" + i + "数字" + uploadManagement.Pk_UM_Id + uploadManagement.UM_DataId + uploadManagement.UM_Exec); i++; if (serviceResult == null) { //没有查到返回 Console.WriteLine("没有查到信息"); return; } //用于接受云服务器端返回的字符串 string strWebResult = ""; //创建一个新的用来接受服务器端返回结果的实体类对象 WebResult webResult = new WebResult(); //固定的url serviceResult.URL = "msg"; serviceResult.Data = JsonTools.Obj2JSONStrNew <SendMsgDTO>(sendMsgDto); try { //2.上传 //返回的值 strWebResult = HttpSender.POSTByJsonStr(serviceResult.URL, serviceResult.Data); } catch { Console.WriteLine("发送失败"); } if (strWebResult != null && strWebResult != "") { //将接受云服务器的字符串装换成实体类对象 webResult = JsonTools.DeserializeJsonToObject <WebResult>(strWebResult); //3.根据结果删除,返回信息中是否包括0和1,包括就删除 if (webResult.result == "0") { uploadManagementService.deleteByPrimaryKey(uploadManagement.Pk_UM_Id); } else if (webResult.result == "1") { uploadManagementService.deleteByPrimaryKey(uploadManagement.Pk_UM_Id); } else if (webResult.result == "2") { break;//不做处理,五分钟后再发,目的是等待云服务器建表 } } else { Console.WriteLine("云端返回为空"); //return; } } }
/// <summary> /// 异步进程与UI更新 /// </summary> #region 绑定通知公告 private void BindNotice() { System.Threading.Tasks.Task.Factory.StartNew(() => { try { //如果用户没有被上传则return,不允许发心跳,否则就按照不合法冻结了 if (new UploadManagementDAO().CheckExistAuth() != null) { return; } HeartBeatOffice heartBeatOffice = new HeartBeatOffice(); HttpHeartBeat result = heartBeatOffice.GetHeartBeatByCurrent(); //心跳直接上传 !HttpSender.Ping() || if (result == null) { //如果没有取到值 return; } string jsonStr = HttpSender.POSTByJsonStr("communicationController/analysisJson", JsonTools.Obj2JSONStrNew <HttpHeartBeat>(result)); HttpHeartBeat webResult = JsonTools.DeserializeJsonToObject <HttpHeartBeat>(jsonStr); //本地数据更改 if (webResult == null) { return; } heartBeatOffice.SolveHeartbeat(webResult); Dispatcher.Invoke(new Action(() => { if (webResult.authStatus == 0) { //正常心跳不处理 } else if (webResult.authStatus == 1) { //冻结,弹窗,然后关闭窗口 // 程序强制退出 authDao.UpdateByUserName(webResult.username, 1); // 停止定时器 timerNotice.Stop(); MessageBoxX.Warning(LanguageUtils.ConvertLanguage("用户被冻结,即将退出,请联系宝德龙管理员解冻!", "The user is frozen, will exit, please contact the administrator thaw!")); Environment.Exit(0); } else if (webResult.authStatus == 2) { //解冻,只需要更改数据库。界面无反馈,不处理 //authDao.UpdateByUserName(webResult.username, 2); } else if (webResult.authStatus == 3) { //永久离线,只需要更改数据库。界面无反馈,不处理 //authDao.UpdateByUserName(webResult.username, 3); } else if (webResult.authStatus == 4) { //已删除,按照冻结处理 //authDao.UpdateByUserName(webResult.username, 1); timerNotice.Stop(); MessageBoxX.Warning(LanguageUtils.ConvertLanguage("用户被删除,即将退出,请联系宝德龙管理员恢复!", "The user is removed, will exit, please contact the administrator to restore!")); Environment.Exit(0); } })); } catch { } }); }
private void Button_Click(object sender, RoutedEventArgs e) { string pingJsonStr = JsonTools.Obj2JSONStrNew(new HttpHeartBeat("ping", "ping")); MessageBox.Show(pingJsonStr); }
/// <summary> /// /// </summary> /// <param name="uploadManagement">传入上传管理者实体</param> /// <returns>返回可以用来上传的json对象</returns> public ServiceResult GetServiceResult(UploadManagement uploadManagement) { //service返回结果对象 ServiceResult serviceResult = new ServiceResult(); //bdl_activity表 if (uploadManagement.UM_DataTable == "bdl_activity") { //uploadManagement.Pk_UM_Type = "ActivityEntity"; ActivityDAO activityDAO = new ActivityDAO(); var result = activityDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } ActivityDTO activityDTO = new ActivityDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <ActivityDTO>(activityDTO); } //bdl_member表 else if (uploadManagement.UM_DataTable == "bdl_member") { MemberDAO memberDAO = new MemberDAO(); var result = memberDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } MemberDTO memberDTO = new MemberDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <MemberDTO>(memberDTO); } //bdl_personal_setting表 else if (uploadManagement.UM_DataTable == "bdl_personal_setting") { PersonalSettingDAO personalSettingDAO = new PersonalSettingDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = personalSettingDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } PersonalSettingDTO personalSettingDTO = new PersonalSettingDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <PersonalSettingDTO>(personalSettingDTO); } //bdl_skeleton_length表 else if (uploadManagement.UM_DataTable == "bdl_skeleton_length") { SkeletonLengthDAO skeletonLengthDAO = new SkeletonLengthDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = skeletonLengthDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } SkeletonLengthDTO skeletonLengthDTO = new SkeletonLengthDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <SkeletonLengthDTO>(skeletonLengthDTO); } //bdl_system_setting表 else if (uploadManagement.UM_DataTable == "bdl_system_setting") { SystemSettingDAO systemSettingDAO = new SystemSettingDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = systemSettingDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } SystemSettingDTO systemSettingDTO = new SystemSettingDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <SystemSettingDTO>(systemSettingDTO); } //bdl_training_activity_record表 else if (uploadManagement.UM_DataTable == "bdl_training_activity_record") { TrainingActivityRecordDAO trainingActivityRecordDAO = new TrainingActivityRecordDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = trainingActivityRecordDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } TrainingActivityRecordDTO trainingActivityRecordDTO = new TrainingActivityRecordDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainingActivityRecordDTO>(trainingActivityRecordDTO); } //bdl_training_course表 else if (uploadManagement.UM_DataTable == "bdl_training_course") { TrainingCourseDAO trainingCourseDAO = new TrainingCourseDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = trainingCourseDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } TrainingCourseDTO trainingCourseDTO = new TrainingCourseDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainingCourseDTO>(trainingCourseDTO); } //bdl_training_device_record表 else if (uploadManagement.UM_DataTable == "bdl_training_device_record") { TrainingDeviceRecordDAO trainingDeviceRecordDAO = new TrainingDeviceRecordDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = trainingDeviceRecordDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } TrainingDeviceRecordDTO trainingDeviceRecordDTO = new TrainingDeviceRecordDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainingDeviceRecordDTO>(trainingDeviceRecordDTO); } //bdl_training_plan表 else if (uploadManagement.UM_DataTable == "bdl_training_plan") { TrainingPlanDAO trainingPlanDAO = new TrainingPlanDAO(); //Tr devicePrescriptionDAO = new DevicePrescriptionDAO(); var result = trainingPlanDAO.Load(uploadManagement.UM_DataId); if (result == null) { return(null); } TrainingPlanDTO trainingPlanDTO = new TrainingPlanDTO(result); serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainingPlanDTO>(trainingPlanDTO); } return(serviceResult); }
/// <summary> /// 定时器轮询方法 /// </summary> /// <param name="threadCount"></param> /// public void Run() { if (setterDao.ListAll() == null) { //网路不通 或 未注册 不上传//Console.WriteLine("大数据线程实例化run方法-执行:"); return; } //从上传表查询30条数据 var result = uploadManagementService.ListLimit30(); if (result == null) { Console.WriteLine("大数据线程RUN方法-result==null"); } //遍历查询到的数据集合 foreach (var uploadManagement in result) { //生成新的SendMsgDTO对象(上传云平台的最终对象) SendMsgDTO sendMsgDto = new SendMsgDTO(); //根据表名,给字段dataType(数据所在实体类)赋值 switch (uploadManagement.UM_DataTable) { case "bdl_auth": sendMsgDto.dataType = "Auther"; break; case "bdl_customdata": sendMsgDto.dataType = "CustomData"; break; case "bdl_datacode": sendMsgDto.dataType = "DataCode"; break; case "bdl_deviceprescription": sendMsgDto.dataType = "DevicePrescription"; break; case "bdl_deviceset": sendMsgDto.dataType = "DeviceSet"; break; case "bdl_devicesort": sendMsgDto.dataType = "DeviceSort"; break; case "bdl_onlinedevice": sendMsgDto.dataType = "OnlineDevice"; break; case "bdl_physicalpower": sendMsgDto.dataType = "PhysicalPower"; break; case "bdl_prescriptionresult": sendMsgDto.dataType = "PrescriptionResult"; break; case "bdl_set": sendMsgDto.dataType = "Setter"; break; case "bdl_symptominfo": sendMsgDto.dataType = "SymptomInfo"; break; case "bdl_traininfo": sendMsgDto.dataType = "TrainInfo"; break; case "bdl_user": sendMsgDto.dataType = "User"; break; case "bdl_error": sendMsgDto.dataType = "Error"; break; default: Console.WriteLine("没找到对应的表"); //Console.WriteLine(uploadManagement.UM_DataTable); break; } sendMsgDto.dataExec = uploadManagement.UM_Exec; //操作方式 0是add(insert) 1是update sendMsgDto.dataId = uploadManagement.UM_DataId; //数据的id sendMsgDto.belongProduct = "Recovery"; //项目名称必须是这个,与云平台相一致 if (sendMsgDto.dataType == "Error") { sendMsgDto.belongProduct = "RecoveryError"; } // Console.WriteLine("大数据线程实例化Upload方法-table:" + uploadManagement.UM_DataTable); //1.根据上传表内容查询具体数据(这里的数据是已经转换成json串形式),赋值给字段content ServiceResult serviceResult = null; try { serviceResult = uploadManagementService.GetServiceResult(uploadManagement); } catch (Exception e) { logger.Error("uploadManagement上传云平台失败"); } /* * int i = 1; * Console.WriteLine("这里是上传表的每一条内容" + i + "数字" + uploadManagement.Pk_UM_Id + uploadManagement.UM_DataId + uploadManagement.UM_Exec); * i++;*/ if (serviceResult == null) { //没有查到返回 Console.WriteLine("上传表查询失败____________________"); logger.Error("上传表查询失败," + DateTime.Now.ToString()); continue; } sendMsgDto.content = serviceResult.Data; //用于接受云服务器端返回的字符串 string strWebResult = ""; //创建一个新的用来接受服务器端返回结果的对象 WebResult webResult = new WebResult(); //这里是url的后缀,每一条数据都是发送到这个地方 serviceResult.URL = "msg"; //将发送的实体类SendMsgDTO装成json串 serviceResult.Data = JsonTools.Obj2JSONStrNew <SendMsgDTO>(sendMsgDto); //2.上传和接受云服务器端返回的字符串 //strWebResult = HttpSender.POSTByJsonStr(serviceResult.URL, serviceResult.Data); strWebResult = HTTPClientHelper.HttpPost(serviceResult.Data); //将接受到的字符串赋值给webResult对象 webResult = JsonTools.DeserializeJsonToObject <WebResult>(strWebResult); //Console.WriteLine("线程"+ threadCount +" id: "+webResult.dataId +"type: "+ webResult.dataType + "结果:"+webResult.result); //3.根据返回结果删除 //返回值result为0或1删除上传表所对应的的内容,2则跳出循环,不做处理,隔五分钟再次上传 if (webResult.result == "0") { uploadManagementService.deleteByPrimaryKey(uploadManagement.Pk_UM_Id); } else if (webResult.result == "1") { uploadManagementService.deleteByPrimaryKey(uploadManagement.Pk_UM_Id); } else if (webResult.result == "2") { Console.WriteLine("线程"); break;//不做处理,五分钟后再发,目的是等待云服务器建表 } else { logger.Error("失败的内容:" + webResult.result + "," + DateTime.Now.ToString()); //Console.WriteLine("失败的内容:" + webResult.result); } //Console.WriteLine("-----------------------------返回结果 dataid"+webResult.dataId +"type:"+webResult.dataType+"result:"+webResult.result); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { string pingJsonStr = JsonTools.Obj2JSONStrNew(new UploadManagementService().ListLimit30()); MessageBox.Show(pingJsonStr); }