Exemplo n.º 1
0
 public ActionResult Create(IFormFile torrentFile)
 {
     try
     {
         string name = torrentFile.FileName;
         using (var stream = new FileStream($"{Final.FilePath_DownLoad}{name}", FileMode.Create))
         {
             torrentFile.CopyTo(stream);
             stream.Close();
         }
         Task.Run(() =>
         {
             FileDownLoad downLoad = new FileDownLoad
             {
                 SavePath    = Final.FilePath_DownLoad,
                 ToolPath    = @"C:\Users\myweb\Downloads\aria2-1.34.0-win-64bit-build1\aria2-1.34.0-win-64bit-build1\aria2c.exe",
                 TorrentFile = $"{Final.FilePath_DownLoad}{name}"
             };
             downLoad.Start();
         });
         //返回首页
         return(RedirectToRoute("Index"));
     }
     catch
     {
         return(Json("下载错误,请重新上传文件"));
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// 登录之后初始化
    /// </summary>
    public void AfterLoginInit()
    {
        if (isAfterLoginInit)
        {
            if (isLoginSucceed)
            {
                SaveLoginInfo(IP, Port, info);
                CommunicationObject.Instance.GetUnitySetting();

                //OpenSignalR(IP, Port);
                //Invoke("AfterLoginSuccessfully", 2f);//延迟两秒可以使(正在登录...)动画更流畅一点。
                CheckVersion((value, isVersionLower, info) =>
                {
                    if (value)
                    {
                        LoginSuccess();
                    }
                    else
                    {
                        DianChangLogin.Instance.CloseLoginProcess();
                        if (info != null)
                        {
                            string msg           = GetVersionMsg(isVersionLower, info.Version, SystemSettingHelper.versionSetting.VersionNumber);
                            string sureBtnName   = isVersionLower? "下载安装":"继续登录";
                            string cancelBtnName = isVersionLower ? "直接登录" : "取消登录";
                            UGUIMessageBox.Show(msg, sureBtnName, cancelBtnName, () =>
                            {
                                if (isVersionLower)
                                {
                                    CommunicationObject.Instance.DebugLog("更新版本");
                                    if (downLoad == null)
                                    {
                                        downLoad = FileDownLoad.Instance;
                                        downLoad.ShowProgress += DownLoad_ShowProgress;
                                    }
                                    if (downLoad)
                                    {
                                        Debug.Log("download:" + info.LocationURL);
                                        CommunicationObject.Instance.DebugLog("download:" + info.LocationURL);
                                        if (HttpDownloadCheck.Instance)
                                        {
                                            HttpDownloadCheck.Instance.EnableCheck = true;
                                        }
                                        downLoad.Download(info.LocationURL);
                                    }
                                    else
                                    {
                                        Debug.LogError("downLoad == null");
                                        CommunicationObject.Instance.DebugLog("downLoad == null");
                                    }
                                }
                                else
                                {
                                    DianChangLogin.Instance.LoginProcess();
                                    LoginSuccess();
                                }
                            }, () =>
                            {
                                if (isVersionLower)
                                {
                                    DianChangLogin.Instance.LoginProcess();
                                    LoginSuccess();
                                }
                            }, () =>
                            {
                                Debug.Log("Cancel update...");
                            });
                        }
                        else
                        {
                            UGUIMessageBox.Show("版本号获取失败!");
                        }
                    }
                });
            }
            else
            {
                AfterLoginFailed();
            }
            isAfterLoginInit = false;
        }
    }