void ExportUsers_Click(Object sender, EventArgs e)
        {
            try
            {
                IFormatter formatter = new BinaryFormatter();

                SaveFileDialog saveFileDialog = new SaveFileDialog
                {
                    Filter = "usr files (*.usr)|*.usr",
                    FilterIndex = 2,
                    RestoreDirectory = true
                };

                bool? result = saveFileDialog.ShowDialog();

                Stream stream;

                if (result == true)
                {
                    if ((stream = saveFileDialog.OpenFile()) != null)
                    {
                        formatter.Serialize(stream, Singleton.Instance.users.Count);

                        foreach (User user in Singleton.Instance.users)
                        {
                            formatter.Serialize(stream, user);
                        }

                        Singleton.Show_MessageBox("zapisano pomyślnie!");
                        stream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Singleton.Show_MessageBox(ex.Message + "\nspróbuj ponownie za chwilę");
            }
        }
Beispiel #2
0
        public void Set_Start(int interval)
        {
            try
            {
                using (StreamReader sr = new StreamReader("settings.txt"))
                {
                    try
                    {
                        filePath = sr.ReadLine();
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show("BŁĄD WCZYTYWANIA USTAWIEŃ!", "FATAL ERROR");
                    }

                    try
                    {
                        Load_Settings_With_Password();
                    }
                    catch (Exception ex)
                    { Singleton.Show_MessageBox(ex.Message + "nie można wczytać ustawień"); }
                }
            }
            catch (Exception eee)
            { }

            timer.Interval = new TimeSpan(0, 0, 0, 0, interval);
            timer.Tick    += new EventHandler(OnTimedEvent);
            timer.Start();

            Checker_Thread = new Thread(Status_Checker);
            Checker_Thread.Start();

            Alarm_Thread = new Thread(Alarm);
            Alarm_Thread.Start();
        }
Beispiel #3
0
 private void Send_Email(string msg, string adress)
 {
     Singleton.Show_MessageBox("Wysłano email na adres: " + adress + " o treści: " + msg);
     //email_manager.Send(adress, "ALERT", msg);
 }
        void ImportConfig_Click(Object sender, EventArgs e)
        {
            if (Singleton.Instance.Admin)
            {
                try
                {
                    IFormatter formatter = new BinaryFormatter();

                    OpenFileDialog openFileDialog = new OpenFileDialog
                    {
                        InitialDirectory = "c:\\Users\\Szymon\\Desktop",
                        Filter = "config files (*.cnf)|*.cnf",
                        FilterIndex = 2,
                        RestoreDirectory = true
                    };
                    bool? result = openFileDialog.ShowDialog();

                    Stream stream;

                    if (result == true)
                    {
                        if ((stream = openFileDialog.OpenFile()) != null)
                        {

                            int users_count = (int)formatter.Deserialize(stream);
                            int messages_count = (int)formatter.Deserialize(stream);

                            Singleton.Instance.Clear_Users();
                            for (int i = 0; i < users_count; i++)
                            {
                                User user = (User)formatter.Deserialize(stream);
                                Singleton.Instance.Add_User(user);
                            }

                            Singleton.Instance.Clear_Messages_Dict();
                            for (int i = 0; i < messages_count; i++)
                            {
                                string id = (string)formatter.Deserialize(stream);
                                Message_Add msg = (Message_Add)formatter.Deserialize(stream);
                                Singleton.Instance.messages_dict[id] = msg;
                            }


                            Singleton.Instance.configuration = new Dictionary<string, Dictionary<string, Configuration>>();
                            foreach (User user in Singleton.Instance.users)
                            {
                                Singleton.Instance.configuration[user.Get_ID()] = new Dictionary<string, Configuration>();
                            }


                            foreach (User user in Singleton.Instance.users)
                            {
                                int n = (int)formatter.Deserialize(stream);
                                for (int i = 0; i < n; i++)
                                {
                                    string msg_id = (string)formatter.Deserialize(stream);
                                    Configuration load = (Configuration)formatter.Deserialize(stream);
                                    Singleton.Instance.Add_To_Config(user.Get_ID(), msg_id, load);
                                }
                            }

                            Singleton.Instance.Add_Lines_To_Windows();

                            Singleton.Show_MessageBox("wczytano pomyślnie");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Singleton.Show_MessageBox(ex.Message);
                }
            }
            else
                Singleton.Show_MessageBox("Niewystarczające uprawnienia!");
        }
Beispiel #5
0
 private void SetPort_Click(Object sender, EventArgs e)
 {
     Singleton.Instance.port = COM_Box.Text;
     Singleton.Show_MessageBox("zmieniono port na: " + COM_Box.Text);
 }