Commit e25d7aff authored by 247321453's avatar 247321453

fix

parent 94a5187d
...@@ -21,7 +21,8 @@ public partial class DataEditForm : Form ...@@ -21,7 +21,8 @@ public partial class DataEditForm : Form
{ {
#region 成员变量 #region 成员变量
string GAMEPATH,PICPATH,LUAPTH; string GAMEPATH,PICPATH,LUAPTH;
string GITURL="https://github.com/247321453/DataEcitorX"; readonly string GITURL="https://github.com/247321453/DataEcitorX";
readonly string VERURL="http://hi.baidu.com/247321453";
Card oldCard=new Card(0); Card oldCard=new Card(0);
Card srcCard=new Card(0); Card srcCard=new Card(0);
ImageForm imgform=new ImageForm(); ImageForm imgform=new ImageForm();
...@@ -788,10 +789,7 @@ void Menuitem_aboutClick(object sender, EventArgs e) ...@@ -788,10 +789,7 @@ void Menuitem_aboutClick(object sender, EventArgs e)
void Menuitem_checkupdateClick(object sender, EventArgs e) void Menuitem_checkupdateClick(object sender, EventArgs e)
{ {
if(MyUpdate.CheckUpdate()) MyUpdate.CheckUpdate(VERURL);
{
MyUpdate.Download();
}
} }
void Menuitem_githubClick(object sender, EventArgs e) void Menuitem_githubClick(object sender, EventArgs e)
{ {
......
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="Data" /> <Folder Include="Data" />
<Folder Include="Core" /> <Folder Include="Core" />
<Folder Include="Update" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Data\card-attribute.txt"> <None Include="Data\card-attribute.txt">
...@@ -104,8 +103,6 @@ ...@@ -104,8 +103,6 @@
<None Include="readme.txt"> <None Include="readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Update\Release.zip" />
<None Include="Update\version.txt" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -18,30 +18,69 @@ namespace DataEditorX ...@@ -18,30 +18,69 @@ namespace DataEditorX
/// </summary> /// </summary>
public static class MyUpdate public static class MyUpdate
{ {
static readonly string VERURL="https://github.com/247321453/DataEditorX/raw/master/DataEditorX/Update/version.txt"; static string downloadURL="";
static readonly string DOWNURL="https://github.com/247321453/DataEditorX/raw/master/DataEditorX/Update/Release.zip"; static string Head="[DataEditorX]";
public static bool CheckUpdate() static string Vhead="v";
static string Thead="t";
static string Dhead="d";
public static bool CheckUpdate(string url)
{ {
string ver,lasttime; string ver,lasttime,verurl;
int l=-1; int t,w;
string html=GetHtmlContentByUrl(VERURL); string html=GetHtmlContentByUrl(url);
if(string.IsNullOrEmpty(html)) if(string.IsNullOrEmpty(html))
{ {
MyMsg.Error("无法获取版本!"); MyMsg.Error("无法获取版本!");
return false; return false;
} }
l=html.IndexOf(" time:"); t=html.IndexOf(Head);
ver=(l>=0)?html.Substring(4,l):"?.?.?.?"; w=(t>=0)?html.IndexOf(Head,t+1):0;
lasttime=(l>=0)?html.Substring(l):"????-??-?? ??:??"; if(w<=0)
{
MyMsg.Error("无法解释网址内容!\n"+url);
return false;
}
verurl=html.Substring(t+Head.Length,w-t-Head.Length);
if(!verurl.StartsWith("http://",StringComparison.OrdinalIgnoreCase))
verurl="http://"+verurl;
#if DEBUG
MyMsg.Show(verurl);
#endif
html= GetHtmlContentByUrl(verurl);
if(string.IsNullOrEmpty(html))
{
MyMsg.Error("无法解释网址内容!\n"+verurl);
return false;
}
w=0;
t=html.IndexOf("<"+Vhead+">",w);
w=(t>=0)?html.IndexOf("<"+Vhead+">",t+1):0;
ver=(w>0)?html.Substring(t+Vhead.Length+2,w-t-Vhead.Length-2):"?.?.?.?";
t=html.IndexOf("<"+Thead+">",w);
w=(t>=0)?html.IndexOf("<"+Thead+">",t+1):0;
lasttime=(w>0)?html.Substring(t+Thead.Length+2,w-t-Thead.Length-2):"????-??-?? ??:??";
t=html.IndexOf("<"+Dhead+">",w);
w=(t>=0)?html.IndexOf("<"+Dhead+">",t+1):0;
downloadURL=(w>0)?html.Substring(t+Dhead.Length+2,w-t-Dhead.Length-2):"";
if(!string.IsNullOrEmpty(downloadURL))
{
downloadURL=downloadURL.Replace(" http://","\nhttp://");
Clipboard.SetText(downloadURL);
}
MyMsg.Show("当前版本:"+Application.ProductVersion MyMsg.Show("当前版本:"+Application.ProductVersion
+"\n最新版本:"+ver +"\n最新版本:"+ver
+"\n最后更新时间:"+lasttime); +"\n最后更新时间:"+lasttime
+"\n下载地址:(已经复制到粘贴板)\n"+downloadURL
);
return false; return false;
}
public static void Download()
{
} }
/// <summary> /// <summary>
///根据url获取网站html内容 /// </summary> ///根据url获取网站html内容 /// </summary>
......
...@@ -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.1.0.3")] [assembly: AssemblyVersion("1.2.0.0")]
ver:1.1.0.3 time:2014-5-21 10:00
\ No newline at end of file
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