private void UpdateCell(string range, object value)
        {
            var updateValues = new List <IList <object> >
            {
                new List <object>
                {
                    value
                }
            };

            _googleSheetsService.SetValue(_sheetsId, range, updateValues);
            Thread.Sleep(_interval);
        }
Beispiel #2
0
        private static void DuplicateCoverageLog(IServiceProvider serviceProvider, IGoogleSheetsService googleSheetsService, string sourceId, string targetId)
        {
            var dateTimeHelper = serviceProvider.GetService <IDateTimeHelper>();

            var now       = dateTimeHelper.Now;
            var sheetName = now.ToString("yyyy");

            //// Read
            var firstRow    = 1;
            var maxRow      = string.Empty;
            var startColumn = "A";
            var endColumn   = "BH";
            var range       = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{maxRow}";

            Console.WriteLine($"Source Range: {range}");
            var sourceList = googleSheetsService.GetValues(sourceId, range);

            //// Write
            var targetRange = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{sourceList.Count + 1}";

            Console.WriteLine($"Target Range: {targetRange}");
            googleSheetsService.SetValue(targetId, targetRange, sourceList);
        }
Beispiel #3
0
        private static void DuplicateCoverage(IGoogleSheetsService googleSheetsService, string sourceId, string targetId)
        {
            var sheetName = "Coverage";

            //// Read
            var firstRow    = 2;
            var maxRow      = string.Empty;
            var startColumn = "A";
            var endColumn   = "J";
            var range       = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{maxRow}";

            Console.WriteLine($"Source Range: {range}");
            var sourceList = googleSheetsService.GetValues(sourceId, range);
            var methodList = Program.SheetRangeToEntityList(sourceList);

            //// Write
            endColumn = "H";
            var targetRange = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{sourceList.Count + 1}";

            Console.WriteLine($"Target Range: {targetRange}");
            var targetList = Program.EntityListToSheetRange(methodList);

            googleSheetsService.SetValue(targetId, targetRange, targetList);
        }
Beispiel #4
0
        public void Log(IList <CoverageEntity> methodList)
        {
            //// Load Sheet Log Data
            var currentMethodList = GetCurrentMethodList();

            //// Sync Method and Coverage
            var newMethodList = new List <CoverageEntity>();

            foreach (var method in methodList)
            {
                var methodLog = currentMethodList.FirstOrDefault(i => i.Equals(method));

                if (methodLog != null)
                {
                    methodLog.UpdateCoverage(method);
                }
                else
                {
                    newMethodList.Add(method);
                }
            }

            //// Write Log Data
            int firstColumn = 5;
            var now         = _dateTimeHelper.Now;
            var col         = GetColumnLetterByWeek(firstColumn, now);

            //// Write Method
            Console.WriteLine("** Write Coverage Log");
            foreach (var method in currentMethodList)
            {
                if (method.Status != CoverageStatus.Unchange)
                {
                    Console.WriteLine($"{method.ToString()}");
                    var range  = $"{now.Year}!{col.columnLetter}{method.RawIndex}";
                    var values = SheetHelper.ObjectToValues(method.Coverage);
                    _googleSheetsService.SetValue(_sheetsId, range, values);
                    Thread.Sleep(_interval);
                }
            }

            //// Write New Method
            Console.WriteLine("** Write New Method");
            var index = currentMethodList.Count + 1;

            foreach (var method in newMethodList)
            {
                Console.WriteLine($"{method.ToString()}");

                ++index;
                var range = $"{now.Year}!A{index}:{col.columnLetter}{index}";

                var row = new object[col.column];
                row[0] = method.Repository;
                row[1] = method.Project;
                row[2] = method.Namespace;
                row[3] = method.Class;
                row[4] = method.Method;
                row[col.column - 1] = method.Coverage;
                var values = new List <IList <object> > {
                    row
                };

                _googleSheetsService.SetValue(_sheetsId, range, values);
                Thread.Sleep(_interval);
            }
        }