Commit b6da4134 authored by 247321453's avatar 247321453

1.3.2.0

parent f9899a86
......@@ -18,32 +18,10 @@ namespace DataEditorX
/// </summary>
public class CheckUpdate
{
static string URL="";
public static string URL="";
static string HEAD="[DataEditorX]",HEAD2="[URL]";
public static void UpdateTip(string VERURL)
{
string newver=Check(VERURL);
int iver,iver2;
int.TryParse(Application.ProductVersion.Replace(".",""), out iver);
int.TryParse(newver.Replace(".",""), out iver2);
if(iver2>iver)
{
if(MyMsg.Question(string.Format(
MyMsg.GetString("have a new version.{0}version:{1}"),
"\n",newver)))
{
if(DownLoad(URL,Path.Combine(Application.StartupPath, newver+".update.zip"),null))
{
MyMsg.Show("Download succeed.");
}
}
}
else if(iver2>0)
MyMsg.Show(string.Format(MyMsg.GetString("Is Last Version.{0}Version:{1}"),
"\n",newver));
else
MyMsg.Error(MyMsg.GetString("Check update fail!"));
}
public static bool isOK=false;
public static string Check(string VERURL)
{
string urlver="0.0.0.0";
......@@ -99,41 +77,35 @@ public static string GetHtmlContentByUrl(string url)
}
#endregion
public static bool DownLoad(string URL,string filename,System.Windows.Forms.ProgressBar prog)
public static void DownLoad(string filename)
{
try
{
HttpWebRequest Myrq = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
if (prog != null)
{
prog.Maximum = (int)totalBytes;
}
System.IO.Stream st = myrp.GetResponseStream();
System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create);
Stream st = myrp.GetResponseStream();
Stream so = new System.IO.FileStream(filename+".tmp", FileMode.Create);
long totalDownloadedByte = 0;
byte[] by = new byte[1024];
byte[] by = new byte[2048];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
System.Windows.Forms.Application.DoEvents();
so.Write(by, 0, osize);
if (prog != null)
{
prog.Value = (int)totalDownloadedByte;
}
osize = st.Read(by, 0, (int)by.Length);
}
so.Close();
st.Close();
File.Move(filename+".tmp", filename);
}
catch (System.Exception)
{
return false;
isOK= false;
}
return true;
isOK=true;
}
}
}
......@@ -96,6 +96,7 @@ private void InitializeComponent()
this.pl_image = new System.Windows.Forms.Panel();
this.lb_types = new System.Windows.Forms.Label();
this.lb_tiptexts = new System.Windows.Forms.Label();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
......@@ -680,6 +681,13 @@ private void InitializeComponent()
this.lb_tiptexts.Text = "Tips Texts";
this.lb_tiptexts.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// backgroundWorker1
//
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.WorkerSupportsCancellation = true;
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.BackgroundWorker1DoWork);
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.BackgroundWorker1RunWorkerCompleted);
//
// DataEditForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -743,6 +751,7 @@ private void InitializeComponent()
this.ResumeLayout(false);
this.PerformLayout();
}
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.Panel pl_image;
private System.Windows.Forms.ToolStripMenuItem menuitem_copyselectto;
private System.Windows.Forms.ToolStripMenuItem menuitem_github;
......
......@@ -29,7 +29,9 @@ public partial class DataEditForm : Form
int MaxRow=20;
int page=1,pageNum=1;
int cardcount;
bool isdownload;
bool isbgcheck;
string NEWVER="0.0.0.0";
List<Card> cardlist=new List<Card>();
Image m_cover;
......@@ -97,10 +99,14 @@ void DataEditFormLoad(object sender, EventArgs e)
//set null card
oldCard=new Card(0);
SetCard(oldCard);
isbgcheck=true;
isdownload=false;
//Menuitem_checkupdateClick(null,null);
if(File.Exists(nowCdbFile))
Open(nowCdbFile);
}
void InitString()
{
btn_add.Text=MyMsg.GetString("Add");
......@@ -869,7 +875,13 @@ void Menuitem_aboutClick(object sender, EventArgs e)
void Menuitem_checkupdateClick(object sender, EventArgs e)
{
CheckUpdate.UpdateTip(ConfigurationManager.AppSettings["updateURL"]);
if(!backgroundWorker1.IsBusy)
{
isdownload=false;
isbgcheck=false;
backgroundWorker1.RunWorkerAsync();
}
}
......@@ -981,5 +993,71 @@ void Menuitem_quitClick(object sender, EventArgs e)
}
#endregion
void BackgroundWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
if(isdownload)
CheckUpdate.DownLoad(Path.Combine(Application.StartupPath, NEWVER+".zip"));
else
{
NEWVER=CheckUpdate.Check(ConfigurationManager.AppSettings["updateURL"]);
}
}
void BackgroundWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
if(isdownload)
{
if(CheckUpdate.isOK)
MyMsg.Show(MyMsg.GetString("Download succeed."));
else
MyMsg.Show(MyMsg.GetString("Download fail.")+"\n"+CheckUpdate.URL);
}
else
{
string newver=NEWVER;
int iver,iver2;
int.TryParse(Application.ProductVersion.Replace(".",""), out iver);
int.TryParse(newver.Replace(".",""), out iver2);
if(iver2>iver)
{
if(MyMsg.Question(string.Format(
MyMsg.GetString("have a new version.{0}version:{1}"),
"\n",newver)))
{
if(!backgroundWorker1.IsBusy)
{
isdownload=true;
isbgcheck=false;
backgroundWorker1.RunWorkerAsync();
}
}
}
else if(iver2>0)
{
if(!isbgcheck)
{
if( MyMsg.Question(string.Format(
MyMsg.GetString("Is Last Version.{0}Version:{1}"),
"\n",newver+"\n")))
{
if(!backgroundWorker1.IsBusy)
{
isdownload=true;
isbgcheck=false;
backgroundWorker1.RunWorkerAsync();
}
}
}
}
else
{
if(!isbgcheck)
MyMsg.Error(MyMsg.GetString("Check update fail!"));
}
}
}
}
}
......@@ -120,6 +120,9 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>130, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
......
......@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
......@@ -13,6 +13,6 @@
<add key="language" value="chs" />
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32" />
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
</appSettings>
</configuration>
......@@ -35,10 +35,11 @@ All Now Copy To 当前所有卡片复制到...
Quit 退出
Is Last Version.{0}Version:{1} 已经是最新版本!{0}版本号:{1}
Is Last Version.{0}Version:{1} 已经是最新版本!{0}版本号:{1}是否重新下载?
Check update fail! 查询失败!
have a new version.{0}version:{1} 发现一个新版本。是否下载?{0}版本号{1}
Download succeed. 下载成功。
Download fail. 下载失败。
Please select a DataBase! 请打开一个数据库!
File is not exists! 文件不存在!
......
......@@ -14,6 +14,11 @@
★更新历史
1.3.2.0
修复
1.3.1.0
自动检查更新
添加下载文件
1.3.0.1
分文件夹
1.3.0.0
......
No preview for this file type
......@@ -13,6 +13,6 @@
<add key="language" value="chs" />
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32" />
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
</appSettings>
</configuration>
......@@ -35,10 +35,11 @@ All Now Copy To 当前所有卡片复制到...
Quit 退出
Is Last Version.{0}Version:{1} 已经是最新版本!{0}版本号:{1}
Is Last Version.{0}Version:{1} 已经是最新版本!{0}版本号:{1}是否重新下载?
Check update fail! 查询失败!
have a new version.{0}version:{1} 发现一个新版本。是否下载?{0}版本号{1}
Download succeed. 下载成功。
Download fail. 下载失败。
Please select a DataBase! 请打开一个数据库!
File is not exists! 文件不存在!
......
......@@ -14,6 +14,11 @@
★更新历史
1.3.2.0
修复
1.3.1.0
自动检查更新
添加下载文件
1.3.0.1
分文件夹
1.3.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment