Adding check on promote and wait buffers during import

This commit is contained in:
Dan Hellem 2017-09-22 11:01:31 -07:00
Родитель f2d0f3b9a6
Коммит 2674f027a4
6 изменённых файлов: 119 добавлений и 45 удалений

Просмотреть файл

@ -56,15 +56,20 @@
<ManifestKeyFile>Ardvark_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@ -92,6 +97,7 @@
<Compile Include="ViewModels\ImportResponseViewModel.cs" />
<Compile Include="ViewModels\ImportViewModel.cs" />
<Compile Include="ViewModels\ProcessesListViewModel.cs" />
<Compile Include="ViewModels\PromoteStatusViewModel.cs" />
<Compile Include="ViewModels\StandardResponseViewModel.cs" />
<Compile Include="ViewModels\TeamSettings.cs" />
</ItemGroup>
@ -100,14 +106,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Release.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<None Include="Ardvark_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\app.manifest" />
<None Include="SamplesFiles\MyFile.csv" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -135,10 +135,11 @@ namespace Aardvark.Domain
{
importViewModel.ImportResponseViewModel = result;
importViewModel.Success = true;
importViewModel.Message = "Import succeeded for '" + zipPath + "'";
importViewModel.Message = "Import succeeded for '" + zipPath + "'";
importViewModel.PromoteJobId = result.promoteJobId;
}
else
{
{
importViewModel.ImportResponseViewModel = null;
importViewModel.Success = false;
importViewModel.Message = response.ReasonPhrase;
@ -183,5 +184,34 @@ namespace Aardvark.Domain
return response;
}
}
/// <summary>
/// get the promote status of specific promote job id
/// </summary>
/// <param name="promoteJobId"></param>
/// <returns>PromoteStatusViewModel</returns>
public PromoteStatusViewModel GetPromoteStatus(string promoteJobId)
{
PromoteStatusViewModel vm = null;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(_apiurl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _login);
HttpResponseMessage response = client.GetAsync("_apis/work/processAdmin/processes/status/" + promoteJobId).Result;
if (response.IsSuccessStatusCode)
{
vm = response.Content.ReadAsAsync<PromoteStatusViewModel>().Result;
}
response.Dispose();
return vm;
}
}
}
}

Просмотреть файл

@ -8,6 +8,7 @@ using System.IO;
using System.IO.Compression;
using Aardvark.ViewModels;
using Aardvark.Domain;
using System.Threading;
namespace ImportExportProcessExamples
{
@ -118,7 +119,7 @@ namespace ImportExportProcessExamples
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Importing Project");
ImportSingle(_source);
var i = ImportSingle(_source);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Done");
@ -433,30 +434,15 @@ namespace ImportExportProcessExamples
else
{
return;
}
}
var status = 0;
foreach (var item in list)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Importing process '" + item.ZipFilePath + "': ");
status = ImportSingle(item.ZipFilePath);
ImportViewModel vm = process.ImportSingleProcessRESTCall(item.ZipFilePath);
if (!vm.Success)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: " + vm.Message);
foreach (var result in vm.validationResults)
{
Console.WriteLine("Line " + result.line + " : " + result.description);
}
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success");
}
if (status == 0) break;
}
process = null;
@ -511,29 +497,29 @@ namespace ImportExportProcessExamples
process = null;
}
private static void ImportSingle(string zipFile)
private static int ImportSingle(string zipFile)
{
if (!File.Exists(zipFile))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: Invlaid argument, zip file not found");
return;
return 0;
}
Processes process = new Processes(_appConfig);
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Importing process '" + zipFile + "': ");
Console.Write("importing process '" + zipFile + "': ");
ImportViewModel vm = process.ImportSingleProcessRESTCall(zipFile);
ImportViewModel importVm = process.ImportSingleProcessRESTCall(zipFile);
if (!vm.Success)
if (!importVm.Success)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: " + vm.Message);
Console.WriteLine("Error: " + importVm.Message);
Console.WriteLine("");
foreach (var item in vm.validationResults)
foreach (var item in importVm.validationResults)
{
Console.WriteLine("Line " + item.line + " : " + item.description);
}
@ -543,10 +529,46 @@ namespace ImportExportProcessExamples
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success");
}
Console.ForegroundColor = ConsoleColor.White;
Console.Write("checking promote status...");
PromoteStatusViewModel promoteStatusVm = new PromoteStatusViewModel() { complete = 0 };
do
{
//check the status of the promote job
promoteStatusVm = process.GetPromoteStatus(importVm.PromoteJobId);
Console.Write(".");
if (promoteStatusVm == null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: promote json package is empty");
break;
}
Thread.Sleep(10000);
}
while (promoteStatusVm.complete == 0);
Thread.Sleep(10000);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success");
Console.ForegroundColor = ConsoleColor.White;
Console.Write("adding a buffer to promote process (this may take a couple minutes): ");
Thread.Sleep(120000);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success");
}
process = null;
return 1;
}
public static void ShowHelp()

Просмотреть файл

@ -11,6 +11,7 @@ namespace Aardvark.ViewModels
public ImportResponseViewModel ImportResponseViewModel { get; set; } = null;
public string Message { get; set; }
public bool Success { get; set; } = false;
public string PromoteJobId { get; set; } = "0";
public Validationresult[] validationResults { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aardvark.ViewModels
{
public class PromoteStatusViewModel
{
public string id { get; set; }
public int complete { get; set; }
public int pending { get; set; }
public int remainingRetries { get; set; }
public bool successful { get; set; }
public string message { get; set; }
}
}

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
</packages>