102 lines
4.0 KiB
C#
102 lines
4.0 KiB
C#
using Android.Util;
|
|
using CommunityToolkit.Maui.Alerts;
|
|
using CommunityToolkit.Maui.Core;
|
|
using DevExpress.Maui.Core.Internal;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http.Json;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WorkFlowCheck.Common.DTO;
|
|
|
|
namespace WorkFlowCheck.MAUI.Helper
|
|
{
|
|
public static class SystemHelper
|
|
{
|
|
public static string DatabaseName = "";
|
|
public static bool Syncronised = false;
|
|
public static UserDTO SystemUserDTO;
|
|
public static string ProgramVersion = "v1.1.036";
|
|
|
|
#if DEBUG
|
|
//public static string ApiBaseUrl = $"http://10.0.2.2:59027/";
|
|
//public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
|
|
public static string ApiBaseUrl = $"https://uat.wfcapi.nuvolar.hu/";
|
|
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
|
|
|
|
#endif
|
|
#if !DEBUG
|
|
public static string ApiBaseUrl = $"https://uat.wfcapi.nuvolar.hu/";
|
|
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
|
|
#endif
|
|
public async static Task GetAPIInfoAsync()
|
|
{
|
|
using (var httpClient = new HttpClient())
|
|
{
|
|
|
|
httpClient.BaseAddress = new Uri(ApiBaseUrl);
|
|
httpClient.DefaultRequestHeaders.Add("X-Api-Key", ApiKey);
|
|
|
|
string endpoint = $"{ApiBaseUrl}api/System/GetDatabaseAndVersionInfo";
|
|
var retVal = new RoleDTO();
|
|
try
|
|
{
|
|
var response = await httpClient.GetFromJsonAsync<ApiResponseDTO<string>>(endpoint);
|
|
if (response != null)
|
|
{
|
|
if (response.IsSuccess)
|
|
{
|
|
DatabaseName = response.Data;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//Log.Error(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
public async static Task ShowSnackBar(string message,
|
|
string actionButtonTextColor = "#FFFFFF00",
|
|
string backgroundColor = "#FFFF0000",
|
|
string textColor = "##FFFFFF00",
|
|
int duration = 10,
|
|
string actionButtonText = "Ok",
|
|
Func<Task> action = null)
|
|
{
|
|
var visualOptions = new SnackbarOptions
|
|
{
|
|
ActionButtonTextColor = Color.FromArgb(actionButtonTextColor),
|
|
CornerRadius = new CornerRadius(10),
|
|
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
|
BackgroundColor = Color.FromArgb(backgroundColor),
|
|
TextColor = Color.FromArgb(textColor)
|
|
|
|
};
|
|
var snackbar = Snackbar.Make(
|
|
message,
|
|
duration: TimeSpan.FromSeconds(duration),
|
|
action: async () =>
|
|
{
|
|
if (action != null)
|
|
await action();
|
|
},
|
|
actionButtonText: actionButtonText,
|
|
visualOptions: visualOptions
|
|
);
|
|
await snackbar.Show();
|
|
}
|
|
public static string ColorToHex(Color color)
|
|
{
|
|
// ARGB értékek lekérése
|
|
uint colorInt = (uint)color.ToArgb();
|
|
|
|
// Hexadecimális stringgé alakítás, és a '#'-t is hozzáadjuk
|
|
return $"#{colorInt:X8}";
|
|
}
|
|
}
|
|
}
|