Esempio n. 1
0
 private void GetMaxConcDownloads()
 {
     if (!isCycle)
     {
         return;
     }
     if (!maxConcDowns.HasValue || maxConcDowns.Value == 0)
     {
         int          iMaxDownloads = 5;//默认值5
         Aria2cOption globalOption  = GetGlobalOption();
         if (globalOption != null)
         {
             string max_downloads = globalOption.Option["max-concurrent-downloads"];
             if (!string.IsNullOrEmpty(max_downloads))
             {
                 iMaxDownloads = int.Parse(max_downloads);
             }
         }
         maxConcDowns = iMaxDownloads;
     }
 }
        /// <summary>
        /// 设置全局下载设置
        /// </summary>
        /// <param name="option">设置信息</param>
        /// <returns>成功返回true, 失败返回fale</returns>
        public static bool ChangeGlobalOption(Aria2cOption option)
        {
            string ok = aria2c.ChangeGlobalOption(Aria2cRpcSecret, option.ToXmlRpcStruct());

            return(IsOK(ok));
        }
        /// <summary>
        /// 下载任务设置
        /// </summary>
        /// <param name="gid">任务标识符</param>
        /// <param name="options">设置参数</param>
        /// <returns>成功返回true, 失败返回fale</returns>
        public static bool ChangeOption(string gid, Aria2cOption option)
        {
            string ok = aria2c.ChangeOption(gid, option.ToXmlRpcStruct());

            return(IsOK(ok));
        }
 /// <summary>
 /// 获取全局下载设置
 /// </summary>
 /// <param name="option">设置信息</param>
 /// <returns>成功返回任务设置, 失败返回空</returns>
 public static Aria2cOption GetGlobalOption()
 {
     XmlRpcStruct xmlstruct = aria2c.GetGlobalOption();
     Aria2cOption option = new Aria2cOption(xmlstruct);
     return option;
 }