internal void RemovePlayer(IMessageBase messageBase)
        {
            Deregistration deregistration = (Deregistration)messageBase;
            int            playerID       = deregistration.UserId;

            Logger.Debug($"{playerID} wants to deregister");

            bool success = PlayerData.Instance.RemovePlayer(playerID);

            if (success)
            {
                Logger.Info("Removing player " + playerID + " with sessionid " + _sessionIds[playerID]);
                SendReliable(new DeregistrationSuccess
                {
                    UserId = playerID
                });
                lock (_sessionIds)
                    _sessionIds[playerID] = -1;
                PlayerIDManager.FreeID(playerID);
            }
            else
            {
                Logger.Warn("Could not remove player " + playerID);
            }

            StrategyManager.Instance.UpdatePlayerList();
        }
Example #2
0
        public static void ValidateAndSaveDerigistration(Deregistration deregistrationObject, DataClasses1DataContext dbContext, out List<ResultMessages> messages)
        {
            ResultMessages result = new ResultMessages();
            messages = new List<ResultMessages>();

            foreach (DeregistrationAbmeldung deregistration in deregistrationObject.Abmeldung)
            {
                result = new ResultMessages();

                if (getOpenedDeregistrationOrder(deregistration.Vehicle.VIN).Count == 0)
                {
                    if (ValidateGuid(deregistration.Header))
                    {
                        string valGuid = ValidateGuid(deregistration.Header, dbContext);
                        if (valGuid == string.Empty)
                        {
                            try
                            {
                                CreateDeregOrder(deregistration, dbContext);
                                result.Sucessed = "Sucessed imported VIN: " + deregistration.Vehicle.VIN;
                                messages.Add(result);
                            }
                            catch (Exception ex)
                            {
                                result.Error = ex.Message;
                                result.Deregistration = deregistration;
                                messages.Add(result);
                            }

                        }
                        else
                        {
                            result.Error = valGuid;
                            result.Deregistration = deregistration;
                            messages.Add(result);
                        }
                    }
                    else
                    {
                        result.Error = "Eins oder mehrere Felder im Header sind keine gültigen Guids";
                        result.Deregistration = deregistration;
                        messages.Add(result);
                    }
                }
                else
                {
                    result.Error = "Für dieses Fahrzeug gibt es noch offene Aufträge";
                    result.Deregistration = deregistration;
                    messages.Add(result);
                }
            }
        }
        public List<ResultMessages> VehicleDerigistration(Deregistration newDereg, string username, string password, string InternalId)
        {
            List<ResultMessages> results = new List<ResultMessages>();
            ResultMessages message = new ResultMessages();
            List<Guid> allowedCustomers = new List<Guid>();
            XMLHelper orderHelper = new XMLHelper();

            allowedCustomers = CheckLogin.CheckUser(username, password, InternalId);
            if (allowedCustomers.Count > 0)
            {
                using (DataClasses1DataContext dbContext = new DataClasses1DataContext(new Guid(ConfigurationManager.AppSettings["currentUser"])))
                {
                    try
                    {
                        dbContext.WriteLogItem("Zugriff von der IP Adresse: " + this.Context.Request.UserHostAddress + "Webservice VehicleDeregestration()", LogTypes.INFO);
                        string file = orderHelper.XmlSerializeAndSave(newDereg, OrderTypes.VehicleDeregistration);

                        if (File.Exists(file))
                        {
                            ValidateOrderType.ValidateAndSaveDerigistration(newDereg, dbContext, out results);
                        }
                        else
                        {
                            throw new Exception(file);
                        }
                    }

                    catch (Exception ex)
                    {
                       message.Error="Fehler beim verabeiten der Daten, bitte wiederholen Sie den Vorgang" + Environment.NewLine + "Fehlermeldung: " + ex.Message;
                       results.Add(message);
                    }
                }
            }

            return results;
        }