Пример #1
0
        private void Setting_CheckDiskSpace()
        {
            bool watchFlag = true;

            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                if (!watchFlag)
                {
                    return;
                }

                try
                {
                    bool flag = false;

                    if (_amoebaInterfaceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("10GB"))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_amoebaInterfaceManager.State == ManagerState.Stop)
                        {
                            _amoebaInterfaceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_amoebaInterfaceManager.State == ManagerState.Start)
                        {
                            _amoebaInterfaceManager.Stop();
                            Log.Information("Stop");

                            watchFlag = false;

                            App.Current.Dispatcher.InvokeAsync(() =>
                            {
                                if (_dialogService.ShowDialog(LanguagesManager.Instance.MainWindow_SpaceNotFound_Message,
                                                              MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel) == MessageBoxResult.OK)
                                {
                                    watchFlag = true;
                                }
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 3, 0));
        }
Пример #2
0
        private void Setting_CheckDiskSpace()
        {
            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                try
                {
                    bool flag = false;


                    if (_serviceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("32GB") &&
                        _serviceManager.Report.Core.Cache.FreeSpace < (_serviceManager.Size / 3))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_serviceManager.State == ManagerState.Stop)
                        {
                            _serviceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_serviceManager.State == ManagerState.Start)
                        {
                            _serviceManager.Stop();
                            Log.Information("Stop");
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 30));
        }