public void HaltReasonUpload() { bool firsttry = true; while (true) { try { var haltinfo = new haltinfo(); haltinfo.device_name = Properties.TerminalParameters.Default.terminal_name; haltinfo.time_start = start; haltinfo.time_end = end; haltinfo.halt_reason = reason; haltinfo.storetime = DateTime.Now; using (var mysql = FluentNhibernateHelper.GetSession()) { mysql.Save(haltinfo); mysql.Flush(); } FangpuTerminal.HaltUI updateUI = new FangpuTerminal.HaltUI(updateui); FangpuTerminal.BeginInvoke(updateUI); try { TextCommand.DeleteFile("haltinfo.txt"); } catch (Exception ex) { TerminalLogWriter.WriteErroLog(typeof(stoptable), "上传失败"); } break; } catch { if (firsttry == true) { MessageBox.Show("停机信息上传失败!\n与数据中心连接出错!请稍后重试", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } firsttry = false; FangpuTerminal.log.Error("停机原因存储出错"); } } }
public void HaltReasonUpload() { bool firsttry = true; while (true) { try { var mysql = new FangpuDatacenterModelEntities(); var haltinfo = new haltinfo(); haltinfo.device_name = Properties.TerminalParameters.Default.terminal_name; haltinfo.time_start = start; haltinfo.time_end = end; haltinfo.halt_reason = reason; haltinfo.storetime = DateTime.Now; mysql.haltinfo.Add(haltinfo); mysql.SaveChanges(); FangpuTerminal.HaltUI S1 = new FangpuTerminal.HaltUI(updateui); FangpuTerminal.BeginInvoke(S1); try { TextCommand.DeleteFile("haltinfo.txt"); } catch { } break; } catch { if (firsttry == true) { MessageBox.Show("停机信息上传失败!\n与数据中心连接出错!请稍后重试", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } firsttry = false; FangpuTerminal.log.Error("停机原因存储出错"); } } }