using Ease.NetCore.Utility; using Microsoft.Reporting.NETCore; using System; using System.Security.Claims; namespace OnlineSalesAutoCrop.CoreAPI { /// /// /// public static class Helper { /// /// Creates a new claim with the specified type and value. /// /// The type of the claim, such as a role or permission identifier. Cannot be null or empty. /// The value of the claim, representing the associated data for the specified type. Cannot be null or empty. /// A object initialized with the specified type and value. public static Claim CreateClaim(string type, string value) { return new Claim(type: type, value: value); } /// /// /// /// /// public static DateTimeOffset CreateEaseCacheOptions(double expirationInMinutes = 1440) { return DateTime.Now.AddMinutes(expirationInMinutes); } /// /// Decrypt data by 128 bit AES encryption algorithm /// /// Used to decrypt data /// Value to decrypt and value must be Base64String /// Return plain text data if successful otherwise throw error public static string DecryptData(string secret, string data) { if (data == null || data.Length <= 0) throw new ArgumentNullException(nameof(data)); if (secret == null || secret.Length <= 0) throw new ArgumentNullException(nameof(secret)); try { data = Global.CipherFunctions.DecryptByAES(privateKey: secret, publicKey: secret, data: data, input: 2, output: 3); } catch { data = "*Key/Data Error*"; } return data; } /// /// /// /// /// /// /// /// public static byte[] GenerateRdlcOutputFile(LocalReport report, string format, out string contentType) { try { byte[] bytes = report.Render(format: format, deviceInfo: null, mimeType: out contentType, encoding: out string _, fileNameExtension: out string _, streams: out string[] _, warnings: out Warning[] _); return bytes; } catch (Exception e) { throw new InvalidOperationException(e.Message, e); } } } /// /// /// public static partial class StatusCodesExt { /// /// /// public const int PasswordChanged = 898; /// /// /// public const int StatusSessionExpired = 899; } }