Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private void CallToInitApp(
            IBluetoothLowEnergyAdapter adapter,
            IUserDialogs dialogs,
            string appVersion)
        {
            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskSchedulerOnUnobservedTaskException;

            Utils.Print("FormsApp: Interactive [ " + Data.Get.IsFromScripting + " ]");

            appVersion_str = appVersion;

            deviceId = CrossDeviceInfo.Current.Id;

            // Profiles manager
            credentialsService = new CredentialsService();

            // Initializes Bluetooth
            ble_interface = new BleSerial(adapter);

            AppResources.Culture = CrossMultilingual.Current.DeviceCultureInfo;

            // Config path
            ConfigPaths();

            string Mode = GenericUtilsClass.ChekInstallMode();

            if (Data.Get.IsAndroid && Mode.Equals("None"))
            {
                var MamServ = DependencyService.Get <IMAMService>();
                MamServ.UtilMAMService();
                if (Mobile.configData.HasIntune)
                {
                    GenericUtilsClass.SetInstallMode("Intune");
                    this.LoadConfigurationAndOpenScene(dialogs);
                    return;
                }
            }

            // var MamServ = DependencyService.Get<IMAMService>();
            // MamServ.UtilMAMService();

            if (VersionTracking.IsFirstLaunchEver || Mode.Equals("None"))
            {
                SecureStorage.RemoveAll();
                Device.BeginInvokeOnMainThread(() =>
                {
                    MainPage = new NavigationPage(new AclaraInstallPage());
                });
            }
            else
            {
                if (Mode.Equals("Intune"))
                {
                    var MamServ = DependencyService.Get <IMAMService>();
                    MamServ.UtilMAMService();
                }
                else if (Mode.Equals("FTP"))
                {
                    // Check if FTP settings is in securestorage
                    GenericUtilsClass.CheckFTPDownload();
                }

                this.LoadConfigurationAndOpenScene(dialogs);
            }
        }