修復iReaper
iReaper是下載WebCast的利器,可惜作者早已不再維護,相關更新地址也被關閉,現在使用,就會發現無法獲取課程列表.
還好,這個軟件是開源軟件.使用者可以下載代碼自行維護,且課程列表是由微軟發布的,只要軟件設計合理,理論上存在恢復的可能.經過一段時間的研究,我終于成功修復,現將方法分享如下.
1.從官方下載源碼并解壓.下載地址
2.打開位于Client-1.2R2目錄下的解決方案后,取消源代碼管理,取消所有項目的數字簽名.此時編譯解決方法,應是能通過的.
3.在iReaper.Download項目Initializer文件夾CheckInfoXMLTask文件CheckInfoXMLTask類內,增加如下方法
private void ConditionalGetXml(DateTime LocalDate) { string path = "http://www.microsoft.com/china/msdn/webcast/sdk/info.xml"; //create HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path); request.IfModifiedSince = LocalDate; request.Method = WebRequestMethods.Http.Get; //try to get response try { response = (HttpWebResponse)request.GetResponse(); } catch (Exception e) //For some reason the HttpWebResponse class throws an exception on 3xx responses { WebException we = e as WebException; if ( we != null && we.Response != null) { response = (HttpWebResponse)we.Response; } else { throw; } } //if responseCode is 304,which means no need to update. if (response.StatusCode == HttpStatusCode.NotModified)//check if not modified { response.Close(); this.resultObj = "NotModified"; return; } //if means there is something mistake. else if (response.ContentLength == -1) { throw new ApplicationException(StringResources.ERROR_GetInfoXML + response.StatusDescription + "(" + response.StatusCode.ToString() + ")"); } else if (response.ContentType == "text/xml") //the index.zip is updated since last time { File.Delete(InfoXmlPath); //set message this.InitManager.SetMessage(StringResources.BeginDownload + DataFileName); //get last modified date of DateTime LastModified = response.LastModified; //get the network stream Stream netStream = response.GetResponseStream(); //create the file local stream try { fsStream = new FileStream(InfoXmlPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None); //set the creation time as minValue in case the download is interrputed. //download long length = response.ContentLength; byte[] buffer = new byte[1024]; fsStream.SetLength(response.ContentLength); int iRead = 0; while (fsStream.Position < length) { iRead = netStream.Read(buffer, 0, 1024); fsStream.Write(buffer, 0, iRead); //set message int percentage = (int)(fsStream.Position * 100 / length); this.InitManager.SetMessage(StringResources.Downloading + percentage.ToString() + "%"); } fsStream.Close(); } catch { //close the stream to set the last write time fsStream.Close(); throw; } finally { netStream.Close(); } File.SetLastWriteTime(InfoXmlPath, LastModified); //set message this.resultObj = "Modified"; // Extract this zip file to l } }
將JobContent方法內的
this.ConditionalGet(localDate);
修改為
this.ConditionalGetXml(localDate);
4.iReaper項目Initializer文件夾WelcomePanel.cs文件WebcomePanel類InitTask方法內,注釋第37到第39行,即檢查新版本數據,如下
//檢查新版本數據 //task = new CheckNewVersionTask(); //task.InitManager = this.initalizer1; //task.Invoke();
5.iReaper.Download項目CourseData文件夾CourseXmlParser.cs文件CourseXmlParser類LoadXml方法內,注釋if語句內代碼,如下
//工廠 public static void LoadXml() { CourseXmlParser parser = new InfoXMLParser(); parser.ParseCourseXml(); if (OnCourseAddedFinished != null) { //OnCourseAddedFinished(parser, EventArgs.Empty); } }
此時應能打開程序并成功加載課程了,但要想實現下載,則還需繼續修改
6.AppServices項目Properties文件夾Settings.settings文件內,將DownloadBaseUrl值由
http://www.daiyue.info/download.aspx
修改為
http://www.microsoft.com/china/msdn/webcast/download.aspx
7.iReaper.Download項目Running文件夾CourseFileWorker.cs文件CourseFileWorker類onFinished方法,注釋第542行代碼,如下
private void onFinished() { this.cData.LifetimeStatue = LifetimePosition.DownloadProcessed; this.cData.RunState = RunningStatue.Finished; //this.RegisterForCounter(); if (OnFileDownloaded != null) { OnFileDownloaded(this.cData); } }
OK,現在就請愉快的使用并下載吧.
上面的修改,其實是禁用了軟件版本更新檢查,禁用了查詢并修改了下載地址.在實際使用中會發現課程列表不是最新的,這其實是微軟更新不及時導致的,與軟件無關.
如果你需要下載最新的課程,推薦使用下面兩個網站.
最后吐槽兩句,現在微軟是不是不重視WebCast了,記得以前,特別是08年以前,每當微軟推出一個新技術或版本升級時,都會及時發布最新的課程進行推廣,比如.Net 3.0就有好幾個課程.怎么現在我最想知道的Asp.Net Mvc 4, .Net 4.0/4.5, C# 5.0, Wcf 4.0, Wwf 4.0, 異步編程等,一個合適的也沒有呢?
參考

浙公網安備 33010602011771號