Exemplo n.º 1
0
        public void TestMethod1()
        {
            var parser = new CFLogParser();
            var models = parser.Parse(@"C:\tools\cflogget\temp\commerble-corp\logfile.log");

            foreach (var p in typeof(CFLogModel).GetProperties())
            {
                var column = p.GetCustomAttributes(typeof(ColumnAttribute), false).FirstOrDefault() as ColumnAttribute;
                if (column == null)
                {
                    continue;
                }

                if (p.PropertyType != typeof(string))
                {
                    continue;
                }

                var maxValue  = "";
                var maxLength = 0;
                foreach (var m in models)
                {
                    var value = (string)p.GetValue(m) ?? "";
                    if (value.Length > maxLength)
                    {
                        maxLength = value.Length;
                        maxValue  = value;
                    }
                }
                Console.WriteLine($"** {p.Name}({column.TypeName}): {maxLength}, {maxValue}\n");
            }
        }
Exemplo n.º 2
0
        public async Task DropObject()
        {
            var bucketName = BucketName;
            var key        = $"{RootDirectory}/E3ML3BHZTNV1SW.2018-10-10-01.20e2f9d0.gz";
            var gzFilePath = $"temp/{key}";

            var accessor = new S3Accessor(ProfileName);
            await accessor.DropObject(bucketName, key, gzFilePath);

            var logFilePath = gzFilePath.Replace(".gz", ".log");
            await accessor.Decompress(gzFilePath, logFilePath);

            var parser = new CFLogParser();
            var models = parser.Parse(logFilePath);

            var tableName = $"table_{DateTime.Now:yyyyMMddHHmmss}";
            var database  = new DatabaseManager("Data Source=.\\sqlexpress;Initial Catalog=cflogget;Integrated Security=True;Connection Timeout=10");

            database.CreateTable(tableName);
            database.Insert(tableName, models);

            TestHelper.WriteConsole(models);
        }