Beispiel #1
0
 private ApiClient()
 {
     ApiClientHelper.Init();
     OrganizationClient = new OrganizationClient(ApiClientHelper.Client);
     CalendarClient     = new CalendarClient(ApiClientHelper.Client);
     TwilioClient       = new TwilioClient(ApiClientHelper.Client);
 }
Beispiel #2
0
 public TileHub(StatesClient statesClient, ServiceClient serviceClient, CalendarClient calendarClient, IConfigStore configStore)
 {
     StatesClient   = statesClient;
     ServiceClient  = serviceClient;
     ConfigStore    = configStore;
     CalendarClient = calendarClient;
 }
        private async Task ProcessOverrides(BaseTile tile)
        {
            switch (tile)
            {
            // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API.
            case CalendarTile ct:
                // Required because for some reason, the calendar API is not available
                // via the "inside" supervisor API, only the "external" fully-qualified
                // API endpoint.
                var config = await ConfigStore.GetConfigAsync();

                var calClient = new CalendarClient(new Uri(!string.IsNullOrWhiteSpace(config.Settings?.OverrideAssetUri) ? config.Settings.OverrideAssetUri : config.Settings.BaseUri), config.Settings.AccessToken);

                var state = await StatesClient.GetState(ct.EntityId);

                var calItems = await calClient.GetEvents(ct.EntityId);

                await Clients.Caller.SendCalendarInfo(ct, state, calItems);

                break;

            // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection.
            case DateTile dt:
                var date = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(dt.TimeZoneId));
                await Clients.Caller.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt"));

                break;
            }
        }
        private async Task <Calendar> FetchCalendarAsync(string calendarId, CalendarOptions.Calendar calendarOptions)
        {
            if (_calendarCache.TryGetValue(calendarId, out var calendar))
            {
                return(calendar);
            }

            var sourceId = calendarOptions.Source;

            if (!_clients.TryGetValue(sourceId, out var client))
            {
                var source = _options.Sources[sourceId];
                client = new CalendarClient(source.ExchangeUrl, source.Username, source.Password);

                if (_options.MaxEvents.HasValue)
                {
                    client.MaxEvents = _options.MaxEvents.Value;
                }

                _clients[sourceId] = client;
            }

            calendar = new Calendar(await client.GetCalendarByIdAsync(calendarOptions.ExchangeId));
            if (calendarOptions.Name != null)
            {
                calendar.Name = calendarOptions.Name;
            }

            calendar.Id       = calendarId;
            calendar.Location = calendarOptions.Location;

            _calendarCache.Add(calendarId, calendar);
            return(calendar);
        }
 public EmailProcessorFactory(CalendarClient calendarClient)
 {
     _processors = new Dictionary <string, IEmailProcessor>
     {
         [Constants.Invitation]  = new InvitationProcessor(calendarClient),
         [Constants.Rescheduled] = new RescheduledProcessor(calendarClient),
         [Constants.Cancelled]   = new CancelledProcessor(calendarClient)
     };
 }
 public IndexModel(
     ILogger <IndexModel> logger,
     ProjectClient projectClient,
     ToDoItemClient todoClient,
     TeamDirectoryClient teamDirectoryClient,
     CalendarClient calendarClient)
 {
     _logger              = logger;
     _projectClient       = projectClient;
     _todoClient          = todoClient;
     _teamDirectoryClient = teamDirectoryClient;
     _calendarClient      = calendarClient;
 }
Beispiel #7
0
 public IndexModel(
     TeamDirectoryClient teamDirectoryClient,
     AbsenceClient absenceClient,
     CalendarClient calendarClient,
     ChatClient chatClient,
     SettingsStorage settingsStorage,
     IConfiguration configuration,
     ILogger <IndexModel> logger)
 {
     _teamDirectoryClient = teamDirectoryClient;
     _absenceClient       = absenceClient;
     _calendarClient      = calendarClient;
     _chatClient          = chatClient;
     _settingsStorage     = settingsStorage;
     _meetingUrlTemplate  = configuration["Space:ServerUrl"].TrimEnd('/') + "/meetings/{0}";
     _logger = logger;
 }
        public ItemsViewModel()
        {
            Title       = "Browse";
            Staff       = new ObservableCollection <Staff>();
            Calendars   = new ObservableCollection <Calendar>();
            LoadCommand = new Command(() => Load());
            CallSelectedCalenderCommand = new Command(async() =>
            {
                Console.WriteLine("Yes " + SelectedCalendar.PhoneNumber);
//                Device.OpenUri(new Uri($"tel:{SelectedCalendar.PhoneNumber}"));
                var phoneDialer = CrossMessaging.Current.PhoneDialer;
                if (phoneDialer.CanMakePhoneCall)
                {
                    phoneDialer.MakePhoneCall(SelectedCalendar.PhoneNumber);
                }
            });

            MessagingCenter.Subscribe <CalendarSettingsPage, PhoneLink>(this, "SaveCalendar", async(obj, item) =>
            {
                await CalendarClient.SavePhoneLink(item);
                await ExecuteLoadCommand(true);
            });
        }
Beispiel #9
0
        private async Task ProcessOverrides(BaseTile tile)
        {
            switch (tile)
            {
            // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API.
            case CalendarTile ct:
                await Clients.Caller.SendCalendarInfo(ct, await StatesClient.GetState(ct.EntityId), await CalendarClient.GetEvents(ct.EntityId));

                break;

            // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection.
            case DateTile dt:
                var date = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(dt.TimeZoneId));
                await Clients.Caller.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt"));

                break;
            }
        }
        public static async Task Main(string[] args)
        {
            var options = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", true)
                          .AddUserSecrets <Program>()
                          .AddCommandLine(args)
                          .Build()
                          .Get <CalendarOptions>();

            var client    = new CalendarClient(options.ExchangeUrl, options.Username, options.Password);
            var calendars = (await client.ListCalendarsAsync()).OrderBy(c => c.Name).ToList();

            using (var writer = new JsonTextWriter(Console.Out))
            {
                writer.Formatting  = Formatting.Indented;
                writer.Indentation = 2;

                await writer.WriteStartObjectAsync();

                foreach (var calendar in calendars)
                {
                    if (!string.IsNullOrWhiteSpace(options.Filter) && !calendar.Name.Contains(options.Filter, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    await writer.WritePropertyNameAsync(Regex.Replace(calendar.Name, "\\W+", "_").Trim('_'));

                    await writer.WriteStartObjectAsync();

                    await writer.WritePropertyNameAsync("Name");

                    await writer.WriteValueAsync(calendar.Name);

                    await writer.WritePropertyNameAsync("Location");

                    await writer.WriteNullAsync();

                    await writer.WritePropertyNameAsync("Source");

                    if (options.Source != null)
                    {
                        await writer.WriteValueAsync(options.Source);
                    }
                    else
                    {
                        await writer.WriteNullAsync();
                    }

                    await writer.WritePropertyNameAsync("ExchangeId");

                    await writer.WriteValueAsync(calendar.Id);

                    await writer.WritePropertyNameAsync("ShowInTodayOverview");

                    await writer.WriteValueAsync(false);

                    await writer.WriteEndObjectAsync();
                }

                await writer.WriteEndObjectAsync();
            }

            Console.ReadLine();
        }
 public RescheduledProcessor(CalendarClient calendarClient)
 {
     _calendarClient = calendarClient;
 }
 public CancelledProcessor(CalendarClient calendarClient)
 {
     _calendarClient = calendarClient;
 }
 public InvitationProcessor(CalendarClient calendarClient)
 {
     _calendarClient = calendarClient;
 }
        private async Task ProcessOverrides(BaseTile tile)
        {
            switch (tile)
            {
            // Calendars use a special API that isn't (might not be?) exposed via the WebSocket API.
            case CalendarTile ct:
                await Clients.All.SendCalendarInfo(ct, await StatesClient.GetState(ct.EntityId), await CalendarClient.GetEvents(ct.EntityId));

                break;

            // Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection.
            case DateTile dt:
                var date = !string.IsNullOrWhiteSpace(dt.TimeZoneId)
                        ? TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(dt.TimeZoneId))
                        : DateTime.Now;
                await Clients.All.SendDateTime(dt, date.ToString(dt.DateFormatString ?? "dddd MMMM d"), date.ToString(dt.TimeFormatString ?? "h:mm tt"));

                break;
            }
        }