/// <summary> /// xml文件保存 /// </summary> public static bool SaveAsConfigurationFile(SystemRunRecordData systemRunRecordData, string savePath) { XmlSerializer xmlSerializer = null; StreamWriter streamWriter = null; try { xmlSerializer = new XmlSerializer(typeof(SystemRunRecordData)); streamWriter = new StreamWriter(savePath); XmlWriter xmlWriter = XmlWriter.Create(streamWriter); xmlSerializer.Serialize(streamWriter, systemRunRecordData); streamWriter.Close(); } catch (System.Exception ex) { MonitorAllConfig.Instance().WriteLogToFile("ExistCatch:写入Xml文件出现异常" + ex.ToString(), true); return(false); } finally { if (streamWriter != null) { streamWriter.Close(); } } return(true); }
/// <summary> /// Xml文件读取 /// </summary> public static bool ReadConfigurationFile(string readPath, out SystemRunRecordData systemRunRecordData) { FileStream fileStream = null; XmlSerializer xmlSerializer = null; systemRunRecordData = null; try { fileStream = new FileStream(readPath, FileMode.Open); xmlSerializer = new XmlSerializer(typeof(SystemRunRecordData)); systemRunRecordData = (SystemRunRecordData)xmlSerializer.Deserialize(fileStream); } catch (Exception ex) { MonitorAllConfig.Instance().WriteLogToFile("ExistCatch:读取Xml文件出现异常" + ex.ToString(), true); return(false); } finally { if (fileStream != null) { fileStream.Close(); } } return(true); }
/// <summary> ///清除系统记录数据 /// </summary> private void ClearSystemRefreshData() { if (_systemRunRecordData != null) { _systemRunRecordData = null; _syetemRefreshIndex = 0; _systemRunRecordData = new SystemRunRecordData(); } }
/// <summary> /// 更新记录数据 /// </summary> /// <param name="monitor"></param> private void AddSystemRunData(ErrType item,int count) { if (_systemRunRecordData==null) { _systemRunRecordData = new SystemRunRecordData(); } if (item == ErrType.DVI) { _systemRunRecordData.SenderErrCount += (uint)count; } else if (item == ErrType.SenderCard) { _systemRunRecordData.SenderErrCount += (uint)count; } else if (item == ErrType.CabinetDoor) { _systemRunRecordData.CabinetDoorMonitorIndex += (uint)count; } else if (item == ErrType.Fan) { _systemRunRecordData.FanAlarmSwitchCount += (uint)count; } else if (item == ErrType.Humidity) { _systemRunRecordData.HumidityAlarmCount += (uint)count; } else if (item == ErrType.MonitorCard) { _systemRunRecordData.MCStatusErrCount += (uint)count; } else if (item == ErrType.Power) { _systemRunRecordData.PowerAlarmSwitchCount += (uint)count; } else if (item == ErrType.Redundancy) { _systemRunRecordData.RedundantStateCount += (uint)count; } else if (item == ErrType.SBStatus) { _systemRunRecordData.ReceiveCardErroeIndex += (uint)count; } else if (item == ErrType.Smoke) { _systemRunRecordData.SmokeMonitorErrorIndex += (uint)count; } else if (item == ErrType.Soket) { _systemRunRecordData.CabinetMonitorIndex += (uint)count; } else if (item == ErrType.Temperature) { _systemRunRecordData.TemperatureMonitorErrorIndex += (uint)count; } }
/// <summary> /// 载入系统运行记录数据 /// </summary> public void LoadLastRunStatusFile() { string fileName = ConstValue.EMAIL_NOTIFY_LOG_PATH + FILENAME + ".xml"; if (File.Exists(fileName)) { SystemRunStatuslFileAccessor.ReadConfigurationFile(fileName, out _systemRunRecordData); } if (_systemRunRecordData == null) { _systemRunRecordData = new SystemRunRecordData(); } _syetemRefreshIndex = (int)_systemRunRecordData.SystemRefeshIndex; }
/// <summary> /// 获得刷新后数据 /// </summary> private void GetSystemRefreshData() { if (_emailConfig.TimeEMailNotify) { if (_systemRunRecordData == null) { _systemRunRecordData = new SystemRunRecordData(); } _systemRunRecordData.SystemRefeshIndex = (uint)_syetemRefreshIndex; string fileName = ConstValue.EMAIL_NOTIFY_LOG_PATH + FILENAME + ".xml"; SystemRunStatuslFileAccessor.SaveAsConfigurationFile(_systemRunRecordData, fileName); } else { _syetemRefreshIndex = 0; } }
/// <summary> /// xml�ļ����� /// </summary> public static bool SaveAsConfigurationFile(SystemRunRecordData systemRunRecordData, string savePath) { XmlSerializer xmlSerializer = null; StreamWriter streamWriter = null; try { xmlSerializer = new XmlSerializer(typeof(SystemRunRecordData)); streamWriter = new StreamWriter(savePath); XmlWriter xmlWriter = XmlWriter.Create(streamWriter); xmlSerializer.Serialize(streamWriter, systemRunRecordData); streamWriter.Close(); } catch (System.Exception ex) { MonitorAllConfig.Instance().WriteLogToFile("ExistCatch��д��Xml�ļ������쳣" + ex.ToString(), true); return false; } finally { if (streamWriter != null) { streamWriter.Close(); } } return true; }
/// <summary> /// Xml�ļ���ȡ /// </summary> public static bool ReadConfigurationFile(string readPath, out SystemRunRecordData systemRunRecordData) { FileStream fileStream = null; XmlSerializer xmlSerializer = null; systemRunRecordData = null; try { fileStream = new FileStream(readPath, FileMode.Open); xmlSerializer = new XmlSerializer(typeof(SystemRunRecordData)); systemRunRecordData = (SystemRunRecordData)xmlSerializer.Deserialize(fileStream); } catch (Exception ex) { MonitorAllConfig.Instance().WriteLogToFile("ExistCatch����ȡXml�ļ������쳣" + ex.ToString(), true); return false; } finally { if (fileStream != null) { fileStream.Close(); } } return true; }