Пример #1
0
        private List <SA_S3Object> RefreshS3BucketObjectList(string s3BucketName)
        {
            S3Helper s3Helper = new S3Helper(
                GlobalVariables.Enviroment,
                GlobalVariables.Region,
                GlobalVariables.Color,
                s3BucketName
                );
            var s3ObjList = s3Helper.GetBucketFileList();

            _envAwsS3ObjectList[s3BucketName].Clear();
            _envAwsS3ObjectList[s3BucketName].AddRange(s3ObjList);
            return(s3ObjList);
        }
Пример #2
0
        public async Task <List <string> > GeneratePreviewData()
        {
            var ret = new List <string>();

            try
            {
                await Task.Run(() =>
                {
                    var sourceFiles = s3ArtifactHelper.GetBucketFileList(appsSourceFolder);
                    ret.Add($"ZIP files to be delivered on {GlobalVariables.Enviroment.ToUpper()} ({s3ArtifactHelper.BucketName}):{Environment.NewLine}");
                    var nameLimit        = 60;
                    var countFiles       = 0;
                    var countLambdaFiles = 0;
                    foreach (var file in sourceFiles)
                    {
                        if (file.FullName.ToLower().IndexOf(".zip") < 0)
                        {
                            continue;
                        }
                        var fileName = Path.GetFileName(file.FullName);
                        var row      = fileName;
                        int spaceNum = nameLimit - fileName.Length;
                        while (spaceNum > 0)
                        {
                            row += " ";
                            spaceNum--;
                        }
                        ret.Add($"{row}\t{file.LastModified}\t{file.Size}{Environment.NewLine}");
                        countFiles++;
                        if (file.FullName.ToLower().IndexOf("lambda") >= 0)
                        {
                            countLambdaFiles++;
                        }
                    }
                    ret.Add($"{Environment.NewLine}Find {countFiles} files, including {countLambdaFiles} lambda function files.{Environment.NewLine}");
                });

                ret.Add($"{Environment.NewLine}New version:{Environment.NewLine}");
                var version = await ReadAppVersion(appsSourceFolder);

                ret.Add($"{version}{Environment.NewLine}");

                try
                {
                    ret.Add($"Current version:{Environment.NewLine}");
                    version = await ReadAppVersion(appsDestinationFolder);

                    ret.Add($"{version}{Environment.NewLine}");
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("The specified key does not exist."))
                    {
                        ret.Add("'version.txt' does not exist in detination folder");
                    }
                    else
                    {
                        throw ex;
                    }
                }
                return(ret);
            }
            catch (Exception ex)
            {
                ret.Add($"Error was found from the preview. Please check.{Environment.NewLine}");
                ret.Add($"Error message: {ex.Message}{Environment.NewLine}");
                ret.Add($"Stack trace: {ex.StackTrace}{Environment.NewLine}");
                return(ret);
            }
        }