static async Task RunAsync() { logger.LogInformation("Inside RunAsync"); // Get Token var httpResponse = await GetTokenAsync(); string apiResponse = httpResponse.Content.ReadAsStringAsync().Result; var token = JsonConvert.DeserializeObject <Token>(apiResponse); //Get Service Message var currentStatus = await getCurrentStatus(token); string currResponse = currentStatus.Content.ReadAsStringAsync().Result; currentSvcStatus = JsonConvert.DeserializeObject <CurrentStatus>(currResponse); logger.LogInformation($"Status Message Count {currentSvcStatus.value.Count()}"); await GetServiceMessage(token); NotifyPIR(); //Compare with last known status and notify if needed CompareAndNotify(); // notifyTeamsPlanner(messages); if (Environment.GetEnvironmentVariable("Env") == "Dev") { System.IO.File.WriteAllText(path + $"\\Data\\CurrentStatus.json", JsonConvert.SerializeObject(currentSvcStatus)); System.IO.File.WriteAllText(path + $"\\Data\\Messages.json", JsonConvert.SerializeObject(messages)); } else { UploadtoAzureBlobStorage("CurrentStatus.json", JsonConvert.SerializeObject(currentSvcStatus)); UploadtoAzureBlobStorage("Messages.json", JsonConvert.SerializeObject(messages)); UploadtoAzureBlobStorage("LastRun.json", currentBatchNumber.ToString()); System.IO.File.WriteAllText($"D:\\home\\site\\wwwroot\\Data\\CurrentStatus.json", JsonConvert.SerializeObject(currentSvcStatus)); System.IO.File.WriteAllText($"D:\\home\\site\\wwwroot\\Data\\Messages.json", JsonConvert.SerializeObject(messages)); } }
static void Init() { try { logger.LogInformation("Inside Init"); // Get the Message Corresponding to last batch from file system if (Environment.GetEnvironmentVariable("Env") == "Dev") { lastKnownSvcStatus = JsonConvert.DeserializeObject <CurrentStatus>(System.IO.File.ReadAllText(path + $"\\Data\\CurrentStatus.json")); } else { lastKnownSvcStatus = JsonConvert.DeserializeObject <CurrentStatus>(System.IO.File.ReadAllText($"D:\\home\\site\\wwwroot\\Data\\CurrentStatus.json")); } logger.LogInformation($"lastKnownSvcStatus {lastKnownSvcStatus}"); } catch (Exception ex) { logger.LogInformation($"Could not load lastKnownSvcStatus {ex.Message}"); logger.LogInformation($"lastKnownSvcStatus {ex.StackTrace.ToString()}"); } }