| | |
| | | } |
| | | catch (Exception ex)
|
| | | {
|
| | | DesignDebug.LogError(ex.Message); |
| | | DebugEx.LogError(ex.Message); |
| | | ret = false; |
| | | } |
| | | #endif |
| | |
| | | } |
| | | catch (Exception ex)
|
| | | { |
| | | DesignDebug.LogWarning("ERROR: " + ex); |
| | | DebugEx.LogWarning("ERROR: " + ex); |
| | | mHadError = true; |
| | | } |
| | | finally
|
| | |
| | | } |
| | | catch (WebException webEx)
|
| | | { |
| | | DesignDebug.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); |
| | | DesignDebug.LogWarning("ERROR: " + webEx); |
| | | DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); |
| | | DebugEx.LogWarning("ERROR: " + webEx); |
| | | mHadError = true; |
| | | gDownloadIsRunningCount--; |
| | | done = true; |
| | |
| | | } |
| | | catch (System.Exception e)
|
| | | { |
| | | DesignDebug.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); |
| | | DesignDebug.LogWarning("ERROR: " + e); |
| | | DebugEx.LogWarning("<color=red>Request File Head ERROR: " + mRemoteFile + "</color>"); |
| | | DebugEx.LogWarning("ERROR: " + e); |
| | | mHadError = true; |
| | | gDownloadIsRunningCount--; |
| | | done = true; |
| | |
| | | float dur = System.Environment.TickCount - tick1; |
| | | if (dur > timeOut)
|
| | | { |
| | | DesignDebug.LogWarningFormat("获取远程文件{0} 信息超时!", mRemoteFile); |
| | | DebugEx.LogWarningFormat("获取远程文件{0} 信息超时!", mRemoteFile); |
| | | mHadError = true; |
| | | break; |
| | | } |
| | |
| | | } |
| | | if (mHadError)
|
| | | { |
| | | DesignDebug.LogWarningFormat("获取远程文件{0} 信息失败!", mRemoteFile); |
| | | DebugEx.LogWarningFormat("获取远程文件{0} 信息失败!", mRemoteFile); |
| | | headRequest.Abort(); |
| | | done = true; |
| | | gDownloadIsRunningCount--; |
| | |
| | | } |
| | | else if (localFileSize > mRemoteFileSize || outDated)
|
| | | { |
| | | if (!outDated) DesignDebug.LogWarning("Local file is larger than remote file, but not outdated. PANIC!"); |
| | | if (!outDated) DebugEx.LogWarning("Local file is larger than remote file, but not outdated. PANIC!"); |
| | | if (outDated)
|
| | | { |
| | | DesignDebug.LogWarning(mLocalFileTemp + " Local file is outdated, deleting"); |
| | | DebugEx.LogWarning(mLocalFileTemp + " Local file is outdated, deleting"); |
| | | } |
| | | try
|
| | | { |
| | |
| | | } |
| | | catch (System.Exception e)
|
| | | { |
| | | DesignDebug.LogWarning("<color=red>Could not delete local file</color>"); |
| | | DesignDebug.LogError(e); |
| | | DebugEx.LogWarning("<color=red>Could not delete local file</color>"); |
| | | DebugEx.LogError(e); |
| | | } |
| | | |
| | | while (File.Exists(mLocalFileTemp))
|
| | |
| | | } |
| | | catch (System.Exception e)
|
| | | { |
| | | DesignDebug.LogWarning("<color=red>Could not delete local file</color>"); |
| | | DesignDebug.LogWarning(e); |
| | | DebugEx.LogWarning("<color=red>Could not delete local file</color>"); |
| | | DebugEx.LogWarning(e); |
| | | } |
| | | while (File.Exists(localFile))
|
| | | {
|
| | |
| | | } |
| | | catch (System.Exception ex)
|
| | | { |
| | | DesignDebug.LogWarning("BeginGetResponse exception: " + ex.Message); |
| | | DesignDebug.LogWarning(ex); |
| | | DebugEx.LogWarning("BeginGetResponse exception: " + ex.Message); |
| | | DebugEx.LogWarning(ex); |
| | | if (fileRequest != null)
|
| | | { |
| | | fileRequest.Abort(); |
| | |
| | | float dur = System.Environment.TickCount - tick1; |
| | | if (dur > timeOut)
|
| | | { |
| | | DesignDebug.LogWarningFormat("下载远程文件{0} 超时!", mRemoteFile); |
| | | DebugEx.LogWarningFormat("下载远程文件{0} 超时!", mRemoteFile); |
| | | mHadError = true; |
| | | break; |
| | | } |
| | |
| | | |
| | | if (mHadError)
|
| | | { |
| | | DesignDebug.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); |
| | | DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); |
| | | if (fileRequest != null)
|
| | | { |
| | | fileRequest.Abort(); |
| | |
| | | } |
| | | catch (Exception ex)
|
| | | { |
| | | DesignDebug.LogWarning("<color=red>ERROR: " + mRemoteFile + "</color>"); |
| | | DesignDebug.LogWarning(ex); |
| | | DebugEx.LogWarning("<color=red>ERROR: " + mRemoteFile + "</color>"); |
| | | DebugEx.LogWarning(ex); |
| | | if (inStream != null)
|
| | | { |
| | | inStream.Close(); |
| | |
| | | if (dura > timeOut)
|
| | | { |
| | | fileWriteState = FileWriteState.Timeout; |
| | | DesignDebug.LogWarningFormat("[RemoteFile] 远程文件{0} 读取超时{1}!", mRemoteFile, dura); |
| | | DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 读取超时{1}!", mRemoteFile, dura); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | if (fileWriteState == FileWriteState.Error || fileWriteState == FileWriteState.Timeout)
|
| | | { |
| | | DesignDebug.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); |
| | | DebugEx.LogWarningFormat("[RemoteFile] 远程文件{0} 下载失败! ", localFile); |
| | | if (fileResponse != null)
|
| | | { |
| | | fileResponse.Close(); |
| | |
| | | if (localTempFileInfo.Length != mRemoteFileSize && mRemoteFileSize != 0L)
|
| | | { |
| | | mHadError = true; |
| | | DesignDebug.LogError(string.Format(localFile + " 下载完成后, 但是大小{0} 和远程文件不一致 {1}", localTempFileInfo.Length, mRemoteFileSize)); |
| | | DebugEx.LogError(string.Format(localFile + " 下载完成后, 但是大小{0} 和远程文件不一致 {1}", localTempFileInfo.Length, mRemoteFileSize)); |
| | | } |
| | | else
|
| | | { //大小一致 |
| | |
| | | } |
| | | catch (Exception ex)
|
| | | { |
| | | DesignDebug.LogError(ex); |
| | | DebugEx.LogError(ex); |
| | | mHadError = true; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (!processErroring)
|
| | | { |
| | | DesignDebug.LogWarning(ex); |
| | | DesignDebug.LogWarning("ReadDataCallback 异常信息: " + ex.Message); |
| | | DebugEx.LogWarning(ex); |
| | | DebugEx.LogWarning("ReadDataCallback 异常信息: " + ex.Message); |
| | | } |
| | | if (fs != null)
|
| | | { |
| | |
| | | { |
| | | if (result == null)
|
| | | { |
| | | DesignDebug.LogError("Asynch result is null!"); |
| | | DebugEx.LogError("Asynch result is null!"); |
| | | mHadError = true; |
| | | } |
| | | |
| | | HttpWebRequest webRequest = (HttpWebRequest)result.AsyncState; |
| | | if (webRequest == null)
|
| | | { |
| | | DesignDebug.LogError("Could not cast to web request"); |
| | | DebugEx.LogError("Could not cast to web request"); |
| | | mHadError = true; |
| | | } |
| | | |
| | | fileResponse = webRequest.EndGetResponse(result) as HttpWebResponse; |
| | | if (fileResponse == null)
|
| | | { |
| | | DesignDebug.LogError("Asynch response is null!"); |
| | | DebugEx.LogError("Asynch response is null!"); |
| | | mHadError = true; |
| | | } |
| | | } |
| | | catch (Exception ex)
|
| | | { |
| | | mHadError = true; |
| | | DesignDebug.LogWarning(ex); |
| | | DesignDebug.LogWarning("[RemoteFile] AsynchCallback 异常: " + ex.Message); |
| | | DebugEx.LogWarning(ex); |
| | | DebugEx.LogWarning("[RemoteFile] AsynchCallback 异常: " + ex.Message); |
| | | } |
| | | } |
| | | #endif |