internal static async Task <string> Cmd_Get_Setup_Data() { if (LocalData.IsDownloadedSetupData) { return("OK"); } LocalData.IsDownloadedSetupData = false; try { string a = await CmdDownloadSetupData(); if (a.Equals("Error")) { return("Could not connect to server"); } else { a = a.Substring(10, a.Length - 20); string tmp_Server_NotAuthorized_UserName = a.Substring(0, 20); string tmp_Server_NotAuthorized_UserPass = a.Substring(20, 20); LocalData.ServerNotAuthorizedUserPass = GlobalFunctions.ConvertToSecureString(tmp_Server_NotAuthorized_UserPass); LocalData.ServerNotAuthorizedUserName = GlobalFunctions.ConvertToSecureString(tmp_Server_NotAuthorized_UserName); a = string.Empty; tmp_Server_NotAuthorized_UserName = string.Empty; tmp_Server_NotAuthorized_UserPass = string.Empty; LocalData.IsDownloadedSetupData = true; return("OK"); } } catch (Exception ex) { LocalData.IsDownloadedSetupData = false; return(ex.Message); } }
public async static void Authorize(string ParUserName, string ParPassword) { LocalData.CurrJWT = string.Empty; BlazorTimeAnalyzer.DevelopmentMode = !LocalData.ProductionOrDevelopmentMode; BlazorTimeAnalyzer.Reset(); BlazorTimeAnalyzer.LogAllAddition = true; BlazorTimeAnalyzer.Add("A1", MethodBase.GetCurrentMethod()); timerHelper.Stop(); if (await WebApi.CmdGetJWT(GlobalFunctions.ConvertToSecureString(ParUserName), GlobalFunctions.ConvertToSecureString(ParPassword), WebApiUserTypesEnum.Authorized)) { BlazorTimeAnalyzer.Add("A2", MethodBase.GetCurrentMethod()); TSUser tmpTSUser = new TSUser { UserName = ParUserName, Password = ParPassword, }; BlazorTimeAnalyzer.Add("A2", MethodBase.GetCurrentMethod()); LocalData.CurrTSUser = await WebApiFunctions.CmdTSUserAuthorize(tmpTSUser); BlazorTimeAnalyzer.Add("A3", MethodBase.GetCurrentMethod()); if (LocalData.CurrTSUser.UserName.ToLower().Equals("error!")) { LocalData.AppHasGlobalError = true; AddError(LocalData.CurrTSUser.FullName, MethodBase.GetCurrentMethod(), true, false); } else { LocalData.IsAuthenticated = !LocalData.CurrTSUser.ID.Equals(Guid.Empty); if (LocalData.IsAuthenticated) { timerHelper.OnTick = TimerTick; timerHelper.Start(1, 10000); BlazorTimeAnalyzer.Add("A4", MethodBase.GetCurrentMethod()); await WebApiFunctions.CmdGetFeedback(); BlazorTimeAnalyzer.Add("A5", MethodBase.GetCurrentMethod()); await WebApiFunctions.CmdGetReaction(); BlazorTimeAnalyzer.Add("A6", MethodBase.GetCurrentMethod()); LocalData.LoginLogout = LocalData.CurrTSUser.UserName; LocalData.btModal.Close(); CmdNavigate("DesktopPage"); LocalData.EventConsumerName = "TodosPage"; LocalData.componentBridge.InvokeRefresh(); LocalData.compHeader.Refresh(); LocalData.AppHasGlobalError = false; BlazorTimeAnalyzer.Add("A7", MethodBase.GetCurrentMethod()); } else { bool b = await WebApi.CmdGetJWT(LocalData.ServerNotAuthorizedUserName, LocalData.ServerNotAuthorizedUserPass, WebApiUserTypesEnum.NotAuthorized); if (b) { timerHelper.OnTick = TimerTick; timerHelper.Start(1, 10000); } LocalData.AppHasGlobalError = true; } } } BlazorTimeAnalyzer.LogAll(); }