Beispiel #1
0
        /// <summary>
        /// Assigns Flight.Key
        /// </summary>
        private void AssignFlightKey()
        {
            var userId = GetUserPrimaryIdInfo().Id;

            // try to get deals server flight key from input list
            var flightKey = InputFlights != null?InputFlights.FirstOrDefault(_ => _.StartsWith(Flight.KeyPrefix, true, CultureInfo.InvariantCulture)) : null;

            if (flightKey != null)
            {
                // get flight key from flight dictionary by full key match
                Flight flight;
                if (!Flight.List.TryGetValue(flightKey, out flight))
                {
                    // get flight key from flight dictionary by partial key match (take most recent version)
                    flight = Flight.List.Where(_ => _.Key.StartsWith(flightKey, true, CultureInfo.InvariantCulture)).OrderByDescending(_ => _.Value.Version).FirstOrDefault().Value;
                }

                if (flight != null)
                {
                    flightKey = flight.Key;
                    //// Check whether client-flight combination is valid;
                    var pcfps = QueryRanking.GetPlacementCfps(Client, flightKey, false);
                    if (pcfps != null)
                    {
                        // if client-flight combination is valid - remove from input list to avoid duplicate logging
                        InputFlights = InputFlights.Where(_ => _.ToLower() != flightKey.ToLower()).ToList();
                    }
                    else
                    {
                        // if client-flight combination is not valid set key to null
                        flightKey = null;
                    }
                }
                else
                {
                    // if not present in index set key to null
                    flightKey = null;
                }
            }

            FlightKey = flightKey ?? ClientFlightAllocation.GetFlightKey(Client.Key, userId);
        }