Пример #1
0
 public SyncApplication()
 {
     ConsoleHelper.Info($"Init {ApplicationName}");
     UserCredential   = new UserCredentialManager(Scopes);
     CalendarManager  = new CalendarManager(ApplicationName, UserCredential.Credential);
     ClassroomManager = new ClassroomManager(ApplicationName, UserCredential.Credential);
 }
Пример #2
0
        private void ValidateCalendarDomainShare()
        {
            var acls   = CalendarManager.GetACLs(ClassroomManager.GetClassromCalendars());
            var result = CalendarManager.GetMissingDomainACLs(acls);

            if (result.Count > 0)
            {
                ConsoleHelper.Error($"Found {result.Count} calendars missing domain rule.");
                foreach (var item in result)
                {
                    ConsoleHelper.Error(item.Key);
                }
                var updated = CalendarManager.AddDomainACLRule(result);
                int i       = 0;
                foreach (var item in updated)
                {
                    var req = CalendarManager.Service.Acl.Insert(CalendarManager.NewDomainRule(), item.Key);
                    var res = req.Execute();
                    i++;
                    ConsoleHelper.Info($"Updated calendar {item.Key} - {i} of {updated.Count}");
                }
            }
            else
            {
                ConsoleHelper.Success("No calendars missing domain rule.");
            }
        }
Пример #3
0
        private void RemovePrefixFromClassroomEvents()
        {
            var eventsList = CalendarManager.GetEventsFromCalendars(CalendarManager.CalendarList.Items.Where(x => x.Id.Contains("classroom")).Select(x => x.Id));

            foreach (var events in eventsList)
            {
                foreach (var ev in events.Value.Items)
                {
                    if (CalendarManager.RemovePrefix(ev))
                    {
                        var req = CalendarManager.Service.Events.Patch(ev, events.Key, ev.Id);
                        var res = req.Execute();
                        ConsoleHelper.Info($"Patched {ev.Summary} in {events.Value.Summary}.");
                    }
                }
            }
            Print(eventsList);
        }