Commit b6da4134 authored by 247321453's avatar 247321453

1.3.2.0

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