public async Task <Boolean> MakeMeAvailable(HttpClient httpClient, OAuthTokenRoot authToken, String ucwaMakeMeAvailableRootUrl, BotAttributes botAttributes, TelemetryClient tc) { try { string makeMeAvailableResults = string.Empty; httpClient.DefaultRequestHeaders.Clear(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken.access_token); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var makeMeAvailablePostData = JsonConvert.SerializeObject(botAttributes); //Successfull response is Http 204 No content var httpResponseMessage = await httpClient.PostAsync(ucwaMakeMeAvailableRootUrl, new StringContent(makeMeAvailablePostData, Encoding.UTF8, "application/json")); string result = httpResponseMessage.Content.ReadAsStringAsync().Result; if (result == String.Empty) { return(true); } else { return(false); } } catch (Exception ex) { Console.WriteLine("Failed to set the status of the bot as Online"); tc.TrackTrace("Failed to set the status of the bot as Online"); tc.TrackException(ex); throw new CustomException("Error occured in " + MethodBase.GetCurrentMethod().Name + ":" + ex.Message + " TargetSite:" + ex.TargetSite + " StackTrace: " + ex.StackTrace); } }
// Constructor dependency injection public UCWAMakeMeAvailable(HttpClient httpClient, OAuthTokenRoot authToken, String ucwaMakeMeAvailableRootUrl, BotAttributes botAttributes, TelemetryClient tc) { UCWAConfiguration._httpClient = httpClient; _ucwaMakeMeAvailableRootUrl = ucwaMakeMeAvailableRootUrl; _authToken = authToken; _botAttributes = botAttributes; UCWAConfiguration._tc = tc; }
// Constructor dependency injection public UCWAReportMyActivity(HttpClient httpClient, OAuthTokenRoot authToken, String ucwaKeepMeOnlineUrl, BotAttributes botAttributes, TelemetryClient tc) { UCWAConfiguration._httpClient = httpClient; _keepMeOnlineUrl = ucwaKeepMeOnlineUrl; _authToken = authToken; _botAttributes = botAttributes; UCWAConfiguration._tc = tc; }
public async Task SetIMStatus(HttpClient httpClient, TelemetryClient tc) { List <string> MessageFormats = new List <string>(); MessageFormats.Add("Plain"); MessageFormats.Add("Html"); List <string> Modalities = new List <string>(); // Modalities.Add("PhoneAudio"); Modalities.Add("Messaging"); BotAttributes botAttributes = new BotAttributes { phoneNumber = "", signInAs = "Online", // Status - Online, Busy, DoNotDisturb, BeRightBack, Away, or Offwork supportedMessageFormats = MessageFormats, supportedModalities = Modalities }; var ucwaMakeMeAvailableRootUrl = DI._config.GetSection("UCWA:ucwa_applications_host").Value + UCWAConfiguration.ucwaApplication + UCWAConfiguration.ucwaMakeMeAvailableUri; if (ucwaMakeMeAvailableRootUrl != String.Empty) { // Generic GetService< T> method is an extension method. Add namespace Microsoft.Extensions.DependencyInjection var ucwaMakeMeAvailableService = DI._serviceProvider.GetService <IUCWAMakeMeAvailable>(); // Set the status online if (await ucwaMakeMeAvailableService.MakeMeAvailable(httpClient, UCWAConfiguration.authToken, ucwaMakeMeAvailableRootUrl, botAttributes, tc)) { Console.WriteLine("Skype ID's status set to Online."); tc.TrackTrace("Skype ID's status set to Online."); } else { Console.WriteLine("Unable to set Skype ID's status as Online."); tc.TrackTrace("Unable to set Skype ID's status as Online."); } return; } else { Console.WriteLine("ucwaMakeMeAvailableRootUrl is empty. Unable to set Skype ID's status as Online."); tc.TrackTrace("ucwaMakeMeAvailableRootUrl is empty. Unable to set Skype ID's status as Online."); } }
static void SetIMStatus(TelemetryClient tc) { List <string> MessageFormats = new List <string>(); MessageFormats.Add("Plain"); MessageFormats.Add("Html"); List <string> Modalities = new List <string>(); // Modalities.Add("PhoneAudio"); Modalities.Add("Messaging"); BotAttributes botAttributes = new BotAttributes { phoneNumber = "", signInAs = "Online", // Status - Online, Busy, DoNotDisturb, BeRightBack, Away, or Offwork supportedMessageFormats = MessageFormats, supportedModalities = Modalities }; var ucwaMakeMeAvailableRootUri = UcwaMakeMeAvailable.GetMakeMeAvailableUri(ucwaApplicationsHost, tc); if (ucwaMakeMeAvailableRootUri != String.Empty) { if (UcwaMakeMeAvailable.MakeMeAvailable(httpClient, ConfigData.authToken, ucwaMakeMeAvailableRootUri, botAttributes, tc)) { Console.WriteLine("Skype ID's status set to Online."); tc.TrackTrace("Skype ID's status set to Online."); } else { Console.WriteLine("Unable to set Skype ID's status as Online."); tc.TrackTrace("Unable to set Skype ID's status as Online."); } return; } }
// Use this for initialization protected override void Awake() { base.Awake(); attributes = gameObject.GetComponent<BotAttributes>(); parentAction = gameObject.GetComponent<BotActions>(); }
public float speedDecreaseRate; /**< Speed decrease rate by gold. */ // Use this for initialization protected override void Awake() { base.Awake(); attributes = gameObject.GetComponent <BotAttributes>(); parentAction = gameObject.GetComponent <BotActions>(); }