Пример #1
0
        /// <summary>
        /// Callback Method that should be callled when Synchronization (Communication) error occurs.
        /// </summary>
        /// <param name="type">Type of error that occurs.</param>
        internal void ErrorCallBack(Synchronization.ErrorType type)
        {
            Console.WriteLine("Calling");
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { ErrorCallBack(type); });
                return;
            }
            else
            {
                switch (type)
                {
                    case Synchronization.ErrorType.AllreadyBindTCPPort:
                        synch.StopSynchronizing();
                        Close();
                        break;
                    case Synchronization.ErrorType.ConnectionProblem:
                        MessageBox.Show("Nebylo možno navázat spojení, ujistěte se zda je druhá instance stále zapnuta a viditelná.");
                        synch.StopSynchronizing();
                        Close();
                        break;
                    case Synchronization.ErrorType.ConnectionLost:
                        MessageBox.Show("Došlo ke ztrátě spojení.");
                        synch.StopSynchronizing();
                        Close();
                        break;

                }
            }
        }
Пример #2
0
 /// <summary>
 /// Standart constructor for easy data set and connect to instance and send Changes.
 /// </summary>
 /// <param name="db">Database reference, where change should be get.</param>
 /// <param name="synch">Synchronization instance where quest and dictionaries are located.</param>
 /// <param name="ip">Where to connect and send changes.</param>
 public ChangeSender(Database db, Synchronization synch, IPAddress ip)
 {
     this.db = db;
     this.synch = synch;
     closed = false;
     senderThread = new Thread(connectForSynchronizeParallel);
     senderThread.IsBackground = true;
     senderThread.Name = " - Sender Client Thread";
     senderThread.Start(ip);
 }
Пример #3
0
        /// <summary>
        /// Standart Constructor for easy data set.
        /// </summary>
        /// <param name="device">Synchronization Device with which it is going to synchronize.</param>
        /// <param name="synch">Backend Synchronize instance that support behavior.</param>
        internal SynchForm(SynchronizationDevice device, Synchronization synch)
        {
            this.synch           = synch;
            synch.CallbackError += ErrorCallBack;

            InitializeComponent();

            this.Text = "Synchronizace: " + device.Name + " - " + device.IP.ToString();

            string lastsynch = device.LastSynchDate == DateTime.MinValue ? "Nikdy" : device.LastSynchDate.ToString(Constants.UserFriendlyDateTimeFormat);

            labelIP.Text        = device.IP.ToString();
            labelLastSynch.Text = lastsynch;
            labelName.Text      = device.Name;
            labelID.Text        = device.DeviceID;

            DialogResult  = DialogResult.Cancel;
            synchronizing = false;
        }
Пример #4
0
        /// <summary>
        /// Standart Constructor for easy data set.
        /// </summary>
        /// <param name="device">Synchronization Device with which it is going to synchronize.</param>
        /// <param name="synch">Backend Synchronize instance that support behavior.</param>
        internal SynchForm(SynchronizationDevice device, Synchronization synch)
        {
            this.synch = synch;
            synch.CallbackError += ErrorCallBack;
            
            InitializeComponent();

            this.Text = "Synchronizace: " + device.Name + " - " + device.IP.ToString();

            string lastsynch = device.LastSynchDate == DateTime.MinValue ? "Nikdy" : device.LastSynchDate.ToString(Constants.UserFriendlyDateTimeFormat);

            labelIP.Text = device.IP.ToString();
            labelLastSynch.Text = lastsynch;
            labelName.Text = device.Name;
            labelID.Text = device.DeviceID;

            DialogResult = DialogResult.Cancel;
            synchronizing = false;
        }
Пример #5
0
        /// <summary>
        /// Standart Constructor
        /// </summary>
        public MainForm()
        {
            visibilityCheckBoxBypass = false;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            db = new Database("Database");
            synch = new Synchronization(db);

            notificationAdder = new NotificationAdder(db, notificationEvents);
            previewWorker = new PreviewWorker(db, this, listboxPreviewData, previewBoldedDates);
            searchWorker = new SearchWorker(db, this, listboxSearchData, searchBoldedDates);

            synch.CallbackError += ErrorCallBack;

            bypassInvokeEvents = false;

            // Preview start values
            dateTimePickerPreviewFrom.CustomFormat = Constants.UserFriendlyDateTimeFormat;
            dateTimePickerPreviewTo.CustomFormat = Constants.UserFriendlyDateTimeFormat;

            dateTimePickerPreviewFrom.Value = DateTime.Now;
            dateTimePickerPreviewTo.Value = DateTime.Now.AddDays(7);

            // Add start values
            dateTimePickerAddStartDate.CustomFormat = Constants.UserFriendlyDateTimeFormat;
            dateTimePickerAddEndDate.CustomFormat = Constants.UserFriendlyDateTimeFormat;
            dateTimePickerAddNotificationDate.CustomFormat = Constants.UserFriendlyDateTimeFormat;

            dateTimePickerAddStartDate.Value = DateTime.Now;
            dateTimePickerAddEndDate.Value = DateTime.Now.AddDays(7);

            // Search start values
            dateTimePickerSearchFrom.CustomFormat = Constants.UserFriendlyDateTimeFormat;
            dateTimePickerSearchTo.CustomFormat = Constants.UserFriendlyDateTimeFormat;
            dateTimePickerSearchNotificationDate.CustomFormat = Constants.UserFriendlyDateTimeFormat;

            // Synch start values
            labelSynchInstanceID.Text = synch.InstanceID;
            ApplicationInfo appInfo = db.GetApplicationInfo();
            textBoxSynchAppName.Text = appInfo.Name;
            textBoxSynchGroupID.Text = appInfo.GroupID;
            checkBoxPreviewGlobalNotification.Checked = appInfo.NotifyEvents;

            if (!visibilityCheckBoxBypass)
                checkBoxSynchChangeVisibility.Checked = appInfo.Visible;
        }
Пример #6
0
 /// <summary>
 /// Callback for Synchronization Errors. It react on error, that is related to it.
 /// </summary>
 /// <param name="type">Type of error that occurs.</param>
 internal void ErrorCallBack(Synchronization.ErrorType type)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { ErrorCallBack(type); });
         return;
     }
     else
     {
         switch (type)
         {
             case Synchronization.ErrorType.AllreadyBindUDPPort:
                 visibilityCheckBoxBypass = true;
                 checkBoxSynchChangeVisibility.Checked = false;
                 MessageBox.Show("Aktualně již na tomto počítači běží naslouchání UPD s portem: " + Constants.UDPPort);
                 break;
             case Synchronization.ErrorType.AllreadyBindTCPPort:
                 MessageBox.Show("Aktualně již na tomto počítači běží TCP server s portem: " + Constants.TCPPort);
                 break;
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Standart constructor.
 /// </summary>
 /// <param name="synch">Instance of Synchronization.</param>
 public Responder(Synchronization synch)
 {
     this.synch = synch;
 }
Пример #8
0
 /// <summary>
 /// Constructor for LocalChangeFinder
 /// </summary>
 /// <param name="db">Database reference.</param>
 /// <param name="synch">Syncrhonization reference.</param>
 public LocalChangeFinder(Database db, Synchronization synch)
 {
     this.db    = db;
     this.synch = synch;
 }
Пример #9
0
        /// <summary>
        /// Standart Constructor for easy data set.
        /// </summary>
        /// <param name="device">Device with which one this should be synchronized.</param>
        /// <param name="synch">Reference to synchronization.</param>
        public ChangeReceiver(SynchronizationDevice device, Synchronization synch, Dictionary<string, Synchronization.ChangeSide> resultChanges)
        {
            this.synch = synch;
            bypassWaiting = false;
            closed = false;
            this.resultChanges = resultChanges;

            listenerThread = new Thread(receivingParallel);
            listenerThread.IsBackground = true;
            listenerThread.Name = " - Listener Thread";
            listenerThread.Start(device.LastSynchDate);
        }
Пример #10
0
 /// <summary>
 /// Standart constructor.
 /// </summary>
 /// <param name="synch">Instance of Synchronization.</param>
 public Responder(Synchronization synch)
 {
     this.synch = synch;
 }
Пример #11
0
 /// <summary>
 /// Constructor for LocalChangeFinder
 /// </summary>
 /// <param name="db">Database reference.</param>
 /// <param name="synch">Syncrhonization reference.</param>
 public LocalChangeFinder(Database db, Synchronization synch)
 {
     this.db = db;
     this.synch = synch;
 }