Beispiel #1
0
        public ustawienia()
        {
            InitializeComponent();
            _aUstawienia = new ustawieniaAplikacji();

            applicationConfig oApplication = new applicationConfig();

            oApplication.sPathToConfigFile = Application.StartupPath + @"\settings.xml";
            oApplication.ReadBinary();

            _aUstawienia = oApplication.aUstawienia;
        }
Beispiel #2
0
        private void rozpocznijBackup()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new rozpoczlijBackupDelegate(this.rozpocznijBackup));
                return;
            }
            try
            {
                this.Hide();

                string sSciezka = String.Empty;

                applicationConfig oApplication = new applicationConfig();
                oApplication.sPathToConfigFile = Application.StartupPath + @"\settings.xml";
                oApplication.ReadBinary();

                if (oApplication.aUstawienia.aUstawienia.ContainsKey("sciezka"))
                {
                    sSciezka = Convert.ToString(oApplication.aUstawienia.aUstawienia["sciezka"]);
                }
                else
                {
                    sSciezka = Application.StartupPath;
                }

                this.getListServers();

                _iAllCnt = aListSerwerow.Count;
                int iCnt;
                progressBar1.Maximum = _iAllCnt;

                for (iCnt = 0; iCnt < _iAllCnt; iCnt++)
                {
                    if (aListSerwerow[iCnt]["type"] == "mysql")
                    {
                        pq.Enqueue(new MySqlBackup(
                                       aListSerwerow[iCnt]["host"],
                                       aListSerwerow[iCnt]["baza"],
                                       aListSerwerow[iCnt]["haslo"],
                                       aListSerwerow[iCnt]["login"],
                                       sSciezka), Convert.ToInt32(aListSerwerow[iCnt]["priorytet"]));
                    }
                }

                progressBar1.Value = 0;
                iCnt = 1;
                while (pq.Count > 0)
                {
                    PriorityQueueItem <Backup, int> item = pq.Dequeue();

                    sStripStatus.Text = "Tworzenie kopi bazy: " + item.Value.sBazaDanych;

                    int iStep = (int)(iCnt / _iAllCnt);

                    string sTxt;
                    if (sStripStatus.Text.Length > 60)
                    {
                        sTxt = sStripStatus.Text.Substring(1, 60);
                    }
                    else
                    {
                        sTxt = sStripStatus.Text;
                    }

                    notifyIcon.Text = sTxt + "...";
                    notifyIcon.ShowBalloonTip(_iTimeShowBaloon, "Tworznie kopi bazy danych", sTxt, ToolTipIcon.Info);

                    item.Value.makeBackup();

                    if (!item.Value.sBaseState)
                    {
                        notifyIcon.Text = "Błąd tworzenia kopi bazy: " + item.Value.sBazaDanych + "...";
                        notifyIcon.ShowBalloonTip(_iTimeShowBaloon, "Tworznie kopi bazy danych", notifyIcon.Text, ToolTipIcon.Error);
                        System.Threading.Thread.Sleep(1000);
                    }
                }

                pq.Clear();
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Win32 Error!!!");
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "IO Error");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Critical Error");
            }
        }