示例#1
0
 internal static void DeployArchive(string path)
 {
     IsRunning = true;
     IsRunningChanged?.Invoke(true);
     try
     {
         if (Directory.Exists(_settings.WoWDirectory))
         {
             if (File.Exists(path))
             {
                 log.Info("Deploying archive: " + path);
                 Unzip(path);
                 log.Info("Archive is deployed: " + path);
             }
             else
             {
                 log.Info("Archive " + path + " isn't found");
                 Notify.TrayPopup("Backup error", "Archive " + path + " isn't found", NotifyUserType.Error, true);
             }
         }
         else
         {
             log.Info("WoW dir (" + _settings.WoWDirectory + ") isn't found");
             Notify.TrayPopup("Backup error", "WoW dir (" + _settings.WoWDirectory + ") isn't found", NotifyUserType.Error, true);
         }
     }
     catch (Exception ex)
     {
         log.Error("Deploying error: " + ex.Message);
         Notify.TrayPopup("Deploying error", ex.Message, NotifyUserType.Error, true);
     }
     IsRunningChanged?.Invoke(false);
     IsRunning = false;
 }
示例#2
0
        internal void UpdateState_DbgThread(DbgProcessState newState)
        {
            bool raiseStateChanged, raiseIsRunningChanged, raiseIsDebuggingChanged;

            lock (lockObj) {
                raiseStateChanged = state != newState;
                state             = newState;
                var newIsRunning = CalculateIsRunning_NoLock();
                raiseIsRunningChanged   = cachedIsRunning != newIsRunning;
                cachedIsRunning         = newIsRunning;
                raiseIsDebuggingChanged = state == DbgProcessState.Terminated;
            }
            if (raiseStateChanged)
            {
                OnPropertyChanged(nameof(State));
            }
            if (raiseIsRunningChanged)
            {
                IsRunningChanged?.Invoke(this, EventArgs.Empty);
            }
            if (raiseIsDebuggingChanged)
            {
                IsDebuggingChanged?.Invoke(this, EventArgs.Empty);
            }
        }
示例#3
0
        internal void Add_DbgThread(DbgEngine engine, DbgRuntimeImpl runtime, DbgProcessState newState)
        {
            bool raiseStateChanged, raiseDebuggingChanged, raiseIsRunningChanged;

            DbgThread[] addedThreads;
            lock (lockObj) {
                engineInfos.Add(new EngineInfo(engine, runtime));
                var newDebugging = CalculateDebugging_NoLock();
                raiseStateChanged     = state != newState;
                raiseDebuggingChanged = !StringArrayEquals(debugging, newDebugging);
                state = newState;
                if (raiseDebuggingChanged)
                {
                    debugging = newDebugging;
                }
                var newIsRunning = CalculateIsRunning_NoLock();
                raiseIsRunningChanged   = cachedIsRunning != newIsRunning;
                cachedIsRunning         = newIsRunning;
                addedThreads            = runtime.Threads;
                runtime.ThreadsChanged += DbgRuntime_ThreadsChanged;
            }
            RuntimesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgRuntime>(runtime, added: true));
            if (addedThreads.Length != 0)
            {
                ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(addedThreads, added: true));
            }
            if (raiseStateChanged)
            {
                OnPropertyChanged(nameof(State));
            }
            if (raiseIsRunningChanged)
            {
                IsRunningChanged?.Invoke(this, EventArgs.Empty);
            }
            if (raiseDebuggingChanged)
            {
                OnPropertyChanged(nameof(Debugging));
            }
        }
示例#4
0
        public void Stop()
        {
            IsLoading = true;

            if (_ip2LocationService.IsStarted)
            {
                _ip2LocationService.Stop();
            }

            Logger.Info("Stopping all listeners...");
            foreach (var listener in Listeners)
            {
                listener.Connect -= ListenerOnConnect;
                listener.Stop();
                Logger.Debug("Listener {0}:{1} stopped", listener.IpAddress, listener.Port);
            }
            Logger.Info("All Listeners stopped");
            Logger.Debug("Disconnect all administrations");
            lock (_administrationListLock)
            {
                foreach (var administration in Administrations.ToList())
                {
                    administration.Value.Dispose();
                }
            }

            Logger.Debug("Disconnect all clients");
            foreach (var client in Clients)
            {
                client.Value.Dispose();
            }

            Logger.Info("All clients and administrations disconnected");
            _clientOnlineChecker?.Stop();
            IsRunning = false;
            IsLoading = false;
            IsRunningChanged?.Invoke(this, EventArgs.Empty);
        }
示例#5
0
        public async void Start()
        {
            IsLoading = true;
            if (_certificate == null)
            {
                Logger.Fatal("Start failed: No SSL certificate loaded");
                return;
            }
            await Task.Run(() => _ip2LocationService.Start(Ip2LocationEmailAddress, Ip2LocationPassword));

            Logger.Info("Starting all listeners...");
            foreach (var listener in Listeners)
            {
                listener.Connect += ListenerOnConnect;
                listener.Start();
                Logger.Debug("Listener {0}:{1} started successfully", listener.IpAddress, listener.Port);
            }

            if (bool.Parse(GlobalConfig.Current.IniFile.GetKeyValue("SERVER", "CheckForDeadConnections")))
            {
                Logger.Debug("Start online checker");
                if (_clientOnlineChecker == null)
                {
                    _clientOnlineChecker =
                        new ClientOnlineChecker(int.Parse(GlobalConfig.Current.IniFile.GetKeyValue("SERVER", "CheckForDeadConnectionsInterval")),
                                                Clients);
                }
                else
                {
                    _clientOnlineChecker.Start();
                }
            }

            IsRunning = true;
            IsLoading = false;
            IsRunningChanged?.Invoke(this, EventArgs.Empty);
        }
示例#6
0
 protected void OnIsRunningChanged(bool busy)
 {
     IsRunningChanged?.Invoke(busy);
 }
示例#7
0
        private static void MakeNewArchive(bool scheduledBackup)
        {
            Guid _lock    = Program.ShutdownLock.GetLock();
            Guid _wowLock = MainWindow.Instance.WoWLaunchLock.GetLock();

            try
            {
                IsRunning = true;
                IsRunningChanged?.Invoke(true);
                if (Directory.Exists(_settings.WoWDirectory + "\\WTF"))
                {
                    if (Utils.CalcDirectorySize(_settings.WoWDirectory + "\\WTF") <= 1024 * 1024 * 1024)
                    {
                        try
                        {
                            log.Info("WTF directory OK");
                            CreateBackupDir();
                            log.Info("Backup directory OK");
                            DeleteOldFiles();
                            log.Info("Old archives are deleted");
                            Zip();
                            log.Info("Backup is successfully created");
                        }
                        catch (DirectoryNotFoundException directoryNotFoundEx)
                        {
                            log.Info($"Directory not found: {directoryNotFoundEx.Message}, let's wait for ten minutes...");
                            if (!scheduledBackup)
                            {
                                Notify.TrayPopup("Backup error: directory not found", directoryNotFoundEx.Message, NotifyUserType.Error, true);
                            }
                            else
                            {
                                _settings.WoWAddonsBackupLastDate = DateTime.UtcNow - TimeSpan.FromHours(_settings.WoWAddonsBackupMinimumTimeBetweenBackup - 1); // wait for one hour
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Error($"Backup error ({ex.GetType()}): {ex.Message}");
                            Notify.TrayPopup("Backup error", ex.Message, NotifyUserType.Error, true);
                        }
                        finally
                        {
                            try
                            {
                                DeleteBrokenFiles();
                                log.Info("Broken files are removed");
                            }
                            catch (DirectoryNotFoundException directoryNotFoundEx)
                            {
                                log.Info($"Can't delete broken files because {directoryNotFoundEx.Message}");
                            }
                            catch (Exception ex)
                            {
                                log.Error("Can't delete broken files: " + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        log.Info("WTF directory is too large");
                        Notify.TrayPopup("Backup error", "WTF directory is too large (> 1GB)", NotifyUserType.Error, true);
                    }
                }
                else
                {
                    log.Info("WTF directory isn't found");
                    Notify.TrayPopup("Backup error", "\"WTF\" folder isn't found", NotifyUserType.Error, true);
                }
                IsRunningChanged?.Invoke(false);
                IsRunning = false;
            }
            finally
            {
                Program.ShutdownLock.ReleaseLock(_lock);
                MainWindow.Instance.WoWLaunchLock.ReleaseLock(_wowLock);
            }
        }
 public virtual void OnIsRunngingChanged(Boolean isRunning)
 {
     IsRunningChanged?.Invoke(this, new BooleanEventArgs(isRunning));
 }
示例#9
0
 protected virtual void OnIsRunningChanged(EventArgs e) => IsRunningChanged?.Invoke(this, e);
 public void Stop()
 {
     _locationManager.StopUpdatingLocation();
     IsRunning = false;
     IsRunningChanged?.Invoke(this, IsRunning);
 }
 public void Start()
 {
     _locationManager.StartUpdatingLocation();
     IsRunning = true;
     IsRunningChanged?.Invoke(this, IsRunning);
 }
示例#12
0
 private void OnIsRunningChanged()
 {
     IsRunningChanged?.Invoke(this, EventArgs.Empty);
 }
示例#13
0
 public void Stop()
 {
     _locationManager.RemoveUpdates(this);
     IsRunning = false;
     IsRunningChanged?.Invoke(this, false);
 }
示例#14
0
 public void Start()
 {
     IsRunning = true;
     IsRunningChanged?.Invoke(this, true);
     _locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, this);
 }