go
This commit is contained in:
60
C4IT.API/ApiCache.cs
Normal file
60
C4IT.API/ApiCache.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Runtime.Caching;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
class ApiCache
|
||||
{
|
||||
public static object GetValue(string key)
|
||||
{
|
||||
MemoryCache memoryCache = MemoryCache.Default;
|
||||
|
||||
return memoryCache.Get(key);
|
||||
}
|
||||
|
||||
public static object AddOrGet(string key, object value, DateTimeOffset absExpiration)
|
||||
{
|
||||
MemoryCache memoryCache = MemoryCache.Default;
|
||||
lock (memoryCache)
|
||||
{
|
||||
return memoryCache.AddOrGetExisting(key, value, absExpiration);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Add(string key, object value, DateTimeOffset absExpiration)
|
||||
{
|
||||
|
||||
MemoryCache memoryCache = MemoryCache.Default;
|
||||
lock (memoryCache)
|
||||
{
|
||||
return memoryCache.Add(key, value, absExpiration);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Delete(string key)
|
||||
{
|
||||
MemoryCache memoryCache = MemoryCache.Default;
|
||||
if (memoryCache.Contains(key))
|
||||
{
|
||||
memoryCache.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> GetAllKeysInCache()
|
||||
{
|
||||
MemoryCache memoryCache = MemoryCache.Default;
|
||||
List<String> cacheKeys = new List<String>();
|
||||
var keys= memoryCache.Where(o => true).Select(o => o.Key);
|
||||
|
||||
foreach (var key in keys)
|
||||
{
|
||||
cacheKeys.Add(key);
|
||||
}
|
||||
|
||||
return cacheKeys;
|
||||
}
|
||||
}
|
||||
}
|
||||
170
C4IT.API/C4IT.API.CustomerPanel.csproj
Normal file
170
C4IT.API/C4IT.API.CustomerPanel.csproj
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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>{C965495D-D326-4521-9B6A-668227ED0651}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>C4IT.API.CustomerPanel</RootNamespace>
|
||||
<AssemblyName>C4IT.API.CustomerPanel</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<Reference Include="Matrix42.Common">
|
||||
<HintPath>..\SB_DLLs\Matrix42.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Matrix42.Contracts.Common">
|
||||
<HintPath>..\SB_DLLs\Matrix42.Contracts.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Matrix42.DataLayer.Common">
|
||||
<HintPath>..\SB_DLLs\Matrix42.DataLayer.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Matrix42.Pandora.Contracts">
|
||||
<HintPath>..\SB_DLLs\Matrix42.Pandora.Contracts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Caching.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Options, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Options.8.0.2\lib\net462\Microsoft.Extensions.Options.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.4.2.2\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Security, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Security.4.2.2\lib\net45\Microsoft.Owin.Security.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</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.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Http">
|
||||
<HintPath>..\SB_DLLs\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<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" />
|
||||
<Reference Include="update4u.SPS.Config">
|
||||
<HintPath>..\SB_DLLs\update4u.SPS.Config.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="update4u.SPS.DataLayer">
|
||||
<HintPath>..\SB_DLLs\update4u.SPS.DataLayer.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Common Code\Logging\C4IT.Logging.LogManager.cs">
|
||||
<Link>Common\C4IT.Logging.LogManager.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Common Code\Security\C4IT.Security.SecurePassword.cs">
|
||||
<Link>Common\C4IT.Security.SecurePassword.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\CommonAssembyInfo.cs">
|
||||
<Link>Properties\CommonAssembyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApiCache.cs" />
|
||||
<Compile Include="cDirectDbCompat.cs" />
|
||||
<Compile Include="ConverterHelper.cs" />
|
||||
<Compile Include="CustomerPanelController.cs" />
|
||||
<Compile Include="CustomerPanelHelper.cs" />
|
||||
<Compile Include="CustomerPanelHub.cs" />
|
||||
<Compile Include="PrivateCustomerPanelSecurePassword.cs" />
|
||||
<Compile Include="CustomerPanelSecurePassword.cs" />
|
||||
<Compile Include="DeepLinkBuilder.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="SignFiles.cmd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\C4IT.API.Contracts\C4IT.API.Contracts.csproj">
|
||||
<Project>{6cf1365b-c5bc-479c-b7bf-9229dec98988}</Project>
|
||||
<Name>C4IT.API.Contracts</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>call "$(ProjectDir)PostBuildCopy.bat" "$(Configuration)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
70
C4IT.API/ConverterHelper.cs
Normal file
70
C4IT.API/ConverterHelper.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
public static class ConverterHelper
|
||||
{
|
||||
public static string Html2Plaintext(string html)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(html))
|
||||
return string.Empty;
|
||||
|
||||
// 1. HTML‐Entities dekodieren (z.B. &uuml; → ü)
|
||||
string decoded = WebUtility.HtmlDecode(html);
|
||||
|
||||
// 2. </p> und <br> durch Zeilenumbruch ersetzen
|
||||
string withBreaks = Regex.Replace(
|
||||
decoded,
|
||||
@"</(?:p|div|li|blockquote|pre|h[1-6]|tr)\s*> # schließende Block-Tags
|
||||
|<(?:br|hr)\b[^>]*> # <br>, <hr>
|
||||
|<(?:ul|ol|table|thead|tbody|tfoot|article # öffnende Block-Container
|
||||
|section|nav|aside|header|footer
|
||||
|figure|figcaption|details|summary)[^>]*>",
|
||||
" ",
|
||||
RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
|
||||
|
||||
// 3. Alle übrigen Tags entfernen
|
||||
string noTags = Regex.Replace(withBreaks, @"<[^>]+>", string.Empty);
|
||||
|
||||
return noTags.Trim();
|
||||
}
|
||||
|
||||
public static bool ObjectToBoolConverter(object source)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (source.Equals("1"))
|
||||
{
|
||||
source = 1;
|
||||
}
|
||||
return Convert.ToBoolean(source);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int ObjectToIntConverter(object source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToInt32(source);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ObjectToStringConverter(this object value)
|
||||
{
|
||||
return (value ?? string.Empty).ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
156
C4IT.API/CustomerPanelController.cs
Normal file
156
C4IT.API/CustomerPanelController.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using C4IT.API.Contracts;
|
||||
using C4IT.Logging;
|
||||
using System.Reflection;
|
||||
using System.Web.Http.Controllers;
|
||||
using Matrix42.Pandora.Contracts;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using Matrix42.Pandora.Contracts.Internationalization;
|
||||
using System.Security.Principal;
|
||||
using update4u.SPS.DataLayer.Query.FunctionExpression;
|
||||
using System.Net.Http;
|
||||
using System.Net;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
[RoutePrefix("api/c4it/customerpanel")]
|
||||
|
||||
public class CustomerPanelController : ApiController
|
||||
{
|
||||
private readonly CustomerPanelHelper _CPanelHelper = new CustomerPanelHelper();
|
||||
|
||||
public static bool IsInitialized { get; private set; } = false;
|
||||
|
||||
public IPandoraUserProfile UserProfile => _userProfile;
|
||||
|
||||
public ICultureConfuguration GlobalSettings => _globalSettings;
|
||||
|
||||
public LanguageInfo[] Languages => _languages ?? (_languages = GlobalSettings.GetLanguages());
|
||||
|
||||
private static Object initLock = new object();
|
||||
internal static CustomerPanelController controller = null;
|
||||
|
||||
private readonly IPandoraUserProfile _userProfile;
|
||||
private readonly ICultureConfuguration _globalSettings;
|
||||
private LanguageInfo[] _languages = null;
|
||||
public CustomerPanelController(IPandoraUserProfile pandoraUserProfile, ICultureConfuguration globalSettings)
|
||||
{
|
||||
controller = this;
|
||||
_userProfile = pandoraUserProfile;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
protected override void Initialize(HttpControllerContext controllerContext)
|
||||
{
|
||||
base.Initialize(controllerContext);
|
||||
try
|
||||
{
|
||||
lock (initLock)
|
||||
{
|
||||
if (IsInitialized)
|
||||
return;
|
||||
|
||||
var Ass = Assembly.GetExecutingAssembly();
|
||||
var LM = cLogManagerFile.CreateInstance(LocalMachine: true, A: Ass);
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
cLogManager.DefaultLogger.LogAssemblyInfo(Ass);
|
||||
|
||||
CustomerPanelSecurePassword.Init();
|
||||
PrivateCustomerPanelSecurePassword.Init();
|
||||
|
||||
IsInitialized = true;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
}
|
||||
|
||||
[Route("version"), HttpGet]
|
||||
public Version GetVersion()
|
||||
{
|
||||
return _CPanelHelper.getVersion();
|
||||
}
|
||||
|
||||
[Route("closeallclients"), HttpGet]
|
||||
public bool GetCloseAllClients()
|
||||
{
|
||||
return _CPanelHelper.GetCloseAllClients();
|
||||
}
|
||||
|
||||
[Route("config"), HttpGet]
|
||||
public CustomerPanelConfig GetConfig(bool noCache = false)
|
||||
{
|
||||
return _CPanelHelper.GetConfig(noCache);
|
||||
}
|
||||
|
||||
[Route("tickets/{userid:guid}"), HttpGet]
|
||||
public List<Ticket> GetTicketsByUserId(Guid userId)
|
||||
{
|
||||
return _CPanelHelper.GetTickets(userId);
|
||||
}
|
||||
[Route("tickets"), HttpGet]
|
||||
public List<Ticket> GetTickets()
|
||||
{
|
||||
return _CPanelHelper.GetTickets(controller.UserProfile.UserId);
|
||||
}
|
||||
|
||||
[Route("resetCache"), HttpGet]
|
||||
public bool ResetCache()
|
||||
{
|
||||
return this._CPanelHelper.ResetCache();
|
||||
}
|
||||
|
||||
[Route("announcements/{userid:guid}"), HttpGet]
|
||||
public List<Contracts.Announcement> GetAnnouncementsByUserId(announcementType type, Guid userId, bool noCache = false)
|
||||
{
|
||||
return GetAnnouncementsInternal(type, userId, noCache);
|
||||
}
|
||||
|
||||
[Route("announcements"), HttpGet]
|
||||
public List<Contracts.Announcement> GetAnnouncements(announcementType type, bool noCache = false)
|
||||
{
|
||||
return GetAnnouncementsInternal(type, null, noCache);
|
||||
}
|
||||
|
||||
[Route("isalive"), HttpGet]
|
||||
public HttpResponseMessage isAlive()
|
||||
{
|
||||
return new HttpResponseMessage(HttpStatusCode.NoContent);
|
||||
}
|
||||
|
||||
private List<Contracts.Announcement> GetAnnouncementsInternal(announcementType type, Guid? userId, bool noCache)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case announcementType.Regular:
|
||||
return userId.HasValue
|
||||
? this._CPanelHelper.GetRegularAnnouncements(userId.Value)
|
||||
: this._CPanelHelper.GetRegularAnnouncements(controller.UserProfile.UserId);
|
||||
case announcementType.Adhoc:
|
||||
return this._CPanelHelper.GetAdHocAnnouncements(noCache);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Route("Encode"), HttpPost]
|
||||
public string Encode(string str)
|
||||
{
|
||||
return this._CPanelHelper.Encode(str);
|
||||
}
|
||||
|
||||
[Route("ApiCache"), HttpGet]
|
||||
public Object GetApiCache()
|
||||
{
|
||||
return ApiCache.GetAllKeysInCache();
|
||||
}
|
||||
|
||||
//[Route("JoinPool"), HttpGet]
|
||||
//public void JoinHubPool()
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
1009
C4IT.API/CustomerPanelHelper.cs
Normal file
1009
C4IT.API/CustomerPanelHelper.cs
Normal file
File diff suppressed because it is too large
Load Diff
57
C4IT.API/CustomerPanelHub.cs
Normal file
57
C4IT.API/CustomerPanelHub.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
/*
|
||||
public delegate void ClientConnectionEventHandler(string clientId);
|
||||
public delegate void ClientNameChangedEventHandler(string clientId, string newName);
|
||||
public delegate void ClientGroupEventHandler(string clientId, string groupName);
|
||||
|
||||
public delegate void MessageReceivedEventHandler(string senderClientId, string message);
|
||||
class CustomerPanelHub : Hub
|
||||
{
|
||||
static ConcurrentDictionary<string, string> _users = new ConcurrentDictionary<string, string>();
|
||||
|
||||
public static event ClientConnectionEventHandler ClientConnected;
|
||||
public static event ClientConnectionEventHandler ClientDisconnected;
|
||||
public static event ClientNameChangedEventHandler ClientNameChanged;
|
||||
|
||||
public static event ClientGroupEventHandler ClientJoinedToGroup;
|
||||
public static event ClientGroupEventHandler ClientLeftGroup;
|
||||
|
||||
public static event MessageReceivedEventHandler MessageReceived;
|
||||
|
||||
public static void ClearState()
|
||||
{
|
||||
_users.Clear();
|
||||
}
|
||||
|
||||
//Called when a client is connected
|
||||
public override Task OnConnected()
|
||||
{
|
||||
_users.TryAdd(Context.ConnectionId, Context.ConnectionId);
|
||||
|
||||
ClientConnected?.Invoke(Context.ConnectionId);
|
||||
|
||||
return base.OnConnected();
|
||||
}
|
||||
|
||||
//Called when a client is disconnected
|
||||
public override Task OnDisconnected(bool stopCalled)
|
||||
{
|
||||
string userName;
|
||||
_users.TryRemove(Context.ConnectionId, out userName);
|
||||
|
||||
ClientDisconnected?.Invoke(Context.ConnectionId);
|
||||
|
||||
return base.OnDisconnected(stopCalled);
|
||||
}
|
||||
}
|
||||
*/
|
||||
class CustomerPanelHub
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
22
C4IT.API/CustomerPanelSecurePassword.cs
Normal file
22
C4IT.API/CustomerPanelSecurePassword.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using C4IT.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
static public class CustomerPanelSecurePassword
|
||||
{
|
||||
public readonly static string FFH = "RL5?IX%E1fE^37cUWDY~u+|NA";
|
||||
public readonly static string FFK = "PyTLMoZo0Ece/tbEA+nmiUOcn14cjg1KPG9185EoHD5EVWUWPm2iUDwXX+8Vne4saDsihtj7CeKi0aeOFqKEL05lmrmEkVFrYOQ1yhVaLdNzz+yw2KGZ9cF9nS0g+le5PqKg67vfiueoQWwvUQYkbLjjARPm3eoaUcjqFTZqVZ7vcW4C6eushQZ4NrOAzd5WcVENU55l6ORnstRW+SoT+SV2t4MO3ObXWlOK495Gerf44juHDeVGfPL+MjnfcIyUvEVe0AcC+Uddvn7atlbcjBF2m317wVqsogKoAPDpaGHhWAW6D6j8ezP2DSRvDmYXm7EuRXqbb6XatwO1TC/JWnPBk2sHR3/suiURx0ui34oD5e+/QbqapG++caQhba4jf+ailaBrKCdauMPP+BJ6d1Zulu+6NXTWknpbQo9qgPQfWk6B9WQJfzyzUxQ8uey4TaRqS6TDgdqObSddXnzk5pjBhvwNSWOtfvaoX4m4h2iHCTWDp+O3g94MR/StOjIK/eX/D0bIbVxXQD3jgjqyiFoPYbZM6QrNT+CaXD3eEpiBKRojxe1jd5fUOj2gq64HYAvD1DQhvP/6MgR87BOeUGWwrXm8PIwyc4wMoj8RnEEnkH8+yjx9SvHfv7Gb2tW4JDKXOaCZF7+NOrDe3L9ECJh3XyyE6a6kI7eW+XEbjFh/8ugPgqbP2rGAFlKES5AzaPN3ePl2Dv/9s00gYyuGhnM02iWTkj7wOzOTpTaIrhS4uZdBxqlIxnbw/UCDkajitaqq8zeGXWNTAAEc8G4FELXruw0QbwIIuszOS770gAGsmSbpLeOtDyYNFWnnuYlZfhuCyofrk02mnB2e+nZ6p4O9G+MvZkgimeST23MnhLdLNFEIASlwFxDqD9X0GfKN0zD4S2LrwT0yp8mKfgJPyKxG9f3Dwr7yuWIIodplWcIQa/NYVEn/0lga43+F6fSv73uhAKBKqlaivMnZXRqzrX9YsRxgzMOuVJm9WXs0iWhV/Q183vrUVyQnx4H1cZq7p+RriIwEn6Y/01RgE5TzpLILDGdT56if4BGDVoKa4RcAFq4kamdAj8VnLtNTZSt+QA2IOrISFcoiFpn6Z5ZPpjp3ktP5EcqFi/jPNiLn1aQi4c4xhgsggd+S+bpEr2Q31p6WKDv40w2wXmClNz2Ck8BcYtN7z040WGqGtfu4gDPiYpQedytPwzc65ipxKJQ8/sv4At0kVd5U+u/Gsc2lYcDU5va/t338ioKOj1nfB9YmIUuxjvd5hzCmWjHizf/rjMV7SF7PbCsq3RZtPa2Hy4BcXkV5YaoZACN3wgOHadkiz1T3rAGC8KhoiJ94dlQvkwwtoNDblMrpnKoHedBDgsl1Gg09fAzlyXQ6ofNonzOsMERdSwNDyDuOQCoDK809bhxsyGeGvLsWDS7srI7ODedjevx6Obdvpgb95YXKPBIzSXgZRMKMNwTJNMUA4qWrNPZOiW0tkYRhZujN50oMHX2ZJfRKllknJk5SgiijKxlSPd4Abk62n9eGG42DXC1dAEpNoDkiP6lWbtaxVOVL6Kr+LsgD0G6N0Y21Q8YpEH1MTW+462AHaZkcnsVAEGWH";
|
||||
public static cSecurePassword Instance { get; private set; } = null;
|
||||
|
||||
static public void Init()
|
||||
{
|
||||
Instance = new cSecurePassword(FFH);
|
||||
Instance.SetRsaKey(FFK);
|
||||
}
|
||||
}
|
||||
}
|
||||
93
C4IT.API/DeepLinkBuilder.cs
Normal file
93
C4IT.API/DeepLinkBuilder.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
public enum ViewType
|
||||
{
|
||||
New, // open create dialog
|
||||
Preview, // open preview
|
||||
Action, // run action/wizard
|
||||
Edit // open edit dialog
|
||||
}
|
||||
|
||||
public class DeepLinkBuilder
|
||||
{
|
||||
public string Host { get; set; }
|
||||
public string AppName { get; set; }
|
||||
|
||||
// Parameter f<>r view-options
|
||||
public bool? Embedded { get; set; }
|
||||
public Guid? DialogId { get; set; }
|
||||
public Guid? ObjectId { get; set; }
|
||||
public int? Archived { get; set; }
|
||||
public string Type { get; set; }
|
||||
public ViewType? ViewType { get; set; }
|
||||
public Guid? ActionId { get; set; }
|
||||
public Guid? ViewId { get; set; }
|
||||
|
||||
public object PresetParams { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Baut die URL basierend auf den gesetzten Eigenschaften.
|
||||
/// </summary>
|
||||
/// <returns>Die erstellte DeepLink-URL als string.</returns>
|
||||
public string BuildUrl()
|
||||
{
|
||||
var viewOptions = new Dictionary<string, object>();
|
||||
|
||||
if (Embedded.HasValue)
|
||||
viewOptions["embedded"] = Embedded.Value;
|
||||
if (DialogId.HasValue)
|
||||
viewOptions["dialogId"] = DialogId.Value;
|
||||
if (ObjectId.HasValue)
|
||||
viewOptions["objectId"] = ObjectId.Value;
|
||||
if (Archived.HasValue)
|
||||
viewOptions["archived"] = Archived.Value;
|
||||
if (!string.IsNullOrEmpty(Type))
|
||||
viewOptions["type"] = Type;
|
||||
if (ViewType.HasValue)
|
||||
viewOptions["viewType"] = ViewType.Value.ToString().ToLower();
|
||||
if (ActionId.HasValue)
|
||||
viewOptions["actionId"] = ActionId.Value;
|
||||
if (ViewId.HasValue)
|
||||
viewOptions["viewId"] = ViewId.Value;
|
||||
|
||||
string viewOptionsJson = JsonConvert.SerializeObject(viewOptions);
|
||||
string encodedViewOptions = HttpUtility.UrlEncode(viewOptionsJson);
|
||||
string url = $"{Host.TrimEnd('/')}/wm/app-{AppName}/?view-options={encodedViewOptions}";
|
||||
|
||||
if (PresetParams != null)
|
||||
{
|
||||
string presetParamsJson = JsonConvert.SerializeObject(PresetParams);
|
||||
string encodedPresetParams = HttpUtility.UrlEncode(presetParamsJson);
|
||||
url += $"&presetParams={encodedPresetParams}";
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statische Methode zur Erstellung eines DeepLinks basierend auf den angegebenen Parametern.
|
||||
/// </summary>
|
||||
/// <param name="host">Der Hostname der Anwendung.</param>
|
||||
/// <param name="appName">Der Name der Anwendung.</param>
|
||||
/// <param name="viewType">Der Typ der Ansicht.</param>
|
||||
/// <param name="type">Der Type des Objekts.</param>
|
||||
/// <returns>Die erstellte DeepLink-URL als string.</returns>
|
||||
public static string CreateDeepLink(string host, string appName, ViewType viewType, string type)
|
||||
{
|
||||
var builder = new DeepLinkBuilder
|
||||
{
|
||||
Host = host,
|
||||
AppName = appName,
|
||||
ViewType = viewType,
|
||||
Type = type,
|
||||
};
|
||||
|
||||
return builder.BuildUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
C4IT.API/PostBuildCopy.bat
Normal file
51
C4IT.API/PostBuildCopy.bat
Normal file
@@ -0,0 +1,51 @@
|
||||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
REM Überprüfe, ob die Konfiguration als Parameter übergeben wurde
|
||||
IF "%1"=="" (
|
||||
echo ERROR: Keine Konfiguration übergeben. Verwenden Sie z. B. "Debug" oder "Release".
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
REM Setze die Quelldateien und das Zielverzeichnis
|
||||
SET SourceDir=%~dp0bin\%1
|
||||
SET TargetDir=\\srvwsm001.imagoverum.com\c$\Program Files (x86)\Matrix42\Matrix42 Workplace Management\svc\bin
|
||||
|
||||
REM Debugging-Ausgabe
|
||||
echo Starting Post-Build Copy Script...
|
||||
echo Source Directory: %SourceDir%
|
||||
echo Target Directory: %TargetDir%
|
||||
|
||||
REM Prüfe, ob die Quelldateien existieren
|
||||
IF NOT EXIST "%SourceDir%\C4IT.API.Contracts.dll" (
|
||||
echo ERROR: C4IT.API.Contracts.dll nicht gefunden.
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
IF NOT EXIST "%SourceDir%\C4IT.API.CustomerPanel.dll" (
|
||||
echo ERROR: C4IT.API.CustomerPanel.dll nicht gefunden.
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
REM Kopiere die Dateien
|
||||
echo Kopiere C4IT.API.Contracts.dll...
|
||||
xcopy "%SourceDir%\C4IT.API.Contracts.dll" "%SourceDir%\..\..\..\..\Matrix42\C4IT_CustomerPanel\Matrix42Libs" /Y
|
||||
IF ERRORLEVEL 1 (
|
||||
echo ERROR: Kopiervorgang von C4IT.API.Contracts.dll fehlgeschlagen.
|
||||
EXIT 1
|
||||
)
|
||||
xcopy "%SourceDir%\C4IT.API.Contracts.dll" "%TargetDir%" /Y
|
||||
IF ERRORLEVEL 1 (
|
||||
echo ERROR: Kopiervorgang von C4IT.API.Contracts.dll fehlgeschlagen.
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
echo Kopiere C4IT.API.CustomerPanel.dll...
|
||||
xcopy "%SourceDir%\C4IT.API.CustomerPanel.dll" "%TargetDir%" /Y
|
||||
IF ERRORLEVEL 1 (
|
||||
echo ERROR: Kopiervorgang von C4IT.API.CustomerPanel.dll fehlgeschlagen.
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
echo Dateien erfolgreich kopiert.
|
||||
ENDLOCAL
|
||||
22
C4IT.API/PrivateCustomerPanelSecurePassword.cs
Normal file
22
C4IT.API/PrivateCustomerPanelSecurePassword.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using C4IT.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace C4IT.API
|
||||
{
|
||||
static public class PrivateCustomerPanelSecurePassword
|
||||
{
|
||||
public readonly static string FFH = "RL5?IX%E1fE^37cUWDY~u+|NA";
|
||||
public readonly static string FFK = "PyTLMoZo0Ece/tbEA+nmiUOcn14cjg1KPG9185EoHD5EVWUWPm2iUDwXX+8Vne4saDsihtj7CeKi0aeOFqKEL05lmrmEkVFrYOQ1yhVaLdNzz+yw2KGZ9cF9nS0g+le5PqKg67vfiueoQWwvUQYkbLjjARPm3eoaUcjqFTZqVZ7vcW4C6eushQZ4NrOAzd5WcVENU55l6ORnstRW+SoT+SV2t4MO3ObXWlOK495Gerf44juHDeVGfPL+MjnfcIyUvEVe0AcC+Uddvn7atlbcjBF2m317wVqsogKoAPDpaGHhWAW6D6j8ezP2DSRvDmYXm7EuRXqbb6XatwO1TC/JWnPBk2sHR3/suiURx0ui34oD5e+/QbqapG++caQhba4jf+ailaBrKCdauMPP+BJ6d1Zulu+6NXTWknpbQo9qgPQfWk6B9WQJfzyzUxQ8uey4TaRqS6TDgdqObSddXnzk5pjBhvwNSWOtfvaoX4m4h2iHCTWDp+O3g94MR/StOjIK/eX/D0bIbVxXQD3jgjqyiFoPYbZM6QrNT+CaXD3eEpiBKRojxe1jd5fUOj2gq64HYAvD1DQhvP/6MgR87BOeUGWwrXm8PIwyc4wMoj8RnEEnkH8+yjx9SvHfv7Gb2tW4JDKXOaCZF7+NOrDe3L9ECJh3XyyE6a6kI7eW+XEbjFh/8ugPgqbP2rGAFlKES5AzaPN3ePl2Dv/9s00gYyuGhnM02iWTkj7wOzOTpTaIrhS4uZdBxqlIxnbw/UCDkajitaqq8zeGXWNTAAEc8G4FELXruw0QbwIIuszOS770gAGsmSbpLeOtDyYNFWnnuYlZfhuCyofrk02mnB2e+nZ6p4O9G+MvZkgimeST23MnhLdLNFEIASlwFxDqD9X0GfKN0zD4S2LrwT0yp8mKfgJPyKxG9f3Dwr7yuWIIodplWcIQa/NYVEn/0lga43+F6fSv73uhAKBKqlaivMnZXRqzrX9YsRxgzMOuVJm9WXs0iWhV/Q183vrUVyQnx4H1cZq7p+RriIwEn6Y/01RgE5TzpLILDGdT56if4BGDVoKa4RcAFq4kamdAj8VnLtNTZSt+QA2IOrISFcoiFpn6Z5ZPpjp3ktP5EcqFi/jPNiLn1aQi4c4xhgsggd+S+bpEr2Q31p6WKDv40w2wXmClNz2Ck8BcYtN7z040WGqGtfu4gDPiYpQedytPwzc65ipxKJQ8/sv4At0kVd5U+u/Gsc2lYcDU5va/t338ioKOj1nfB9YmIUuxjvd5hzCmWjHizf/rjMV7SF7PbCsq3RZtPa2Hy4BcXkV5YaoZACN3wgOHadkiz1T3rAGC8KhoiJ94dlQvkwwtoNDblMrpnKoHedBDgsl1Gg09fAzlyXQ6ofNonzOsMERdSwNDyDuOQCoDK809bhxsyGeGvLsWDS7srI7ODedjevx6Obdvpgb95YXKPBIzSXgZRMKMNwTJNMUA4qWrNPZOiW0tkYRhZujN50oMHX2ZJfRKllknJk5SgiijKxlSPd4Abk62n9eGG42DXC1dAEpNoDkiP6lWbtaxVOVL6Kr+LsgD0G6N0Y21Q8YpEH1MTW+462AHaZkcnsVAEGWH";
|
||||
public static cSecurePassword Instance { get; private set; } = null;
|
||||
|
||||
static public void Init()
|
||||
{
|
||||
Instance = new cSecurePassword(FFH);
|
||||
Instance.SetRsaKey(FFK, "C4itF4sdCustomerPanelWebApi");
|
||||
}
|
||||
}
|
||||
}
|
||||
8
C4IT.API/Properties/AssemblyInfo.cs
Normal file
8
C4IT.API/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("C4IT.API")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("c965495d-d326-4521-9b6a-668227ed0651")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
11
C4IT.API/SignFiles.cmd
Normal file
11
C4IT.API/SignFiles.cmd
Normal file
@@ -0,0 +1,11 @@
|
||||
set ProductName="C4IT Customer Panel API"
|
||||
|
||||
set SignTool=..\..\Common Code\Tools\signtool.exe
|
||||
set TimeStamp=http://rfc3161timestamp.globalsign.com/advanced
|
||||
|
||||
set Src=.\bin\Release
|
||||
"%SignTool%" sign /a /tr %TimeStamp% /td SHA256 /fd SHA256 /d %ProductName% "%Src%\C4IT.API.Contracts.dll" "%Src%\C4IT.API.CustomerPanel.dll" "%Src%\C4IT.API.Contracts.dll"
|
||||
|
||||
pause
|
||||
|
||||
|
||||
27
C4IT.API/app.config
Normal file
27
C4IT.API/app.config
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
|
||||
20
C4IT.API/packages.config
Normal file
20
C4IT.API/packages.config
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Caching.Abstractions" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.1" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.1" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Options" version="8.0.2" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Primitives" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net472" />
|
||||
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" targetFramework="net472" />
|
||||
<package id="Microsoft.Owin.Security" version="4.2.2" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="Owin" version="1.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user