private void btnCarica_Click(object sender, RoutedEventArgs e)
        {
            string tmpStr = txtAppConfig.Text;

            //Apps.AppConfigFile.LoadFromFile(ref App.config, testo: out tmpStr, encrypted: out _);
            App.config = (Apps.AppConfigFile)App.config.LoadFromFile(testo: ref tmpStr, encrypted: out _, inErr: out _);
            if (tmpStr != "")
            {
                txtAppConfig.Text = tmpStr;
            }


            if (txtAppConfig.Text == "")
            {
                MsgBx.Show("", "Non sono riuscito a leggere il file o il file è vuoto, consultare il log", MsgBxPicture.Alert);

                if (Serialize.SerializeInText(App.Config, ref tmpStr) == false)
                {
                    txtAppConfig.Text = "";
                }
                else
                {
                    txtAppConfig.Text = tmpStr;
                }
            }
        }
        async internal void TestPath()
        {
            if (SelectedPath == null)
            {
                MsgBx.Show("", "There isn't a selected path, click on a path", MsgBxPicture.Info);
                return;
            }

            ViewState = ViewStates.InTestCalculation;
            StringBuilder result = new StringBuilder();

            Task <bool> taskThread = Task <bool> .Factory.StartNew(() => SelectedPath.CalculateFileList());

            await taskThread;

            if (taskThread.Result == false)
            {
                MsgBx.Show("", "Selected path is not valid", MsgBxPicture.Info);
                return;
            }

            foreach (string file in SelectedPath.FilesSelected)
            {
                result.Append(file + Util.crLf);
            }

            TestResult = result.ToString().RemoveFinal(Util.crLf);

            ViewState = ViewStates.InTestResultShowing;
        }
        private void btnSalva_Click(object sender, RoutedEventArgs e)
        {
            //Apps.AppConfigFile tmp = App.Config;
            if (Serialize.DeserializeFromText(txtAppConfig.Text, ref App.config) == false)
            {
                MsgBx.Show("", "Non sono riuscito a deserializzare la configurazione nell'oggetto App.config, consultare il log", MsgBxPicture.Critical);
            }

            if (App.Config.SaveOnFile(App.config.IsEncrypted) == true)
            {
                //if (Apps.AppConfigFile.LoadFromFile(ref App.config, out _) == true)
                App.config = (Apps.AppConfigFile)App.config.LoadFromFile(out bool inErr);
                if (inErr == false)
                {
                    Log.main.Add(new Mess(LogType.info, "Configurazione salvata correttamente"));
                    this.Close();
                }
                else
                {
                    MsgBx.Show("", "La configurazione è stata salvata su file ma il successivo caricamento è fallito, consultare il log", MsgBxPicture.Critical);
                }
            }
            else
            {
                MsgBx.Show("", "Non sono riuscito a salvare la configurazione nel file, consultare il log", MsgBxPicture.Critical);
            }
        }
Exemple #4
0
        //private void PathsWithFiltersChanged(object sender, BindListEventArgs e)
        //{
        //    OnPropertyChanged(nameof(PathsWithFilters));
        //    ((PathWithFilters)e.oggetto).PropertyChanged += PathWithFiltersPropertyChanged;
        //}

        //private void PathWithFiltersPropertyChanged(object sender, PropertyChangedEventArgs e)
        //{
        //    OnPropertyChanged(nameof(PathsWithFilters));
        //}


        public void SetSelectedPath(PathWithFilters selectedPath)
        {
            string msgBxResult = MsgBx.Show("", "Do you want to select file or folder?", MsgBxPicture.Info, new List <string> {
                "File", "Folder", "Cancel"
            });

            if (msgBxResult == "File")
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.Multiselect = false;
                bool?result = dlg.ShowDialog();

                if (result != null && result == true)
                {
                    selectedPath.Path = dlg.FileName;
                }
            }
            else if (msgBxResult == "Folder")
            {
                var dialog = new System.Windows.Forms.FolderBrowserDialog();
                System.Windows.Forms.DialogResult result = dialog.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    selectedPath.Path = dialog.SelectedPath;
                }
            }
        }
Exemple #5
0
 public void Delete()
 {
     if (MsgBx.Show("", $"Do you want to delete {Name} backup?", MsgBxPicture.Question, MsgBxButtonSet.YesNo) == MsgBxButton.Yes)
     {
         BackupsM.Instance.Remove(this);
     }
 }
        private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string path = Directory.GetCurrentDirectory();
            var    url  = new Uri(Path.Combine(path, "resources/about.htm"));
            //Process.Start(url.ToString());
            MsgBx msgbx = new MsgBx(url.ToString());

            msgbx.Show();
        }
Exemple #7
0
        private void thrCicloMessageManager()
        {
            Mess mess; string tmpStr = "";

            //Threading.Thread.Sleep(150) 'Non potendo mettere la creazione di questo thread dentro Inizializza(poichè shared), attendo un po' di tempo

            while (true)
            {
                Thread.Sleep(1);

#if DEBUG == false
                try {
#endif

                while (logQueue.Count > 0)
                {
                    if (logQueue.TryDequeue(out mess) == false)
                    {
                        break;
                    }
                    do
                    {
                        Logger(mess);  //Prima loggo poichè se dopo il log c'è la procedura di chiusura non ho tanto tempo per loggare
                        Viewer(ref mess);

                        mess.nCicloInGestore += 1;
                        if (mess.nCicloInGestore > 200)
                        {
                            if (mess.visualiz == false)
                            {
                                tmpStr = "visualizzare";
                            }
                            if (mess.loggato == false)
                            {
                                tmpStr = "loggare";
                            }
                            MsgBx.Show("", "Non sono riuscito a " + tmpStr + " il mess: " + mess.testoDaVisual + " " + mess.testoDaLoggare, MsgBxPicture.Alert);

                            goto ExitWhile;
                        }
                        else if (mess.nCicloInGestore > 1)
                        {
                            Thread.Sleep(1);
                        }
                    } while (mess.loggato == false || mess.visualiz == false);
                }
                ExitWhile :;
#if DEBUG == false
            }
            catch (Exception ex) {
                //NotificaErrThrCiclo(ex, True) qui non posso poichè richiamerebbe se stesso
            }
#endif
            }
        }
Exemple #8
0
        public override BackupCompressionResult StartStopCompression(Guid guid = default)
        {
            switch (this.State)
            {
            case BackupStates.Idle:
                return(StartCompression());

            case BackupStates.Compressing:
                if (this.ThrCompression != null && this.ThrCompression.IsAlive == true)
                {
                    if (MsgBx.Show("", "Kill compression thread could cause app crash, do you want continue?", MsgBxPicture.Alert, MsgBxButtonSet.YesNo) == MsgBxButton.No)
                    {
                        return(null);
                    }
                    this.State = BackupStates.WaitToStop;
                    //this.IsInWaitToStop = true;
                    ThrCompression.Abort();
                    DateTime startTime = DateTime.Now;

                    while (ThrCompression.IsAlive)
                    {
                        System.Threading.Thread.Sleep(30);
                        if ((DateTime.Now - startTime).TotalMilliseconds > SettingsM.Instance.TimeoutStopCompressingSignalMs)
                        {
                            break;
                        }
                    }

                    if (ThrCompression.IsAlive == false)
                    {
                        this.State = BackupStates.Idle;
                        this.Progress.Percentage = 0;
                        //this.IsInWaitToStop = false;
                        //this.InCompressing = false;
                    }
                }
                return(null);

            case BackupStates.SavingInFTP:
                return(null);

            case BackupStates.WaitToStop:
                MsgBx.Show("", "Backup is already in wait to stop", MsgBxPicture.Info);
                return(null);

            default:
                Log.main.Add(new Mess(LogType.Warn, Log.main.warnUserText, $"Unexpected value for State:<{State}>"));
                return(null);
            }
        }
        private void BgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            pBar.Value = 100;

            MsgBx msgbx = new MsgBx(SuccessLog);

            msgbx.Show();

            if (HasErrors)
            {
                MsgBx msgbx2 = new MsgBx(ErrorLog);
                msgbx2.Show();
            }

            txtTarget.Text     = string.Empty;
            btnDecrypt.Enabled = false;
            btnEncrypt.Enabled = false;
            pBar.SendToBack();
        }