示例#1
0
        public void ParsePartitionKey()
        {
            var key1 = new DateKey(new DateTime(year: 2016, month: 4, day: 1).ToUniversalTime());
            var key2 = DateKey.Parse(key1.Key);

            Assert.Equal(key1, key2);
        }
示例#2
0
文件: Program.cs 项目: karelz/jenkins
        private static async Task CheckUnknown()
        {
            var account   = GetStorageAccount();
            var buildUtil = new BuildUtil(account);
            var date      = DateTimeOffset.UtcNow - TimeSpan.FromDays(1);
            var populator = new BuildTablePopulator(account.CreateCloudTableClient(), CreateClient(), Console.Out);
            var table     = account.CreateCloudTableClient().GetTableReference(AzureConstants.TableNames.BuildResultDate);

            foreach (var entity in buildUtil.GetBuildResultsByKindName(date, BuildResultClassification.Unknown.Name, AzureUtil.ViewNameAll))
            {
                var entityDate = DateKey.Parse(entity.PartitionKey);
                var before     = new DateKey(entityDate.Date.AddDays(-1));
                var after      = new DateKey(entityDate.Date.AddDays(1));

                var op     = TableOperation.Retrieve(before.Key, entity.RowKey);
                var result = await table.ExecuteAsync(op);

                if (result.Result != null)
                {
                    await table.ExecuteAsync(TableOperation.Delete(entity));

                    continue;
                }

                op     = TableOperation.Retrieve(after.Key, entity.RowKey);
                result = await table.ExecuteAsync(op);

                if (result.Result != null)
                {
                    await table.ExecuteAsync(TableOperation.Delete(entity));

                    continue;
                }
            }
        }
示例#3
0
文件: Program.cs 项目: karelz/jenkins
        private static async Task Random()
        {
            /*
             * var boundBuildId = BoundBuildId.Parse("https://dotnet-ci.cloudapp.net/job/dotnet_corefx/job/master/job/fedora23_debug_tst/134/");
             * var buildId = boundBuildId.BuildId;
             * var client = CreateClient(uri: boundBuildId.HostUri, auth: true);
             * var buildInfo = await client.GetBuildInfoAsync(buildId);
             * var buildResult = await client.GetBuildResultAsync(buildInfo);
             * var test = await client.GetFailedTestCasesAsync(buildId);
             * var prInfo = await client.GetPullRequestInfoAsync(buildId);
             */
            var testboundBuildId = BoundBuildId.Parse("https://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/release_1.0.0/job/x64_release_rhel7.2_pri1_flow/30/");
            var testbuildId      = testboundBuildId.BuildId;
            var client           = CreateClient(uri: testboundBuildId.HostUri, auth: true);
            var elapsedTimeObj   = client.GetBuildInfo(testbuildId).Duration;

            Console.WriteLine($"\tET: {elapsedTimeObj.TotalMilliseconds}");

            var account = GetStorageAccount();
            var dateKey = new DateKey(DateTimeOffset.UtcNow - TimeSpan.FromDays(1));
            var table   = account.CreateCloudTableClient().GetTableReference(AzureConstants.TableNames.BuildResultDate);
            var query   = new TableQuery <BuildResultEntity>()
                          .Where(FilterUtil
                                 .Column(ColumnNames.PartitionKey, dateKey, ColumnOperator.GreaterThanOrEqual)
                                 .And(FilterUtil.Column("MachineName", "Azure0602081822")));
            var all = await AzureUtil.QueryAsync(table, query);

            foreach (var entity in all)
            {
                var boundBuildId = new BoundBuildId(SharedConstants.DotnetJenkinsUri.Host, entity.BuildId);
                Console.WriteLine(boundBuildId.Uri);
            }
        }
示例#4
0
文件: Program.cs 项目: karelz/jenkins
        private static async Task ViewNameMigration()
        {
            var account          = GetStorageAccount();
            var client           = account.CreateCloudTableClient();
            var viewNameTable    = client.GetTableReference(AzureConstants.TableNames.ViewNameDate);
            var buildResultTable = client.GetTableReference(AzureConstants.TableNames.BuildResultDate);
            var startDate        = DateTimeOffset.UtcNow - TimeSpan.FromDays(14);

            var query = new TableQuery <DynamicTableEntity>()
                        .Where(FilterUtil.SinceDate(ColumnNames.PartitionKey, startDate))
                        .Select(new[] { "PartitionKey", nameof(BuildResultEntity.ViewName) });
            var all = await AzureUtil.QueryAsync(buildResultTable, query);

            var set  = new HashSet <Tuple <DateKey, string> >();
            var list = new List <ViewNameEntity>();

            foreach (var entity in all)
            {
                var dateKey  = DateKey.Parse(entity.PartitionKey);
                var viewName = entity.Properties[nameof(BuildResultEntity.ViewName)].StringValue;
                var tuple    = Tuple.Create(dateKey, viewName);
                if (set.Add(tuple))
                {
                    list.Add(new ViewNameEntity(dateKey, viewName));
                }
            }

            await AzureUtil.InsertBatchUnordered(viewNameTable, list);
        }
示例#5
0
        private static async Task MigrateDateKeyCore <T>(string tableName)
            where T : ITableEntity, new()
        {
            Console.WriteLine($"Processing {tableName}");

            var account = GetStorageAccount();
            var table   = account.CreateCloudTableClient().GetTableReference(tableName);

            var startKey = new DateKey(DateKey.StartDate);
            var endKey   = new DateKey(DateTimeOffset.UtcNow);
            var query    = TableQueryUtil.And(
                TableQueryUtil.PartitionKey(startKey.Key, ColumnOperator.GreaterThanOrEqual),
                TableQueryUtil.PartitionKey(endKey.Key, ColumnOperator.LessThanOrEqual));
            var list = await AzureUtil.QueryAsync <T>(table, query);

            Console.WriteLine($"Processing {list.Count} entities");
            var deleteList = new List <EntityKey>();

            foreach (var entity in list)
            {
                deleteList.Add(entity.GetEntityKey());

                var dateKey     = DateKey.Parse(entity.PartitionKey);
                var dateTimeKey = new DateTimeKey(dateKey.Date, DateTimeKeyFlags.Date);
                entity.PartitionKey = dateTimeKey.Key;
            }

            Console.WriteLine("Writing new values");
            await AzureUtil.InsertBatchUnordered(table, list);

            Console.WriteLine("Deleting old values");
            await AzureUtil.DeleteBatchUnordered(table, deleteList);
        }
示例#6
0
        public void PartitionKey()
        {
            var key1 = new DateKey(new DateTime(year: 2016, month: 4, day: 1).ToUniversalTime());
            var key2 = new DateKey(new DateTime(year: 2016, month: 4, day: 2).ToUniversalTime());

            Assert.Equal("00000305", key1.Key);
            Assert.Equal("00000306", key2.Key);
        }
        public override string ToString()
        {
            var returnString =
                $"Key: {Key.ToKeyString()}," +
                $" DateKey: {DateKey.ToShortDateString()}," +
                $" Text: {Text}," +
                $" ParentWithDictionary: {ParentWithDictionary.ToShortString()}," +
                $" ParentWithDictionaryNullable: {ParentWithDictionaryNullable?.ToShortString()};";

            onToString(ref returnString);
            return(returnString);
        }
        public string ToShortString()
        {
            var returnString =
                $"{Key.ToKeyString()}," +
                $" {DateKey.ToShortDateString()}," +
                $" {Text}," +
                $" {ParentWithDictionary.ToShortString()}," +
                $" {ParentWithDictionaryNullable?.ToShortString()}";

            onToShortString(ref returnString);
            return(returnString);
        }
        public string ToTraceString()
        {
            var returnString =
                $"{this.GetKeyOrHash()}|" +
                $" {DateKey.ToShortDateString()}|" +
                $" {Text}|" +
                $" ParentWithDictionary {ParentWithDictionary.GetKeyOrHash()}|" +
                $" ParentWithDictionaryNullable {ParentWithDictionaryNullable?.GetKeyOrHash()}";

            onToTraceString(ref returnString);
            return(returnString);
        }
示例#10
0
        public void PartitionKey()
        {
            var dateTime = DateTimeOffset.UtcNow;
            var data     = new CounterData(
                dateTime,
                "hello world",
                isJenkins: false);
            var key    = new DateKey(dateTime);
            var entity = new TestCounterEntity(data);

            Assert.Equal(key.Key, entity.PartitionKey);
        }
示例#11
0
        private void buttonMergeByMonth_Click(object sender, EventArgs e)
        {
            var chartArea = this.savingChart.ChartAreas.Add("AAAA");


            foreach (var seriesAux in this.savingChart.Series)
            {
                foreach (var pointsOfSeriesAux in seriesAux.Points)
                {
                    DateKey dateKey = DateKey.ToDateKey(pointsOfSeriesAux.AxisLabel);
                    pointsOfSeriesAux.AxisLabel = dateKey.Month.ToString();
                }
            }
        }