Ejemplo n.º 1
0
        public async Task <string> ReadAppVersion(string folder)
        {
            var strVersion = string.Empty;

            try
            {
                var versionFile = await s3ArtifactHelper.DownloadFile($"{folder}version.txt");

                using (StreamReader sr = new StreamReader(versionFile))
                {
                    strVersion = sr.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Read version.txt file from {folder} failed. Error message: {ex.Message}");
            }
            strVersion = Regex.Replace(strVersion, @"\t|\n|\r", "");
            return(strVersion.Trim());
        }
Ejemplo n.º 2
0
        private async void downloadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var      s3BucketName = GetS3BucketName(_currentNode);
                S3Helper s3Helper     = new S3Helper(
                    GlobalVariables.Enviroment,
                    GlobalVariables.Region,
                    GlobalVariables.Color,
                    s3BucketName
                    );
                if (dgViewS3Files.SelectedRows.Count > 0)
                {
                    DialogResult result = folderBrowserDialog1.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        string folder = folderBrowserDialog1.SelectedPath;
                        foreach (var row in dgViewS3Files.SelectedRows)
                        {
                            var    s3FilePath = ((DataGridViewRow)row).Cells[0].Value.ToString();
                            string fileName   = Path.Combine(folder, Path.GetFileName(s3FilePath));
                            var    stream     = await s3Helper.DownloadFile(s3FilePath);

                            using (Stream file = File.Create(fileName))
                            {
                                CopyStream(stream, file);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }