Example #1
0
        private IHttpClient GetHttpClient(Request.Request request)
        {
            var builder    = new HttpClientBuilder();
            var cacheKey   = GetCacheKey(request, builder);
            var httpClient = _cacheHandlers.Get(cacheKey);

            if (httpClient == null)
            {
                httpClient = builder.Create();
            }
            _cacheHandlers.Set(cacheKey, httpClient, TimeSpan.FromHours(6));
            return(httpClient);
        }
Example #2
0
        public Variables()
        {
            SortByIv              = false;
            LoginOnAntim8         = false;
            PokemonCounter        = 0;
            PokestopCounter       = 0;
            quickGuidePos         = 0;
            TopLeftImage          = new BitmapImage();
            firstStart            = true;
            CommandLineBox        = new List <MessageDesign>();
            CommandLineLabels     = new Label[8];
            Requester             = new Request.Request();
            stopBotTime           = new DateTime();
            RecentlyCaughtPokemon = new List <PokemonListe>();
            PlayerPosition        = new MapLayer();
            translator            = new Translation();
            luckyEggEnabled       = false;
            luckyEggTime          = new DateTime();
            addThingsToMap        = true;
            updatePlayerPosition  = true;
            PokemonMapPosition    = new MapLayer();
            enableSchedule        = false;
            accountCreation       = false;
            continueWithAccount   = false;
            codename              = "";
            StopBotSchedule       = new DateTime();
            StartBotSchedule      = new DateTime();
            setDateByField        = true;
            NewStartBotTime       = new DateTime();
            NewStopBotTime        = new DateTime();
            PokeNest              = new List <PokemonNest>();
            PokemonNestLayer      = new MapLayer();
            username              = "";
            Key             = "";
            needUpdate      = false;
            password        = "";
            isConnected     = false;
            imageNew        = new Image();
            imageNew.Height = 50;
            imageNew.Width  = 50;
            BitmapImage biIm = new BitmapImage();

            biIm.BeginInit();
            biIm.UriSource         = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Images", "player.png"));
            biIm.DecodePixelWidth  = 50;
            biIm.DecodePixelHeight = 50;
            biIm.EndInit();
            imageNew.Source  = biIm;
            imageNew.Opacity = 0.9;
            imageNew.Stretch = System.Windows.Media.Stretch.None;
        }
Example #3
0
        /// <summary>
        /// When RoomRequest is loaded from DB
        /// </summary>
        /// <param name="rRq"></param>
        public RoomRequestVMUser(RoomRequest rRq, Request.Request rq, VM.ProfilePreviewVM host) // when it comes from DB to view
        {
            ID              = rRq.ID;
            Host            = host;
            CheckInRequest  = rq.CheckIn;
            CheckOutRequest = rq.CheckOut;
            CheckInOwner    = rRq.CheckInOwner;
            CheckOutOwner   = rRq.CheckOutOwner;
            CheckIn         = rRq.CheckInUser;
            CheckOut        = rRq.CheckOutUser;
            string cur = "$";//currency has to be set by user

            if (rq.Type == Request.RequestType.Bound)
            {
                cur = Request.Request.GetCurrency(rq.SalesPricePDay);
                PricePNigthPRoom = (rq.SalesPricePDay); //SalesPrices in rq are per Room
                PricePWeekPRoom  = (rq.SalesPricePWeek);
                PricePMonthPRoom = (rq.SalesPricePMonth);
                cur             = Request.Request.GetCurrency(rq.SalesPricePDay);
                PricePRoomPTime = (Request.Request.CalcPrice(rRq.CheckInUser, rRq.CheckOutUser, Request.Request.Price(PricePNigthPRoom), Request.Request.Price(PricePWeekPRoom), Request.Request.Price(PricePMonthPRoom), 1).ToString("0.00") + cur);
            }
            if (rq.Type == Request.RequestType.Free)
            {
                cur       = Request.Request.GetCurrency(rq.PriceMax);
                PriceSpan = (rq.PriceMax) + "-" + (rq.PriceMin);
            }
            if (rRq.PriceOwner != null)
            {
                PriceOwner = Request.Request.PriceCurrency(rRq.PriceOwner, cur);
            }
            if (rRq.PriceUser != null)
            {
                Price = Request.Request.PriceCurrency(rRq.PriceUser, cur);
            }
            SingleBedOwner = rRq.SingleBedPropose > 0;
            DoubleBedOwner = rRq.DoubleBedPropose > 0;
            ShareRoomOwner = rRq.ShareRoomPropose;
            Status         = rRq.RoomRequestResponse.responseStatus;
            BedRooms       = rq.Accommodation.AccomProfile.BedRooms;
            Roomtype       = rRq.RoomType.ToString();
            RoomRqID       = rRq.ID; //not needed

            Text       = rRq.Message;
            ShareRoom  = rRq.ShareRoom;
            DoubleBed  = rRq.DoubleBed > 0;
            SingleBed  = rRq.SingleBed > 0;
            Request_ID = rRq.Request_ID;
            RqType     = rq.Type;
            //available rooms calc in controller...
        }
Example #4
0
        public static void AddNotification(Request.Request request, string text)
        {
            if (request == null)
            {
                return;
            }

            var notificatationQuery = $"INSERT INTO Notifications(IDEmployee, IDType, Text, Target) VALUES ({request.EmployeeID}, 1, '{text}', {request.EmployeeID})";

            using (var connection = new MySqlConnection(ConnectionDB.Connection))
            {
                connection.Open();
                new MySqlCommand(notificatationQuery, connection).ExecuteNonQuery();
                connection.Close();
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="rRq"></param>
 /// <param name="rq"></param>
 public RReqVMListItemRqOwn(RoomRequest rRq, Request.Request rq, VM.ProfilePreviewVM profileUser)
 {
     ID            = rRq.ID;
     CheckIn       = rRq.CheckInUser.ToString("dd.MM.yyyy");
     CheckOut      = rRq.CheckOutUser.ToString("dd.MM.yyyy");
     TravelerPrice = rRq.PriceUser;
     RoomType      = rRq.RoomTypeToString();
     Status        = rRq.RoomRequestResponse.StatusString;
     Flatmate      = profileUser;
     if (rq.Type == Request.RequestType.Bound)
     {
         CalcPrice      = Request.Request.PriceCurrency(Request.Request.CalcPrice(rRq.CheckInUser, rRq.CheckOutUser, Request.Request.Price(rq.Accommodation.AccomProfile.PricePNight), Request.Request.Price(rq.Accommodation.AccomProfile.PricePWeek), Request.Request.Price(rq.Accommodation.AccomProfile.PricepMonth), rq.Accommodation.AccomProfile.BedRooms).ToString());
         CalcPriceSales = Request.Request.PriceCurrency(Request.Request.CalcPrice(rRq.CheckInUser, rRq.CheckOutUser, Request.Request.Price(rq.SalesPricePDay), Request.Request.Price(rq.SalesPricePWeek), Request.Request.Price(rq.SalesPricePMonth), 1).ToString());
     }
     if (rq.Type == Request.RequestType.Free)
     {
         PriceRange = rq.PriceMin + " - " + rq.PriceMax;
     }
     //Thumbs = Accommodation.Likibu.Offer.StringToArray(rq.Accommodation.AccomProfile.Thumbnails).ToList().FirstOrDefault();
 }
        public async Task <Response <HttpResponseMessage> > GetResponse(Request.Request request)
        {
            var builder = new HttpClientBuilder();

            using (var handler = new HttpClientHandler {
                CookieContainer = request.CookieContainer
            })
            {
                if (request.IsQos)
                {
                    builder.WithQoS(request.QosProvider, _logger, handler);
                }

                using (var httpClient = builder.Build(handler))
                {
                    try
                    {
                        var response = await httpClient.SendAsync(request.HttpRequestMessage);

                        return(new OkResponse <HttpResponseMessage>(response));
                    }
                    catch (TimeoutRejectedException exception)
                    {
                        return
                            (new ErrorResponse <HttpResponseMessage>(new RequestTimedOutError(exception)));
                    }
                    catch (BrokenCircuitException exception)
                    {
                        return
                            (new ErrorResponse <HttpResponseMessage>(new RequestTimedOutError(exception)));
                    }
                    catch (Exception exception)
                    {
                        return(new ErrorResponse <HttpResponseMessage>(new UnableToCompleteRequestError(exception)));
                    }
                }
            }
        }
Example #7
0
        public RoomRequestListUser(RoomRequest rRq, Request.Request rq, VM.ProfilePreviewVM rqOwnerPrev)
        {
            ID         = rRq.ID;
            Request_ID = rq.ID;
            CheckIn    = rRq.CheckInUser.ToString("dd.MM.yyyy");
            CheckOut   = rRq.CheckOutUser.ToString("dd.MM.yyyy");
            string cur = "";

            if (rq.Type == Request.RequestType.Bound)
            {
                cur = Request.Request.GetCurrency(rq.SalesPricePDay);

                CalcPrice = Request.Request.CalcPrice(rRq.CheckInUser, rRq.CheckOutUser, Request.Request.Price(rq.SalesPricePDay), Request.Request.Price(rq.SalesPricePWeek), Request.Request.Price(rq.SalesPricePMonth), 1).ToString() + cur;
            }
            Title       = rq.Title;
            Price       = rRq.PriceUser;
            Thumb       = Accommodation.Likibu.Offer.StringToArray(rq.Accommodation.AccomProfile.Thumbnails).FirstOrDefault();
            Roomtype    = rRq.RoomType.ToString();
            BedRooms    = rq.Accommodation.AccomProfile.BedRooms;
            RqOwnerPrev = rqOwnerPrev;
            Status      = rRq.RoomRequestResponse.StatusString;
            Rstate      = rRq.RoomRequestResponse.responseStatus;
        }
Example #8
0
        public IDelegatingHandlerHandlerProvider Get(Request.Request request)
        {
            var handlersAppliedToAll = _allRoutesProvider.Get();

            var provider = new DelegatingHandlerHandlerProvider();

            foreach (var handler in handlersAppliedToAll)
            {
                provider.Add(handler);
            }

            if (request.IsTracing)
            {
                provider.Add(() => (DelegatingHandler)_tracingHandler);
            }

            if (request.IsQos)
            {
                provider.Add(() => new PollyCircuitBreakingDelegatingHandler(request.QosProvider, _loggerFactory));
            }

            return(provider);
        }
Example #9
0
        public Response <IDelegatingHandlerHandlerProvider> Get(Request.Request request)
        {
            try
            {
                if (_housed.TryGetValue(request.ReRouteKey, out var provider))
                {
                    //todo once day we might need a check here to see if we need to create a new provider
                    provider = _housed[request.ReRouteKey];
                    return(new OkResponse <IDelegatingHandlerHandlerProvider>(provider));
                }

                provider = _factory.Get(request);
                AddHoused(request.ReRouteKey, provider);
                return(new OkResponse <IDelegatingHandlerHandlerProvider>(provider));
            }
            catch (Exception ex)
            {
                return(new ErrorResponse <IDelegatingHandlerHandlerProvider>(new List <Error>()
                {
                    new UnableToFindDelegatingHandlerProviderError($"unabe to find delegating handler provider for {request.ReRouteKey} exception is {ex}")
                }));
            }
        }
Example #10
0
        public async Task <Response <HttpResponseMessage> > GetResponse(Request.Request request)
        {
            using (var handler = new HttpClientHandler {
                CookieContainer = request.CookieContainer
            })
                using (var httpClient = new HttpClient(handler))
                {
                    try
                    {
                        var response = await httpClient.SendAsync(request.HttpRequestMessage);

                        return(new OkResponse <HttpResponseMessage>(response));
                    }
                    catch (Exception exception)
                    {
                        return
                            (new ErrorResponse <HttpResponseMessage>(new List <Error>
                        {
                            new UnableToCompleteRequestError(exception)
                        }));
                    }
                }
        }
Example #11
0
        /// <summary>
        /// this goes to the View When RoomRequest is created(when applying for a request)
        /// </summary>
        /// <param name="checkIn"></param>
        /// <param name="checkOut"></param>

        public RoomRequestVMUser(DateTime checkin, DateTime checkout, Request.Request rq)
        {
            CheckInRequest  = rq.CheckIn;
            CheckOutRequest = rq.CheckOut;
            CheckIn         = checkin;
            CheckOut        = checkout;
            RqType          = rq.Type;

            if (rq.Type == Request.RequestType.Bound)
            {
                string cur = Request.Request.GetCurrency(rq.SalesPricePDay);
                PricePNigthPRoom = (rq.SalesPricePDay); //SalesPrices in rq are per Room
                PricePWeekPRoom  = (rq.SalesPricePWeek);
                PricePMonthPRoom = (rq.SalesPricePMonth);
                PricePRoomPTime  = (Request.Request.CalcPrice(checkin, checkout, Request.Request.Price(PricePNigthPRoom), Request.Request.Price(PricePWeekPRoom), Request.Request.Price(PricePMonthPRoom), 1).ToString());
            }
            if (rq.Type == Request.RequestType.Free)
            {
                PriceSpan = Request.Request.PriceCurrency(rq.PriceMax) + "-" + Request.Request.PriceCurrency(rq.PriceMin);
            }
            Request_ID = rq.ID;
            BedRooms   = rq.Accommodation.AccomProfile.BedRooms;
        }
Example #12
0
 public void SetUpstreamRequestForThisRequest(Request.Request request)
 {
     _requestScopedDataRepository.Add("Request", request);
 }
Example #13
0
        private IHttpClient GetHttpClient(string cacheKey, IHttpClientBuilder builder, Request.Request request)
        {
            var httpClient = _cacheHandlers.Get(cacheKey);

            if (httpClient == null)
            {
                httpClient = builder.Create(request);
            }

            return(httpClient);
        }
Example #14
0
 public abstract void HandleRequest(Request.Request request);
 public PedidoController()
 {
     _request = new Request.Request();
 }
Example #16
0
        private HttpMessageHandler CreateHttpMessageHandler(HttpMessageHandler httpMessageHandler, Request.Request request)
        {
            var provider = _house.Get(request);

            //todo handle error
            provider.Data.Get()
            .Select(handler => handler)
            .Reverse()
            .ToList()
            .ForEach(handler =>
            {
                var delegatingHandler          = handler();
                delegatingHandler.InnerHandler = httpMessageHandler;
                httpMessageHandler             = delegatingHandler;
            });
            return(httpMessageHandler);
        }
Example #17
0
 public ReservationsVM(List <Accommodation.BedRoom> Bedrooms, List <RoomRequestVMOwner> reservations, List <RoomRequestVMOwner> approvals, Request.Request rq)
 {
     ID           = rq.ID;
     Approvals    = approvals;
     Reservations = reservations;
     BedRooms     = Bedrooms;
     Duration     = rq.CheckOut - rq.CheckIn;
     Start        = rq.CheckIn;
     End          = rq.CheckOut;
 }