inital
This commit is contained in:
365
FasdCockpitBase/ExternalToolExecutor.cs
Normal file
365
FasdCockpitBase/ExternalToolExecutor.cs
Normal file
@@ -0,0 +1,365 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.Security;
|
||||
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdCockpitBase
|
||||
{
|
||||
public class cExternalToolExecutor
|
||||
{
|
||||
public interface iNamedParameter
|
||||
{
|
||||
string Title { get; set; }
|
||||
string GetValue();
|
||||
(string Title, string Value) GetTitleValuePair();
|
||||
}
|
||||
|
||||
[DllImport("shell32.dll", EntryPoint = "ShellExecute")]
|
||||
public static extern long ShellExecute(int hwnd, string cmd, string file, string param1, string param2, int swmode);
|
||||
|
||||
private static cCredential RemoteToolAlternateCredentials;
|
||||
|
||||
public class cProcessResult
|
||||
{
|
||||
public cProcessResult(int returnCode) { ReturnCode = returnCode; }
|
||||
public int ReturnCode = -1;
|
||||
public string StandardOutput = null;
|
||||
public string StandardError = null;
|
||||
}
|
||||
|
||||
static protected cCredential GetRemoteToolCredentials(string Title)
|
||||
{
|
||||
if (RemoteToolAlternateCredentials == null)
|
||||
{
|
||||
var Caption = cMultiLanguageSupport.GetItem("RemoteTool.Credentials.Caption");
|
||||
Caption = string.Format(Caption, Title);
|
||||
var Message = cMultiLanguageSupport.GetItem("RemoteTool.Credentials.Message");
|
||||
|
||||
RemoteToolAlternateCredentials = cInputCredentials.GetCredentials(Caption, Message);
|
||||
}
|
||||
|
||||
return RemoteToolAlternateCredentials;
|
||||
}
|
||||
|
||||
static protected void AddFileSecurity(string fileName, string account, FileSystemRights rights, AccessControlType controlType)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileSecurity fSecurity = File.GetAccessControl(fileName);
|
||||
fSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));
|
||||
File.SetAccessControl(fileName, fSecurity);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
static protected string ReplaceEnvironmentVariables(string input)
|
||||
{
|
||||
var output = input;
|
||||
|
||||
try
|
||||
{
|
||||
var specialFolders = Enum.GetValues(typeof(Environment.SpecialFolder)).Cast<Environment.SpecialFolder>();
|
||||
|
||||
foreach (var specialFolder in specialFolders)
|
||||
{
|
||||
var specialFolderName = "%" + specialFolder.ToString() + "%";
|
||||
var specialFolderPath = Environment.GetFolderPath(specialFolder);
|
||||
output = output.Replace(specialFolderName, specialFolderPath);
|
||||
}
|
||||
|
||||
output = Environment.ExpandEnvironmentVariables(output);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static protected async Task<cProcessResult> RunProcessAsync(string Cmd, string Params, cCredential Credentials, bool Hidden)
|
||||
{
|
||||
try
|
||||
{
|
||||
cProcessResult processResult = new cProcessResult(0);
|
||||
|
||||
var process = createProcessInstance(Cmd, Params, Credentials, true, Hidden);
|
||||
|
||||
TaskCompletionSource<int> _resultAwaiter = null;
|
||||
_resultAwaiter = new TaskCompletionSource<int>();
|
||||
EventHandler resultEventHandler = null;
|
||||
resultEventHandler = (sender, args) =>
|
||||
{
|
||||
process.Exited -= resultEventHandler;
|
||||
_resultAwaiter.SetResult(process.ExitCode);
|
||||
};
|
||||
process.Exited += resultEventHandler;
|
||||
process.EnableRaisingEvents = true;
|
||||
|
||||
try
|
||||
{
|
||||
process.Start();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E, LogLevels.Warning);
|
||||
return new cProcessResult(E.HResult);
|
||||
}
|
||||
|
||||
var t1 = process.StandardOutput.ReadToEndAsync();
|
||||
var t2 = process.StandardError.ReadToEndAsync();
|
||||
var t3 = _resultAwaiter.Task;
|
||||
|
||||
await Task.WhenAll(t1, t2, t3);
|
||||
|
||||
processResult.StandardOutput = (await t1);
|
||||
processResult.StandardError = (await t2);
|
||||
processResult.ReturnCode = (await t3);
|
||||
|
||||
return processResult;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return new cProcessResult(E.HResult);
|
||||
}
|
||||
}
|
||||
|
||||
static protected cProcessResult StartProcessAsync(string Cmd, string Params, cCredential Credentials, bool Hidden)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var process = createProcessInstance(Cmd, Params, Credentials, false, Hidden))
|
||||
{
|
||||
var _s = process.Start();
|
||||
}
|
||||
return new cProcessResult(0);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E, LogLevels.Warning);
|
||||
return new cProcessResult(E.HResult);
|
||||
}
|
||||
}
|
||||
|
||||
static protected Process createProcessInstance(string Cmd, string Params, cCredential Credentials, bool Wait, bool Hidden)
|
||||
{
|
||||
try
|
||||
{
|
||||
var processInformation = new ProcessStartInfo(Cmd, Params);
|
||||
processInformation.UseShellExecute = false;
|
||||
if (Credentials != null)
|
||||
{
|
||||
processInformation.LoadUserProfile = true;
|
||||
processInformation.UserName = Credentials.User;
|
||||
processInformation.Password = Credentials.Password;
|
||||
processInformation.Domain = Credentials.Domain;
|
||||
}
|
||||
|
||||
if (Hidden)
|
||||
{
|
||||
processInformation.CreateNoWindow = true;
|
||||
processInformation.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
}
|
||||
|
||||
if (Wait)
|
||||
{
|
||||
processInformation.RedirectStandardOutput = true;
|
||||
processInformation.RedirectStandardError = true;
|
||||
}
|
||||
|
||||
var process = new Process() { StartInfo = processInformation };
|
||||
|
||||
return process;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static public string ReplaceParameters(string input, Dictionary<string, iNamedParameter> NamedParameters, bool ReplaceEnvironment, Dictionary<cAdjustableParameter, object> ParameterDictionary = null)
|
||||
{
|
||||
string output = input;
|
||||
try
|
||||
{
|
||||
if (input != null)
|
||||
{
|
||||
if (ParameterDictionary != null)
|
||||
{
|
||||
foreach (var parameter in ParameterDictionary)
|
||||
{
|
||||
var _str = parameter.Key.GetValueString(parameter.Value);
|
||||
output = output.Replace("%" + parameter.Key.ParameterName + "%", _str);
|
||||
}
|
||||
}
|
||||
|
||||
if (NamedParameters != null)
|
||||
foreach (var namedParameter in NamedParameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
var parameterName = namedParameter.Key;
|
||||
|
||||
var namedParameterKeyValuePair = namedParameter.Value.GetTitleValuePair();
|
||||
var parameterLabel = namedParameterKeyValuePair.Title;
|
||||
var parameterValue = namedParameterKeyValuePair.Value;
|
||||
|
||||
output = output.Replace("%" + parameterName + ".Label%", parameterLabel);
|
||||
output = output.Replace("%" + parameterName + ".Value%", parameterValue);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (ReplaceEnvironment)
|
||||
output = ReplaceEnvironmentVariables(output);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static async Task<cProcessResult> StartLocalActionAsync(cFasdQuickActionLocal localAction, Dictionary<string, iNamedParameter> NamedParameters, string ProgramTitle, Dictionary<cAdjustableParameter, object> ParameterDictionary = null)
|
||||
{
|
||||
cProcessResult _resultProcess = new cProcessResult(0);
|
||||
|
||||
cCredential Credentials = null;
|
||||
if (localAction.StartWithAlternateCredentials)
|
||||
Credentials = GetRemoteToolCredentials(ProgramTitle);
|
||||
|
||||
const string constPowershellPath = @"%System%\WindowsPowerShell\v1.0\powershell.exe";
|
||||
|
||||
string parameters = null;
|
||||
string cmd = null;
|
||||
string scriptName = null;
|
||||
bool dontUseShell = true;
|
||||
|
||||
bool isHidden = false;
|
||||
bool isScript = false;
|
||||
bool doWait = (localAction.ColumnOutputFormattings?.Count > 0);
|
||||
|
||||
if (localAction is cFasdQuickActionLocalScript quickActionScript)
|
||||
{
|
||||
isScript = true;
|
||||
isHidden = true;
|
||||
doWait = true;
|
||||
|
||||
cmd = constPowershellPath;
|
||||
scriptName = Path.GetTempFileName();
|
||||
if (File.Exists(scriptName))
|
||||
File.Delete(scriptName);
|
||||
scriptName += ".ps1";
|
||||
|
||||
if (quickActionScript.IsBase64)
|
||||
File.WriteAllBytes(scriptName, quickActionScript.ScriptBinary);
|
||||
else
|
||||
File.WriteAllText(scriptName, quickActionScript.Script, Encoding.Unicode);
|
||||
|
||||
if (localAction.StartWithAlternateCredentials && (Credentials != null))
|
||||
AddFileSecurity(scriptName, Credentials.GetAccount(true), FileSystemRights.Read, AccessControlType.Allow);
|
||||
|
||||
parameters = $"-NoLogo -ExecutionPolicy bypass -file \"{scriptName}\"";
|
||||
|
||||
if (localAction.Parameters != null)
|
||||
parameters += " " + localAction.Parameters;
|
||||
}
|
||||
else if (localAction is cFasdQuickActionLocalCmd quickActionCmd)
|
||||
{
|
||||
cmd = quickActionCmd.Cmd;
|
||||
parameters = quickActionCmd.Parameters;
|
||||
dontUseShell = quickActionCmd.DontUseShell;
|
||||
}
|
||||
else
|
||||
return _resultProcess;
|
||||
|
||||
cmd = ReplaceEnvironmentVariables(cmd);
|
||||
|
||||
if (parameters != null)
|
||||
parameters = ReplaceParameters(parameters, NamedParameters, true, ParameterDictionary);
|
||||
|
||||
try
|
||||
{
|
||||
if (!dontUseShell && !localAction.StartWithAlternateCredentials)
|
||||
{
|
||||
var PRet = (int)ShellExecute(0, "open", cmd, parameters, null, 5);
|
||||
|
||||
/*
|
||||
* The Microsoft docs states as following regarding the return value of a ShellExecute:
|
||||
* https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
|
||||
*
|
||||
* If the function succeeds, it returns a value greater than 32.
|
||||
* If the function fails, it returns an error value that indicates the cause of the failure.
|
||||
* The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however.
|
||||
* It can be cast only to an INT_PTR and compared to either 32 or the following error codes below.
|
||||
*/
|
||||
const int highestFailureReturnCode = 32;
|
||||
|
||||
// Our internal cPorcessResult is built that way a ReturnCode of 0 is considered as successfull.
|
||||
// This has to be mapped to the HINSTANCE result code above.
|
||||
if (PRet > highestFailureReturnCode)
|
||||
PRet = 0;
|
||||
|
||||
_resultProcess = new cProcessResult(PRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
if (localAction.RequireAdministrator && localAction.StartWithAlternateCredentials)
|
||||
{
|
||||
cmd = ReplaceEnvironmentVariables("%System%\\WindowsPowerShell\\v1.0\\powershell.exe");
|
||||
var argumentList = parameters.Replace("\"", "\"\"");
|
||||
var Cmd = $"Start-Process \"{cmd}\" -WindowStyle Hidden -Wait -Verb \"runas\" -ArgumentList \"{argumentList}\"";
|
||||
var parameterByteArray = Encoding.Unicode.GetBytes(Cmd);
|
||||
parameters = Convert.ToBase64String(parameterByteArray);
|
||||
parameters = "-NonInteractive -NoLogo -ExecutionPolicy bypass -EncodedCommand " + parameters;
|
||||
isHidden = true;
|
||||
}
|
||||
|
||||
if (doWait)
|
||||
_resultProcess = await RunProcessAsync(cmd, parameters, Credentials, isHidden);
|
||||
else
|
||||
_resultProcess = StartProcessAsync(cmd, parameters, Credentials, isHidden);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
if (isScript)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(scriptName);
|
||||
}
|
||||
catch { }
|
||||
;
|
||||
}
|
||||
|
||||
return _resultProcess;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
143
FasdCockpitBase/F4SD-Cockpit-Client-Base.csproj
Normal file
143
FasdCockpitBase/F4SD-Cockpit-Client-Base.csproj
Normal file
@@ -0,0 +1,143 @@
|
||||
<?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>{6DCED162-2229-4483-BA70-4471BCDD29CF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>FasdCockpitBase</RootNamespace>
|
||||
<AssemblyName>F4SD-Cockpit-Client-Base</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>false</Deterministic>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</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>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Demo%28Debug%29|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Demo%28Debug%29\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NewFeatures%28Debug%29|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\NewFeatures%28Debug%29\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MaterialIcons, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialIcons.1.0.3\lib\MaterialIcons.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<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="..\..\C4IT FASD\_Common\C4IT.F4SD.GlobalConfig.cs">
|
||||
<Link>Common\C4IT.F4SD.GlobalConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.F4SD.HealthCardConfig.cs">
|
||||
<Link>Common\C4IT.F4SD.HealthCardConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.F4SD.MenuItem.cs">
|
||||
<Link>Common\C4IT.F4SD.MenuItem.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.F4SD.XmlConfig.cs">
|
||||
<Link>Common\C4IT.F4SD.XmlConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.Base.cs">
|
||||
<Link>Common\C4IT.FASD.Base.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.ConfigBase.cs">
|
||||
<Link>Common\C4IT.FASD.ConfigBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.CopyTemplatesConfig.cs">
|
||||
<Link>Common\C4IT.FASD.CopyTemplatesConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.IconConfig.cs">
|
||||
<Link>Common\C4IT.FASD.IconConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.MenuSectionConfig.cs">
|
||||
<Link>Common\C4IT.FASD.MenuSectionConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\C4IT FASD\_Common\C4IT.FASD.QuickActionConfig.cs">
|
||||
<Link>Common\C4IT.FASD.QuickActionConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Configuration\C4IT.Configuration.ConfigHelper.cs">
|
||||
<Link>Common\C4IT.Configuration.ConfigHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\MultiLanguage\C4IT.MultiLanguage.MultiLanguageSupport.cs">
|
||||
<Link>Common\C4IT.MultiLanguage.MultiLanguageSupport.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Security\C4IT.Security.Credential.cs">
|
||||
<Link>Common\C4IT.Security.Credential.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Security\C4IT.Security.InputCredentials.cs">
|
||||
<Link>Common\C4IT.Security.InputCredentials.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Security\C4IT.Security.SecurePassword.cs">
|
||||
<Link>Common\C4IT.Security.SecurePassword.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Security\C4IT.Security.ThreadImpersonation.cs">
|
||||
<Link>Common\C4IT.Security.ThreadImpersonation.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\XML\C4IT.XML.ConfigParsing.cs">
|
||||
<Link>Common\C4IT.XML.ConfigParsing.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ExternalToolExecutor.cs" />
|
||||
<Compile Include="F4sdCockpitCommunicationM42Base.cs" />
|
||||
<Compile Include="FasdCockpitCommunicationBase.cs" />
|
||||
<Compile Include="Models\F4sdAgentScript.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\F4SD-Logging\F4SD-Logging.csproj">
|
||||
<Project>{7793f281-b226-4e20-b6f6-5d53d70f1dc1}</Project>
|
||||
<Name>F4SD-Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
10
FasdCockpitBase/F4SD-Cockpit-Client-Base.csproj.vspscc
Normal file
10
FasdCockpitBase/F4SD-Cockpit-Client-Base.csproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
40
FasdCockpitBase/F4sdCockpitCommunicationM42Base.cs
Normal file
40
FasdCockpitBase/F4sdCockpitCommunicationM42Base.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using C4IT.Security;
|
||||
|
||||
namespace C4IT.FASD.Cockpit.Communication
|
||||
{
|
||||
public class cF4sdCockpitCommunicationM42Base
|
||||
{
|
||||
public virtual async Task<cF4sdCockpitM42BearerTokenInfo> ValidateLogonPassthrough()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<cF4sdCockpitM42BearerTokenInfo> ValidateLogonBasic(string User, string Password)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<cF4sdCockpitM42BearerTokenInfo> ValidateLogonToken(string Token)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class cF4sdCockpitM42BearerTokenInfo
|
||||
{
|
||||
public string Token;
|
||||
public DateTime ValidUntil;
|
||||
}
|
||||
}
|
||||
175
FasdCockpitBase/FasdCockpitCommunicationBase.cs
Normal file
175
FasdCockpitBase/FasdCockpitCommunicationBase.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using FasdCockpitBase.Models;
|
||||
|
||||
namespace C4IT.FASD.Cockpit.Communication
|
||||
{
|
||||
public abstract class cFasdCockpitCommunicationBase
|
||||
{
|
||||
public static cFasdCockpitCommunicationBase Instance { get; set; }
|
||||
|
||||
public static cF4sdUserInfo CockpitUserInfo = null;
|
||||
public static object CockpitUserInfoLock = new object();
|
||||
|
||||
public Dictionary<Guid, cF4SDHealthCardRawData> CachedHealthCardRawData { get; set; } = new Dictionary<Guid, cF4SDHealthCardRawData>();
|
||||
|
||||
public delegate Task CheckConnectionStatusDelegate();
|
||||
|
||||
public CheckConnectionStatusDelegate CheckConnectionStatus;
|
||||
|
||||
public cF4sdCockpitCommunicationM42Base M42 = new cF4sdCockpitCommunicationM42Base();
|
||||
|
||||
public abstract bool IsDemo();
|
||||
|
||||
public abstract bool CheckConnectionInfo();
|
||||
|
||||
public abstract Task<cCheckConnectionResult> CheckConnection(Version minServerVersion);
|
||||
|
||||
public abstract Task<Guid> GetUserIdByAccount(string userName, string userDomain);
|
||||
|
||||
public abstract Task<cF4sdUserInfo> WinLogon();
|
||||
|
||||
public abstract Task<cF4SdUserInfoChange> RegisterExternalTokenAsync(cF4SDTokenRegistration Token);
|
||||
|
||||
public abstract Task<cF4SDAdditionalUserInfo> GetAdditionalUserInfo(enumAdditionalAuthentication Type);
|
||||
|
||||
public abstract Task<bool> IsAnalyticsModuleActive();
|
||||
|
||||
public abstract Task<bool> CreateUserSession(cF4SDUserSessionParameters sessionParameter);
|
||||
public abstract Task CloseUserSession(Guid sessionId);
|
||||
public abstract Task<bool> StartCase(cF4SDCaseParameters caseParameters);
|
||||
public abstract Task<bool> UpdateCase(cF4SDCaseStatusParameters caseStatusParameters, List<cF4SDCaseTime> caseTimes);
|
||||
public abstract Task<bool> KeepAliveCase(Guid caseId);
|
||||
public abstract Task<bool> KeepAliveSession(Guid sessionId);
|
||||
|
||||
public abstract Task<bool> ReportQuickAction(cF4SDQuickActionParameters quickActionParameters);
|
||||
|
||||
public static bool Debug_apiValues = false;
|
||||
public static bool Debug_apiTiming = false;
|
||||
|
||||
public abstract Task<cFasdBaseConfig> GetConfiguration(enumFasdConfigurationType configType);
|
||||
|
||||
public abstract Task<Guid?> GetSearchResultsStart(string searchValue, CancellationToken cancellationToken);
|
||||
public abstract Task<cFasdApiSearchResultCollection> GetSearchResultsResult(Guid taskID, CancellationToken cancellationToken);
|
||||
public abstract Task GetSearchResultsStop(Guid taskID, CancellationToken cancellationToken);
|
||||
|
||||
public abstract Task<cFasdApiSearchResultCollection> GetPhoneSearchResults(cPhoneSearchParameters searchInfo);
|
||||
public abstract Task<cFasdApiSearchResultCollection> GetComputerSearchResults(string Name, string Domain);
|
||||
public abstract Task<cFasdApiSearchResultCollection> GetUserSearchResults(string Name, List<string> SIDs);
|
||||
|
||||
public abstract Task<cF4sdStagedSearchResultRelationTaskId> StartGatheringRelations(IEnumerable<cFasdApiSearchResultEntry> relatedTo, CancellationToken token);
|
||||
public abstract Task<cF4sdStagedSearchResultRelations> GetStagedRelations(Guid id, CancellationToken token);
|
||||
|
||||
public abstract Task<List<cF4sdApiSearchResultRelation>> GetSearchResultRelations(enumF4sdSearchResultClass resultType, List<cFasdApiSearchResultEntry> searchResults);
|
||||
public abstract Task<List<cF4sdApiSearchResultRelation>> GetTicketOverviewRelations(string key, bool useRoleScope, int count);
|
||||
|
||||
public abstract Task<cF4SDHealthCardRawData> GetHealthCardData(cF4sdHealthCardRawDataRequest requestData);
|
||||
|
||||
public abstract Task<cF4SDHealthCardRawData> GetHealthCardData(Guid healthCardId);
|
||||
|
||||
public abstract Task<List<cF4SDHealthCardRawData.cHealthCardDetailsTable>> GetDetailsData(cF4sdHealthCardRawDataRequest requestData);
|
||||
|
||||
public abstract Task<int> GetPagedDataCount(cF4sdHealthSelectionDataRequest requestData);
|
||||
|
||||
public abstract Task<cF4SDHealthCardRawData.cHealthCardTable> GetPagedData(cF4sdHealthSelectionDataRequest requestData);
|
||||
|
||||
public abstract Task<bool> UpdateHealthcardTableData(cF4SDWriteParameters dataParameter);
|
||||
public abstract Task<bool> Matrix42TicketFinalization(cApiM42Ticket ticketData);
|
||||
|
||||
public abstract Task<List<List<object>>> GetQuickActionHistory(string QuickActionName, int OrgId, int DeviceId, int? UserId);
|
||||
|
||||
public abstract Task<bool> GetAgentApiAccessInfo();
|
||||
|
||||
public abstract Task<bool> GetCockpitConfiguration();
|
||||
|
||||
public abstract Task<bool> GetAgentOnlineStatus(int AgentDeviceId, int? AgentUserId = null);
|
||||
|
||||
public abstract Task<cF4sdAgentScript> GetQuickActionOfAgent(int ScriptId);
|
||||
|
||||
public abstract Task<List<cF4sdAgentScript>> GetQuickActionsOfAgent();
|
||||
public abstract Task<List<string>> GetQuickActionsOfServer();
|
||||
|
||||
public abstract Task<Guid> ActualizeAgentData(int AgentDeviceId, int? AgentUserId = null);
|
||||
|
||||
public abstract Task<enumActualizeStatus> GetActualizeAgentDataStatus(Guid actualizeId, enumFasdInformationClass informationClass);
|
||||
|
||||
public abstract Task<Guid?> TryActivateDirectConnection(int DeviceId);
|
||||
|
||||
public abstract Task StopDirectConnection(Guid connectionId);
|
||||
|
||||
public abstract Task<bool> IsDirectConnectionUp(Guid connectionId);
|
||||
|
||||
public abstract Task<bool> DirectConnectionExtendDuration(Guid connectonId, int timeOutInSeconds);
|
||||
|
||||
public abstract Task<cF4sdAgentScriptInformation> RunAgentScript(cF4sdQuickActionRemote Script, int OrgCode, int DeviceId, int? DeviceAccountId, string Parameters);
|
||||
public abstract Task<enumQuickActionStatus> GetAgentQuickActionStatus(int TaskId);
|
||||
public abstract Task<cF4sdQuickActionRevision> GetAgentRevision(int RevisionId, int OrgId);
|
||||
|
||||
public abstract Task CancelAgentTask(int TaskId);
|
||||
|
||||
public abstract Task InitializeAfterOnlineAsync();
|
||||
|
||||
public abstract Task TerminateAsync();
|
||||
|
||||
public abstract Uri GetMediaContentUri(string ContentRelPath);
|
||||
}
|
||||
|
||||
|
||||
public enum enumConnectionStatus
|
||||
{
|
||||
unknown = 0,
|
||||
serverNotFound,
|
||||
serverResponseError,
|
||||
incompatibleServerVersion,
|
||||
serverNotConfigured,
|
||||
serverStarting,
|
||||
connected,
|
||||
}
|
||||
|
||||
public enum enumQuickActionStatus
|
||||
{
|
||||
Unknown = -1,
|
||||
ConnectingToClient = 1,
|
||||
WaitingForUserAcceptance = 2,
|
||||
Running = 3,
|
||||
Finished = 4,
|
||||
Cancelled = 5
|
||||
}
|
||||
|
||||
public class cCheckConnectionResult
|
||||
{
|
||||
public enumConnectionStatus ConnectionStatus { get; set; }
|
||||
public cFasdApiConnectionInfo ApiConnectionInfo { get; set; }
|
||||
}
|
||||
|
||||
public class cPhoneSearchParameters
|
||||
{
|
||||
public string phone { get; set; }
|
||||
public string name { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cComputerDomainSearchParameters
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string domain { get; set; }
|
||||
}
|
||||
|
||||
public class cUserSidSearchParameters
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string sids { get; set; }
|
||||
}
|
||||
|
||||
public class cTicketSearchParameters
|
||||
{
|
||||
public string ticketName { get; set; }
|
||||
public string ticketId { get; set; }
|
||||
public string userName { get; set; }
|
||||
public string sids { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
25
FasdCockpitBase/Models/F4sdAgentScript.cs
Normal file
25
FasdCockpitBase/Models/F4sdAgentScript.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FasdCockpitBase.Models
|
||||
{
|
||||
public enum enumAgentScriptType { computer = 1, user = 2 }
|
||||
|
||||
public class cF4sdAgentScript
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public enumAgentScriptType Type { get; set; }
|
||||
public bool UserPermissionRequired { get; set; }
|
||||
}
|
||||
|
||||
public class cF4sdAgentScriptInformation
|
||||
{
|
||||
public int ScriptId { get; set; }
|
||||
public int RevisionId { get; set; }
|
||||
public int TaskId { get; set; }
|
||||
}
|
||||
}
|
||||
13
FasdCockpitBase/Properties/AssemblyInfo.cs
Normal file
13
FasdCockpitBase/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
[assembly: AssemblyTitle("F4SD Cockpit Client base libary")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("6dced162-2229-4483-ba70-4471bcdd29cf")]
|
||||
|
||||
5
FasdCockpitBase/packages.config
Normal file
5
FasdCockpitBase/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MaterialIcons" version="1.0.3" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user