Skip to content

Commit

Permalink
Update to version 7.0.7.0
Browse files Browse the repository at this point in the history
1. 修复 错误记录4KB压缩方法中不记录新错误信息的bug
2. 更改 Pixiv站点搜索无效时只记录错误、不再多弹出一次提示信息框
3. 优化 Pixiv站点登录错误提示、提供可直接复制的内置公用账号功能
优化错误提示
  • Loading branch information
usaginya committed Sep 18, 2019
1 parent 06c9402 commit 91f3c0f
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 82 deletions.
13 changes: 4 additions & 9 deletions MoeLoaderDelta/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,14 +1051,9 @@ private void Button_Click(object sender, RoutedEventArgs e)
//prefetch
string pageString = PreFetcher.Fetcher.GetPreFetchedPage(
realPage, realNum, Uri.EscapeDataString(SearchWord), SiteManager.Instance.Sites[nowSelectedIndex]);
if (pageString != null)
{
imgList = SiteManager.Instance.Sites[nowSelectedIndex].GetImages(pageString, WebProxy);
}
else
{
imgList = SiteManager.Instance.Sites[nowSelectedIndex].GetImages(realPage, realNum, Uri.EscapeDataString(SearchWord), WebProxy);
}
imgList = !string.IsNullOrWhiteSpace(pageString)
? SiteManager.Instance.Sites[nowSelectedIndex].GetImages(pageString, WebProxy)
: SiteManager.Instance.Sites[nowSelectedIndex].GetImages(realPage, realNum, Uri.EscapeDataString(SearchWord), WebProxy);

//过滤图片列表
imgList = SiteManager.Instance.Sites[nowSelectedIndex].FilterImg(
Expand All @@ -1071,7 +1066,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
{
Dispatcher.Invoke(new VoidDel(() =>
{
MessageBox.Show(this, "获取图片遇到错误: " + ex.Message,
MessageBox.Show(this, $"获取图片:{SearchWord}\r\n错误:{ex.Message}",
ProgramName, MessageBoxButton.OK, MessageBoxImage.Warning);
}));
}
Expand Down
4 changes: 2 additions & 2 deletions MoeLoaderDelta/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.6.91")]
[assembly: AssemblyFileVersion("7.0.6.91")]
[assembly: AssemblyVersion("7.0.7.0")]
[assembly: AssemblyFileVersion("7.0.7.0")]
[assembly: GuidAttribute("e1b87586-4b7e-4f4a-be97-55d3349ed5a6")]
4 changes: 2 additions & 2 deletions MoeSite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.3.9")]
[assembly: AssemblyFileVersion("1.3.3.9")]
[assembly: AssemblyVersion("1.3.4.0")]
[assembly: AssemblyFileVersion("1.3.4.0")]
34 changes: 19 additions & 15 deletions MoeSite/SiteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MoeLoaderDelta
{
/// <summary>
/// 管理站点定义
/// Last 20190824
/// Last 20190918
/// </summary>
public class SiteManager
{
Expand Down Expand Up @@ -59,7 +59,7 @@ private SiteManager()
}
catch (Exception ex)
{
echoErrLog("站点载入过程", ex);
EchoErrLog("站点载入过程", ex);
}
}
}
Expand Down Expand Up @@ -101,6 +101,7 @@ public static bool LoginSite(ImageSite imageSite, ref string cookie, string Logg

if (result)
{
shc.Timeout = shc.Timeout * 2;
shc.Set("Cookie", tmp_cookie);
try
{
Expand All @@ -124,7 +125,7 @@ public static bool LoginSite(ImageSite imageSite, ref string cookie, string Logg
cookie = string.Empty;
}
}

return result;
}

Expand All @@ -151,7 +152,7 @@ public static bool LoginSite(ImageSite imageSite, ref string cookie, string Logg
/// <param name="extra_info">附加错误信息</param>
/// <param name="NoShow">不显示信息</param>
/// <param name="NoLog">不记录Log</param>
public static void echoErrLog(string SiteShortName, Exception ex = null, string extra_info = null, bool NoShow = false, bool NoLog = false)
public static void EchoErrLog(string SiteShortName, Exception ex = null, string extra_info = null, bool NoShow = false, bool NoLog = false)
{
int maxlog = 4096;
bool exisnull = ex == null;
Expand All @@ -172,20 +173,23 @@ public static void echoErrLog(string SiteShortName, Exception ex = null, string
}
if (!NoShow)
{
MessageBox.Show((string.IsNullOrWhiteSpace(extra_info) ? ex.Message : extra_info), $"{SiteShortName} 错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(string.IsNullOrWhiteSpace(extra_info) ? ex.Message : extra_info, $"{SiteShortName} 错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
//压缩记录
if (new FileInfo(logPath).Length > maxlog)
long sourceLength = new FileInfo(logPath).Length;
if (sourceLength > maxlog)
{
char[] a = new char[maxlog];
using (FileStream fs = new FileStream(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
byte[] buffer = new byte[maxlog];
using (FileStream fs = new FileStream(logPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
{
using (StreamReader sr = new StreamReader(fs))
{
sr.ReadBlock(a, 0, maxlog);
}
int newleng = (int)sourceLength - maxlog;
newleng = newleng > maxlog ? maxlog : newleng;
fs.Seek(newleng, SeekOrigin.Begin);
fs.Read(buffer, 0, maxlog);
fs.Seek(0, SeekOrigin.Begin);
fs.SetLength(0);
fs.Write(buffer, 0, maxlog);
}
File.WriteAllText(logPath, new string(a));
}

}
Expand All @@ -194,9 +198,9 @@ public static void echoErrLog(string SiteShortName, Exception ex = null, string
/// </summary>
/// <param name="SiteShortName">站点短名</param>
/// <param name="extra_info">附加错误信息</param>
public static void echoErrLog(string SiteShortName, string extra_info, bool NoShow = false, bool NoLog = false)
public static void EchoErrLog(string SiteShortName, string extra_info, bool NoShow = false, bool NoLog = false)
{
echoErrLog(SiteShortName, null, extra_info, NoShow, NoLog);
EchoErrLog(SiteShortName, null, extra_info, NoShow, NoLog);
}
}
}
4 changes: 2 additions & 2 deletions SitePack/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.7.9")]
[assembly: AssemblyFileVersion("1.0.7.9")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
8 changes: 4 additions & 4 deletions SitePack/SiteATFBooru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void Login(IWebProxy proxy)
token = hdoc.DocumentNode.SelectSingleNode("//meta[@name='csrf-token']").Attributes["content"].Value;
if (token.Length < 9)
{
SiteManager.echoErrLog(SiteName, "自动登录失败[1] ");
SiteManager.EchoErrLog(SiteName, "自动登录失败[1] ");
return;
}

Expand All @@ -111,7 +111,7 @@ private void Login(IWebProxy proxy)

if (!pagedata.Contains("setUserId"))
{
SiteManager.echoErrLog(SiteName, $"{SiteName} 自动登录失败");
SiteManager.EchoErrLog(SiteName, $"{SiteName} 自动登录失败");
}
else
{
Expand All @@ -123,7 +123,7 @@ private void Login(IWebProxy proxy)
}
catch (Exception e)
{
SiteManager.echoErrLog(SiteName, e, e.Message.Contains("IP") ? e.Message : "可能无法连接到服务器");
SiteManager.EchoErrLog(SiteName, e, e.Message.Contains("IP") ? e.Message : "可能无法连接到服务器");
}
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ private bool IELogin()
}
else if (startLogin)
{
SiteManager.echoErrLog(SiteName, "用户未登录或登录失败 ");
SiteManager.EchoErrLog(SiteName, "用户未登录或登录失败 ");
}

return result;
Expand Down
1 change: 1 addition & 0 deletions SitePack/SitePack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
Expand Down
Loading

0 comments on commit 91f3c0f

Please sign in to comment.