-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Recommend SQL Instance rehost for IaaS migration * Add ModernizeToAzureSqlMi option * Added static forex rates * Add BC and security cost * Add Decommissioned_Machines * Remove SQL services logic (#48) * Fix debugging (#49) * Add Ahub savings (#50) * Add Financial_Summary (#51) * integrated Financial Summary Changes * Adjust worksheet priorities * Updated Financial Summary code * Financial Summary code * Code clean up (#52) * Add OnPrem IaaS and PaaS costs (#54) * Update PBIT and pipeline (#55) * Add support status to assessment reports (#56) * Update PBIT (#58) * Update PBIT * Update PBIT * Fix console self-host feedback (#60) * Fix console self-host feedback * Fix assessment completion message * Update PBIT * Fix PaaS source counts (#61) * Fix PaaS source counts * Fix null response API --------- Co-authored-by: vrindagoel-microsoft <[email protected]>
- Loading branch information
1 parent
bfff4f9
commit 827a49f
Showing
79 changed files
with
2,938 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Azure.Migrate.Export.Common; | ||
using Azure.Migrate.Export.HttpRequestHelper; | ||
using Azure.Migrate.Export.Models; | ||
|
||
namespace Azure.Migrate.Export.Assessment | ||
{ | ||
public class BusinessCaseBuilder | ||
{ | ||
private readonly BusinessCaseInformation BusinessCaseInformationObj; | ||
|
||
public BusinessCaseBuilder(BusinessCaseInformation businessCaseInformationObj) | ||
{ | ||
BusinessCaseInformationObj = businessCaseInformationObj; | ||
} | ||
|
||
public KeyValuePair<BusinessCaseInformation, AssessmentPollResponse> BuildBusinessCase(UserInput userInputObj) | ||
{ | ||
if (userInputObj.CancellationContext.IsCancellationRequested) | ||
UtilityFunctions.InitiateCancellation(userInputObj); | ||
|
||
AssessmentPollResponse result = AssessmentPollResponse.NotCreated; | ||
bool isBusinessCaseCreated = false; | ||
|
||
try | ||
{ | ||
isBusinessCaseCreated = new HttpClientHelper().CreateBusinessCase(userInputObj, BusinessCaseInformationObj).Result; | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
throw; | ||
} | ||
catch (AggregateException aeCreateBizCase) | ||
{ | ||
string errorMessage = ""; | ||
foreach (var e in aeCreateBizCase.Flatten().InnerExceptions) | ||
{ | ||
if (e is OperationCanceledException) | ||
throw; | ||
else | ||
errorMessage = errorMessage + e.Message + " "; | ||
} | ||
result = AssessmentPollResponse.NotCreated; | ||
userInputObj.LoggerObj.LogWarning($"Business case {BusinessCaseInformationObj.BusinessCaseName} creation failed: {errorMessage}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
result = AssessmentPollResponse.NotCreated; | ||
userInputObj.LoggerObj.LogWarning($"Business case {BusinessCaseInformationObj.BusinessCaseName} creation failed: {ex.Message}"); | ||
} | ||
|
||
if (!isBusinessCaseCreated) | ||
return new KeyValuePair<BusinessCaseInformation, AssessmentPollResponse>(BusinessCaseInformationObj, AssessmentPollResponse.NotCreated); | ||
|
||
result = PollBusinessCaseState(userInputObj).Result; | ||
|
||
return new KeyValuePair<BusinessCaseInformation, AssessmentPollResponse>(BusinessCaseInformationObj, result); | ||
} | ||
|
||
private async Task<AssessmentPollResponse> PollBusinessCaseState(UserInput userInputObj) | ||
{ | ||
int numberOfTries = 0; | ||
AssessmentPollResponse pollResult = AssessmentPollResponse.Created; | ||
|
||
while (numberOfTries < 25) | ||
{ | ||
Thread.Sleep(60000); | ||
try | ||
{ | ||
pollResult = await new HttpClientHelper().PollBusinessCase(userInputObj, BusinessCaseInformationObj); | ||
|
||
if (pollResult == AssessmentPollResponse.Error) | ||
{ | ||
userInputObj.LoggerObj.LogInformation($"Polling for business case {BusinessCaseInformationObj.BusinessCaseName} resulted in non-retryable error"); | ||
numberOfTries += 1; | ||
} | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
throw; | ||
} | ||
catch (AggregateException aePollBizCase) | ||
{ | ||
string errorMessage = ""; | ||
foreach (var e in aePollBizCase.Flatten().InnerExceptions) | ||
{ | ||
if (e is OperationCanceledException) | ||
throw e; | ||
else | ||
{ | ||
errorMessage = errorMessage + e.Message + " "; | ||
} | ||
} | ||
userInputObj.LoggerObj.LogWarning($"Business case {BusinessCaseInformationObj.BusinessCaseName} polling failed: {errorMessage}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
userInputObj.LoggerObj.LogWarning($"Business case {BusinessCaseInformationObj.BusinessCaseName} polling failed: {ex.Message}"); | ||
} | ||
|
||
if (pollResult == AssessmentPollResponse.Completed || | ||
pollResult == AssessmentPollResponse.OutDated || | ||
pollResult == AssessmentPollResponse.Invalid) | ||
break; | ||
} | ||
|
||
userInputObj.LoggerObj.LogInformation($"Polling for business case {BusinessCaseInformationObj.BusinessCaseName} completed"); | ||
return pollResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.