コード例 #1
0
        private void HandleStatusTimerTick(object sender, EventArgs e)
        {
            StatusTimer.Stop();
            var status = VideoDedupDlg.WcfProxy.GetVideoComparisonStatus(
                ComparisonToken.Value,
                ImageComparisonIndex);

            UpdateVideoComparisonResult(status.VideoCompareResult);
            UpdateImageComparisonResult(status);

            if (!status.ImageComparisons.Any())
            {
                StatusTimer.Start();
                return;
            }

            ImageComparisonIndex = status.ImageComparisons
                                   .Max(kvp => kvp.Item1);
            ImageComparisonIndex += 1;
            var maxImages = (int)NumMaxImageComparison.Value;

            if (ImageComparisonIndex >= maxImages)
            {
                VideoDedupDlg.WcfProxy.CancelCustomVideoComparison(
                    ComparisonToken.Value);
                return;
            }

            StatusTimer.Start();
        }
コード例 #2
0
        private void AlarmsActivate_Click(object sender, EventArgs e)
        {
            AlarmsLoad.Enabled = false;
            Active             = !Active;
            if (Active)
            {
                BattlelistTimer          = new Timer(AlarmTimeIntervals);
                BattlelistTimer.Execute += BattlelistTimer_Execute;
                StatusTimer.Interval     = StatusTimeInterval;
                StatusTimer.Enabled      = true;
                StatusTimer.Start();
                AlarmsActivate.Text = "Deactivate";
                BattlelistTimer.Start();
            }
            else
            {
                StatusTimer.Stop();
                StatusTimer.Enabled = false;
                AlarmsActivate.Text = "Activate";
                BattlelistTimer.Stop();
            }

            statusText         = "";
            RunStatus          = false;
            Tabs.Enabled       = !Active;
            AlarmsLoad.Enabled = !Active;
        }
コード例 #3
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                databaseDriver.Execute("UPDATE profiles SET status=0, sesskey = NULL");
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Tell the base to dispose all free objects
            Dispose();
        }
コード例 #4
0
 protected override void OnClosed(EventArgs e)
 {
     if (ComparisonToken.HasValue)
     {
         StatusTimer.Stop();
         VideoDedupDlg.WcfProxy.CancelCustomVideoComparison(
             ComparisonToken.Value);
     }
     base.OnClosed(e);
 }
コード例 #5
0
        private void StatusTimer_Tick(object sender, EventArgs e)

        {
            SplashScreenStatus.Text = "در حال " + LoadingModules[i];
            stTimer();
            i++;
            if (i >= 7)
            {
                StatusTimer.Stop();
                k = 1;
            }
        }
コード例 #6
0
        private void BtnStartComparison_Click(object sender, EventArgs e)
        {
            if (ComparisonToken.HasValue)
            {
                StatusTimer.Stop();
                VideoDedupDlg.WcfProxy.CancelCustomVideoComparison(
                    ComparisonToken.Value);
            }

            CleanUpResult();

            if ((int)NumMaxImageComparison.Value <= 0)
            {
                return;
            }

            var startData = VideoDedupDlg.WcfProxy.StartCustomVideoComparison(
                new CustomVideoComparisonData
            {
                AlwaysLoadAllImages       = true,
                LeftFilePath              = TxtLeftFilePath.Text,
                RightFilePath             = TxtRightFilePath.Text,
                MaxImageCompares          = (int)NumMaxImageComparison.Value,
                MaxImageDifferencePercent =
                    (int)NumMaxDifferentPercentage.Value,
                MaxDifferentImages = (int)NumMaxDifferentImages.Value,
            });

            if (startData.ComparisonToken == null)
            {
                _ = MessageBox.Show(
                    "Couldn't start comparison." + Environment.NewLine
                    + startData.ErrorMessage,
                    "Erro starting comparison",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            ComparisonToken = startData.ComparisonToken;

            StatusTimer.Start();
        }
コード例 #7
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            base.IgnoreNewConnections = true;
            Exiting = true;

            // Unregister events so we dont get a shit ton of calls
            GpcmClient.OnSuccessfulLogin -= GpcmClient_OnSuccessfulLogin;
            GpcmClient.OnDisconnect      -= GpcmClient_OnDisconnect;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                using (Database.GamespyDatabase db = new Database.GamespyDatabase())
                    db.Execute("UPDATE player SET online=0");
            }
            catch (Exception e)
            {
                Program.ErrorLog.Write("WARNING: [GpcmServer.Shutdown] Failed to update client database: " + e.Message);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Shutdown the listener socket
            base.ShutdownSocket();

            // Tell the base to dispose all free objects
            base.Dispose();
        }
コード例 #8
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;


            // Unregister events so we dont get a shit ton of calls
            GPCMClient.OnSuccessfulLogin -= ClientSuccessfulLogin;
            GPCMClient.OnDisconnect      -= ClientDisconnected;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                LoginQuery.ResetStatusAndSessionKey();
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            DB.Dispose();

            // Tell the base to dispose all free objects
            Dispose();
        }
コード例 #9
0
 protected override void Dispose(bool disposingManagedResources)
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     if (disposingManagedResources)
     {
     }
     PollTimer?.Stop();
     PollTimer?.Dispose();
     StatusTimer?.Stop();
     StatusTimer?.Dispose();
     // Disconnected all connected clients
     Console.WriteLine("Disconnecting all users...");
     //Parallel.ForEach(LoggedInSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //Parallel.ForEach(InLoginSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //LoginQuery.ResetAllStatusAndSessionKey();
     LoggedInSession.Clear();
     DB.Dispose();
     base.Dispose(disposingManagedResources);
 }
コード例 #10
0
        private void SetStatus(string Text, Color Color, bool Temp = true)
        {
            if (StatusTimer != null && StatusTimer.IsEnabled)
            {
                StatusTimer.Stop();

                StatusText.Text      = Text;
                StatusBar.Background = new SolidColorBrush(Color);

                if (Temp)
                {
                    StatusTimer = new DispatcherTimer()
                    {
                        Interval = TimeSpan.FromSeconds(5)
                    };
                    StatusTimer.Tick += delegate
                    {
                        StatusBar.BeginAnimation(MarginProperty, new ThicknessAnimation()
                        {
                            From           = StatusBar.Margin,
                            To             = new Thickness(0, 0, 0, -30),
                            Duration       = TimeSpan.FromSeconds(0.5),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        StatusTimer.Stop();
                    };
                    StatusTimer.Start();
                }
            }
            else
            {
                StatusText.Text      = Text;
                StatusBar.Background = new SolidColorBrush(Color);

                if (Temp)
                {
                    StatusTimer = new DispatcherTimer()
                    {
                        Interval = TimeSpan.FromSeconds(5)
                    };
                    StatusTimer.Tick += delegate
                    {
                        StatusBar.BeginAnimation(MarginProperty, new ThicknessAnimation()
                        {
                            From           = StatusBar.Margin,
                            To             = new Thickness(0, 0, 0, -30),
                            Duration       = TimeSpan.FromSeconds(0.5),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        StatusTimer.Stop();
                    };
                }

                if (StatusBar.Margin.Bottom > -30)
                {
                    return;
                }
                var Animation = new ThicknessAnimation()
                {
                    From           = StatusBar.Margin,
                    To             = new Thickness(0, 0, 0, 0),
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                };
                if (Temp)
                {
                    Animation.Completed += delegate { StatusTimer.Start(); }
                }
                ;
                StatusBar.BeginAnimation(MarginProperty, Animation);
            }
        }
コード例 #11
0
        //WARNING: Status timer can slow down processing significantly if processing is in a tight loop.
        public void StatusTimerTest(MainForm frm)
        {
            StatusTimer timer          = new StatusTimer();
            long        loopMax        = 100000000;
            int         statusInterval = 5;

            try
            {
                _msg.Length = 0;
                _msg.Append("StatusTimerTest started ...\r\n");
                WriteMessageToLog(_msg.ToString());

                timer.NumSecondsInterval = statusInterval;
                timer.Start();  //report status every two seconds

                _msg.Length = 0;
                _msg.Append("\r\nLooping ");
                _msg.Append(loopMax.ToString("#,##0"));
                _msg.Append(" times... \r\n");
                WriteMessageToLog(_msg.ToString());

                for (long num = 1; num <= loopMax; num++)
                {
                    if (timer.StatusReportDue())
                    {
                        _msg.Length = 0;
                        _msg.Append("Loop count = ");
                        _msg.Append(num.ToString("#,##0"));
                        _msg.Append(" Elapsed time to this point: ");
                        _msg.Append(timer.GetFormattedElapsedTime());
                        WriteMessageToLog(_msg.ToString());
                    }
                }
                _msg.Length = 0;
                _msg.Append("Loop count = ");
                _msg.Append(loopMax.ToString("#,##0"));
                _msg.Append(" Elapsed time to this point: ");
                _msg.Append(timer.GetFormattedElapsedTime());
                WriteMessageToLog(_msg.ToString());


                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append(Environment.NewLine);
                _msg.Append("Total Elapsed Time:   ");
                _msg.Append(timer.GetFormattedElapsedTime());
                _msg.Append(Environment.NewLine);
                _msg.Append("Elapsed milliseconds: ");
                _msg.Append(timer.GetElapsedTime().TotalMilliseconds.ToString("#,##0"));
                _msg.Append(Environment.NewLine);
                WriteMessageToLog(_msg.ToString());

                timer.Stop();
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteMessageToLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... StatusTimerTest finished.");
                WriteMessageToLog(_msg.ToString());
            }
        }
コード例 #12
0
 /// <summary>
 /// Handles the Tick event of the statusTimer control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 private void statusTimer_Tick(object sender, EventArgs e)
 {
     StatusTimer.Stop();
     this.InfoStatusLabel.Visible = false;
 }
コード例 #13
0
        public string DecryptFile(pfEncryptorRequest decryptorRequest, ref bool decryptionSuccessful)
        {
            PFFileEncryptor decryptor       = null;
            string          decryptedResult = string.Empty;
            StatusTimer     st = new StatusTimer();

            try
            {
                if (String.IsNullOrEmpty(decryptorRequest.SourceObject))
                {
                    _msg.Length = 0;
                    _msg.Append("You must specify path to a file to decrypt.");
                    throw new System.Exception(_msg.ToString());
                }

                if (String.IsNullOrEmpty(decryptorRequest.DestinationObject))
                {
                    decryptorRequest.DestinationObject = decryptorRequest.SourceObject + ".decrypted";
                }

                if (string.IsNullOrEmpty(decryptorRequest.EncryptionKey) ||
                    string.IsNullOrEmpty(decryptorRequest.EncryptionIV))
                {
                    _msg.Length = 0;
                    _msg.Append("You must specify both Key and IV values.");
                    throw new System.Exception(_msg.ToString());
                }

                if (decryptorRequest.SourceObject == decryptorRequest.DestinationObject)
                {
                    _msg.Length = 0;
                    _msg.Append("Source and destination file paths are the same. They must be different for decryption routine to work.");
                    throw new System.Exception(_msg.ToString());
                }


                decryptor = new PFFileEncryptor(decryptorRequest.EncryptionAlgorithm);
                decryptor.currentStatusReport        += UpdateStatus;
                decryptor.StatusReportIntervalSeconds = _statusReportIntervalSeconds;

                decryptor.Key = decryptorRequest.EncryptionKey;
                decryptor.IV  = decryptorRequest.EncryptionIV;

                st.ShowElapsedTimeMilliseconds = false;
                st.Start();

                if (decryptorRequest.UseBinaryEncryption == false)
                {
                    if (decryptorRequest.DestinationObjectType == pfEncryptorObjectType.File)
                    {
                        decryptedResult = decryptor.Decrypt(decryptorRequest.SourceObject, decryptorRequest.DestinationObject, st);
                    }
                    else
                    {
                        decryptedResult = decryptor.Decrypt(decryptorRequest.SourceObject);
                    }
                }
                else
                {
                    decryptedResult = decryptor.DecryptBinary(decryptorRequest.SourceObject, decryptorRequest.DestinationObject, st);
                }

                decryptorRequest.DestinationObject = decryptedResult;

                decryptionSuccessful = true;
            }
            catch (System.Exception ex)
            {
                decryptionSuccessful = false;
                _msg.Length          = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                if (decryptor != null)
                {
                    decryptor.currentStatusReport -= UpdateStatus;
                    decryptor = null;
                }
                if (st != null)
                {
                    if (st.StatusTimerIsRunning)
                    {
                        st.Stop();
                    }
                    st = null;
                }
            }


            return(decryptedResult);
        }
コード例 #14
0
 private void StatusTimer_Tick(object sender, EventArgs e)
 {
     fnc_ClearStatus();
     StatusTimer.Stop();
 }