(1) RestClient project added, (2) Testmethods.Q2CorrectionFromHisotry modified.

This commit is contained in:
Milan Hanajik 2020-01-08 15:50:58 +01:00
parent 91461eb2cc
commit ab43cabc57
33 changed files with 74067 additions and 71 deletions

2
.gitignore vendored
View File

@ -14,6 +14,8 @@ GraphLib/bin
GraphLib/obj GraphLib/obj
TracingDB/bin TracingDB/bin
TracingDB/obj TracingDB/obj
RestClient/bin
RestClient/obj
Results/bin/ Results/bin/
Results/obj/ Results/obj/
ResultsBrowser/bin/ ResultsBrowser/bin/

198
RestClient/BaseClient.cs Normal file
View File

@ -0,0 +1,198 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace RestClient
{
public class BaseClient
{
private string _token;
private string _baseUrl;
public string ErrorMessage { get; set; }
private readonly HttpClient client;
private AuthenticationHeaderValue _authValue;
public BaseClient(string baseUrl)
{
this._baseUrl = baseUrl;
}
public void SetToken(string token)
{
_authValue = new AuthenticationHeaderValue("Bearer", token);
}
protected Uri GetUrl(string relativeUrl)
{
try
{
return new Uri(_baseUrl + relativeUrl);
}
catch (Exception)
{
Trace.TraceError("Invalid url " + relativeUrl);
return null;
}
}
protected async Task<TResult> GetResultAsync<TResult>(string relativeUrl)
{
ErrorMessage = String.Empty;
Uri url = null;
try
{
url = new Uri(_baseUrl + relativeUrl);
}
catch (Exception)
{
Trace.TraceError("Invalid url " + relativeUrl);
return default(TResult);
}
using (var client = GetClient())
{
try
{
var result = await client.GetAsync(url).ConfigureAwait(false);
var parsedResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
if (result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<TResult>(parsedResult);
}
if (result.StatusCode == System.Net.HttpStatusCode.NotFound)
{
//Create not an error message, because communication is okay, only the meter is not available in database.
return default(TResult);
}
try
{
string Messages = await result.Content.ReadAsStringAsync();
var errors = JsonConvert.DeserializeObject<Dictionary<string, object>>(Messages);
string ServiceError = String.Empty;
if (errors != null)
{
ServiceError = errors["Message"].ToString();
}
ErrorMessage = string.Format("Error message: {0}", ServiceError);
}
catch
{
result.EnsureSuccessStatusCode();
}
return default(TResult);
}
catch (Exception ex)
{
string Message = ex.Message;
if (ex.InnerException != null)
{
Message += ". " + ex.InnerException.Message;
}
Trace.TraceError(Message);
ErrorMessage = Message;
return default(TResult);
}
}
}
/// <summary>
/// Post method.
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="relativeUrl"></param>
/// <param name="Position"></param>
/// /// <param name="withBaseUrl"></param>
/// <returns>The new resource</returns>
protected async Task<string> PostWithReturnDataAsync<TResult>(string relativeUrl, bool withBaseUrl, TResult Position)
{
string data = string.Empty;
ErrorMessage = String.Empty;
Uri url = null;
try
{
if (withBaseUrl)
{
url = new Uri(_baseUrl + relativeUrl);
}
else
{
url = new Uri(relativeUrl);
}
}
catch (Exception ex)
{
Trace.TraceError("Invalid url " + url);
ErrorMessage = ex.Message;
return data;
}
using (var client = GetClient())
{
try
{
string json = JsonConvert.SerializeObject(Position);
HttpContent content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url.ToString(), content).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
data = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return data;
}
else
{
if (response.StatusCode == HttpStatusCode.NotFound)
{
ErrorMessage = String.Format("Status code: {0}. Url: {1}", response.StatusCode, url);
}
else
{
string errorMessageService = string.Empty;
string message = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
if (string.IsNullOrEmpty(message))
{
errorMessageService = response.ReasonPhrase;
}
else
{
try
{
var errors = JsonConvert.DeserializeObject<Dictionary<string, object>>(message);
errorMessageService = errors["Message"].ToString();
}
catch (Exception)
{
errorMessageService = message;
}
}
ErrorMessage = String.Format("Status code: {0}. Error message: {1}", response.StatusCode, errorMessageService);
}
return data;
}
}
catch (Exception ex)
{
Trace.TraceError(ex.Message);
ErrorMessage = ex.Message;
return data;
}
}
}
protected HttpClient GetClient()
{
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = _authValue;
return client;
}
}
}

View File

@ -0,0 +1,82 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Newtonsoft.Json;
using RestClient.Models;
namespace RestClient
{
public class GetQ2PreCorrectionClient : BaseClient
{
public GetQ2PreCorrectionClient(string baseUrl)
: base(baseUrl)
{ }
public async Task GetToken(string name, string password, string urlLogin)
{
LoginUser user = new LoginUser { Name = name, Password = password };
var response = await PostWithReturnDataAsync(urlLogin, false, user).ConfigureAwait(false);
var tmp = JsonConvert.DeserializeObject<CustomJwt>(response);
if (tmp != null)
{
SetToken(tmp.access_token);
}
else
{
throw new Exception(string.Format("No token loaded: {0}", ErrorMessage));
}
}
public async Task<Q2PreCorrection> GetQ2Correction(string relativeUrl)
{
ErrorMessage = String.Empty;
Uri url = GetUrl(relativeUrl);
if (url == null) return new Q2PreCorrection { AreDataCalculated = false, CorrLR = 0, CorrRL = 0, };
using (var client = GetClient())
{
try
{
var result = await client.GetAsync(url).ConfigureAwait(false);
string jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
if (result.IsSuccessStatusCode)
{
Q2PreCorrection retVal = new Q2PreCorrection();
string pattern = "\"areDataCalculated\":";
int position = jsonResult.IndexOf(pattern) + pattern.Length;
int length = jsonResult.Substring(position).IndexOfAny(new char[] { ',', '}', '\r', '\n' });
retVal.AreDataCalculated = bool.Parse(jsonResult.Substring(position, length));
pattern = "\"right\":";
position = jsonResult.IndexOf(pattern) + pattern.Length;
length = jsonResult.Substring(position).IndexOfAny(new char[] { ',', '}', '\r', '\n' });
retVal.CorrLR = int.Parse(jsonResult.Substring(position, length));
pattern = "\"left\":";
position = jsonResult.IndexOf(pattern) + pattern.Length;
length = jsonResult.Substring(position).IndexOfAny(new char[] { ',', '}', '\r', '\n' });
retVal.CorrRL = int.Parse(jsonResult.Substring(position, length));
return retVal;
}
else
{
return new Q2PreCorrection { AreDataCalculated = false, CorrLR = 0, CorrRL = 0, };
}
}
catch (Exception ex)
{
string Message = ex.Message;
if (ex.InnerException != null)
{
Message += ". " + ex.InnerException.Message;
}
Trace.TraceError(Message);
ErrorMessage = Message;
return new Q2PreCorrection { AreDataCalculated = false, CorrLR = 0, CorrRL = 0, };
}
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace RestClient.Models
{
public class CustomJwt
{
public string access_token { get; set; }
public string token_type { get; set; }
public int expires_in { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace RestClient.Models
{
public class LoginUser
{
public string Name { get; set; }
public string Password { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RestClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RestClient")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("46e3b0e1-209f-4550-b0dd-d7e2c039b3ce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,11 @@
using System;
namespace RestClient
{
public class Q2PreCorrection
{
public bool AreDataCalculated;
public int CorrLR;
public int CorrRL;
}
}

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RestClient</RootNamespace>
<AssemblyName>RestClient</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseClient.cs" />
<Compile Include="GetQ2PreCorrectionClient.cs" />
<Compile Include="Models\CustomJwt.cs" />
<Compile Include="Models\LoginUser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Q2PreCorrection.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
</packages>

14
TBF.sln
View File

@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypt", "Decrypt\Decrypt.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.csproj", "{DA9B09F3-A99D-4883-A954-537560453674}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.csproj", "{DA9B09F3-A99D-4883-A954-537560453674}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient", "RestClient\RestClient.csproj", "{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -202,6 +204,18 @@ Global
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.Build.0 = Release|x86 {DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.Build.0 = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.ActiveCfg = Release|x86 {DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.Build.0 = Release|x86 {DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.Build.0 = Release|x86
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|x86.ActiveCfg = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Debug|x86.Build.0 = Debug|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|Any CPU.Build.0 = Release|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|x86.ActiveCfg = Release|Any CPU
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -18,7 +18,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
readonly FromHistoryCfg cfg; readonly FromHistoryCfg cfg;
public bool SimultWithPrevious { get { return true; } } public bool SimultWithPrevious { get { return false; } }
public bool SimultWithNext { get { return false; } } public bool SimultWithNext { get { return false; } }
#region Configuration Change Handling #region Configuration Change Handling

View File

@ -16,6 +16,8 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
public bool UseWebService; public bool UseWebService;
public string BaseUrl;
public string RelativeUrl;
public bool UseLocalDB; public bool UseLocalDB;
public string ProcedureName; public string ProcedureName;
public string ProcedureNameAlt1; public string ProcedureNameAlt1;
@ -34,6 +36,8 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
ParentName = string.Empty; ParentName = string.Empty;
UseWebService = false; UseWebService = false;
BaseUrl = "https://tludockerhost1:5011/api/";
RelativeUrl = "q2correction";
UseLocalDB = true; UseLocalDB = true;
ProcedureName = "iPERL Smart Suez DN15 Q3_2.5 R800"; ProcedureName = "iPERL Smart Suez DN15 Q3_2.5 R800";
ProcedureNameAlt1 = "iPERL Suez DN15 Q3_2.5 R800"; ProcedureNameAlt1 = "iPERL Suez DN15 Q3_2.5 R800";

View File

@ -10,7 +10,7 @@ using TBF.Resources;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{ {
public partial class FromHistoryCfgCtrl : UserControl, IComponentCfgCtrl public partial class FromHistoryCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{ {
static readonly ILog log = LogManager.GetLogger(typeof(FromHistoryCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(FromHistoryCfgCtrl));
@ -26,6 +26,10 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
private TextBox procedureNameAlt2TextBox; private TextBox procedureNameAlt2TextBox;
private CheckBox useWebServiceCheckBox; private CheckBox useWebServiceCheckBox;
private CheckBox useDefaultValuesCheckBox; private CheckBox useDefaultValuesCheckBox;
private TextBox relativeUrlTextBox;
private Label relativeUrlLabel;
private TextBox baseUrlTextBox;
private Label baseUrlLabel;
public bool ShowMore { get { return false; } } public bool ShowMore { get { return false; } }
@ -60,6 +64,8 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
classNameLabel.Text = config.Factory.ClassName; classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
useWebServiceCheckBox.Checked = config.UseWebService; useWebServiceCheckBox.Checked = config.UseWebService;
baseUrlTextBox.Text = config.BaseUrl;
relativeUrlTextBox.Text = config.RelativeUrl;
useLocalDBCheckBox.Checked = config.UseLocalDB; useLocalDBCheckBox.Checked = config.UseLocalDB;
procedureNameTextBox.Text = config.ProcedureName; procedureNameTextBox.Text = config.ProcedureName;
procedureNameAlt1TextBox.Text = config.ProcedureNameAlt1; procedureNameAlt1TextBox.Text = config.ProcedureNameAlt1;
@ -71,6 +77,8 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{ {
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
useWebServiceCheckBox.Enabled = true; useWebServiceCheckBox.Enabled = true;
baseUrlTextBox.Enabled = true;
relativeUrlTextBox.Enabled = true;
useLocalDBCheckBox.Enabled = true; useLocalDBCheckBox.Enabled = true;
procedureNameTextBox.Enabled = true; procedureNameTextBox.Enabled = true;
procedureNameAlt1TextBox.Enabled = true; procedureNameAlt1TextBox.Enabled = true;
@ -95,41 +103,14 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
} }
if (config.UseWebService != useWebServiceCheckBox.Checked) flags |= UpdateDifferent(ref config.UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
{ flags |= UpdateDifferent(ref config.BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
config.UseWebService = useWebServiceCheckBox.Checked; flags |= UpdateDifferent(ref config.RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange); flags |= UpdateDifferent(ref config.UseLocalDB, useLocalDBCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
} flags |= UpdateDifferent(ref config.ProcedureName, procedureNameTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
flags |= UpdateDifferent(ref config.ProcedureNameAlt1, procedureNameAlt1TextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
if (config.UseLocalDB != useLocalDBCheckBox.Checked) flags |= UpdateDifferent(ref config.ProcedureNameAlt2, procedureNameAlt2TextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
{ flags |= UpdateDifferent(ref config.UseDefaultValues, useDefaultValuesCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
config.UseLocalDB = useLocalDBCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureName != procedureNameTextBox.Text)
{
config.ProcedureName = procedureNameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt1 != procedureNameAlt1TextBox.Text)
{
config.ProcedureNameAlt1 = procedureNameAlt1TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt2 != procedureNameAlt2TextBox.Text)
{
config.ProcedureNameAlt2 = procedureNameAlt2TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseDefaultValues != useDefaultValuesCheckBox.Checked)
{
config.UseDefaultValues = useDefaultValuesCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{ {
@ -153,33 +134,37 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
this.procedureNameAlt2TextBox = new System.Windows.Forms.TextBox(); this.procedureNameAlt2TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt2Label = new System.Windows.Forms.Label(); this.procedureNameAlt2Label = new System.Windows.Forms.Label();
this.useDefaultValuesCheckBox = new System.Windows.Forms.CheckBox(); this.useDefaultValuesCheckBox = new System.Windows.Forms.CheckBox();
this.relativeUrlTextBox = new System.Windows.Forms.TextBox();
this.relativeUrlLabel = new System.Windows.Forms.Label();
this.baseUrlTextBox = new System.Windows.Forms.TextBox();
this.baseUrlLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// procedureNameTextBox // procedureNameTextBox
// //
this.procedureNameTextBox.Enabled = false; this.procedureNameTextBox.Enabled = false;
this.procedureNameTextBox.Location = new System.Drawing.Point(190, 124); this.procedureNameTextBox.Location = new System.Drawing.Point(165, 176);
this.procedureNameTextBox.Name = "procedureNameTextBox"; this.procedureNameTextBox.Name = "procedureNameTextBox";
this.procedureNameTextBox.Size = new System.Drawing.Size(171, 20); this.procedureNameTextBox.Size = new System.Drawing.Size(217, 20);
this.procedureNameTextBox.TabIndex = 6; this.procedureNameTextBox.TabIndex = 10;
// //
// procedureNameLabel // procedureNameLabel
// //
this.procedureNameLabel.AutoSize = true; this.procedureNameLabel.AutoSize = true;
this.procedureNameLabel.Location = new System.Drawing.Point(65, 127); this.procedureNameLabel.Location = new System.Drawing.Point(40, 179);
this.procedureNameLabel.Name = "procedureNameLabel"; this.procedureNameLabel.Name = "procedureNameLabel";
this.procedureNameLabel.Size = new System.Drawing.Size(85, 13); this.procedureNameLabel.Size = new System.Drawing.Size(85, 13);
this.procedureNameLabel.TabIndex = 5; this.procedureNameLabel.TabIndex = 9;
this.procedureNameLabel.Text = "Procedure name"; this.procedureNameLabel.Text = "Procedure name";
// //
// useLocalDBCheckBox // useLocalDBCheckBox
// //
this.useLocalDBCheckBox.AutoSize = true; this.useLocalDBCheckBox.AutoSize = true;
this.useLocalDBCheckBox.Enabled = false; this.useLocalDBCheckBox.Enabled = false;
this.useLocalDBCheckBox.Location = new System.Drawing.Point(38, 103); this.useLocalDBCheckBox.Location = new System.Drawing.Point(13, 155);
this.useLocalDBCheckBox.Name = "useLocalDBCheckBox"; this.useLocalDBCheckBox.Name = "useLocalDBCheckBox";
this.useLocalDBCheckBox.Size = new System.Drawing.Size(129, 17); this.useLocalDBCheckBox.Size = new System.Drawing.Size(129, 17);
this.useLocalDBCheckBox.TabIndex = 4; this.useLocalDBCheckBox.TabIndex = 8;
this.useLocalDBCheckBox.Text = "2. Use local database"; this.useLocalDBCheckBox.Text = "2. Use local database";
this.useLocalDBCheckBox.UseVisualStyleBackColor = true; this.useLocalDBCheckBox.UseVisualStyleBackColor = true;
// //
@ -187,7 +172,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
// //
this.useWebServiceCheckBox.AutoSize = true; this.useWebServiceCheckBox.AutoSize = true;
this.useWebServiceCheckBox.Enabled = false; this.useWebServiceCheckBox.Enabled = false;
this.useWebServiceCheckBox.Location = new System.Drawing.Point(38, 78); this.useWebServiceCheckBox.Location = new System.Drawing.Point(13, 74);
this.useWebServiceCheckBox.Name = "useWebServiceCheckBox"; this.useWebServiceCheckBox.Name = "useWebServiceCheckBox";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(117, 17); this.useWebServiceCheckBox.Size = new System.Drawing.Size(117, 17);
this.useWebServiceCheckBox.TabIndex = 3; this.useWebServiceCheckBox.TabIndex = 3;
@ -197,15 +182,15 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
// nameTextBox // nameTextBox
// //
this.nameTextBox.Enabled = false; this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(190, 45); this.nameTextBox.Location = new System.Drawing.Point(165, 38);
this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(171, 20); this.nameTextBox.Size = new System.Drawing.Size(217, 20);
this.nameTextBox.TabIndex = 2; this.nameTextBox.TabIndex = 2;
// //
// nameLabel // nameLabel
// //
this.nameLabel.AutoSize = true; this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(132, 48); this.nameLabel.Location = new System.Drawing.Point(107, 41);
this.nameLabel.Name = "nameLabel"; this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1; this.nameLabel.TabIndex = 1;
@ -214,7 +199,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
// classNameLabel // classNameLabel
// //
this.classNameLabel.AutoSize = true; this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(187, 16); this.classNameLabel.Location = new System.Drawing.Point(162, 14);
this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(89, 13); this.classNameLabel.Size = new System.Drawing.Size(89, 13);
this.classNameLabel.TabIndex = 0; this.classNameLabel.TabIndex = 0;
@ -223,50 +208,88 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
// procedureNameAlt1TextBox // procedureNameAlt1TextBox
// //
this.procedureNameAlt1TextBox.Enabled = false; this.procedureNameAlt1TextBox.Enabled = false;
this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(190, 147); this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(165, 199);
this.procedureNameAlt1TextBox.Name = "procedureNameAlt1TextBox"; this.procedureNameAlt1TextBox.Name = "procedureNameAlt1TextBox";
this.procedureNameAlt1TextBox.Size = new System.Drawing.Size(171, 20); this.procedureNameAlt1TextBox.Size = new System.Drawing.Size(217, 20);
this.procedureNameAlt1TextBox.TabIndex = 8; this.procedureNameAlt1TextBox.TabIndex = 12;
// //
// procedureNameAlt1Label // procedureNameAlt1Label
// //
this.procedureNameAlt1Label.AutoSize = true; this.procedureNameAlt1Label.AutoSize = true;
this.procedureNameAlt1Label.Location = new System.Drawing.Point(65, 150); this.procedureNameAlt1Label.Location = new System.Drawing.Point(40, 202);
this.procedureNameAlt1Label.Name = "procedureNameAlt1Label"; this.procedureNameAlt1Label.Name = "procedureNameAlt1Label";
this.procedureNameAlt1Label.Size = new System.Drawing.Size(106, 13); this.procedureNameAlt1Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt1Label.TabIndex = 7; this.procedureNameAlt1Label.TabIndex = 11;
this.procedureNameAlt1Label.Text = "Procedure name Alt1"; this.procedureNameAlt1Label.Text = "Procedure name Alt1";
// //
// procedureNameAlt2TextBox // procedureNameAlt2TextBox
// //
this.procedureNameAlt2TextBox.Enabled = false; this.procedureNameAlt2TextBox.Enabled = false;
this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(190, 170); this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(165, 222);
this.procedureNameAlt2TextBox.Name = "procedureNameAlt2TextBox"; this.procedureNameAlt2TextBox.Name = "procedureNameAlt2TextBox";
this.procedureNameAlt2TextBox.Size = new System.Drawing.Size(171, 20); this.procedureNameAlt2TextBox.Size = new System.Drawing.Size(217, 20);
this.procedureNameAlt2TextBox.TabIndex = 10; this.procedureNameAlt2TextBox.TabIndex = 14;
// //
// procedureNameAlt2Label // procedureNameAlt2Label
// //
this.procedureNameAlt2Label.AutoSize = true; this.procedureNameAlt2Label.AutoSize = true;
this.procedureNameAlt2Label.Location = new System.Drawing.Point(65, 173); this.procedureNameAlt2Label.Location = new System.Drawing.Point(40, 225);
this.procedureNameAlt2Label.Name = "procedureNameAlt2Label"; this.procedureNameAlt2Label.Name = "procedureNameAlt2Label";
this.procedureNameAlt2Label.Size = new System.Drawing.Size(106, 13); this.procedureNameAlt2Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt2Label.TabIndex = 9; this.procedureNameAlt2Label.TabIndex = 13;
this.procedureNameAlt2Label.Text = "Procedure name Alt2"; this.procedureNameAlt2Label.Text = "Procedure name Alt2";
// //
// useDefaultValuesCheckBox // useDefaultValuesCheckBox
// //
this.useDefaultValuesCheckBox.AutoSize = true; this.useDefaultValuesCheckBox.AutoSize = true;
this.useDefaultValuesCheckBox.Enabled = false; this.useDefaultValuesCheckBox.Enabled = false;
this.useDefaultValuesCheckBox.Location = new System.Drawing.Point(38, 202); this.useDefaultValuesCheckBox.Location = new System.Drawing.Point(13, 258);
this.useDefaultValuesCheckBox.Name = "useDefaultValuesCheckBox"; this.useDefaultValuesCheckBox.Name = "useDefaultValuesCheckBox";
this.useDefaultValuesCheckBox.Size = new System.Drawing.Size(126, 17); this.useDefaultValuesCheckBox.Size = new System.Drawing.Size(126, 17);
this.useDefaultValuesCheckBox.TabIndex = 11; this.useDefaultValuesCheckBox.TabIndex = 15;
this.useDefaultValuesCheckBox.Text = "3. Use default values"; this.useDefaultValuesCheckBox.Text = "3. Use default values";
this.useDefaultValuesCheckBox.UseVisualStyleBackColor = true; this.useDefaultValuesCheckBox.UseVisualStyleBackColor = true;
// //
// relativeUrlTextBox
//
this.relativeUrlTextBox.Enabled = false;
this.relativeUrlTextBox.Location = new System.Drawing.Point(120, 119);
this.relativeUrlTextBox.Name = "relativeUrlTextBox";
this.relativeUrlTextBox.Size = new System.Drawing.Size(262, 20);
this.relativeUrlTextBox.TabIndex = 7;
//
// relativeUrlLabel
//
this.relativeUrlLabel.AutoSize = true;
this.relativeUrlLabel.Location = new System.Drawing.Point(40, 122);
this.relativeUrlLabel.Name = "relativeUrlLabel";
this.relativeUrlLabel.Size = new System.Drawing.Size(71, 13);
this.relativeUrlLabel.TabIndex = 6;
this.relativeUrlLabel.Text = "Relative URL";
//
// baseUrlTextBox
//
this.baseUrlTextBox.Enabled = false;
this.baseUrlTextBox.Location = new System.Drawing.Point(120, 96);
this.baseUrlTextBox.Name = "baseUrlTextBox";
this.baseUrlTextBox.Size = new System.Drawing.Size(262, 20);
this.baseUrlTextBox.TabIndex = 5;
//
// baseUrlLabel
//
this.baseUrlLabel.AutoSize = true;
this.baseUrlLabel.Location = new System.Drawing.Point(40, 99);
this.baseUrlLabel.Name = "baseUrlLabel";
this.baseUrlLabel.Size = new System.Drawing.Size(56, 13);
this.baseUrlLabel.TabIndex = 4;
this.baseUrlLabel.Text = "Base URL";
//
// FromHistoryCfgCtrl // FromHistoryCfgCtrl
// //
this.Controls.Add(this.relativeUrlTextBox);
this.Controls.Add(this.relativeUrlLabel);
this.Controls.Add(this.baseUrlTextBox);
this.Controls.Add(this.baseUrlLabel);
this.Controls.Add(this.useDefaultValuesCheckBox); this.Controls.Add(this.useDefaultValuesCheckBox);
this.Controls.Add(this.procedureNameAlt2TextBox); this.Controls.Add(this.procedureNameAlt2TextBox);
this.Controls.Add(this.procedureNameAlt2Label); this.Controls.Add(this.procedureNameAlt2Label);
@ -280,7 +303,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
this.Controls.Add(this.nameLabel); this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel); this.Controls.Add(this.classNameLabel);
this.Name = "FromHistoryCfgCtrl"; this.Name = "FromHistoryCfgCtrl";
this.Size = new System.Drawing.Size(400, 250); this.Size = new System.Drawing.Size(400, 300);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -7,6 +7,7 @@ using System.Linq;
using NHibernate; using NHibernate;
using log4net; using log4net;
using Results.Entities; using Results.Entities;
using RestClient;
using TBF.UiBridge; using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
@ -44,7 +45,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
/// Populate TestResult data entity with data /// Populate TestResult data entity with data
/// ///
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null) if (tstRslt != null)
{ {
tstRslt.StartTime = DateTime.Now; tstRslt.StartTime = DateTime.Now;
@ -52,7 +53,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
tstRslt.TestDone = true; tstRslt.TestDone = true;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++) for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{ {
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
if (meterRslt != null) if (meterRslt != null)
{ {
meterRslt.TestDone = true; meterRslt.TestDone = true;
@ -61,6 +62,10 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
} }
} }
if (!success)
{
Bridge.OnError(this, "Q2 pre-correction sa nedá načítať");
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed));
return new List<Event> { success ? Event.Done : Event.RecoverableError }; return new List<Event> { success ? Event.Done : Event.RecoverableError };
@ -74,15 +79,26 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
try try
{ {
return false; GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfg.BaseUrl);
client.GetToken("ReadUser", "sensus", "https://sluprimadev/SensusCore/api/v1/Locations/1/Login2").Wait();
/// TODO: Use webservice Q2PreCorrection response = client.GetQ2Correction(cfg.RelativeUrl).Result;
//IsQ2PreCorrectionCalculated = true; if (response != null && response.AreDataCalculated)
//return true; {
CalculatedQ2PreCorrectionLR = response.CorrLR;
CalculatedQ2PreCorrectionRL = response.CorrRL;
IsQ2PreCorrectionCalculated = true;
log.WarnFormat("Q2 corrections from a REST client are: LR = {0}, RL = {1}", CalculatedQ2PreCorrectionLR, CalculatedQ2PreCorrectionRL);
return true;
}
else
{
log.ErrorFormat("Failed to obtain Q2 corrections from a REST client");
return false;
}
} }
catch (Exception exc) catch (Exception exc)
{ {
log.ErrorFormat("Failed to calculate Q2 corrections: {0}", exc.Message); log.ErrorFormat("Failed to obtain Q2 corrections from a REST client: {0}", exc.Message);
return false; return false;
} }
} }

View File

@ -3472,6 +3472,10 @@
<Project>{0C0A1F4D-1363-4544-A7C5-196C76D26CCA}</Project> <Project>{0C0A1F4D-1363-4544-A7C5-196C76D26CCA}</Project>
<Name>GraphLib</Name> <Name>GraphLib</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\RestClient\RestClient.csproj">
<Project>{46e3b0e1-209f-4550-b0dd-d7e2c039b3ce}</Project>
<Name>RestClient</Name>
</ProjectReference>
<ProjectReference Include="..\TracingDB\TracingDB.csproj"> <ProjectReference Include="..\TracingDB\TracingDB.csproj">
<Project>{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}</Project> <Project>{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}</Project>
<Name>TracingDB</Name> <Name>TracingDB</Name>

View File

@ -14,6 +14,8 @@ rmdir /s /q GraphLib\bin
rmdir /s /q GraphLib\obj rmdir /s /q GraphLib\obj
rmdir /s /q TracingDB\bin rmdir /s /q TracingDB\bin
rmdir /s /q TracingDB\obj rmdir /s /q TracingDB\obj
rmdir /s /q RestClient\bin
rmdir /s /q RestClient\obj
rmdir /s /q Results\bin rmdir /s /q Results\bin
rmdir /s /q Results\obj rmdir /s /q Results\obj
rmdir /s /q ResultsBrowser\bin rmdir /s /q ResultsBrowser\bin
@ -28,4 +30,3 @@ rmdir /s /q Users\bin
rmdir /s /q Users\obj rmdir /s /q Users\obj
rmdir /s /q UserManagement\bin rmdir /s /q UserManagement\bin
rmdir /s /q UserManagement\obj rmdir /s /q UserManagement\obj


Binary file not shown.

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff