private void TimerRunSync(Object state) { List <DBUser> users = DatabaseHandler.GetSyncs(); if (!ADHandler.ReloadGroup()) { Logger.Send("Target group could not be reloaded during sync check. was the group deleted?", Logger.LogLevel.ERROR, 17); } O365Client client = new O365Client(); try { client.GetAccessToken(ConfigHandler.O365TenantName, ConfigHandler.ClientID, ConfigHandler.ClientSecret, ConfigHandler.O365ServiceUsername, ConfigHandler.O365ServicePassword).Wait(); } catch (AggregateException ae) { foreach (Exception e in ae.Flatten().InnerExceptions) { Logger.Send("Exception thrown when requesting an Access Token from O365: " + e.Message, Logger.LogLevel.ERROR, 17); } } catch (Exception ex) { Logger.Send("Exception thrown when requesting an Access Token from O365: " + ex.Message, Logger.LogLevel.ERROR, 17); } foreach (DBUser user in users) { Logger.Send("Syncing password for user: "******" originally changed at " + user.TimestampDatetime.ToLocalTime().ToString(), Logger.LogLevel.INFO, 17); try { client.ChangePassword(user.Username, user.Password).Wait(); user.Processed = SyncProcessedStatus.COMPLETE; } catch (AggregateException ae) { foreach (Exception e in ae.Flatten().InnerExceptions) { Logger.Send("Exception thrown when changing users password: "******"Exception thrown when changing users password: " + ex.Message, Logger.LogLevel.ERROR, 17); user.Processed = SyncProcessedStatus.FAILED; } } DatabaseHandler.UpdateSyncStatus(users); _timerSync.Change(SYNC_WAIT_TIME, Timeout.Infinite); }
private async Task <SkillResponse> WarnManager(IntentRequest intentRequest) { using (O365Client _client = new O365Client()) { string resultado = await _client.SendTeamAlert("ferran", "spsaturdaydemo.onmicrosoft.com"); _response = ResponseBuilder.Tell(resultado); _response.Response.ShouldEndSession = false; return(_response); } }
private async Task <SkillResponse> ReadDocument(IntentRequest intentRequest) { var id_documento = intentRequest.Intent.Slots["id_documento"].Value; using (O365Client _client = new O365Client()) { string resultado = await _client.GetDocument("Eventos", "Documentos", id_documento); _response = ResponseBuilder.Tell(resultado); _response.Response.ShouldEndSession = false; return(_response); } }
static async Task MainAsync() { O365Client client = new O365Client(); try { await client.GetAccessToken("TenantName", ClientID, ClientSecret, userName, userPassword); await client.ChangePassword("testUser", "TestPassword4423"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine(); }
public async Task <SkillResponse> WelcomeMessage() { try { using (O365Client client = new O365Client()) { string name = await client.GetName(); _response = ResponseBuilder.Tell("Bienvenido a SharePoint Saturday Madrid, " + name); _response.Response.ShouldEndSession = false; return(_response); } } catch (Exception) { _response = ResponseBuilder.Tell("Se ha producido un error con la Skill del SharePoint Saturday Madrid"); _response.Response.ShouldEndSession = true; return(_response); } }
private async Task <SkillResponse> ScheduleMeeting(IntentRequest intentRequest) { using (O365Client _client = new O365Client()) { var dia = intentRequest.Intent.Slots["dia"].Value; var mes = intentRequest.Intent.Slots["mes"].Value; var horaInicio = intentRequest.Intent.Slots["hora_inicio"].Value; var horaFin = intentRequest.Intent.Slots["hora_fin"].Value; var tema = intentRequest.Intent.Slots["tema"].Value; int intDia = Convert.ToInt32(dia); int intHoraInicio = Convert.ToInt32(horaInicio); int intHoraFin = Convert.ToInt32(horaFin); bool resultado = await _client.CreateAppointment("Cita", tema, intDia, mes, 2019, intHoraInicio, intHoraFin); _response = ResponseBuilder.Tell("La cita se ha creado correctamente"); _response.Response.ShouldEndSession = false; return(_response); } }
public O365Worker(O365Settings o365Settings) { _o365 = new O365Client(o365Settings); }