feat: support parallel legacy and sandbox extensions
This commit is contained in:
69
Legacy/F4SDM42WebApi/F4SD - M42WebApi.Legacy.csproj
Normal file
69
Legacy/F4SDM42WebApi/F4SD - M42WebApi.Legacy.csproj
Normal file
@@ -0,0 +1,69 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>C4IT.F4SDM</RootNamespace>
|
||||
<AssemblyName>C4ITF4SDM42WebApi</AssemblyName>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<Configurations>Debug;Release;Release_signed</Configurations>
|
||||
<M42LegacyLibrariesDir Condition="'$(M42LegacyLibrariesDir)' == ''">$(MSBuildProjectDirectory)\..\M42Libraries\12.1.3</M42LegacyLibrariesDir>
|
||||
<M42BuildPackage>true</M42BuildPackage>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'Release_signed'">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release_signed'">
|
||||
<M42SignAssemblies>true</M42SignAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Matrix42.Common"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Common.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Matrix42.Contracts.Common"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Contracts.Common.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Matrix42.Contracts.Platform"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Contracts.Platform.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Matrix42.Contracts.ServiceManagement"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Contracts.ServiceManagement.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Matrix42.Pandora.Contracts"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Pandora.Contracts.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Matrix42.Services.Description.Contracts"><HintPath>$(M42LegacyLibrariesDir)\Matrix42.Services.Description.Contracts.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="Newtonsoft.Json"><HintPath>$(M42LegacyLibrariesDir)\Newtonsoft.Json.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Http"><HintPath>$(M42LegacyLibrariesDir)\System.Web.Http.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="System.Web.OData"><HintPath>$(M42LegacyLibrariesDir)\System.Web.OData.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="update4u.SPS.DataLayer"><HintPath>$(M42LegacyLibrariesDir)\update4u.SPS.DataLayer.dll</HintPath><Private>false</Private></Reference>
|
||||
<Reference Include="update4u.SPS.Utility"><HintPath>$(M42LegacyLibrariesDir)\update4u.SPS.Utility.dll</HintPath><Private>false</Private></Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\F4SDHelper\F4SD - Helper.Legacy.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="cM42LogEntry.cs" />
|
||||
<Compile Include="F4SDHelperService.cs" />
|
||||
<Compile Include="F4SDM42WebApiController.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="..\..\SharedAssemblyInfo.cs"><Link>Properties\SharedAssemblyInfo.cs</Link></Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="ValidateLegacyMatrix42References" BeforeTargets="ResolveReferences">
|
||||
<Error Condition="!Exists('$(M42LegacyLibrariesDir)\Matrix42.Common.dll')"
|
||||
Text="Legacy Matrix42 references not found. Set M42LegacyLibrariesDir to the 12.1.3 reference directory." />
|
||||
</Target>
|
||||
|
||||
<Import Project="..\M42LegacyExtension.targets" Condition="Exists('..\M42LegacyExtension.targets')" />
|
||||
</Project>
|
||||
2730
Legacy/F4SDM42WebApi/F4SDHelperService.cs
Normal file
2730
Legacy/F4SDM42WebApi/F4SDHelperService.cs
Normal file
File diff suppressed because it is too large
Load Diff
554
Legacy/F4SDM42WebApi/F4SDM42WebApiController.cs
Normal file
554
Legacy/F4SDM42WebApi/F4SDM42WebApiController.cs
Normal file
@@ -0,0 +1,554 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.OData;
|
||||
using System.Web.OData.Query;
|
||||
|
||||
using Matrix42.Common;
|
||||
using Matrix42.Contracts.ServiceManagement.ServiceContracts;
|
||||
using Matrix42.Pandora.Contracts;
|
||||
using Matrix42.Services.Description.Contracts;
|
||||
using update4u.SPS.Utility.GlobalConfiguration;
|
||||
|
||||
using C4IT.F4SDM;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace C4IT.F4SD
|
||||
{
|
||||
[RoutePrefix("api/C4ITF4SDWebApi")]
|
||||
public partial class F4SDM42WebApiController : ApiController
|
||||
{
|
||||
public static bool IsInitialized { get; private set; } = false;
|
||||
|
||||
public static F4SDM42WebApiController defaultInstance;
|
||||
//private readonly IIncidentService _incidentService;
|
||||
internal readonly GlobalConfigurationProvider _globalConfigurationProvider;
|
||||
public readonly IJournalService _journalService;
|
||||
//public readonly IObjectService _objectService;
|
||||
//public readonly IFragmentService _fragmentService;
|
||||
internal readonly IEntityDataService _entityDataService;
|
||||
internal readonly IPandoraUserProfile _userProfile;
|
||||
|
||||
|
||||
private readonly F4SDHelperService _f4stHelperService;
|
||||
public string BaseUrl => $"{Request.RequestUri.Scheme}://{Request.RequestUri.Host}";
|
||||
public string EndpointBaseUrl => $"{BaseUrl}/m42Services/api/c4itf4sdwebapi";
|
||||
public F4SDM42WebApiController(
|
||||
//IObjectService objectService,
|
||||
//IIncidentService incidentService,
|
||||
IJournalService journalService
|
||||
//IFragmentService fragmentService,
|
||||
, IEntityDataService entityDataService
|
||||
, IPandoraUserProfile userProfile
|
||||
)
|
||||
{
|
||||
defaultInstance = this;
|
||||
//_objectService = objectService;
|
||||
//_fragmentService = fragmentService;
|
||||
//_incidentService = Guard.NullArgument(incidentService, "incidentService");
|
||||
|
||||
_entityDataService = entityDataService;
|
||||
_journalService = journalService;
|
||||
_globalConfigurationProvider = GlobalConfigurationProvider.Instance;
|
||||
_f4stHelperService = new F4SDHelperService();
|
||||
_userProfile = userProfile;
|
||||
}
|
||||
|
||||
private static object initLock = new object();
|
||||
protected override void Initialize(HttpControllerContext controllerContext)
|
||||
{
|
||||
base.Initialize(controllerContext);
|
||||
try
|
||||
{
|
||||
//System.Diagnostics.Debugger.Launch();
|
||||
lock (initLock)
|
||||
{
|
||||
if (IsInitialized || F4SDM42LogsWebApiController.IsInitialized)
|
||||
return;
|
||||
var Ass = Assembly.GetExecutingAssembly();
|
||||
var LM = cLogManagerFile.CreateInstance(LocalMachine: true, A: Ass);
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
cLogManager.DefaultLogger.LogAssemblyInfo(Ass);
|
||||
IsInitialized = true;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
}
|
||||
|
||||
[Route("getDirectLinkCreateTicket"), HttpGet]
|
||||
public async Task<F4SDHelperService.DirectLink> getDirectLinkCreateTicket(string sid = "", string assetname = "")
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return await _f4stHelperService.getDirectLinkCreateTicket(sid, assetname);
|
||||
}
|
||||
|
||||
[Route("getDirectLinkF4SD"), HttpGet]
|
||||
public async Task<string> getDirectLinkF4SD(Guid EOID, string Type)
|
||||
{
|
||||
return await _f4stHelperService.getDirectLinkF4SD(EOID, Type);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[Route("getTicketList"), HttpGet]
|
||||
public async Task<List<cF4SDTicketSummary>> getTicketList(
|
||||
string sid,
|
||||
int hours,
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var decodedPairs = ParseQueues(queues);
|
||||
|
||||
// Nun weiterreichen an Service
|
||||
return await _f4stHelperService.getTicketListByUser(
|
||||
sid,
|
||||
hours,
|
||||
queueoption,
|
||||
decodedPairs
|
||||
);
|
||||
}
|
||||
|
||||
[Route("getTicketListForUser"), HttpGet]
|
||||
public async Task<List<cF4SDTicketSummary>> getTicketListForUser(
|
||||
Guid userId,
|
||||
int hours,
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var decodedPairs = ParseQueues(queues);
|
||||
|
||||
// Nun weiterreichen an Service
|
||||
return await _f4stHelperService.getTicketListByUser(
|
||||
userId,
|
||||
hours,
|
||||
queueoption,
|
||||
decodedPairs
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
[Route("getTicketDetails"), HttpGet]
|
||||
public async Task<F4SDHelperService.cF4SDTicket> getTicketDetails(Guid objectId)
|
||||
{
|
||||
var tickets = await _f4stHelperService.getTicketDetails(new List<Guid>() { objectId });
|
||||
if (tickets.Count > 0)
|
||||
return tickets[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
[Route("getTicketHistory"), HttpGet]
|
||||
public async Task<List<F4SDHelperService.cF4SDTicket.cTicketJournalItem>> getTicketHistory(Guid objectId)
|
||||
{
|
||||
return await _f4stHelperService.GetJournalEntries(objectId);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[Route("getTicketOverviewCounts"), HttpGet]
|
||||
public async Task<F4SDHelperService.TicketOverviewCountsResult> getTicketOverviewCounts(
|
||||
string sid,
|
||||
string scope = "personal",
|
||||
string keys = "",
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var parsedKeys = (keys ?? string.Empty)
|
||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(key => key.Trim())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.ToList();
|
||||
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewCounts(sid, scope, parsedKeys, queueoption, decodedQueues);
|
||||
}
|
||||
|
||||
|
||||
[Route("getTicketOverviewCountsForUser"), HttpGet]
|
||||
public async Task<F4SDHelperService.TicketOverviewCountsResult> getTicketOverviewCountsForUser(
|
||||
Guid userId,
|
||||
string scope = "personal",
|
||||
string keys = "",
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var parsedKeys = (keys ?? string.Empty)
|
||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(key => key.Trim())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.ToList();
|
||||
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewCounts(userId, scope, parsedKeys, queueoption, decodedQueues);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[Route("getTicketOverviewCountsByRoles"), HttpPost]
|
||||
public async Task<F4SDHelperService.TicketOverviewCountsByRoleResult> getTicketOverviewCountsByRoles([FromBody] TicketOverviewCountsByRolesRequest request)
|
||||
{
|
||||
var parsedKeys = (request?.Keys ?? new List<string>())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.Select(key => key.Trim())
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
var roleGuids = (request?.RoleGuids ?? new List<Guid>())
|
||||
.Where(roleId => roleId != Guid.Empty)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var decodedQueues = ParseQueues(request?.Queues ?? string.Empty);
|
||||
return await _f4stHelperService.getTicketOverviewCountsByRoles(
|
||||
request?.Sid,
|
||||
roleGuids,
|
||||
parsedKeys,
|
||||
request?.QueueOption ?? 0,
|
||||
decodedQueues
|
||||
);
|
||||
}
|
||||
|
||||
[Route("getTicketOverviewCountsByRolesForUser"), HttpPost]
|
||||
public async Task<F4SDHelperService.TicketOverviewCountsByRoleResult> getTicketOverviewCountsByRolesForUser([FromBody] TicketOverviewCountsByRolesForUserRequest request)
|
||||
{
|
||||
var parsedKeys = (request?.Keys ?? new List<string>())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.Select(key => key.Trim())
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
var roleGuids = (request?.RoleGuids ?? new List<Guid>())
|
||||
.Where(roleId => roleId != Guid.Empty)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var decodedQueues = ParseQueues(request?.Queues ?? string.Empty);
|
||||
return await _f4stHelperService.getTicketOverviewCountsByRoles(
|
||||
request.userId,
|
||||
roleGuids,
|
||||
parsedKeys,
|
||||
request?.QueueOption ?? 0,
|
||||
decodedQueues
|
||||
);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[Route("getTicketOverviewRelations"), HttpGet]
|
||||
public async Task<List<F4SDHelperService.TicketOverviewRelationDto>> getTicketOverviewRelations(
|
||||
string sid,
|
||||
string scope = "personal",
|
||||
string key = "",
|
||||
int count = 0,
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count, queueoption, decodedQueues);
|
||||
}
|
||||
|
||||
[Route("getTicketOverviewRelationsForUser"), HttpGet]
|
||||
public async Task<List<F4SDHelperService.TicketOverviewRelationDto>> getTicketOverviewRelations(
|
||||
Guid userId,
|
||||
string scope = "personal",
|
||||
string key = "",
|
||||
int count = 0,
|
||||
int queueoption = 0,
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewRelations(userId, scope, key, count, queueoption, decodedQueues);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
[Route("updateActivitySolution/{objectId}"), HttpPost]
|
||||
public async Task<HttpResponseMessage> updateActivitySolution(Guid objectId, [FromBody] string SolutionHtml)
|
||||
{
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
StatusCode = await _f4stHelperService.updateActivitySolution(objectId, SolutionHtml) ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest,
|
||||
};
|
||||
}
|
||||
*/
|
||||
[Route("getPickup/{name}"), HttpGet]
|
||||
//[CacheOutput(UseETAG = true)]
|
||||
public async Task<HttpResponseMessage> getPickup(string name, [FromUri] EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, [FromUri] Int32 group = -1)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
EntityEnumeration enumerationTemp = _entityDataService.GetEnumeration(name, mode);
|
||||
var vals = enumerationTemp.Values;
|
||||
|
||||
if (group > -1)
|
||||
{
|
||||
vals = vals.Where(row => !row.Extentions.TryGetValue("StateGroup", out var stateGroup) || (ConvertHelper.ParseInt(stateGroup, 0) == group)).ToArray();
|
||||
}
|
||||
|
||||
string[] columns = new string[] { "position" };
|
||||
foreach (var item in vals)
|
||||
{
|
||||
item.Extentions = item.Extentions.Where(x => columns.Contains(x.Key.ToLower())).ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
|
||||
EntityEnumeration enumeration = new EntityEnumeration
|
||||
{
|
||||
Name = enumerationTemp.Name,
|
||||
Values = vals.ToArray()
|
||||
};
|
||||
//CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val);
|
||||
return Request.CreateResponse(HttpStatusCode.OK, enumeration);
|
||||
}
|
||||
|
||||
[Route("getMyRoleMemberships", Order = 2), HttpGet]
|
||||
public async Task<HttpResponseMessage> getMyRoleMemberships()
|
||||
{
|
||||
var User = _userProfile.GetInteractiveUserInfo();
|
||||
var filter = AsqlHelper.BuildInCondition("ID", new Guid[] { User.Id });
|
||||
return Request.CreateResponse(HttpStatusCode.OK, await _f4stHelperService.UserPermissionsInfo(filter));
|
||||
}
|
||||
|
||||
[Route("getRoleMemberships", Order = 1), HttpGet]
|
||||
public async Task<HttpResponseMessage> getRoleMemberships([FromUri] GetRoleMembershipsRequest req)
|
||||
{
|
||||
var filter = "";
|
||||
|
||||
if (req.Id != null && req.Id.Value != Guid.Empty)
|
||||
{
|
||||
filter = AsqlHelper.BuildInCondition("ID", new Guid[] { req.Id.Value });
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(req.Sid))
|
||||
{
|
||||
filter = AsqlHelper.BuildInCondition("Accounts.T(SPSAccountClassAD).Sid", new string[] { req.Sid });
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(req.Upn))
|
||||
{
|
||||
filter = AsqlHelper.BuildInCondition("Accounts.T(SPSAccountClassAD).UserPrincipalName", new string[] { req.Upn });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter))
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.OK, await _f4stHelperService.UserPermissionsInfo(filter));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Route("getRoleMemberships/{userId}", Order = 1), HttpGet]
|
||||
public async Task<HttpResponseMessage> getRoleMembershipForUser(Guid userId)
|
||||
{
|
||||
var filter = AsqlHelper.BuildInCondition("ID", new Guid[] { userId });
|
||||
return Request.CreateResponse(HttpStatusCode.OK, await _f4stHelperService.UserPermissionsInfo(filter));
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public class GetRoleMembershipsRequest
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string Sid { get; set; }
|
||||
public string Upn { get; set; }
|
||||
public GetRoleMembershipsRequest() { }
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public class TicketOverviewCountsByRolesRequest
|
||||
{
|
||||
public string Sid { get; set; }
|
||||
public List<Guid> RoleGuids { get; set; } = new List<Guid>();
|
||||
public List<string> Keys { get; set; } = new List<string>();
|
||||
public int? QueueOption { get; set; }
|
||||
public string Queues { get; set; }
|
||||
}
|
||||
|
||||
public class TicketOverviewCountsByRolesForUserRequest
|
||||
{
|
||||
public Guid userId { get; set; }
|
||||
public List<Guid> RoleGuids { get; set; } = new List<Guid>();
|
||||
public List<string> Keys { get; set; } = new List<string>();
|
||||
public int? QueueOption { get; set; }
|
||||
public string Queues { get; set; }
|
||||
}
|
||||
|
||||
private static List<cApiM42TicketQueueInfo> ParseQueues(string queues)
|
||||
{
|
||||
return (queues ?? string.Empty)
|
||||
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(part =>
|
||||
{
|
||||
var decodedPart = HttpUtility.UrlDecode(part)?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(decodedPart))
|
||||
return null;
|
||||
|
||||
var name = decodedPart;
|
||||
string idStr = null;
|
||||
|
||||
var separatorIndex = decodedPart.IndexOf(':');
|
||||
if (separatorIndex >= 0)
|
||||
{
|
||||
name = decodedPart.Substring(0, separatorIndex).Trim();
|
||||
idStr = decodedPart.Substring(separatorIndex + 1).Trim();
|
||||
}
|
||||
|
||||
var queue = new cApiM42TicketQueueInfo();
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
queue.QueueName = name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(idStr))
|
||||
{
|
||||
if (!Guid.TryParse(idStr, out var guid))
|
||||
return null;
|
||||
|
||||
queue.QueueID = guid;
|
||||
queue.QueueName = null;
|
||||
}
|
||||
|
||||
if (queue.QueueID == Guid.Empty && string.IsNullOrWhiteSpace(queue.QueueName))
|
||||
return null;
|
||||
|
||||
return queue;
|
||||
})
|
||||
.Where(q => q != null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
[Route("isAlive"), HttpGet]
|
||||
public HttpResponseMessage isAlive()
|
||||
{
|
||||
return new HttpResponseMessage(HttpStatusCode.NoContent);
|
||||
}
|
||||
|
||||
[Route("loglevel"), HttpGet]
|
||||
public async Task<string> setDebugMode(string debug = "0")
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
await Task.Delay(0);
|
||||
DefaultLogger.Manager.Level = debug == "1" || debug.Equals("true", StringComparison.OrdinalIgnoreCase) ? LogLevels.Debug : LogLevels.Info;
|
||||
return DefaultLogger.Manager.Level.ToString();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("log"), HttpGet]
|
||||
public HttpResponseMessage getLog(string download = "0", int count = 50, string filter = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
return _f4stHelperService.privGetLog(download, count, Request, filter);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RoutePrefix("api/C4ITF4SDWebApi/Logs")]
|
||||
public partial class F4SDM42LogsWebApiController : ApiController
|
||||
{
|
||||
private readonly F4SDHelperService _f4stHelperService;
|
||||
|
||||
public static bool IsInitialized { get; private set; } = false;
|
||||
|
||||
private static object initLock = new object();
|
||||
protected override void Initialize(HttpControllerContext controllerContext)
|
||||
{
|
||||
base.Initialize(controllerContext);
|
||||
try
|
||||
{
|
||||
lock (initLock)
|
||||
{
|
||||
if (IsInitialized || F4SDM42WebApiController.IsInitialized)
|
||||
return;
|
||||
var Ass = Assembly.GetExecutingAssembly();
|
||||
var LM = cLogManagerFile.CreateInstance(LocalMachine: true, A: Ass);
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
cLogManager.DefaultLogger.LogAssemblyInfo(Ass);
|
||||
IsInitialized = true;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
}
|
||||
|
||||
public F4SDM42LogsWebApiController()
|
||||
{
|
||||
_f4stHelperService = new F4SDHelperService();
|
||||
}
|
||||
|
||||
[Route(""), HttpGet]
|
||||
[EnableQuery]
|
||||
public IEnumerable<cM42LogEntry> getLog2(ODataQueryOptions<cM42LogEntry> queryOptions)
|
||||
{
|
||||
try
|
||||
{
|
||||
IQueryable<cM42LogEntry> queryable = _f4stHelperService.privGetLog2().AsQueryable();
|
||||
if (queryOptions.Filter != null)
|
||||
{
|
||||
queryable = queryOptions.Filter.ApplyTo(queryable, new ODataQuerySettings()).Cast<cM42LogEntry>();
|
||||
}
|
||||
return queryable;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Route("$count")]
|
||||
[HttpGet]
|
||||
public int Log2Count(ODataQueryOptions<cM42LogEntry> queryOptions)
|
||||
{
|
||||
IQueryable<cM42LogEntry> queryable = _f4stHelperService.privGetLog2().AsQueryable();
|
||||
if (queryOptions.Filter != null)
|
||||
{
|
||||
queryable = queryOptions.Filter.ApplyTo(queryable, new ODataQuerySettings()).Cast<cM42LogEntry>();
|
||||
}
|
||||
return queryable.Count();
|
||||
}
|
||||
|
||||
[Route("{id}")]
|
||||
[OperationType(OperationType.GetObject)]
|
||||
public cM42LogEntry GetClass(int id)
|
||||
{
|
||||
return _f4stHelperService.privGetLog2(id);
|
||||
}
|
||||
}
|
||||
|
||||
public class cGetPropertyBody
|
||||
{
|
||||
public string TableName { get; set; }
|
||||
public List<string> Columns { get; set; } = new List<string>();
|
||||
public cGetPropertyBody() { }
|
||||
|
||||
}
|
||||
}
|
||||
29
Legacy/F4SDM42WebApi/Properties/AssemblyInfo.cs
Normal file
29
Legacy/F4SDM42WebApi/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Reflection;
|
||||
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("C4IT - F4SD - WebApi for M42")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[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("d8cbffca-0b43-4acc-80ea-c944e7420cee")]
|
||||
|
||||
// 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.*")]
|
||||
21
Legacy/F4SDM42WebApi/cM42LogEntry.cs
Normal file
21
Legacy/F4SDM42WebApi/cM42LogEntry.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Matrix42.Services.Description.Contracts;
|
||||
using System;
|
||||
|
||||
namespace C4IT.F4SDM
|
||||
{
|
||||
[DisplayName(Name = "Log Entry", Type = DisplayNameTypes.Static)]
|
||||
public class cM42LogEntry
|
||||
{
|
||||
public string DisplayName
|
||||
{
|
||||
get => string.Format("Line {0}", LineNumber.ToString());
|
||||
}
|
||||
public DateTime date { get; set; }
|
||||
public string ProcessId { get; set; }
|
||||
public string logLvl { get; set; }
|
||||
public string Theme { get; set; }
|
||||
public string Message { get; set; }
|
||||
[Identifier]
|
||||
public int LineNumber { get; internal set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user