|
@@ -229,15 +229,31 @@ namespace WeChatCore.Entity
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
LogWriter.Write("设置头像发生异常" + DisplayNameDef, LogPathDefine.ExceptionLogPath);
|
|
LogWriter.Write("设置头像发生异常" + DisplayNameDef, LogPathDefine.ExceptionLogPath);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ File.SetAttributes(HeadUrlDef, FileAttributes.Normal);
|
|
|
|
+ File.Delete(HeadUrlDef);
|
|
|
|
+ DownloadImage();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ LogWriter.Write("设置头像发生异常" + e.Message, LogPathDefine.ExceptionLogPath);
|
|
|
|
+ }
|
|
return new BitmapImage(new Uri("pack://application:,,,/WeChatCore;component/Resource/DefultHeader.png"));
|
|
return new BitmapImage(new Uri("pack://application:,,,/WeChatCore;component/Resource/DefultHeader.png"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public void DownloadImage()
|
|
public void DownloadImage()
|
|
{
|
|
{
|
|
|
|
+ string uuid = MethodsHelper.HeadImageSaveFile(DirectoryDefine.HeaderImagePath, DisplayNameDef);
|
|
|
|
+ if (File.Exists(DirectoryDefine.HeaderImagePath + "\\" + uuid + ".jpg"))
|
|
|
|
+ {
|
|
|
|
+ HeadUrlDef = Environment.CurrentDirectory + "\\" + DirectoryDefine.HeaderImagePath + "\\" + uuid + ".jpg";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if (string.IsNullOrWhiteSpace(HeadUrlDef))
|
|
if (string.IsNullOrWhiteSpace(HeadUrlDef))
|
|
{
|
|
{
|
|
- string uuid = MethodsHelper.MsgSaveFile(DirectoryDefine.HeaderImagePath);
|
|
|
|
|
|
+
|
|
HttpHelper.HttpMethods.GetFile(UrlDefine.RootUrl + HeadImgUrl, Environment.CurrentDirectory + "\\" + DirectoryDefine.HeaderImagePath + "\\" + uuid + ".jpg", CommonDefine.Cookies);
|
|
HttpHelper.HttpMethods.GetFile(UrlDefine.RootUrl + HeadImgUrl, Environment.CurrentDirectory + "\\" + DirectoryDefine.HeaderImagePath + "\\" + uuid + ".jpg", CommonDefine.Cookies);
|
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
{
|