-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured the demo applications into a single application.
- Loading branch information
Showing
17 changed files
with
651 additions
and
47 deletions.
There are no files selected for viewing
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
Demos/Archive Data/ArchiveData-Function/Properties/launchSettings.json
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,8 @@ | ||
{ | ||
"profiles": { | ||
"ArchiveData-Function": { | ||
"commandName": "Project", | ||
"commandLineArgs": "host start --pause-on-error --port 7072" | ||
} | ||
} | ||
} |
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,89 @@ | ||
using Azure.Cosmos; | ||
using ShellProgressBar; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using TaleLearnCode.ChChChChanges.Common; | ||
|
||
namespace TaleLearnCode.ChChChChanges.Demonstrator | ||
{ | ||
|
||
public class ArchivalDemo | ||
{ | ||
|
||
private readonly CosmosContainer _container; | ||
|
||
private ArchivalDemo(CosmosClient cosmosClient) | ||
{ | ||
_container = cosmosClient | ||
.GetDatabase(Settings.MoveDataDatabasebaseName) | ||
.GetContainer(Settings.ArchivalContainerName); | ||
} | ||
|
||
public static async Task ExecuteAsync(CosmosClient cosmosClient) | ||
{ | ||
await new ArchivalDemo(cosmosClient).ExecuteAsync(); | ||
} | ||
|
||
private async Task ExecuteAsync() | ||
{ | ||
WelcomeUser(); | ||
await AddDataToCosmosAsync(GetQuestionInteractions()); | ||
} | ||
|
||
private void WelcomeUser() | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine(); | ||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine(@" _____ .__ .__ .__ "); | ||
Console.WriteLine(@" / _ \_______ ____ | |__ |__|__ _______ | | "); | ||
Console.WriteLine(@" / /_\ \_ __ \_/ ___\| | \| \ \/ /\__ \ | | "); | ||
Console.WriteLine(@"/ | \ | \/\ \___| Y \ |\ / / __ \| |__"); | ||
Console.WriteLine(@"\____|__ /__| \___ >___| /__| \_/ (____ /____/"); | ||
Console.WriteLine(@" \/ \/ \/ \/ "); | ||
Console.WriteLine(); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
} | ||
|
||
private List<QuestionInteraction> GetQuestionInteractions() | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine(); | ||
return QuestionInteraction.GetListOfInteractions($"{Settings.DataFolderPath}QuestionInteractions.csv"); | ||
} | ||
|
||
private async Task AddDataToCosmosAsync(List<QuestionInteraction> questionInteractions) | ||
{ | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine("Press any key to start the writing data to Cosmos..."); | ||
Console.ReadKey(); | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine(); | ||
using var progressBar = new ProgressBar(questionInteractions.Count, "Connecting to database"); | ||
|
||
int index = 0; | ||
do | ||
{ | ||
while (!Console.KeyAvailable && index < questionInteractions.Count) | ||
{ | ||
progressBar.Tick($"Writing interaction {index + 1:n0} of {questionInteractions.Count:n0}"); | ||
await _container.CreateItemAsync(questionInteractions[index]); | ||
var delay = questionInteractions[index + 1].InteractionDateTime.Subtract(questionInteractions[index].InteractionDateTime); | ||
await Task.Delay(Convert.ToInt32(delay.TotalMilliseconds)); | ||
index++; | ||
} | ||
if (index >= questionInteractions.Count - 1) break; | ||
} while (Console.ReadKey(true).Key != ConsoleKey.Escape); | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine(); | ||
Console.WriteLine($"Finished writing data to the {Settings.ArchivalContainerName} container"); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
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,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Demonstrator | ||
{ | ||
|
||
public enum DemoOption | ||
{ | ||
Exit = 0, | ||
ArchivingData = 1, | ||
ReplicatingContainers = 2, | ||
DenormalizingData = 3, | ||
EventDrivenArchitecture = 4, | ||
RealTimeReporting = 5 | ||
} | ||
|
||
} |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<AssemblyName>TaleLearnCode.ChChChChanges.Demonstrator</AssemblyName> | ||
<RootNamespace>TaleLearnCode.ChChChChanges.Demonstrator</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" /> | ||
<PackageReference Include="ShellProgressBar" Version="5.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Common\Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.