private bool ProcessFtp()
        {
            if (!int.TryParse(tbx_remote_port.Text, out int iPort))
            {
                iPort = 22;
            }

            if (GenericUtilsClass.TestFtpCredentials(tbx_remote_host.Text, tbx_user_name.Text, tbx_user_pass.Text, tbx_remote_path.Text, iPort))
            {
                config.ftpDownload_Host = tbx_remote_host.Text;
                config.ftpDownload_Pass = tbx_user_pass.Text;
                config.ftpDownload_User = tbx_user_name.Text;
                config.ftpDownload_Path = tbx_remote_path.Text;
                config.HasFTP           = true;
                MTUComm.Mobile.configData.ftpDownload_Port = iPort;

                SecureStorage.SetAsync("ftpDownload_Host", tbx_remote_host.Text);
                SecureStorage.SetAsync("ftpDownload_Port", iPort.ToString());
                // await SecureStorage.SetAsync("ftpDownload_Pass", tbx_user_pass.Text);
                SecureStorage.SetAsync("ftpDownload_User", tbx_user_name.Text);
                SecureStorage.SetAsync("ftpDownload_Path", tbx_remote_path.Text);


                if (!GenericUtilsClass.DownloadConfigFiles())
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and make window visible
        // NOTE: You have 17 seconds to return from this method or iOS will terminate application
        public override bool FinishedLaunching(
            UIApplication app,
            NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            //Distribute.DontCheckForUpdatesInDebug();

            // Get Intun Parameters
            //Online.DownloadIntuneParameters ();
            //Parameters.PrepareFromIntune();

            // Core Foundation Keys:
            // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
            var appVersion = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"];
            var appBuild   = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"];

            IBluetoothLowEnergyAdapter bluetoothLowEnergyAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter();
            IUserDialogs userDialogs = UserDialogs.Instance;
            string       appversion  = appVersion.Description + " ( " + appBuild.Description + " )";

            appSave = new FormsApp(bluetoothLowEnergyAdapter, userDialogs, appversion);

            // Check if FTP settings is in securestorage
            GenericUtilsClass.CheckFTPDownload();

            //TEST.Test ();

            base.LoadApplication(appSave);

            return(base.FinishedLaunching(app, options));
        }
        public async void Btn_Manual_Clicked(object sender, EventArgs e)
        {
            GenericUtilsClass.SetInstallMode("Manual");
            await DisplayAlert("Attention", "The app will close, you must copy the config files in the public folder of the app, and then restart", "OK");

            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
        public async void UpdateFiles()
        {
            String sMessage;

            // Upload log files
            if (GenericUtilsClass.NumLogFilesToUpload(Mobile.LogPath) > 0)
            {
                bool bUpload = await GenericUtilsClass.UploadFiles(false);

                int numFiles = GenericUtilsClass.NumFilesUploaded;

                sMessage = (bUpload) ? $" ** {numFiles.ToString()} Files uploaded successfully ** " : "Error while uploading files to the FTP server";
            }
            else
            {
                sMessage = "There are not log files to upload";
            }

            Device.OpenUri(new Uri(resultCallback + "?" +
                                   "status=success" +
                                   Compression.GetUriParameter() +
                                   "&output_filename=UploadingFiles" +
                                   "&output_data=" + Compression.CompressToUrlUsingGlobal(sMessage)));

            System.Diagnostics.Process.GetCurrentProcess().Kill();
            return;
        }
Esempio n. 5
0
        protected override void OnMAMCreate(Bundle bundle)
        {
            //TabLayoutResource = Resource.Layout.Tabbar;
            // ToolbarResource = Resource.Layout.Toolbar;

            base.OnMAMCreate(bundle);

            UserDialogs.Init(this);
            global::Xamarin.Forms.Forms.Init(this, bundle);

            try
            {
                // If you want to enable/disable the Bluetooth adapter from code, you must call this.
                BluetoothLowEnergyAdapter.Init(this);
            }catch (Exception e) {
                Utils.Print(e.StackTrace);
            }

            // Obtain the bluetooth adapter so we can pass it into our (shared-code) Xamarin Forms app. There are
            // additional Obtain() methods on BluetoothLowEnergyAdapter if you have more specific needs (e.g. if you
            // need to support devices with multiple Bluetooth adapters)
            var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext);


            if (Xamarin.Forms.Device.Idiom == TargetIdiom.Phone)
            {
                RequestedOrientation = ScreenOrientation.Portrait;
            }
            else
            {
                RequestedOrientation = ScreenOrientation.Landscape;
            }

            //CrossCurrentActivity.Current.Init(this, bundle);


            var context = Android.App.Application.Context;
            var info    = context.PackageManager.GetPackageInfo(context.PackageName, 0);

            string value = info.VersionName.ToString();


            // Check if FTP settings is in securestorage
            GenericUtilsClass.CheckFTPDownload();


            LoadApplication(new FormsApp(bluetooth, UserDialogs.Instance, value));
        }
        public async void Btn_Intune_Clicked(object sender, EventArgs e)
        {
            if (!Mobile.IsNetAvailable())
            {
                await DisplayAlert("Attention", "No internet connection, try later", "OK");

                return;
            }
            GenericUtilsClass.SetInstallMode("Intune");
            var MamServ = DependencyService.Get <IMAMService>();

            MamServ.LoginUserMAM();
            await DisplayAlert("Attention", "The app will close to apply the configuration", "OK");

            //MamServ.UtilMAMService();
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
Esempio n. 7
0
        private bool ProcessFtp()
        {
            if (!int.TryParse(tbx_remote_port.Text, out int iPort))
            {
                iPort = 22;
            }

            if (GenericUtilsClass.TestFtpCredentials(tbx_remote_host.Text, tbx_user_name.Text, tbx_user_pass.Text, tbx_remote_path.Text, iPort))
            {
                config.ftpDownload_Host = tbx_remote_host.Text;
                config.ftpDownload_Pass = tbx_user_pass.Text;
                config.ftpDownload_User = tbx_user_name.Text;
                config.ftpDownload_Path = tbx_remote_path.Text;
                config.HasFTP           = true;
                config.ftpDownload_Port = iPort;

                SecureStorage.SetAsync("ftpDownload_Host", tbx_remote_host.Text);
                SecureStorage.SetAsync("ftpDownload_Port", iPort.ToString());
                SecureStorage.SetAsync("ftpDownload_Pass", tbx_user_pass.Text);
                SecureStorage.SetAsync("ftpDownload_User", tbx_user_name.Text);
                SecureStorage.SetAsync("ftpDownload_Path", tbx_remote_path.Text);


                if (GenericUtilsClass.DownloadConfigFiles(out string sFileCert))
                {
                    NewConfigVersion = GenericUtilsClass.CheckFTPConfigVersion();
                    SecureStorage.SetAsync("ConfigVersion", NewConfigVersion);
                    if (!string.IsNullOrEmpty(sFileCert))
                    {
                        Mobile.configData.StoreCertificate(Mobile.configData.CreateCertificate(null, sFileCert));
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public async void Btn_FTP_Clicked(object sender, EventArgs e)
        {
            bool result;

            if (!Mobile.IsNetAvailable())
            {
                await DisplayAlert("Attention", "No internet connection, try later", "OK");

                return;
            }
            GenericUtilsClass.SetInstallMode("FTP");
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            await Navigation.PushAsync(new FtpDownloadSettings(tcs));

            result = await tcs.Task;
            if (!result)
            {
                GenericUtilsClass.SetInstallMode("None");
            }
            await DisplayAlert("Attention", "The app will close to apply the configuration", "OK");

            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
 public void RefreshList()
 {
     FileList   = GenericUtilsClass.LogFilesToUpload(Mobile.LogUserPath, true);
     IndexFile  = FileList.Count - 1;
     TotalFiles = FileList.Count - 1;
 }