Initial commit

parent d4e01322

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckInfoFields", "CheckInfoFields\CheckInfoFields.csproj", "{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E4F77346-B5BD-49E9-A24A-00B99750C9E7}
EndGlobalSection
EndGlobal
<?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>{7442B3B5-49A5-41F0-8B2B-F78C98BE4D33}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CheckInfoFields</RootNamespace>
<AssemblyName>CheckInfoFields</AssemblyName>
<TargetFrameworkVersion>v4.8</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="EntityFramework">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NLog">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\NLog.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RDnL.Logger">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RDnL.Logger.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.BusinessLayer.EF">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.BusinessLayer.EF.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.BusinessLayer.Interfaces">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.BusinessLayer.Interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Common">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.Common.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Customizations.API">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.Customizations.API.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Customizations.Interfaces">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.Customizations.Interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.EventManager">
<HintPath>..\..\..\..\inetpub\wwwroot\OpcenterRDnLEventManager\bin\RnD.EventManager.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.EventManager.Interfaces">
<HintPath>..\..\..\..\inetpub\wwwroot\OpcenterRDnLEventManager\bin\RnD.EventManager.Interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Messages.Client">
<HintPath>..\..\..\..\inetpub\wwwroot\OpcenterRDnLBackEnd\bin\RnD.Messages.Client.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Messages.Interfaces">
<HintPath>..\..\..\..\inetpub\wwwroot\OpcenterRDnLBackEnd\bin\RnD.Messages.Interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Model.EF">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.Model.EF.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.SubstitutionSyntax">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.SubstitutionSyntax.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnD.Uniconnect">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnD.Uniconnect.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RnDSuiteBackend">
<HintPath>..\..\..\..\Distr\OpcenterRDnL_9.1.0.0.3\Implementation\ABP\Opcenter_RDnL_V9.1.0.3_applied_best_practices\OpcenterRDnLLibrary_Builds\Siemens.OpcenterRDnLLibrary.Dependencies\RnDSuiteBackend.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="RDnL\Actions\CheckInfoFieldsCustomAction.cs" />
<Compile Include="RDnL\Conditions\CheckInfoFieldsCustomCondition.cs" />
<Compile Include="Services\CheckInfoFieldsService.cs" />
<Compile Include="Services\MessageService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CheckInfoFields")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CheckInfoFields")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7442b3b5-49a5-41f0-8b2b-f78c98be4d33")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using CheckInfoFields.Services;
using RnD.API;
using RnD.Attributes;
using RnD.Model;
using System;
using System.Linq;
namespace CheckInfoFields.RDnL.Actions
{
[CustomFunction("CheckInfoFieldsCustomAction", RnD.Common.Enums.CustomFunctionType.CustomAction)]
public class CheckInfoFieldsCustomAction : AdvancedCustomFunction, ICustomAction<ICustomContext>
{
#region Consturctors
public CheckInfoFieldsCustomAction(IAPI aAPI) : base(aAPI) { }
#endregion
#region Methods
public void Execute(ICustomContext aContext)
{
var entity = aContext.Entity;
var ssFrom = aContext.Event?.EventDetails.FirstOrDefault(c => c.Key == "SS_FROM")?.Value ?? aContext.SS_FROM;
if (ssFrom is null)
{
Log.Error("ssFrom was null");
return;
}
if(entity is null)
{
Log.Error("entity was null");
return;
}
var userId = (decimal)aContext.Event.UserName;
try
{
var infoFields = CheckInfoFieldsService.GetInfoFields(entity);
var emptyInfoFields = CheckInfoFieldsService.FindEmptyInfoFields(infoFields);
if (emptyInfoFields.Count() != 0)
{
var statusId = (decimal)ssFrom;
var infoFieldNames = CheckInfoFieldsService.GetInfoFieldDisplayTitles(entity, infoFields, DatabaseContext);
var notificationMessage = $"Не заполнены необходимые инфополя: {string.Join(", ", infoFieldNames)}";
CheckInfoFieldsService.ChangeStatus(entity, statusId, DatabaseContext);
CheckInfoFieldsService.SendMessage(userId, notificationMessage, API);
}
else
{
return;
}
}
catch (Exception ex)
{
Log.Error(ex);
CheckInfoFieldsService.SendMessage(userId, ex.Message, API);
}
}
#endregion
}
}
using CheckInfoFields.Services;
using RnD.API;
using RnD.Attributes;
using RnD.Model;
using System;
using System.Linq;
namespace CheckInfoFields.RDnL.Conditions
{
[CustomFunction("CheckInfoFieldsCustomCondition", RnD.Common.Enums.CustomFunctionType.CustomCondition)]
public class CheckInfoFieldsCustomCondition : AdvancedCustomFunction, ICustomCondition<ICustomContext>
{
#region Constructors
public CheckInfoFieldsCustomCondition(IAPI aAPI) : base(aAPI)
{
}
#endregion
#region Methods
public bool Execute(ICustomContext aContext)
{
var entity = aContext.Entity;
var ssFrom = aContext.Event?.EventDetails.FirstOrDefault(c => c.Key == "SS_FROM")?.Value ?? aContext.SS_FROM;
if (ssFrom is null)
{
Log.Error("ssFrom was null");
return false;
}
if (entity is null)
{
Log.Error("entity was null");
return false;
}
var userId = (decimal)aContext.Event.UserName;
try
{
var infoFields = CheckInfoFieldsService.GetInfoFields(entity);
var emptyInfoFields = CheckInfoFieldsService.FindEmptyInfoFields(infoFields);
if (emptyInfoFields.Count() != 0)
{
var statusId = (decimal)ssFrom;
var infoFieldNames = CheckInfoFieldsService.GetInfoFieldDisplayTitles(entity, infoFields, DatabaseContext);
var notificationMessage = $"Не заполнены необходимые инфополя: {string.Join(", ", infoFieldNames)}";
CheckInfoFieldsService.ChangeStatus(entity, statusId, DatabaseContext);
CheckInfoFieldsService.SendMessage(userId, notificationMessage, API);
return false;
}
else
{
return true;
}
}
catch (Exception ex)
{
Log.Error(ex);
CheckInfoFieldsService.SendMessage(userId, ex.Message, API);
return false;
}
}
#endregion
}
}
using RnD.API;
using RnD.Messages.Client;
using RnD.Messages.Interfaces.Data;
using RnD.Model;
using RnD.Model.EF;
using System.Collections.Generic;
using System.Linq;
namespace CheckInfoFields.Services
{
/// <summary>
/// Command service for searching and checking info fields
/// </summary>
internal static class CheckInfoFieldsService
{
#region Methods
/// <summary>
/// Search for empty info fields
/// </summary>
/// <param name="infoFields"></param>
/// <returns>List of empty info fields</returns>
internal static IEnumerable<IInfoField> FindEmptyInfoFields(in IEnumerable<IInfoField> infoFields)
{
var emptyInfoFields = new Stack<IInfoField>();
foreach (var infoField in infoFields)
{
if (string.IsNullOrEmpty(infoField.InfoFieldValue))
{
emptyInfoFields.Push(infoField);
}
}
return emptyInfoFields;
}
/// <summary>
/// Sending a message to a user
/// </summary>
/// <param name="userId"></param>
/// <param name="notificationMessage"></param>
/// <param name="api"></param>
internal static void SendMessage(in decimal userId, in string notificationMessage, in IAPI api)
{
var notificationClient = new NotificationClient();
var userName = api.User.GetUser(userId).UserName;
var notificationType = NotificationType.ErrorMessage;
var connectionName = api.CustomizationSession.ConnectionName;
var browserGuid = api.CustomizationSession.BrowserGuid;
MessageService.SendMessage(notificationMessage,
notificationType,
notificationClient,
userName,
connectionName,
browserGuid);
}
/// <summary>
/// Getting all info fields from an entity
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
internal static IEnumerable<IInfoField> GetInfoFields(in ICustomizationObject entity)
{
var type = entity.GetType();
var property = type.GetProperty("InfoCards");
var infoCards = (IReadOnlyCollection<IInfoCard>)property.GetValue(entity, null);
return infoCards.SelectMany(c => c.InfoFields)
.Where(c => c.IsMandatory == RnD.Common.Enums.ThreeState.Yes);
}
/// <summary>
/// Entity status change
/// </summary>
/// <param name="entity"></param>
/// <param name="statusId"></param>
/// <param name="databaseContext"></param>
internal static void ChangeStatus(in ICustomizationObject entity, in decimal statusId, in RnDConnection databaseContext)
{
dynamic rndvObject;
if (entity is ISpecification specification)
{
rndvObject = databaseContext.RndvSp.Find(new object[] { specification.ID, specification.Version });
}
else if (entity is ISample sample)
{
rndvObject = databaseContext.RndvSc.Find(new object[] { sample.ID });
}
else if (entity is IRequest request)
{
rndvObject = databaseContext.RndvRq.Find(new object[] { request.ID });
}
else
{
return;
}
rndvObject.SS = statusId;
databaseContext.SaveChanges();
}
/// <summary>
/// Getting the display title from the UI
/// </summary>
/// <param name="entity"></param>
/// <param name="infoFields"></param>
/// <param name="databaseContext"></param>
/// <returns></returns>
internal static IEnumerable<string> GetInfoFieldDisplayTitles(in ICustomizationObject entity, in IEnumerable<IInfoField> infoFields, in RnDConnection databaseContext)
{
var names = new List<string>();
foreach (var infoField in infoFields)
{
string name = null;
if (entity is ISpecification specification)
{
name = databaseContext.RndvSpIiLang.FirstOrDefault(c => c.SP == specification.ID &&
c.SP_VERSION == specification.Version &&
c.IINODE == infoField.InfoFieldNodeNumber &&
c.ICNODE == infoField.InfoCardNodeNumber)?.DSP_TITLE;
}
else if (entity is ISample sample)
{
name = databaseContext.RndvScIiLang.FirstOrDefault(c => c.SC == sample.ID &&
c.II == infoField.ID &&
c.ICNODE == infoField.InfoCardNodeNumber &&
c.IINODE == infoField.InfoFieldNodeNumber)?.DSP_TITLE;
}
else if (entity is IRequest request)
{
name = databaseContext.RndvRqIiLang.FirstOrDefault(c => c.RQ == request.ID &&
c.II == infoField.ID &&
c.ICNODE == infoField.InfoCardNodeNumber &&
c.IINODE == infoField.InfoFieldNodeNumber)?.DSP_TITLE;
}
names.Add(name ?? infoField.DisplayTitle);
}
return names;
}
#endregion
}
}
using RnD.Messages.Client;
using RnD.Messages.Interfaces.Data;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace CheckInfoFields.Services
{
/// <summary>
/// Service for send message on frontend
/// </summary>
internal static class MessageService
{
#region Methods
/// <summary>
/// Send message to user on RDnL frontend
/// </summary>
/// <param name="message">Message for send</param>
/// <param name="notificationType"></param>
/// <param name="notificationClient"></param>
/// <param name="userName"></param>
/// <param name="db"></param>
/// <param name="guid"></param>
public static void SendMessage(in string message, in NotificationType notificationType, in NotificationClient notificationClient,
in string userName, in string db, in Guid guid)
{
var notificationMessage = new { Message = message, Arguments = new List<string>() };
var notification = new Notification
{
Data = RuntimeHelpers.GetObjectValue(notificationMessage),
NotificationType = notificationType
};
notificationClient.SendTo(notification, db, userName, guid);
}
#endregion
}
}
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\bin\Debug\CheckInfoFields.dll
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\bin\Debug\CheckInfoFields.pdb
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Debug\CheckInfoFields.csproj.AssemblyReference.cache
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Debug\CheckInfoFields.csproj.CoreCompileInputs.cache
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Debug\CheckInfoFields.dll
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Debug\CheckInfoFields.pdb
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\bin\Release\CheckInfoFields.dll
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\bin\Release\CheckInfoFields.pdb
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Release\CheckInfoFields.csproj.AssemblyReference.cache
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Release\CheckInfoFields.csproj.CoreCompileInputs.cache
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Release\CheckInfoFields.dll
C:\Bryzgalov\Projects\CheckInfoFields\CheckInfoFields\obj\Release\CheckInfoFields.pdb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment