Beispiel #1
0
        private async void SaveSelectedProducts()
        {
            IsExporting      = true;
            _ctsSaveProducts = new CancellationTokenSource();

            var products = SelectedProducts.ToList();

            try
            {
                var task = Export.SaveCollection(products, _ctsSaveProducts.Token);
                CriticalTasks.Add(task);
                await task.ConfigureAwait(false);
            }
            catch (TaskCanceledException)
            {
            }
            catch (System.Exception e)
            {
                _logger.Error(e);
                await MessageBox.ShowAsync("Произошла ошибка во время экспорта.", "Ошибка", MessageBoxButton.OK,
                                           MessageBoxImage.Error).ConfigureAwait(false);
            }
            CriticalTasks.Cleanup();

            IsExporting = false;
        }
Beispiel #2
0
        private async void StartAsync()
        {
            var task = SearchStartAsync();

            CriticalTasks.Add(task);
            await task.ConfigureAwait(false);

            CriticalTasks.Cleanup();
        }
Beispiel #3
0
        void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false)
        {
            if (leftServer || IsSuper)
            {
                return;
            }
            leftServer = true;
            CriticalTasks.Clear();
            ZoneIn = null;

            // Disconnected before sent handshake
            if (name == null)
            {
                if (Socket != null)
                {
                    Socket.Close();
                }
                Logger.Log(LogType.UserActivity, "{0} disconnected.", IP);
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (Socket.Disconnected)
                {
                    PlayerInfo.Online.Remove(this);
                    return;
                }

                if (weapon != null)
                {
                    weapon.Disable();
                }
                if (chatMsg != null)
                {
                    chatMsg = Colors.Escape(chatMsg);
                }
                discMsg = Colors.Escape(discMsg);

                string kickPacketMsg = ChatTokens.Apply(discMsg, this);
                Session.SendKick(kickPacketMsg, sync);
                Socket.Disconnected = true;
                ZoneIn = null;
                if (isKick)
                {
                    TimesBeenKicked++;
                }

                if (!loggedIn)
                {
                    PlayerInfo.Online.Remove(this);
                    Logger.Log(LogType.UserActivity, "{0} ({1}) disconnected. ({2})", truename, IP, discMsg);
                    return;
                }

                Entities.DespawnEntities(this, false);
                ShowDisconnectInChat(chatMsg, isKick);
                SaveStats();

                PlayerInfo.Online.Remove(this);
                OnPlayerDisconnectEvent.Call(this, discMsg);

                level.AutoUnload();
                Dispose();
            } catch (Exception e) {
                Logger.LogError("Error disconnecting player", e);
            } finally {
                Socket.Close();
            }
        }
Beispiel #4
0
        void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false)
        {
            if (leftServer)
            {
                return;
            }
            leftServer = true;
            CriticalTasks.Clear();
            ZoneIn = null;

            // Disconnected before sent handshake
            if (name == null)
            {
                if (Socket != null)
                {
                    Socket.Close();
                }
                Logger.Log(LogType.UserActivity, "{0} disconnected.", ip);
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (Socket.Disconnected)
                {
                    PlayerInfo.Online.Remove(this);
                    return;
                }
                // FlyBuffer.Clear();
                LastAction = DateTime.UtcNow;
                IsAfk      = false;
                isFlying   = false;
                if (weapon != null)
                {
                    weapon.Disable();
                }

                if (chatMsg != null)
                {
                    chatMsg = Colors.Escape(chatMsg);
                }
                discMsg = Colors.Escape(discMsg);

                string kickPacketMsg = ChatTokens.Apply(discMsg, this);
                Send(Packet.Kick(kickPacketMsg, hasCP437), sync);
                Socket.Disconnected = true;
                ZoneIn = null;
                if (isKick)
                {
                    TimesBeenKicked++;
                }

                if (!loggedIn)
                {
                    PlayerInfo.Online.Remove(this);
                    string user = name + " (" + ip + ")";
                    Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg);
                    return;
                }

                Entities.DespawnEntities(this, false);
                ShowDisconnectInChat(chatMsg, isKick);
                save();

                PlayerInfo.Online.Remove(this);
                OnPlayerDisconnectEvent.Call(this, discMsg);

                level.AutoUnload();
                Dispose();
            } catch (Exception e) {
                Logger.LogError("Error disconnecting player", e);
            } finally {
                Socket.Close();
            }
        }
Beispiel #5
0
        void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false)
        {
            if (leftServer)
            {
                return;
            }
            leftServer = true;
            CriticalTasks.Clear();

            //Umm...fixed?
            if (name == null || name.Length == 0)
            {
                if (Socket != null)
                {
                    CloseSocket();
                }
                connections.Remove(this);
                disconnected = true;
                Logger.Log(LogType.UserActivity, "{0} disconnected.", ip);
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (disconnected)
                {
                    CloseSocket();
                    connections.Remove(this);
                    PlayerInfo.Online.Remove(this);
                    return;
                }
                // FlyBuffer.Clear();
                LastAction = DateTime.UtcNow;
                IsAfk      = false;
                isFlying   = false;
                aiming     = false;

                if (chatMsg != null)
                {
                    chatMsg = Colors.Escape(chatMsg);
                }
                discMsg = Colors.Escape(discMsg);

                string kickPacketMsg = ChatTokens.Apply(discMsg, this);
                Send(Packet.Kick(kickPacketMsg, hasCP437), sync);
                disconnected = true;
                if (isKick)
                {
                    TimesBeenKicked++;
                }

                if (!loggedIn)
                {
                    connections.Remove(this);
                    RemoveFromPending();
                    PlayerInfo.Online.Remove(this);

                    string user = name + " (" + ip + ")";
                    Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg);
                    return;
                }

                if (Game.team != null)
                {
                    Game.team.RemoveMember(this);
                }
                TntWarsGame tntwarsgame = TntWarsGame.GameIn(this);
                if (tntwarsgame != null)
                {
                    tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this));
                    tntwarsgame.SendAllPlayersMessage("TNT Wars: " + ColoredName + " %Shas left TNT Wars!");
                }

                Entities.DespawnEntities(this, false);
                ShowDisconnectInChat(chatMsg, isKick);
                save();

                PlayerInfo.Online.Remove(this);
                Server.PlayerListUpdate();
                OnPlayerDisconnectEvent.Call(this, discMsg);

                if (ServerConfig.AutoLoadMaps && level.Config.AutoUnload && !level.IsMuseum && !level.HasPlayers())
                {
                    level.Unload(true);
                }
                Dispose();
            } catch (Exception e) {
                Logger.LogError(e);
            } finally {
                CloseSocket();
            }
        }