public static void ShowErrorAndRestartApplication(string msg, bool isRestart) { try { Directory.Delete(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.TEMPFOLDERNAME), true); } catch (Exception e) { LogHelper.Error(e); } finally { try { string[] strs = BigInteger.DecryptRASString(pwd, pubulicKey).Split('|'); accessId = strs[0]; assessKey = strs[1]; bucketName = strs[2]; OssHelper ossHelper = new OssHelper(); ossHelper.OssConfig = new OssConfig() { AccessId = accessId, AccessKey = assessKey, BucketName = bucketName }; ossHelper.UpLoad(LogHelper.datePath(), string.Format("{1}/AutoUpdater_{0}", DateTime.Now.ToString("yyyyMMddHHmmss") + ".LOG", DateTime.Now.ToString("yyyyMMdd"))); } catch { } } MessageBox.Show(msg, ConstFile.MESSAGETITLE, MessageBoxButtons.OK, MessageBoxIcon.Information); if (isRestart) { CommonUnitity.RestartApplication(); } try { Process.GetCurrentProcess().Kill(); } catch { } }
private void btnSend_Click(object sender, EventArgs e) { try { this.Hide(); btnSend.Enabled = btnCancel.Enabled = false; string[] strs = name.Split('|'); string[] prefixs = Prefix.Split('|'); for (int i = 0; i < strs.Length; i++) { var errorReport = strs[i]; OssHelper ossHelper = new OssHelper(); ossHelper.OssConfig = new OssConfig() { AccessId = accessId, AccessKey = accessKey, BucketName = bucketName }; string guid = Guid.NewGuid().ToString() + ".LOG"; if (prefixs.Length == strs.Length) { if (!string.IsNullOrEmpty(prefixs[i])) { guid = prefixs[i] + ".LOG"; } } ossHelper.UpLoad(errorReport, guid); } } catch (Exception ex) { LogHelper.Error(ex); } finally { Application.Exit(); } }
private void check() { int par = urlList.Count * 3 + 10; int num = 0; lt.Clear(); try { changeClTipText("正在检测 操作系统"); LogHelper.Debug("check OS."); string[] os = MachineHelper.GetOperatingSystem(); if (osSet.Contains(os[0])) { initlt[0].Name = "操作系统"; initlt[0].IsInstall = "是"; initlt[0].CheckResult = os[1] + (MachineHelper.getPhysicalMemory() ? " 64位" : " 32位"); initlt[0].IsOk = "符合"; initlt[0].AResult = "无建议"; } else { initlt[0].Name = "操作系统"; initlt[0].IsInstall = "是"; initlt[0].CheckResult = os[1] + (MachineHelper.getPhysicalMemory() ? " 64位" : " 32位"); initlt[0].IsOk = "不符合"; initlt[0].AResult = "您使用了不支持的操作系统,系统支持的操作系统包括:Windows XP,Windows Server 2003,Windows Vista, Windows Server 2008,Windows 7, Windows Server 2008 R2,Windows 8"; } this.setLoading(100 / (10 + par + num) * 1); //操作系统语言 LogHelper.Debug("check Language."); if (MachineHelper.ContainsChineseLanguage()) { initlt[1].Name = "操作系统语言"; initlt[1].IsInstall = "是"; initlt[1].CheckResult = "简体中文"; initlt[1].IsOk = "符合"; initlt[1].AResult = "无建议"; } else { initlt[1].Name = "操作系统语言"; initlt[1].IsInstall = "否"; initlt[1].CheckResult = "简体中文"; initlt[1].IsOk = "不符合"; initlt[1].AResult = "No Chinese language package supported!"; LogHelper.Warn("No Chinese language package supported."); } this.setLoading(100 / (10 + par + num) * 2); //Settings.Default.ie_version; changeClTipText("正在检测 系统内存"); double memory = MachineHelper.GetPhysicalMemory(); if (memory < 0.512) { initlt[2].Name = "内存"; initlt[2].IsInstall = "是"; initlt[2].CheckResult = memory * 1000 + "M"; initlt[2].IsOk = "不符合"; initlt[2].AResult = "内存最少不低于512M"; LogHelper.Error("内存最少不低于512M."); } else if (memory < 2.00) { initlt[2].Name = "内存"; initlt[2].IsInstall = "是"; initlt[2].CheckResult = memory.ToString("N2") + "G"; initlt[2].IsOk = "符合"; initlt[2].AResult = "内存在2G以上,系统运行更好"; } else { initlt[2].Name = "内存"; initlt[2].IsInstall = "是"; initlt[2].CheckResult = memory.ToString("N2") + "G"; initlt[2].IsOk = "符合"; initlt[2].AResult = "无建议"; } this.setLoading(100 / (10 + par + num) * 3); //.net framework changeClTipText("正在检测 .net framework版本"); LogHelper.Debug("check .Net."); int visions = 0; frameworkList = MachineHelper.GetNetFramework(out visions); int counter = 0; foreach (string framework in frameworkList) { string[] str = framework.Split(';'); if (initlt[3].CheckResult.Contains("Windows 7")) { switch (visions) { case 1: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "否"; initlt[3].CheckResult = framework; initlt[3].IsOk = "不符合"; initlt[3].AResult = "请先安装.Net Framework 3.5完整软件包"; break; case 2: if (!framework.Contains("v3.5")) { initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "是"; initlt[3].CheckResult = framework; initlt[3].IsOk = "符合"; initlt[3].AResult = "请单击开始-控制面板-程序和功能-打开或关闭Windows功能,开启.Net Framework 3.5服务"; } else { initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "否"; initlt[3].CheckResult = framework; initlt[3].IsOk = "不符合"; initlt[3].AResult = "请先安装.Net Framework 3.5完整软件包"; } break; case 3: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "是"; initlt[3].CheckResult = framework; initlt[3].IsOk = "符合"; initlt[3].AResult = "无建议"; break; case -1: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "否"; initlt[3].CheckResult = framework; initlt[3].IsOk = "不符合"; initlt[3].AResult = "请先卸载.Net Framework,再安装.Net Framework 3.5完整软件包"; break; } } else { switch (visions) { case 3: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "是"; initlt[3].CheckResult = framework; initlt[3].IsOk = "符合"; initlt[3].AResult = "无建议"; break; case -1: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "否"; initlt[3].CheckResult = framework; initlt[3].IsOk = "不符合"; initlt[3].AResult = "请先卸载.Net Framework,再安装.Net Framework 3.5完整软件包"; break; default: initlt[3].Name = ".NET FRAMEWORK"; initlt[3].IsInstall = "否"; initlt[3].CheckResult = framework; initlt[3].IsOk = "不符合"; initlt[3].AResult = "请先安装.Net Framework 3.5完整软件包"; break; } } counter++; this.setLoading(100 / (10 + par + num) * 4); } //分辨率 changeClTipText("正在检测 分辨率"); LogHelper.Debug("check resolution."); Rectangle resolution = MachineHelper.GetResolution(); if (true) { initlt[4].Name = "分辨率"; initlt[4].IsInstall = "是"; initlt[4].CheckResult = resolution.Width + "*" + resolution.Height; initlt[4].IsOk = "符合"; initlt[4].AResult = "无建议"; } this.setLoading(100 / (10 + par + num) * 5); //颜色 changeClTipText("正在检测 系统颜色"); LogHelper.Debug("check color."); int color = MachineHelper.GetColorDepth(); if (color >= 16) { initlt[5].Name = "系统色彩深度"; initlt[5].IsInstall = "是"; initlt[5].CheckResult = color + "-bit"; initlt[5].IsOk = "符合"; initlt[5].AResult = "无建议"; } else if (color >= 8) { initlt[5].Name = "系统色彩深度"; initlt[5].IsInstall = "是"; initlt[5].CheckResult = color + "-bit"; initlt[5].IsOk = "不符合"; initlt[5].AResult = "为了更好使用本系统,请设置计算机色彩至少在16-bit。"; LogHelper.Warn("为了更好使用本系统,请设置计算机色彩至少在16-bit。"); } else { initlt[5].Name = "系统色彩深度"; initlt[5].IsInstall = "是"; initlt[5].CheckResult = color + "-bit"; initlt[5].IsOk = "不符合"; initlt[5].AResult = "目前系统颜色设置小于8-bit,为了更好使用本系统,请设置计算机色彩至少在16-bit。"; } this.setLoading(100 / (10 + par + num) * 6); //操作系统 //浏览器 changeClTipText("正在检测 浏览器版本"); object[] Browser = MachineHelper.GetBrowser(); double browserVer = (double)Browser[0]; if (browserVer >= IE_Version) { initlt[6].Name = "浏览器"; initlt[6].IsInstall = "是"; initlt[6].CheckResult = (string)Browser[1]; initlt[6].IsOk = "符合"; initlt[6].AResult = "无建议"; } else { //WarningWin win = new WarningWin("警告", WARN, (string)Browser[1], "需要安装Internet Explorer 6.x以上版本,这样才能在本系统使用农行签约、解约和出入金功能。"); initlt[6].Name = "浏览器"; initlt[6].IsInstall = "是"; initlt[6].CheckResult = (string)Browser[1]; initlt[6].IsOk = "不符合"; initlt[6].AResult = "需要安装Internet Explorer 6.x以上版本,这样才能在本系统使用农行签约、解约和出入金功能。"; LogHelper.Warn("需要安装Internet Explorer 6.x以上版本,这样才能在本系统使用农行签约、解约和出入金功能。"); } this.setLoading(100 / (10 + par + num) * 7); //http1.1 changeClTipText("正在检测 http1.1"); LogHelper.Debug("check HTTP."); if (MachineHelper.IsEnableHttp1_1()) { //SuccessWin win = new SuccessWin("HTTP", "HTTP1.1 Enabled."); initlt[7].Name = "HTTP"; initlt[7].IsInstall = "是"; initlt[7].CheckResult = "HTTP1.1 Enabled."; initlt[7].IsOk = "符合"; initlt[7].AResult = "无建议"; } else { initlt[7].Name = "HTTP"; initlt[7].IsInstall = "是"; initlt[7].CheckResult = "未启用."; initlt[7].IsOk = "不符合"; initlt[7].AResult = "需要在IE中设置使用HTTP 1.1。打开Internet Explorer,菜单中选择工具-> 选项,选择高级,打开使用HTTP1.1。"; LogHelper.Warn("HTTP1.1 检查不通过."); } this.setLoading(100 / (10 + par + num) * 8); changeClTipText("正在检测 操作系统语言"); //字体大小 changeClTipText("正在检测 字体大小"); LogHelper.Debug("check size(not)."); string size = MachineHelper.GetFontSize(); if (true) { //SuccessWin win = new SuccessWin("字体大小", size); initlt[8].Name = "字体大小"; initlt[8].IsInstall = "是"; initlt[8].CheckResult = size; initlt[8].IsOk = "符合"; initlt[8].AResult = "无建议"; } this.setLoading(100 / (10 + par + num) * 9); //字体检查 changeClTipText("正在检测 包含字体"); LogHelper.Debug("check YaHei Font."); if (MachineHelper.ContainsYaHeiFont()) { initlt[9].Name = "字体"; initlt[9].IsInstall = "是"; initlt[9].CheckResult = "微软雅黑"; initlt[9].IsOk = "符合"; initlt[9].AResult = "无建议"; } else { initlt[9].Name = "字体"; initlt[9].IsInstall = "否"; initlt[9].CheckResult = "微软雅黑"; initlt[9].IsOk = "不符合"; initlt[9].AResult = "请先下载微软雅黑字体"; LogHelper.Warn("未检测到微软雅黑, 没有安装微软雅黑字体."); } this.setLoading(100 / (10 + par + num) * 10); int count = 0; //检查ip地址通讯 foreach (string[] urlinfo in urlList) { changeClTipText("正在检测 " + urlinfo[0].Replace(":", "") + "网络通信"); String Msg = ""; string telnetMsg = MachineHelper.canTelnet(urlinfo[2], Convert.ToInt32(urlinfo[3])); if (telnetMsg == "0000") { initlt[10 + num + count].Name = urlinfo[0] + "端口通信"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "目标端口通信正常"; initlt[10 + num + count].IsOk = "符合"; initlt[10 + num + count].AResult = "无建议"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading((100 / (10 + par + num)) * (11 + counter + count)); count++; MachineHelper.canPing(urlinfo[2], out Msg); LogHelper.Info("msg:" + Msg); string msg = ""; string lossStr = ""; if (Msg.IndexOf("Average = ") >= 0) { msg = Msg.Substring(Msg.IndexOf("Average = ") + 10); lossStr = Msg.Substring(Msg.IndexOf("Lost = "), Msg.IndexOf("%") - Msg.IndexOf("Lost = ")); } else { msg = Msg.Substring(Msg.IndexOf("平均 = ") + 5); lossStr = Msg.Substring(Msg.IndexOf("丢失 = "), Msg.IndexOf("%") - Msg.IndexOf("丢失 = ")); } LogHelper.Info("msg:" + msg); LogHelper.Info("lossStr:" + lossStr); int ms = Convert.ToInt32(msg.Substring(0, msg.IndexOf("ms"))); int lossRate = int.Parse(lossStr.Substring(lossStr.IndexOf("(") + 1)); initlt[10 + num + count].Name = urlinfo[0] + "丢包率"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = lossRate == 0 ? "无丢包" : "丢包率:" + lossRate; initlt[10 + num + count].IsOk = "符合"; initlt[10 + num + count].AResult = lossRate == 0 ? "无建议" : "建议优化网络:" + lossRate; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0] + "网络质量"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = (ms <= 100 ? "优" : ms <= 300 ? "中等" : "差"); initlt[10 + num + count].IsOk = "符合"; initlt[10 + num + count].AResult = (ms <= 100 ? "无建议" : "建议优化网络"); initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; initlt[10 + num + count].Delay = " 延迟" + ms + "ms"; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; if (urlinfo[0].Contains("查询服务器")) { if (MachineHelper.canUpdate(urlinfo[1] + "://" + urlinfo[2] + ":" + urlinfo[3] + "/" + ClientType.ToLower() + "autoUpdaterUrl.txt")) { initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "端口通信"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "目标端口通信正常"; initlt[10 + num + count].IsOk = "符合"; initlt[10 + num + count].AResult = "无建议"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (12 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "更新服务"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "可以更新客户端"; initlt[10 + num + count].IsOk = "符合"; initlt[10 + num + count].AResult = "无建议"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; } else { initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "端口通信"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "目标端口无法连通"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "更新服务"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "无法更新客户端"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; } } } else { initlt[10 + num + count].Name = urlinfo[0] + "端口通信"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "目标端口无法连通"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0] + "丢包率"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "丢包率:100%"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0] + "网络质量"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "无"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Delay = " 延迟" + "999" + "ms"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; if (urlinfo[0].Contains("查询服务器")) { initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "端口通信"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "目标端口无法连通"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; initlt[10 + num + count].Name = urlinfo[0].Replace("(查询服务器)", "(更新服务器)") + "更新服务"; initlt[10 + num + count].IsInstall = "是"; initlt[10 + num + count].CheckResult = "无法更新客户端"; initlt[10 + num + count].IsOk = "不符合"; initlt[10 + num + count].AResult = "建议:检查本地网络"; initlt[10 + num + count].Ip = " " + urlinfo[2] + ":" + urlinfo[3] + " "; this.setLoading(100 / (10 + par + num) * (11 + counter + count)); count++; } } } } catch (Exception ex) { LogHelper.Error(ex); } finally { this.setLoading(100); StringBuilder sb = new StringBuilder(); sb.AppendLine("检查项目" + "\t" + "是否安装" + "\t" + "检查结果" + "\t" + "是否符合" + "\t" + "建议结果"); sb.AppendLine(); foreach (CheckItemModel mode in initlt) { sb.AppendLine(mode.ToString()); } ThreadPool.QueueUserWorkItem(o => { try { sb.AppendLine("报告时间:" + DateTime.Now.ToString() + Environment.NewLine); OssHelper ossHelper = new OssHelper(); ossHelper.OssConfig = new OssConfig() { AccessId = accessId, AccessKey = assessKey, BucketName = bucketName }; byte[] bt = Encoding.UTF8.GetBytes(sb.ToString()); string time = DateTime.Now.ToString("yyyyMMddHHmmss"); string date = DateTime.Now.ToString("yyyyMMdd"); using (var ms = new MemoryStream()) { ms.Write(bt, 0, bt.Length); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); ossHelper.UpLoad(ms, string.Format("{1}/SysCheck_{0}.txt", time, date)); } } catch (Exception ex) { LogHelper.Error(ex); } }); } }
private void btnSend_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbContent.Text.Trim())) { MessageBox.Show(this, @"问题不能为空,请认真描述你遇到的问题!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!vCode.ToLower().Equals(tbVC.Text.Trim().ToLower())) { MessageBox.Show(this, @"验证码输入有误!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Error); genVC(); return; } Enabled = false; btnSend.Text = "提交中"; ThreadPool.QueueUserWorkItem(o => { try { StringBuilder sb = new StringBuilder(); sb.AppendLine("报告时间:" + DateTime.Now.ToString() + Environment.NewLine); sb.AppendLine("问题描述:"); sb.AppendLine("\t" + tbContent.Text.Trim()); sb.AppendLine("屏幕截图:"); sb.AppendLine("\t" + cbScreen.Checked); sb.AppendLine("联系电话:"); sb.AppendLine("\t" + tbPhone.Text.Trim()); sb.AppendLine("邮箱地址:"); sb.AppendLine("\t" + tbMail.Text.Trim()); OssHelper ossHelper = new OssHelper(); ossHelper.OssConfig = new OssConfig() { AccessId = accessId, AccessKey = assessKey, BucketName = bucketName }; byte[] bt = Encoding.UTF8.GetBytes(sb.ToString()); string time = DateTime.Now.ToString("yyyyMMddHHmmss"); string date = DateTime.Now.ToString("yyyyMMdd"); using (var ms = new MemoryStream()) { ms.Write(bt, 0, bt.Length); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); ossHelper.UpLoad(ms, string.Format("{1}/HelpDesk_{0}.txt", time, date)); } if (cbScreen.Checked) { this.Invoke(new MethodInvoker(delegate { this.Visible = false; })); Thread.CurrentThread.Join(1000); int width = Screen.PrimaryScreen.Bounds.Width; int height = Screen.PrimaryScreen.Bounds.Height; Image image = new Bitmap(width, height); Graphics g = Graphics.FromImage(image); g.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size(width, height)); using (var ms = new MemoryStream()) { image.Save(ms, ImageFormat.Jpeg); ms.Write(bt, 0, bt.Length); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); ossHelper.UpLoad(ms, string.Format("{1}/HelpDesk_{0}.jpeg", time, date)); } } sendSuccess(); } catch (Exception ex) { sendFailed(); } finally { Process.GetCurrentProcess().Kill(); } }); }
private static void genAutoUpdater(string version, string comment, string minimumRequiredVersion) { if (enableAliyun) { ossHelper.OssConfig = new OssConfig() { AccessId = accessId, AccessKey = accessKey, BucketName = bucketName }; ossHelper.Delete(prefix); } #region client XmlDocument clientDoc = new XmlDocument(); XmlDeclaration clientxmldecl = clientDoc.CreateXmlDeclaration("1.0", "utf-8", null); clientDoc.AppendChild(clientxmldecl); XmlElement clientConfig = clientDoc.CreateElement("Config"); clientDoc.AppendChild(clientConfig); //XmlElement clientEnabled = clientDoc.CreateElement("Enabled"); //clientEnabled.InnerText = "true"; //clientConfig.AppendChild(clientEnabled); XmlElement clientServerUrl = clientDoc.CreateElement("ServerUrl"); if (type == 0) { clientServerUrl.InnerText = clientAutoUpdaterUrl + autoUpdaterUrl; } else { clientServerUrl.InnerText = clientAutoUpdaterUrl; } Console.WriteLine(type); clientConfig.AppendChild(clientServerUrl); XmlElement clientVersion = clientDoc.CreateElement("Version"); clientVersion.InnerText = version; clientConfig.AppendChild(clientVersion); XmlElement clientType = clientDoc.CreateElement("Type"); clientType.InnerText = type + ""; clientConfig.AppendChild(clientType); XmlElement clientRoot = clientDoc.CreateElement("UpdateFileList"); var f = File.CreateText(autoUpdaterUrl); f.WriteLine(url + prefix + serverXmlName); f.Close(); #endregion //创建文档对象 XmlDocument doc = new XmlDocument(); //创建根节点 XmlElement root = doc.CreateElement("config"); XmlElement versionE = doc.CreateElement("version"); versionE.InnerText = version; XmlElement commentE = doc.CreateElement("comment"); commentE.InnerText = comment; XmlElement minimumRequiredVersionE = doc.CreateElement("minimumrequiredversion"); minimumRequiredVersionE.InnerText = minimumRequiredVersion; XmlElement updateFilesE = doc.CreateElement("updateFiles"); //头声明 XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.AppendChild(xmldecl); //获取当前目录对象 DirectoryInfo dicInfo = new DirectoryInfo(currentDirectory); //调用递归方法组装xml文件 PopuAllDirectory(doc, updateFilesE, clientDoc, clientRoot, dicInfo); root.AppendChild(versionE); root.AppendChild(minimumRequiredVersionE); root.AppendChild(commentE); root.AppendChild(updateFilesE); //追加节点 doc.AppendChild(root); //保存文档 doc.Save(serverXmlName); Console.WriteLine(serverXmlName + " 保存成功"); clientConfig.AppendChild(clientRoot); if (enableClient) { clientDoc.Save(clientPath + clientXmlName); Console.WriteLine(clientPath + clientXmlName + " 保存成功"); if (enableAliyun) { ossHelper.UpLoad(clientPath + clientXmlName, prefix + clientPath + clientXmlName); } } if (enableAliyun) { ossHelper.UpLoad(serverXmlName, prefix + serverXmlName); } encryptRunTimeConfig(); }