Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Elapsed event of the PendingChangesTimer control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param>
        public void PendingChangesTimerElapsed(object sender, ElapsedEventArgs e)
        {
            if (PendingChanges.Count == 0)
            {
                return;
            }

            var changes = PendingChanges.ToList();

            PendingChanges.Clear();

            if (File.Exists(_pendingDataPath))
            {
                try { File.Delete(_pendingDataPath); }
                catch { }
            }

            var req = Remote.API.SendDatabaseChanges(changes, _user, _pass);

            if (!req.Success || !req.OK)
            {
                PendingChanges.AddRange(changes);
                PendingChangesTimer.Start();
                SavePendingChanges();
            }
        }