/// <summary> /// 构造函数 /// log功能相关处理 /// </summary> /// <param name="logFunctionType">log相关对象</param> public LogFunctionEvents(LogFunctionType logFunctionType) { try { //如果路径没有,直接在桌面给出一个包 //1.打包log文件 string savepath = new Assist.AssistBot.ArgsIntoValue().BackNormalString(logFunctionType.LogFilePath); if (!Directory.Exists(savepath)) { Directory.CreateDirectory(savepath); } ZipFile zipFile = new ZipFile(Encoding.UTF8); zipFile.AddDirectory("C:/Temp/Ro_Auto_Logs/image"); zipFile.AddFile($"C:/Temp/Ro_Auto_Logs/WebAction_{ComArgs.UseRosName}.log"); //获取当前时间 string nowtime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); //存放 zipFile.Save($"{savepath}/Ro_Auto_Logs_{ComArgs.UseRosName}({nowtime}).zip"); } catch (Exception e) { //添加输出 ComArgs.RoLog.WriteLog(LogStatus.LExpt, "LogFunctionEvents发生异常", e.ToString()); } }
/// <summary> /// logfunction节点处理 /// </summary> /// <param name="logXElement"></param> public LogFunctionNodes(XElement logXElement) { //1.转为对象 LogFunctionType logFunctionType = new LogFunctionType(); XElement logpathele = logXElement.Element(XName.Get("LogFilePath", ComArgs.RosStr)); if (logpathele != null && string.IsNullOrEmpty(logpathele.Value)) { logFunctionType.LogFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } else { if (logpathele != null) { logFunctionType.LogFilePath = logpathele.Value; } } //2.根据要求进行log的操作 LogFunction_Info = logFunctionType; }