public TaskContainer(GameProviderOperationsBase provider, string gameName, NetworkManager client, string selectedComputer, AsyncPack asyncPack)
 {
     Provider         = provider;
     GameName         = gameName;
     Client           = client;
     SelectedComputer = selectedComputer;
     AsyncPack        = asyncPack;
 }
Exemplo n.º 2
0
        public override void RetrieveGame(string gameName, NetworkManager clienta,
                                          string selectedComputer, AsyncPack asyncPack)
        {
            string remotePath = clienta.GetDirFromGameNameSteam(gameName);

            LogManager.GetCurrentClassLogger().Warn(remotePath);
            FtpManager.GetInstance()
            .RetrieveGame(SettingsManager.GetInstance().GetDefaultSteamLibrary(),
                          remotePath, selectedComputer, asyncPack);
        }
Exemplo n.º 3
0
        public void RetrieveGame(string destGamePath, string sourceGamePath,
                                 string targetIpServer, AsyncPack asyncPack)
        {
            // create an FTP client
            _client = new FtpClient(targetIpServer)
            {
                Port        = FtpPort,
                Credentials = new NetworkCredential("anonymous", "*****@*****.**")
            };

            // if you don't specify login credentials, we use the "anonymous" user account

            // begin connecting to the server
            _client.Connect();

            // upload a file and retry 3 times before giving up
            _client.RetryAttempts = 3;

            string sourcePath = _client.GetWorkingDirectory() + sourceGamePath;

            // check if a folder exists
            if (_client.DirectoryExists(sourcePath))
            {
                long totalSize = 0;
                List <FtpListItem> filesToDownloadList = new List <FtpListItem>();
                BuildListOfFilesToDownload(_client, sourcePath, filesToDownloadList, ref totalSize);
                LogManager.GetCurrentClassLogger().Info("Size to be transfered: " + totalSize);

                long alreadyDownloaded = 0;
                // download the files without any sort of verification and error handling YET!
                foreach (var ftpListItem in filesToDownloadList)
                {
                    // TODO: Revisit this code to show some statistics
                    try
                    {
                        _client.DownloadFile(destGamePath + ftpListItem.FullName,
                                             ftpListItem.FullName);
                    }
                    catch (IOException e)
                    {
                        LogManager.GetCurrentClassLogger().Error(e.Message);
                    }
                    alreadyDownloaded += ftpListItem.Size;
                    asyncPack.Window.Dispatcher.Invoke(asyncPack.ToExecute,
                                                       Convert.ToDouble(alreadyDownloaded) / Convert.ToDouble(totalSize) * 100);
                }
            }
            else
            {
                //  throw new DirectoryNotFoundException();
            }

            // disconnect! good bye!
            _client.Disconnect();
        }
Exemplo n.º 4
0
 public abstract void RetrieveGame(string gameName, NetworkManager clienta, string selectedComputer, AsyncPack asyncPack);
 public void QueueJob(GameProviderOperationsBase provider, string gameName, NetworkManager client,
                      string selectedComputer, AsyncPack asyncPack)
 {
     _queue.Enqueue(new TaskContainer(provider, gameName, client, selectedComputer, asyncPack));
     _autoResetEvent.Set();
 }
        public override void RetrieveGame(string gameName, NetworkManager clienta, string selectedComputer, AsyncPack asyncPack)
        {
            string remotePath = clienta.GetDirFromGameNameBlizzard(gameName);

            Console.WriteLine(remotePath);
            FtpManager.GetInstance().RetrieveGame(SettingsManager.GetInstance().GetDefaultBlizzardPath(),
                                                  remotePath, selectedComputer, asyncPack);
        }