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,现在就请愉快的使用并下载吧.

      上面的修改,其实是禁用了软件版本更新检查,禁用了查询并修改了下载地址.在实际使用中会发现课程列表不是最新的,这其实是微软更新不及时导致的,与软件无关.

      如果你需要下载最新的课程,推荐使用下面两个网站.

      iReaper For Web

      WebCast

      最后吐槽两句,现在微软是不是不重视WebCast了,记得以前,特别是08年以前,每当微软推出一个新技术或版本升级时,都会及时发布最新的课程进行推广,比如.Net 3.0就有好几个课程.怎么现在我最想知道的Asp.Net Mvc 4, .Net 4.0/4.5, C# 5.0, Wcf 4.0, Wwf 4.0, 异步编程等,一个合适的也没有呢?

 

      参考

      Webcast的课程信息接口 为什么不更新了?

转载于:https://www.cnblogs.com/ljzforever/archive/2013/05/13/3075166.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐