private bool UpdateConfigFiles() { if (Mobile.configData.HasIntune || Mobile.configData.HasFTP) { if (Mobile.IsNetAvailable()) { GenericUtilsClass.DownloadConfigFiles(out string sFileCert); if (!Mobile.configData.IsCertLoaded && !string.IsNullOrEmpty(sFileCert)) { Mobile.configData.StoreCertificate(Mobile.configData.CreateCertificate(null, sFileCert)); } return(true); } //this.ShowErrorAndKill(new NoInternetException()); //MainPage.DisplayAlert("Attention", "There is not connection at this moment, try again later","OK"); return(false); } else { Mobile.configData.HasFTP = false; // Check if all configuration files are available in public folder bool HasPublicFiles = GenericUtilsClass.HasDeviceAllXmls(Mobile.ConfigPublicPath); //this.abortMission = !this.HasDeviceAllXmls(Mobile.ConfigPublicPath); if (HasPublicFiles) { bool CPD = false; if (GenericUtilsClass.TagGlobal(true, "ConfigPublicDir", out dynamic value)) { if (value != null) { bool.TryParse((string)value, out CPD); } } GenericUtilsClass.CopyConfigFiles(!CPD, Mobile.ConfigPublicPath, Mobile.ConfigPath, out string sFileCert); if (!string.IsNullOrEmpty(sFileCert)) { Mobile.configData.StoreCertificate(Mobile.configData.CreateCertificate(null, sFileCert)); } if (!GenericUtilsClass.HasDeviceAllXmls(Mobile.ConfigPath)) { return(true); } } return(true); } }
private bool InitialConfigProcess() { string Mode = GenericUtilsClass.ChekInstallMode(); if (Mode.Equals("Intune")) { if (Mobile.IsNetAvailable()) { var MamServ = DependencyService.Get <IMAMService>(); MamServ.UtilMAMService(); if (Mobile.configData.HasIntune) { NewConfigVersion = GenericUtilsClass.CheckFTPConfigVersion(); GenericUtilsClass.DownloadConfigFiles(out string sFileCert); if (!Mobile.configData.IsCertLoaded && !string.IsNullOrEmpty(sFileCert)) { Mobile.configData.StoreCertificate(Mobile.configData.CreateCertificate(null, sFileCert)); } return(true); } else { this.ShowErrorAndKill(new IntuneCredentialsException()); GenericUtilsClass.SetInstallMode("None"); return(false); } } else { this.ShowErrorAndKill(new NoInternetException()); } //MainPage.DisplayAlert("Attention", "There is not connection at this moment, try again later","OK"); return(false); } else if (Mode.Equals("Manual")) { Mobile.configData.HasFTP = false; // Check if all configuration files are available in public folder bool HasPublicFiles = GenericUtilsClass.HasDeviceAllXmls(Mobile.ConfigPublicPath); //this.abortMission = !this.HasDeviceAllXmls(Mobile.ConfigPublicPath); if (HasPublicFiles) { bool CPD = false; if (GenericUtilsClass.TagGlobal(true, "ConfigPublicDir", out dynamic value)) { if (value != null) { bool.TryParse((string)value, out CPD); } } GenericUtilsClass.CopyConfigFiles(!CPD, Mobile.ConfigPublicPath, Mobile.ConfigPath, out string sFileCert); if (!string.IsNullOrEmpty(sFileCert)) { Mobile.configData.StoreCertificate(Mobile.configData.CreateCertificate(null, sFileCert)); } NewConfigVersion = GenericUtilsClass.CheckPubConfigVersion(); //if (!GenericUtilsClass.HasDeviceAllXmls(Mobile.ConfigPath)) return(true); } else { this.ShowErrorAndKill(new ConfigurationFilesNotFoundException()); GenericUtilsClass.SetInstallMode("None"); return(false); } } else { //{ // //Configure download FTP // if (Mobile.IsNetAvailable()) // { // bool result =false; // tcs = new TaskCompletionSource<bool>(); // // Console.WriteLine($"------------------------------------FTP Thread: {Thread.CurrentThread.ManagedThreadId}"); // Device.BeginInvokeOnMainThread(async () => // { // MainPage = new NavigationPage(new FtpDownloadSettings(tcs)); // //PopupNavigation.Instance.PushAsync(new FtpDownloadSettings()); // result = await tcs.Task; // if (!this.InitializeConfiguration()) // { // GenericUtilsClass.DeleteConfigFiles(Mobile.ConfigPath); // return; // } // //NewConfigVersion = GenericUtilsClass.CheckFTPConfigVersion(); // GenericUtilsClass.SetInstallMode("FTP"); // if (this.abortMission) // { // this.ShowErrorAndKill(new ConfigurationFilesNotFoundException()); // return; // } // //await SecureStorage.SetAsync("ConfigVersion", NewConfigVersion); // if ( ! Data.Get.IsFromScripting ) // { // Console.WriteLine($"------------------------------------Login Thread: {Thread.CurrentThread.ManagedThreadId}"); // Application.Current.MainPage = new NavigationPage(new AclaraViewLogin(dialogs)); // } // else // tcs1.SetResult(true); // }); // return false; // } // else // { // this.ShowErrorAndKill(new NoInternetException()); // this.abortMission = true; // return false; // } //} return(true); } }