go
This commit is contained in:
85
C4IT.API.Helper/C4IT.API.Helper.csproj
Normal file
85
C4IT.API.Helper/C4IT.API.Helper.csproj
Normal file
@@ -0,0 +1,85 @@
|
||||
<?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>{68000E96-161F-42E4-81C1-552EC2B00BD9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>C4IT.API.Helper</RootNamespace>
|
||||
<AssemblyName>C4IT.API.Helper</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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="log4net">
|
||||
<HintPath>..\lib\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Matrix42.Common">
|
||||
<HintPath>..\..\..\Users\OT202\source\repos\FleetMarketTestWebService\FleetMarketTestWebService\lib\Matrix42.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL" />
|
||||
<Reference Include="Microsoft.Net.Http.Headers">
|
||||
<HintPath>..\lib\Microsoft.Net.Http.Headers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="QRCoder">
|
||||
<HintPath>..\lib\QRCoder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Http">
|
||||
<HintPath>..\..\..\Users\OT202\source\repos\FleetMarketTestWebService\FleetMarketTestWebService\lib\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.DatabaseFileStorage">
|
||||
<HintPath>..\lib\update4u.SPS.DatabaseFileStorage.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="update4u.SPS.DataLayer">
|
||||
<HintPath>..\..\..\Users\OT202\source\repos\FleetMarketTestWebService\FleetMarketTestWebService\lib\update4u.SPS.DataLayer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssembyInfo.cs">
|
||||
<Link>Properties\CommonAssembyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="HelperController.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
178
C4IT.API.Helper/HelperController.cs
Normal file
178
C4IT.API.Helper/HelperController.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using update4u.SPS.DataLayer;
|
||||
using update4u.SPS.DatabaseFileStorage;
|
||||
using update4u.SPS.DataLayer.Schema.Internal;
|
||||
using QRCoder;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net;
|
||||
|
||||
namespace C4IT.API.Helper
|
||||
{
|
||||
[RoutePrefix("api/c4it/helper")]
|
||||
public class HelperController : ApiController
|
||||
{
|
||||
|
||||
|
||||
[Route("copyFiles"), HttpGet]
|
||||
public string copyFiles(Guid sourceEOID, Guid targetEOID)
|
||||
{
|
||||
StorageService storageService = new StorageService();
|
||||
if (!sourceEOID.Equals(Guid.Empty) && !targetEOID.Equals(Guid.Empty))
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Guid sourceTypeID = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + sourceEOID.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
Guid targetTypeID = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + targetEOID.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
|
||||
string targetFolder = StorageService.GetFolderName(targetTypeID, targetEOID);
|
||||
string sourceFolder = StorageService.GetFolderName(sourceTypeID, sourceEOID);
|
||||
List<DatabaseFile> dbFiles = storageService.ListFiles(sourceFolder);
|
||||
|
||||
List<Guid> copyFileGuids = new List<Guid>();
|
||||
foreach (DatabaseFile dbFile in dbFiles)
|
||||
{
|
||||
copyFileGuids.Add(dbFile.FileGuid);
|
||||
|
||||
}
|
||||
storageService.CopyFiles(copyFileGuids, targetFolder);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Route("moveFiles"), HttpGet]
|
||||
public string moveFiles(Guid sourceEOID, Guid targetEOID)
|
||||
{
|
||||
StorageService storageService = new StorageService();
|
||||
if (!sourceEOID.Equals(Guid.Empty) && !targetEOID.Equals(Guid.Empty)) {
|
||||
|
||||
try{
|
||||
Guid sourceTypeID = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + sourceEOID.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
Guid targetTypeID = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + targetEOID.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
|
||||
string targetFolder = StorageService.GetFolderName(targetTypeID, targetEOID);
|
||||
string sourceFolder = StorageService.GetFolderName(sourceTypeID, sourceEOID);
|
||||
|
||||
|
||||
storageService.RenameFolder(sourceFolder, targetFolder);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
[Route("unreadActivity"), HttpPost]
|
||||
public string unreadActivity(Guid[] activiesEOID)
|
||||
{
|
||||
string log = activiesEOID.Length.ToString();
|
||||
if (activiesEOID.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (Guid activityEOID in activiesEOID)
|
||||
{
|
||||
|
||||
Guid typeId = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + activityEOID.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
SPSObject activity = ObjectRequest.GetSPSObject(typeId, activityEOID);
|
||||
log += " / " + activity.GetAttribute("SPSActivityClassBase", "TicketNumber");
|
||||
activity.UpdateAttribute("SPSActivityClassBase","NewInformationReceived",DBNull.Value);
|
||||
activity.Update();
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
return log + " / " + e.Message;
|
||||
}
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
[Route("genQrCode"),HttpGet]
|
||||
public HttpResponseMessage genQRCode(string qrText)
|
||||
{
|
||||
QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||||
QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText,
|
||||
QRCodeGenerator.ECCLevel.Q);
|
||||
QRCode qrCode = new QRCode(qrCodeData);
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20);
|
||||
var dataStream = new MemoryStream(BitmapToBytes(qrCodeImage));
|
||||
var fileName = Path.GetInvalidFileNameChars().Aggregate(qrText.Substring(0, 10), (current, c) => current.Replace(c.ToString(), string.Empty));
|
||||
if (String.IsNullOrEmpty(fileName))
|
||||
{
|
||||
fileName = "dummy";
|
||||
}
|
||||
HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
httpResponseMessage.Content = new StreamContent(dataStream);
|
||||
httpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
|
||||
httpResponseMessage.Content.Headers.ContentDisposition.FileName = fileName+".png";
|
||||
httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/png");
|
||||
|
||||
return httpResponseMessage;
|
||||
}
|
||||
// This method is for converting bitmap into a byte array
|
||||
private static byte[] BitmapToBytes(Bitmap img)
|
||||
{
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Route("copyObject"), HttpGet]
|
||||
|
||||
public string copyObject(Guid objectToCopy)
|
||||
{
|
||||
string log = "";
|
||||
try
|
||||
{
|
||||
Guid sourceTypeID = new Guid(FragmentRequestBase.SimpleLoad(SPSDataEngineSchemaReader.ClassGetIDFromName("SPSCommonClassBase"), "typeid", "[expression-objectid]='" + objectToCopy.ToString() + "'").Rows[0]["typeid"].ToString());
|
||||
SPSObject oldObject = ObjectRequest.GetSPSObject(sourceTypeID, objectToCopy);
|
||||
SPSObject newObject = (SPSObject)oldObject.CreateCopy(true);
|
||||
|
||||
IAttribute k = newObject.ConfigurationItem.AutoNumberAttribute;
|
||||
string attrib = k.DbColumnName;
|
||||
IDataDefinition dd = k.BelongsToSchemaObjectClass;
|
||||
newObject.UpdateAttribute(dd.Name, attrib, DBNull.Value);
|
||||
log = attrib + " / " + dd.Name;
|
||||
|
||||
|
||||
newObject.Update();
|
||||
}catch(Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Route("createUninstall"), HttpPost]
|
||||
public bool createUninstall(Guid[] installBookings)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
C4IT.API.Helper/Properties/AssemblyInfo.cs
Normal file
11
C4IT.API.Helper/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("C4IT.API.Helper")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("68000e96-161f-42e4-81c1-552ec2b00bd9")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
15
C4IT.API.Helper/app.config
Normal file
15
C4IT.API.Helper/app.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<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>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
7
C4IT.API.Helper/packages.config
Normal file
7
C4IT.API.Helper/packages.config
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore.Http.Features" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore.Mvc.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore.Routing.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user