基线 SVN r240

SVN-Revision: r240
This commit is contained in:
cyf
2025-02-06 06:46:06 +00:00
commit ab56a9bcf7
5317 changed files with 902274 additions and 0 deletions
+223
View File
@@ -0,0 +1,223 @@
namespace Lskj.AutoUpdate
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.splitter1 = new System.Windows.Forms.Splitter();
this.label5 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.splitter2 = new System.Windows.Forms.Splitter();
this.panel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 77);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(440, 2);
this.splitter1.TabIndex = 12;
this.splitter1.TabStop = false;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(37, 49);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(89, 12);
this.label5.TabIndex = 3;
this.label5.Text = "是否现在更新?";
//
// panel3
//
this.panel3.Controls.Add(this.btnOk);
this.panel3.Controls.Add(this.btnCancel);
this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel3.Location = new System.Drawing.Point(0, 134);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(440, 44);
this.panel3.TabIndex = 11;
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.Location = new System.Drawing.Point(254, 10);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(83, 23);
this.btnOk.TabIndex = 0;
this.btnOk.Text = "确定";
this.btnOk.UseVisualStyleBackColor = true;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(350, 10);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(83, 23);
this.btnCancel.TabIndex = 0;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(354, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(79, 55);
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.label4);
this.panel2.Location = new System.Drawing.Point(-5, 78);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(450, 67);
this.panel2.TabIndex = 10;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(21, 13);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(71, 12);
this.label3.TabIndex = 0;
this.label3.Text = "系统名:ERP";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(21, 34);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(113, 12);
this.label4.TabIndex = 0;
this.label4.Text = "来 自:更新服务器";
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Controls.Add(this.label5);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(440, 77);
this.panel1.TabIndex = 9;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(36, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(149, 12);
this.label2.TabIndex = 3;
this.label2.Text = "系统检测到有新的版本可用";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(11, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 13);
this.label1.TabIndex = 2;
this.label1.Text = "发现更新";
//
// splitter2
//
this.splitter2.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitter2.Location = new System.Drawing.Point(0, 178);
this.splitter2.Name = "splitter2";
this.splitter2.Size = new System.Drawing.Size(440, 2);
this.splitter2.TabIndex = 13;
this.splitter2.TabStop = false;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(440, 180);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "自动升级";
this.panel3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Splitter splitter2;
}
}
+71
View File
@@ -0,0 +1,71 @@
/******************************
* 说明:下载确认界面
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 下载确认界面
/// </summary>
public partial class FrmMain : Form
{
/// <summary>
/// 下载文件列表
/// </summary>
List<DownloadFileInfo> downloadFileList = null;
public FrmMain()
: this(null)
{
}
public FrmMain(List<DownloadFileInfo> downloadfileList)
{
InitializeComponent();
downloadFileList = downloadfileList;
}
/// <summary>
/// <para>说明:窗口加载</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnLoad(object sender, EventArgs e)
{
foreach (DownloadFileInfo file in this.downloadFileList)
{
ListViewItem item = new ListViewItem(new string[] { file.FileName, file.LastVersion, file.Size.ToString() });
}
this.Activate();
this.Focus();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
File diff suppressed because it is too large Load Diff
+245
View File
@@ -0,0 +1,245 @@
namespace Lskj.AutoUpdate
{
partial class FrmProgress
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmProgress));
this.label3 = new System.Windows.Forms.Label();
this.splitter1 = new System.Windows.Forms.Splitter();
this.progressBarTotal = new System.Windows.Forms.ProgressBar();
this.panel3 = new System.Windows.Forms.Panel();
this.buttonOk = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.labelCurrentItem = new System.Windows.Forms.Label();
this.progressBarCurrent = new System.Windows.Forms.ProgressBar();
this.lblAll = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.splitter2 = new System.Windows.Forms.Splitter();
this.panel3.SuspendLayout();
this.panel2.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(11, 8);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(83, 12);
this.label3.TabIndex = 0;
this.label3.Text = "系统正在升级";
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 63);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(462, 2);
this.splitter1.TabIndex = 10;
this.splitter1.TabStop = false;
//
// progressBarTotal
//
this.progressBarTotal.Location = new System.Drawing.Point(16, 91);
this.progressBarTotal.Name = "progressBarTotal";
this.progressBarTotal.Size = new System.Drawing.Size(438, 12);
this.progressBarTotal.Step = 1;
this.progressBarTotal.TabIndex = 4;
//
// panel3
//
this.panel3.Controls.Add(this.buttonOk);
this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel3.Location = new System.Drawing.Point(0, 188);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(462, 42);
this.panel3.TabIndex = 9;
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(372, 6);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(83, 29);
this.buttonOk.TabIndex = 2;
this.buttonOk.Text = "取消";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.OnCancel);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(33, 26);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(221, 12);
this.label2.TabIndex = 0;
this.label2.Text = "我们正在为您升级,请耐心等待一段时间";
//
// panel2
//
this.panel2.Controls.Add(this.progressBarTotal);
this.panel2.Controls.Add(this.labelCurrentItem);
this.panel2.Controls.Add(this.progressBarCurrent);
this.panel2.Controls.Add(this.lblAll);
this.panel2.Controls.Add(this.label5);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.ForeColor = System.Drawing.SystemColors.ControlDark;
this.panel2.Location = new System.Drawing.Point(0, 63);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(462, 167);
this.panel2.TabIndex = 8;
//
// labelCurrentItem
//
this.labelCurrentItem.AutoSize = true;
this.labelCurrentItem.Location = new System.Drawing.Point(14, 36);
this.labelCurrentItem.Name = "labelCurrentItem";
this.labelCurrentItem.Size = new System.Drawing.Size(65, 12);
this.labelCurrentItem.TabIndex = 0;
this.labelCurrentItem.Text = "正在更新:";
//
// progressBarCurrent
//
this.progressBarCurrent.Location = new System.Drawing.Point(15, 53);
this.progressBarCurrent.Name = "progressBarCurrent";
this.progressBarCurrent.Size = new System.Drawing.Size(438, 12);
this.progressBarCurrent.Step = 1;
this.progressBarCurrent.TabIndex = 5;
//
// lblAll
//
this.lblAll.AutoSize = true;
this.lblAll.Location = new System.Drawing.Point(14, 75);
this.lblAll.Name = "lblAll";
this.lblAll.Size = new System.Drawing.Size(53, 12);
this.lblAll.TabIndex = 2;
this.lblAll.Text = "总进度:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(14, 11);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(101, 12);
this.label5.TabIndex = 0;
this.label5.Text = "来自:更新服务器";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(33, 44);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(245, 12);
this.label4.TabIndex = 0;
this.label4.Text = "这段时间您可以使用您的计算机办理其他事务";
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label3);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(462, 63);
this.panel1.TabIndex = 7;
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(379, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(79, 55);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// splitter2
//
this.splitter2.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitter2.Location = new System.Drawing.Point(0, 230);
this.splitter2.Name = "splitter2";
this.splitter2.Size = new System.Drawing.Size(462, 2);
this.splitter2.TabIndex = 11;
this.splitter2.TabStop = false;
//
// FrmProgress
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(462, 232);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmProgress";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "软件更新";
this.Load += new System.EventHandler(this.OnFormLoad);
this.panel3.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.ProgressBar progressBarTotal;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label labelCurrentItem;
private System.Windows.Forms.ProgressBar progressBarCurrent;
private System.Windows.Forms.Label lblAll;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Splitter splitter2;
}
}
+509
View File
@@ -0,0 +1,509 @@
/******************************
* 说明:下载进度窗口
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Net;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 下载进度窗口
/// </summary>
public partial class FrmProgress : Form
{
/// <summary>
/// 是否下载完成
/// </summary>
private bool isFinished = false;
/// <summary>
/// 下载总数
/// </summary>
private long total = 0;
/// <summary>
/// 当前下载的总数
/// </summary>
private long nDownloadedTotal = 0;
/// <summary>
/// 下载文件列表
/// </summary>
private List<DownloadFileInfo> downloadFileList = new List<DownloadFileInfo>();
/// <summary>
/// 所有文件列表
/// </summary>
private List<DownloadFileInfo> allFileList = null;
private ManualResetEvent evtDownload = null;
private ManualResetEvent evtPerDonwload = null;
private WebClient clientDownload = null;
private AutoUpdater autoUpdater = null;
private delegate void SetProcessBarCallBack(int current, int total);
private delegate void ExitCallBack(bool success);
private delegate void ShowCurrentDownloadFileNameCallBack(string name);
public FrmProgress(List<DownloadFileInfo> downloadFileListTemp, AutoUpdater apd)
{
InitializeComponent();
this.autoUpdater = apd;
this.downloadFileList = downloadFileListTemp;
this.allFileList = downloadFileListTemp.Select(x => new DownloadFileInfo(x.DownloadUrl, x.FileName, x.Version, x.Size, x.LastVersion)).ToList();
//foreach (DownloadFileInfo item in downloadFileListTemp)
//{
// // 本地临时文件夹中不存在此文件则下载.
// string tempUrlPath = CommonUnitity.GetFolderUrl(item);
// tempUrlPath = Path.Combine(CommonUnitity.SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + tempUrlPath, item.FileName);
// if (!File.Exists(tempUrlPath))
// {
// this.downloadFileList.Add(item);
// }
//}
this.lblAll.Text = string.Format("总进度(0/{0})", this.downloadFileList.Count);
}
/// <summary>
/// <para>说明:窗口加载</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnFormLoad(object sender, EventArgs e)
{
evtDownload = new ManualResetEvent(true);
evtDownload.Reset();
ThreadPool.QueueUserWorkItem(new WaitCallback(this.ProcDownload));
}
/// <summary>
/// <para>说明:</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="FormClosingEventArgs"/> instance containing the event data.</param>
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
if (!isFinished && DialogResult.Yes == MessageBox.Show(ConstModel.UPDATE_GIVING_UP, ConstModel.LS_TITLE_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
e.Cancel = true;
return;
}
else
{
if (clientDownload != null)
clientDownload.CancelAsync();
evtDownload.Set();
evtPerDonwload.Set();
}
}
/// <summary>
/// <para>说明:下载文件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="o">The o.</param>
private void ProcDownload(object o)
{
string tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstModel.TEMP_FOLDER_NAME);
if (!Directory.Exists(tempFolderPath))
{
Directory.CreateDirectory(tempFolderPath);
}
evtPerDonwload = new ManualResetEvent(false);
foreach (DownloadFileInfo file in this.downloadFileList)
{
total += file.Size;
}
int count = this.downloadFileList.Count;
while (!evtDownload.WaitOne(0, false))
{
try
{
if (this.downloadFileList.Count == 0)
break;
this.lblAll.Text = string.Format("总进度({0}/{1})", count - this.downloadFileList.Count, count);
DownloadFileInfo file = this.downloadFileList[0];
//Debug.WriteLine(String.Format("Start Download:{0}", file.FileName));
this.ShowCurrentDownloadFileName(file.FileName);
//Download
clientDownload = new WebClient();
//Added the function to support proxy
//clientDownload.Proxy = System.Net.WebProxy.GetDefaultProxy();
clientDownload.Proxy = WebRequest.GetSystemWebProxy();
clientDownload.Proxy.Credentials = CredentialCache.DefaultCredentials;
clientDownload.Credentials = System.Net.CredentialCache.DefaultCredentials;
//End added
clientDownload.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
{
try
{
//this.Text = "接收:" + e.BytesReceived.ToString() + " 字节数:" + progressBarCurrent.Maximum.ToString();
progressBarCurrent.Value = (int)e.BytesReceived / progressBarCurrent.Maximum;
progressBarTotal.Value = (int)((nDownloadedTotal + e.BytesReceived) * 100 / total);
this.SetProcessBar(e.ProgressPercentage, (int)((nDownloadedTotal + e.BytesReceived) * 100 / total));
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
//log the error message,you can use the application's log code
}
};
clientDownload.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) =>
{
try
{
DealWithDownloadErrors();
DownloadFileInfo dfile = e.UserState as DownloadFileInfo;
nDownloadedTotal += dfile.Size;
this.SetProcessBar(0, (int)(nDownloadedTotal * 100 / total));
evtPerDonwload.Set();
}
catch (Exception exp)
{
MessageBox.Show("下载错误202:"+exp.Message);
//log the error message,you can use the application's log code
}
};
evtPerDonwload.Reset();
//Download the folder file
string tempFolderPath1 = CommonUnitity.GetFolderUrl(file);
if (!string.IsNullOrEmpty(tempFolderPath1))
{
tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstModel.TEMP_FOLDER_NAME);
tempFolderPath += tempFolderPath1;
}
else
{
tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstModel.TEMP_FOLDER_NAME);
}
clientDownload.DownloadFileAsync(new Uri(file.DownloadUrl), Path.Combine(tempFolderPath, file.FileName), file);
//Wait for the download complete
evtPerDonwload.WaitOne();
clientDownload.Dispose();
clientDownload = null;
//Remove the downloaded files
this.downloadFileList.Remove(file);
}
catch (Exception e)
{
MessageBox.Show(this.downloadFileList[0].FileName + "\r\n" + e.Message);
ShowErrorAndRestartApplication();
//throw;
}
}
//When the files have not downloaded,return.
if (downloadFileList.Count > 0)
{
return;
}
//Test network and deal with errors if there have
DealWithDownloadErrors();
//Debug.WriteLine("All Downloaded");
foreach (DownloadFileInfo file in this.allFileList)
{
string tempUrlPath = CommonUnitity.GetFolderUrl(file);
string oldPath = string.Empty;
string newPath = string.Empty;
try
{
if (!string.IsNullOrEmpty(tempUrlPath))
{
oldPath = Path.Combine(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1), file.FileName);
newPath = Path.Combine(CommonUnitity.SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + tempUrlPath, file.FileName);
}
else
{
oldPath = Path.Combine(CommonUnitity.SystemBinUrl, file.FileName);
newPath = Path.Combine(CommonUnitity.SystemBinUrl + ConstModel.TEMP_FOLDER_NAME, file.FileName);
}
//just deal with the problem which the files EndsWith xml can not download
System.IO.FileInfo f = new FileInfo(newPath);
if (!file.Size.ToString().Equals(f.Length.ToString()) && !file.FileName.ToString().EndsWith(".xml"))
{
ShowErrorAndRestartApplication();
}
//Added for dealing with the config file download errors
string newfilepath = string.Empty;
if (newPath.Substring(newPath.LastIndexOf(".") + 1).Equals(ConstModel.CONFIG_FILE_KEY))
{
if (System.IO.File.Exists(newPath))
{
if (newPath.EndsWith("_"))
{
newfilepath = newPath;
newPath = newPath.Substring(0, newPath.Length - 1);
oldPath = oldPath.Substring(0, oldPath.Length - 1);
}
File.Move(newfilepath, newPath);
}
}
//End added
if (File.Exists(oldPath))
{
MoveFolderToOld(oldPath, newPath);
}
else
{
//Edit for config_ file
if (!string.IsNullOrEmpty(tempUrlPath))
{
if (!Directory.Exists(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1)))
{
Directory.CreateDirectory(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1));
MoveFolderToOld(oldPath, newPath);
}
else
{
MoveFolderToOld(oldPath, newPath);
}
}
else
{
MoveFolderToOld(oldPath, newPath);
}
}
}
catch (Exception exp)
{
MessageBox.Show("oldPath"+oldPath + "\r\n" + "newPath"+newPath + "\r\n" + exp.Message);
//log the error message,you can use the application's log code
}
}
//After dealed with all files, clear the data
this.allFileList.Clear();
if (this.downloadFileList.Count == 0)
Exit(true);
else
Exit(false);
evtDownload.Set();
}
/// <summary>
/// <para>说明:移动文件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="oldPath">The old path.</param>
/// <param name="newPath">The new path.</param>
private void MoveFolderToOld(string oldPath, string newPath)
{
if (File.Exists(oldPath + ".old"))
System.IO.File.SetAttributes(oldPath + ".old", System.IO.FileAttributes.Normal);
if (File.Exists(oldPath))
System.IO.File.SetAttributes(oldPath, System.IO.FileAttributes.Normal);
if (File.Exists(oldPath + ".old"))
File.Delete(oldPath + ".old");
if (File.Exists(oldPath))
File.Move(oldPath, oldPath + ".old");
File.Move(newPath, oldPath);
}
/// <summary>
/// <para>说明:显示当前下载文件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="name">The name.</param>
private void ShowCurrentDownloadFileName(string name)
{
if (this.labelCurrentItem.InvokeRequired)
{
ShowCurrentDownloadFileNameCallBack cb = new ShowCurrentDownloadFileNameCallBack(ShowCurrentDownloadFileName);
this.Invoke(cb, new object[] { name });
this.labelCurrentItem.Text = "正在更新:" + name;
}
else
{
this.labelCurrentItem.Text = "正在更新:" + name;
}
}
/// <summary>
/// <para>说明:显示当前进度</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="current">The current.</param>
/// <param name="total">The total.</param>
private void SetProcessBar(int current, int total)
{
if (this.progressBarCurrent.InvokeRequired)
{
SetProcessBarCallBack cb = new SetProcessBarCallBack(SetProcessBar);
this.Invoke(cb, new object[] { current, total });
}
else
{
this.progressBarCurrent.Value = current;
this.progressBarTotal.Value = total;
}
}
/// <summary>
/// <para>说明:退出升级程序</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="success">if set to <c>true</c> [success].</param>
private void Exit(bool success)
{
if (this.InvokeRequired)
{
ExitCallBack cb = new ExitCallBack(Exit);
this.Invoke(cb, new object[] { success });
}
else
{
this.isFinished = success;
this.DialogResult = success ? DialogResult.OK : DialogResult.Cancel;
this.Close();
}
}
/// <summary>
/// <para>说明:取消</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnCancel(object sender, EventArgs e)
{
if (!isFinished && DialogResult.Yes == MessageBox.Show(ConstModel.UPDATE_GIVING_UP, ConstModel.LS_TITLE_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
evtDownload.Set();
evtPerDonwload.Set();
autoUpdater.RollBack();
Exit(false);
}
}
/// <summary>
/// <para>说明:下载失败</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void DealWithDownloadErrors()
{
try
{
//Test Network is OK or not.
Config config = new Config().LoadConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstModel.AUTOUPDATE_CONFIG));
WebClient client = new WebClient();
client.DownloadString(config.ServerUrl);
}
catch (Exception e)
{
//MessageBox.Show(e.Message);
//log the error message,you can use the application's log code
ShowErrorAndRestartApplication();
}
}
/// <summary>
/// <para>说明:重新下载</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void ShowErrorAndRestartApplication()
{
DialogResult dlg = MessageBox.Show(ConstModel.UPDATE_CONTINUE, ConstModel.LS_TITLE_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dlg == DialogResult.Yes)
CommonUnitity.RestartApplication();
else
{
if (clientDownload != null)
clientDownload.CancelAsync();
evtDownload.Set();
evtPerDonwload.Set();
autoUpdater.RollBack();
Exit(false);
}
}
}
}
File diff suppressed because it is too large Load Diff
+249
View File
@@ -0,0 +1,249 @@
/******************************
* 说明:Ini 文件操作类
* 创建人:龚宇超
* 创建日期:2017-07-22
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Windows.Forms;
namespace Lskj.AutoUpdate
{
/// <summary>
/// Ini 文件操作类
/// </summary>
public static class IniUtil
{
private static readonly string absolutelyPath = Application.StartupPath + "\\";
private static readonly string mainMenuConfigPath = absolutelyPath + "MenuConfig.ini";
/// <summary>
/// 写入INI文件
/// </summary>
/// <param name="section">节点名称[如[TypeName]]</param>
/// <param name="key">键</param>
/// <param name="val">值</param>
/// <param name="filepath">文件路径</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
/// <summary>
/// 读取INI文件
/// </summary>
/// <param name="section">节点名称</param>
/// <param name="key">键</param>
/// <param name="def">值</param>
/// <param name="retval">stringbulider对象</param>
/// <param name="size">字节大小</param>
/// <param name="filePath">文件路径</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
/// <summary>
/// 获取某个指定节点(Section)中所有KEY和Value
/// </summary>
/// <param name="lpAppName">节点名称</param>
/// <param name="lpReturnedString">返回值的内存地址,每个之间用\0分隔</param>
/// <param name="nSize">内存大小(characters)</param>
/// <param name="lpFileName">Ini文件</param>
/// <returns>内容的实际长度,为0表示没有内容,为nSize-2表示内存大小不够</returns>
[DllImport("kernel32")]
private static extern int GetPrivateProfileSection(string lpAppName, byte[] lpszReturnBuffer, int nSize, string lpFileName);
/// <summary>
/// <para>说明:写入Ini文件(以键值对的形式存放)</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns></returns>
public static void Write(string key, string value)
{
try
{
//根据INI文件名设置要写入INI文件的节点名称
//此处的节点名称完全可以根据实际需要进行配置
string filePath = mainMenuConfigPath;
if (!File.Exists(filePath))
{
File.Create(filePath);
}
string fileName = Path.GetFileNameWithoutExtension(filePath);
WritePrivateProfileString(fileName, key, value, filePath);
}
catch (Exception ex)
{
}
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string key)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = mainMenuConfigPath;
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(fileName, key, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// <para>说明:写入Ini文件(以键值对的形式存放)</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns></returns>
public static void Write(string iniName, string key, string value)
{
try
{
//根据INI文件名设置要写入INI文件的节点名称
//此处的节点名称完全可以根据实际需要进行配置
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (!File.Exists(filePath))
{
File.Create(filePath);
}
string fileName = Path.GetFileNameWithoutExtension(filePath);
WritePrivateProfileString(fileName, key, value, filePath);
}
catch (Exception ex)
{
}
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string iniName, string key)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(fileName, key, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string iniName, string mainKey, string listKey)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(mainKey, listKey, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// 获取INI文件中指定节点(Section)中的所有条目(key=value形式)
/// </summary>
/// <param name="iniFile">Ini文件</param>
/// <param name="section">节点名称</param>
/// <returns>指定节点中的所有项目,没有内容返回string[0]</returns>
public static Dictionary<string, string> GetSectionKeys(string iniFile, string category)
{
Dictionary<string, string> result = new Dictionary<string, string>();
try
{
string filePath = Path.Combine(new string[] { absolutelyPath + iniFile });
if (File.Exists(filePath))
{
byte[] buffer = new byte[2048];
GetPrivateProfileSection(category, buffer, 2048, filePath);
String[] tmp = Encoding.Default.GetString(buffer).Trim('\0').Split('\0');
foreach (String entry in tmp)
{
string[] v = entry.Split('=');
result.Add(v[0], v[1]);
}
return result;
}
}
catch (Exception)
{
}
return result;
}
}
}
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7FDD63DA-78E2-4093-B51E-060491DDFD5A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Lskj.AutoUpdate</RootNamespace>
<AssemblyName>Lskj.AutoUpdate</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\Debug\AllMethodXml\Lskj.AutoUpdate.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="FrmProgress.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmProgress.Designer.cs">
<DependentUpon>FrmProgress.cs</DependentUpon>
</Compile>
<Compile Include="Model\AutoUpdater.cs" />
<Compile Include="Model\CommonUnitity.cs" />
<Compile Include="Model\Config.cs" />
<Compile Include="Model\ConstFile.cs" />
<Compile Include="Model\DownloadFileInfo.cs" />
<Compile Include="Model\IAutoUpdater.cs" />
<Compile Include="Model\IniUtil.cs" />
<Compile Include="Model\LocalFile.cs" />
<Compile Include="Model\ProcessManager.cs" />
<Compile Include="Model\RemoteFile.cs" />
<Compile Include="Model\UpdateFileList.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmProgress.resx">
<DependentUpon>FrmProgress.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="logo.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Binary file not shown.
@@ -0,0 +1,88 @@
/******************************
* 说明:公共类
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 公共类
/// </summary>
public class CommonUnitity
{
/// <summary>
/// 应用程序启动目录
/// </summary>
public static string SystemBinUrl = AppDomain.CurrentDomain.BaseDirectory;
/// <summary>
/// <para>说明:重启应用</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
public static void RestartApplication()
{
Process.Start(Path.Combine(Application.ExecutablePath, ConstModel.LS_ERP_EXE));
Environment.Exit(0);
}
/// <summary>
/// <para>说明:获取文件夹路径</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="file">The file.</param>
/// <returns>System.String.</returns>
public static string GetFolderUrl(DownloadFileInfo file)
{
try
{
string folderPathUrl = string.Empty;
int folderPathPoint = file.DownloadUrl.IndexOf("/", 15) + 1;
string filepathstring = file.DownloadUrl.Substring(folderPathPoint);
if (filepathstring.IndexOf("/") != -1)
{
string[] ExeGroup = filepathstring.Split('/');
for (int i = 0; i < ExeGroup.Length - 1; i++)
{
folderPathUrl += "\\" + ExeGroup[i];
}
if (!Directory.Exists(SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + folderPathUrl))
{
Directory.CreateDirectory(SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + folderPathUrl);
}
if (!Directory.Exists(SystemBinUrl + ConstModel.Batch_FOLDER_NAME))
{
Directory.CreateDirectory(SystemBinUrl + ConstModel.Batch_FOLDER_NAME);
}
}
return folderPathUrl;
}
catch (Exception ex)
{
MessageBox.Show("获取文件夹路径失败:"+ file.DownloadUrl + "\r\n" + ex.Message);
return "";
}
}
}
}
+87
View File
@@ -0,0 +1,87 @@
/******************************
* 说明:自动升级配置文件
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 自动升级配置文件
/// </summary>
public class Config
{
private string _serverUrl = string.Empty;
private UpdateFileList _updateFileList = new UpdateFileList();
/// <summary>
/// 下载地址
/// </summary>
/// <value>The server URL.</value>
public string ServerUrl
{
get { return _serverUrl; }
set { _serverUrl = value; }
}
/// <summary>
/// 下载文件地址
/// </summary>
/// <value>The update file list.</value>
public UpdateFileList UpdateFileList
{
get { return _updateFileList; }
set { _updateFileList = value; }
}
/// <summary>
/// <para>说明:加载配置</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="file">The file.</param>
/// <returns>Config.</returns>
public Config LoadConfig(string file)
{
if (!File.Exists(file)) SaveConfig(file);
XmlSerializer xs = new XmlSerializer(typeof(Config));
StreamReader sr = new StreamReader(file);
Config config = xs.Deserialize(sr) as Config;
sr.Close();
return config;
}
/// <summary>
/// <para>说明:保存配置</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-23 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="file">The file.</param>
public void SaveConfig(string file)
{
XmlSerializer xs = new XmlSerializer(typeof(Config));
StreamWriter sw = new StreamWriter(file);
xs.Serialize(sw, this);
sw.Close();
}
}
}
@@ -0,0 +1,103 @@
/******************************
* 说明:自动更新相关常量定义
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 自动更新相关常量定义
/// </summary>
public class ConstModel
{
/// <summary>
/// 批量打印临时文件夹名BatchPrintFile
/// </summary>
public const string Batch_FOLDER_NAME = "BatchPrintFile";
/// <summary>
/// 临时文件夹名TempFolder
/// </summary>
public const string TEMP_FOLDER_NAME = "TempFolder";
/// <summary>
/// config_
/// </summary>
public const string CONFIG_FILE_KEY = "config_";
/// <summary>
/// AutoUpdater.config
/// </summary>
public const string AUTOUPDATE_CONFIG = "AutoupdateService.xml";
/// <summary>
/// ERPClient
/// </summary>
public const string ERP_CLIENT = "ERPClient";
/// <summary>
/// Ls_ERP
/// </summary>
public const string LS_ERP_NAME = "Ls_ERP";
/// <summary>
/// Ls_ERP.exe
/// </summary>
public const string LS_ERP_EXE = "Ls_ERP.exe";
/// <summary>
/// Ls_Mes
/// </summary>
public const string LS_Mes_NAME = "Ls_MES";
/// <summary>
/// Ls_Mes.exe
/// </summary>
public const string LS_Mes_EXE = "Ls_MES.exe";
/// <summary>
/// Ls_Update
/// </summary>
public const string LS_UPDATE_NAME = "Ls_Update";
/// <summary>
/// Ls_Update.exe
/// </summary>
public const string LS_UPDATE_EXE = "Ls_Update.exe";
/// <summary>
/// LskjCall
/// </summary>
public const string LS_CALL_NAME = "LskjCall";
/// <summary>
/// LskjCall.exe
/// </summary>
public const string LS_CALL_EXE = "LskjCall.exe";
/// <summary>
/// 通知程序
/// </summary>
public const string Ls_Notice = "Ls_Notice";
/// <summary>
/// 朗速ERP
/// </summary>
public const string LS_TITLE_NAME = "系统提示";
/// <summary>
/// Client
/// </summary>
public const string CLIENT_NAME = "Client";
/// <summary>
/// Client.exe
/// </summary>
public const string CLIENT_EXE = "Client.exe";
/// <summary>
/// 软件正在更新中,是否真要放弃更新吗?
/// </summary>
public const string UPDATE_GIVING_UP = "软件正在更新中,是否真要放弃更新吗?";
/// <summary>
/// 软件更新完成,需要重新启动,点击确定启动!
/// </summary>
public const string UPDATE_RESTART = "软件更新完成,需要重新启动,点击确定启动!";
/// <summary>
/// 更新未能完成,如果选择继续我们将尝试重新为您更新,是否继续?
/// </summary>
public const string UPDATE_CONTINUE = "更新未能完成,是否继续?";
}
}
@@ -0,0 +1,68 @@
/******************************
* 说明:下载文件实体类
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 下载文件实体类
/// </summary>
public class DownloadFileInfo
{
private string _downloadUrl;
private string _fileName;
private string _lastver;
private int _size;
private string _version;
/// <summary>
/// 下载地址
/// </summary>
/// <value>The download URL.</value>
public string DownloadUrl { get { return _downloadUrl; } }
/// <summary>
/// 文件全名称
/// </summary>
/// <value>The full name of the file.</value>
public string FileFullName { get { return _fileName; } }
/// <summary>
///文件名称
/// </summary>
/// <value>The name of the file.</value>
public string FileName { get { return Path.GetFileName(FileFullName); } }
/// <summary>
/// 最新版本
/// </summary>
/// <value>The last ver.</value>
public string LastVersion { get { return _lastver; } set { _lastver = value; } }
/// <summary>
/// 文件大小
/// </summary>
/// <value>The size.</value>
public int Size { get { return _size; } }
/// <summary>
/// 版本号
/// </summary>
/// <value>The version.</value>
public string Version { get { return _version; } set { _version = value; } }
public DownloadFileInfo(string url, string name, string ver, int size, string versionid)
{
this._downloadUrl = url;
this._fileName = name;
this._lastver = ver;
this._size = size;
this._version = versionid;
}
}
}
@@ -0,0 +1,43 @@
/******************************
* 说明:自动升级接口
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 自动升级接口
/// </summary>
public interface IAutoUpdater
{
/// <summary>
/// <para>说明:更新</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
void Update();
/// <summary>
/// <para>说明:回滚</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
void RollBack();
}
}
+249
View File
@@ -0,0 +1,249 @@
/******************************
* 说明:Ini 文件操作类
* 创建人:龚宇超
* 创建日期:2017-07-22
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Windows.Forms;
namespace Lskj.AutoUpdate
{
/// <summary>
/// Ini 文件操作类
/// </summary>
public static class IniUtil
{
private static readonly string absolutelyPath = Application.StartupPath + "\\";
private static readonly string mainMenuConfigPath = absolutelyPath + "MenuConfig.ini";
/// <summary>
/// 写入INI文件
/// </summary>
/// <param name="section">节点名称[如[TypeName]]</param>
/// <param name="key">键</param>
/// <param name="val">值</param>
/// <param name="filepath">文件路径</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
/// <summary>
/// 读取INI文件
/// </summary>
/// <param name="section">节点名称</param>
/// <param name="key">键</param>
/// <param name="def">值</param>
/// <param name="retval">stringbulider对象</param>
/// <param name="size">字节大小</param>
/// <param name="filePath">文件路径</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
/// <summary>
/// 获取某个指定节点(Section)中所有KEY和Value
/// </summary>
/// <param name="lpAppName">节点名称</param>
/// <param name="lpReturnedString">返回值的内存地址,每个之间用\0分隔</param>
/// <param name="nSize">内存大小(characters)</param>
/// <param name="lpFileName">Ini文件</param>
/// <returns>内容的实际长度,为0表示没有内容,为nSize-2表示内存大小不够</returns>
[DllImport("kernel32")]
private static extern int GetPrivateProfileSection(string lpAppName, byte[] lpszReturnBuffer, int nSize, string lpFileName);
/// <summary>
/// <para>说明:写入Ini文件(以键值对的形式存放)</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns></returns>
public static void Write(string key, string value)
{
try
{
//根据INI文件名设置要写入INI文件的节点名称
//此处的节点名称完全可以根据实际需要进行配置
string filePath = mainMenuConfigPath;
if (!File.Exists(filePath))
{
File.Create(filePath);
}
string fileName = Path.GetFileNameWithoutExtension(filePath);
WritePrivateProfileString(fileName, key, value, filePath);
}
catch (Exception ex)
{
}
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string key)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = mainMenuConfigPath;
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(fileName, key, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// <para>说明:写入Ini文件(以键值对的形式存放)</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns></returns>
public static void Write(string iniName, string key, string value)
{
try
{
//根据INI文件名设置要写入INI文件的节点名称
//此处的节点名称完全可以根据实际需要进行配置
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (!File.Exists(filePath))
{
File.Create(filePath);
}
string fileName = Path.GetFileNameWithoutExtension(filePath);
WritePrivateProfileString(fileName, key, value, filePath);
}
catch (Exception ex)
{
}
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string iniName, string key)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(fileName, key, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// <para>说明:通过Key获取Value值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-07-22</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="key">键</param>
/// <returns>值</returns>
public static string Read(string iniName, string mainKey, string listKey)
{
string value = string.Empty;
try
{
//判读INI文件是否存在
string filePath = Path.Combine(new string[] { absolutelyPath + iniName });
if (File.Exists(filePath))
{
StringBuilder temp = new StringBuilder(1024);
string fileName = Path.GetFileNameWithoutExtension(filePath);
GetPrivateProfileString(mainKey, listKey, "", temp, 1024, filePath);
return temp + "";
}
}
catch (Exception)
{
}
return value;
}
/// <summary>
/// 获取INI文件中指定节点(Section)中的所有条目(key=value形式)
/// </summary>
/// <param name="iniFile">Ini文件</param>
/// <param name="section">节点名称</param>
/// <returns>指定节点中的所有项目,没有内容返回string[0]</returns>
public static Dictionary<string, string> GetSectionKeys(string iniFile, string category)
{
Dictionary<string, string> result = new Dictionary<string, string>();
try
{
string filePath = Path.Combine(new string[] { absolutelyPath + iniFile });
if (File.Exists(filePath))
{
byte[] buffer = new byte[2048];
GetPrivateProfileSection(category, buffer, 2048, filePath);
String[] tmp = Encoding.Default.GetString(buffer).Trim('\0').Split('\0');
foreach (String entry in tmp)
{
string[] v = entry.Split('=');
result.Add(v[0], v[1]);
}
return result;
}
}
catch (Exception)
{
}
return result;
}
}
}
@@ -0,0 +1,66 @@
/******************************
* 说明:更新文件配置对象
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 更新文件配置对象
/// </summary>
public class LocalFile
{
private string _path;
private string _lastver;
private int _size;
private string _version;
/// <summary>
/// 路径
/// </summary>
/// <value>The path.</value>
[XmlAttribute("path")]
public string Path { get { return _path; } set { _path = value; } }
/// <summary>
/// 最新版本
/// </summary>
/// <value>The last ver.</value>
[XmlAttribute("lastver")]
public string LastVer { get { return _lastver; } set { _lastver = value; } }
/// <summary>
/// 文件大小
/// </summary>
/// <value>The size.</value>
[XmlAttribute("size")]
public int Size { get { return _size; } set { _size = value; } }
/// <summary>
/// 文件版本
/// </summary>
/// <value>The version.</value>
[XmlAttribute("version")]
public string Version { get { return _version; } set { _version = value; } }
public LocalFile(string path, string ver, int size, string versionid)
{
this._path = path;
this._lastver = ver;
this._size = size;
this._version = versionid;
}
public LocalFile()
{
}
}
}
@@ -0,0 +1,158 @@
/******************************
* 说明:启动进程、关闭进程操作
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 启动进程、关闭进程操作
/// </summary>
public class ProcessManager
{
/// <summary>
/// <para>说明:初始化更新,关闭现有软件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
public void InitUpdateEnvironment()
{
if (Exist(ConstModel.ERP_CLIENT))
{
CloseExe(ConstModel.LS_ERP_NAME);
}
CloseExe(ConstModel.CLIENT_NAME);
CloseExe(ConstModel.LS_CALL_NAME);
CloseExe(ConstModel.LS_ERP_NAME);
CloseExe(ConstModel.LS_Mes_NAME);
CloseExe(ConstModel.Ls_Notice);
}
/// <summary>
/// <para>说明:启动主程序</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
public void StartProcess(bool isMes = false)
{
string path = System.Environment.CurrentDirectory;
if (!isMes)
{
if (!Exist(ConstModel.LS_ERP_NAME))
{
StartExe(path, ConstModel.LS_ERP_EXE);
}
}
else
{
if (!Exist(ConstModel.LS_Mes_NAME))
{
StartExe(path, ConstModel.LS_Mes_EXE);
}
}
CloseExe(ConstModel.LS_UPDATE_NAME);
}
/// <summary>
/// <para>说明:启动更新程序</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
public void StartUpdateProcess(bool isMes = false)
{
string path = System.Environment.CurrentDirectory;
CloseExe(ConstModel.CLIENT_NAME);
CloseExe(ConstModel.LS_CALL_NAME);
if (!Exist(ConstModel.LS_UPDATE_NAME))
{
if (!isMes)
{
StartExe(path, ConstModel.LS_UPDATE_EXE);
}
else
{
StartExe(path, ConstModel.LS_UPDATE_EXE, "1");
}
}
CloseExe(ConstModel.LS_ERP_NAME);
CloseExe(ConstModel.LS_Mes_NAME);
CloseExe(ConstModel.Ls_Notice);
}
/// <summary>
/// <para>说明:启动exe绝对路径</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="filePath">The file path.</param>
/// <param name="fileName">Name of the file.</param
/// <param name="args">args</param>
private void StartExe(string filePath, string fileName, string args = "")
{
Process proc = new Process();
proc.StartInfo.UseShellExecute = true;//是否使用操作系统外壳程序启动进程
proc.StartInfo.WorkingDirectory = filePath;//启动进程的初始目录
proc.StartInfo.FileName = fileName;
if (!string.IsNullOrEmpty(args))
{
proc.StartInfo.Arguments = args;
}
proc.Start();
}
/// <summary>
/// <para>说明:关闭的exe进程名</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="exeName">Name of the executable.</param>
public void CloseExe(string exeName)
{
Process[] arrPro = Process.GetProcessesByName(exeName);
foreach (Process pro in arrPro)
pro.Kill();
}
/// <summary>
/// <para>说明:是否存在进程名</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-02-09 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="processName">Name of the process.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
private bool Exist(string processName)
{
Process[] pro = Process.GetProcessesByName(processName);
return pro.Count() > 0;
}
}
}
@@ -0,0 +1,70 @@
/******************************
* 说明:服务器文件配置对象
* 创建人:龚宇超
* 创建日期:2018-02-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace Lskj.AutoUpdate
{
/// <summary>
/// 服务器文件配置对象
/// </summary>
public class RemoteFile
{
private string path;
private string url;
private string lastver;
private int size;
private bool needRestart;
private string version;
/// <summary>
/// 文件名称
/// </summary>
/// <value>The path.</value>
public string Path { get { return path; } }
/// <summary>
/// 下载地址
/// </summary>
/// <value>The URL.</value>
public string Url { get { return url; } }
/// <summary>
/// 最新版本
/// </summary>
/// <value>The last ver.</value>
public string LastVer { get { return lastver; } }
/// <summary>
/// 文件大小
/// </summary>
/// <value>The size.</value>
public int Size { get { return size; } }
/// <summary>
/// 是否需要重启
/// </summary>
/// <value><c>true</c> if [need restart]; otherwise, <c>false</c>.</value>
public bool NeedRestart { get { return needRestart; } }
/// <summary>
/// 版本号
/// </summary>
/// <value>The verison.</value>
public string Verison { get { return version; } }
public RemoteFile(XmlNode node)
{
this.path = node.Attributes["path"].Value;
this.url = node.Attributes["url"].Value;
this.lastver = node.Attributes["lastver"].Value;
this.size = Convert.ToInt32(node.Attributes["size"].Value);
this.needRestart = Convert.ToBoolean(node.Attributes["needRestart"].Value);
this.version = node.Attributes["version"].Value;
}
}
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Lskj.AutoUpdate
{
public class UpdateFileList : List<LocalFile>
{
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Lskj.AutoUpdate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lskj.AutoUpdate")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("68775ff6-b1ce-49c6-b638-0eb541581f58")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Lskj.AutoUpdate.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lskj.AutoUpdate.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Lskj.AutoUpdate.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB