Пример #1
0
        public async Task TestWebGenerationConnection(FtpService ftpService)
        {
            try
            {
                string path = Model.WebGenerationModel.Path;
                if (Model.WebGenerationModel.FtpModeEnabled)
                {
                    string host     = Model.WebGenerationModel.Server;
                    int    port     = Model.WebGenerationModel.Port;
                    string username = Model.WebGenerationModel.Username;
                    string password = Model.WebGenerationModel.Password;
                    var    ftpMode  = Model.WebGenerationModel.FtpMode;

                    await Task.Run(() => ftpService.CheckConnection(host, port, path, username, password, ftpMode)).ConfigureAwait(false);
                }
                else
                {
                    if (!Directory.Exists(path))
                    {
                        throw new DirectoryNotFoundException($"{path} does not exist.");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                throw;
            }
        }