Exemplo n.º 1
0
        private async Task SignIn()
        {
            var client       = new ApiClient.ApiClient();
            var token        = ApplicationSettings.GetMobileToken();
            var signInResult = await client.SignInUser(Login, Password, token);


            new NotificationCenter().SendSinginResult(signInResult.Item1, signInResult.Item2);
        }
Exemplo n.º 2
0
        public MasterDetails GetMasterDetailsForVehicles()
        {
            ApiClient.ApiClient client = new ApiClient.ApiClient(new Uri(ApiBaseUrl));
            var requestUri             = client.CreateRequestUri(ApiClient.ApiType.vehicles.ToString());
            var response = client.getAsync <MasterDetails>(requestUri);

            if (response != null && response.masterData != null)
            {
                return(response);
            }
            return(null);
        }
        public MotorVehicleDetails GetCarDetailsBasedOnSelection(string selection)
        {
            Assert.IsNotNullOrEmpty(selection, "Car type is missing");

            ApiClient.ApiClient client = new ApiClient.ApiClient(new Uri(ApiBaseUrl));
            string relativePath        = $"{ApiType.vehicles.ToString()}/{selection}";
            var    requestUri          = client.CreateRequestUri(relativePath);
            var    response            = client.getAsync <MotorVehicleDetails>(requestUri);

            if (response != null && !string.IsNullOrWhiteSpace(response.Name))
            {
                return(response);
            }
            return(null);
        }
Exemplo n.º 4
0
        private async void SetMobileToken(NotificationCenter arg1, string token)
        {
            ApplicationSettings.SetMobileToken(token);

            var userId = ApplicationSettings.GetUserId();

            // if user not signed in yet
            if (string.IsNullOrWhiteSpace(userId))
            {
                return;
            }

            var apiClient = new ApiClient.ApiClient();

            await apiClient.SetMobileToken(userId, token);
        }
        private async void ActionApi_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var client = new ApiClient.ApiClient();

            var model = new TestViewModel
            {
                ID         = 778899,
                OID        = 0,
                SumInsured = 150
            };

            var res = await client.PostDataToApi(model);

            var data = await client.GetDataFromApi();

            var single = await client.GetDataByIdFromApi(4);
        }
Exemplo n.º 6
0
 //Request the API information in a new thread
 private async void BtnGetApiInfoClick(object sender, RoutedEventArgs e)
 {
     await Task.Run(async() =>
     {
         try
         {
             ChangeRequestBtnState(false);
             var client = new ApiClient.ApiClient("http://apidev.gewaer.io/");
             var leads  = await client.GetAsync("v1/leads");
             ShowApiInfo(leads);
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message, "Error");
         }
     });
 }
        private async void SaveSearch(object obj)
        {
            var apiClient = new ApiClient.ApiClient();
            var result    = await apiClient
                            .CreateSearch(Title, Description, Url, default(bool), (int)AdSource.Ebay, ApplicationSettings.GetUserId());

            try
            {
                var searchItem = JsonConvert.DeserializeObject <SearchItem>(result);

                if (searchItem?.Id > 0)
                {
                    MessagingCenter.Send <CreateSearchViewModel, bool>(this, "SEARCH_CREATION_RESULT", true);
                    InternalCache.AddSearchItem(searchItem);
                }
            }
            catch (Exception ex)
            {
                MessagingCenter.Send <CreateSearchViewModel, bool>(this, "SEARCH_CREATION_RESULT", false);
            }
        }
        private async void SaveSearch(object obj)
        {
            var apiClient = new ApiClient.ApiClient();
            var result    = await apiClient
                            .UpdateSearch(_searchItem.Id.ToString(), Title, Description, Url, _searchItem.IsActive, (int)AdSource.Ebay, ApplicationSettings.GetUserId());

            try
            {
                var searchItem = JsonConvert.DeserializeObject <SearchItem>(result);

                if (searchItem?.Id > 0)
                {
                    MessagingCenter.Send <EditSearchViewModel, bool>(this, "SEARCH_EDIT_RESULT", true);
                    InternalCache.UpdateSearchItem(searchItem);
                }
            }
            catch (Exception ex)
            {
                MessagingCenter.Send <EditSearchViewModel, bool>(this, "SEARCH_EDIT_RESULT", false);
            }
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //var apiConfig = InitOptions<ApiConfig>("api");
            var apiConfig = new ApiConfig();

            var apiClient = new ApiClient.ApiClient(apiConfig);
            var announcer = new Announcer();

            apiClient.Session += (sender, session) =>
            {
                announcer.Update(session);
                System.Console.Title = session.game_clock_display;
            };

            announcer.Announce += (sender, announcement) =>
            {
                System.Console.WriteLine(announcement);
            };

            apiClient.Start();

            System.Console.ReadKey();
        }
        public QuickQuoteResponseModel SaveQuickQuoteDetails(QuickQuoteModel quickQuoteData)
        {
            QuickQuoteResponseModel responseModel = new QuickQuoteResponseModel();

            if (quickQuoteData != null)
            {
                try
                {
                    string response            = string.Empty;
                    ApiClient.ApiClient client = new ApiClient.ApiClient(new Uri(ApiBaseUrl));
                    var requestUri             = client.CreateRequestUri(ApiClient.ApiType.quickQuote.ToString());
                    //requestUri = new Uri("http://localhost:65335/api/QuickQuote/QuickQuotePost");
                    response = client.quickQuotePostAsync(requestUri, quickQuoteData);
                    if (!string.IsNullOrWhiteSpace(response) && response.IndexOf("isSuccess") > 0)
                    {
                        var genericResponse = JsonConvert.DeserializeObject <QuickQuoteResponseGenericModel>(response);
                        if (genericResponse.isSuccess)
                        {
                            responseModel.SuccessModel = JsonConvert.DeserializeObject <QuickQuoteSuccessModel>(response);
                        }
                        else
                        {
                            responseModel.ErrorModel = JsonConvert.DeserializeObject <QuickQuoteErrorModel>(response);
                        }
                    }
                }
                catch (JsonException je)
                {
                    Log.Error("Json exception occured while deserializing the quick quote response", je, typeof(QuickQuoteService));
                }
                catch (Exception ex)
                {
                    Log.Error("Error Happened during SaveQuickQuoteDetails function call ", ex, typeof(QuickQuoteService));
                }
            }
            return(responseModel);
        }
Exemplo n.º 11
0
        public void Init()
        {
            this.apiClient = Setup.GetClient();
            this.request   = new RatesRequest()
            {
                pickupDate         = new DateTime(2014, 12, 1)
                , originPostalCode = "30303"
                , originType       = "business dock"
                , destPostalCode   = "60606"
                , destType         = "business dock"
                , paymentTerms     = "Outbound Prepaid"
                , items            = new List <QuoteItem>()
                {
                    new QuoteItem()
                    {
                        freightClass = 50
                        , weight     = 500
                        , length     = 48
                        , width      = 48
                        , height     = 48
                        , hazardous  = false
                        , pieces     = 1
                        , package    = "Pallets_other"
                    }
                }
                , charges = new List <string>()
                {
                    "liftgate pickup"
                }
            };

            var task = apiClient.GetRates(request);

            task.Wait(30000);
            this.result = task.Result;
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            // Initialize the client
            var client = new ApiClient.ApiClient(ApiUrl, "testing", version: Version, logLevel: ApiClient.ApiClient.LOG_DEBUG, logPath: ".");
            JObject results = null;

            // Get a server
            var queryParams = new NameValueCollection
            {
                {"fqdn", "panopta.com"},
                {"limit", "10"},
                {"offset", "0"}
            };
            results = client.Get("/server", queryParams: queryParams);
            Console.WriteLine(JsonConvert.SerializeObject(results, Formatting.Indented));

            // Create a contact
            var data = JObject.Parse(string.Format(@"{{
                'name': 'john',
                'timezone': '{0}'
            }}", string.Format("{0}/v{1}/timezone/America/Chicago", ApiUrl, Version)));
            results = client.Post("/contact", requestData:data);
            Console.WriteLine(JsonConvert.SerializeObject(results, Formatting.Indented));
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            var uiEnabled = false;
            var gameCount = 0;

            Engine.Random.Instance().SetNewSeed(123);
            _colorMap = MapColors();
            var httpclient        = new ApiClient.ApiClient(new Uri("http://localhost:3000"));
            var algorithmSettings = new AlgorithmSetting <AiWeights>();
            var moves             = new Stack <Move>();

            while (true)
            {
                try
                {
                    algorithmSettings = httpclient.GetAlgorithmSettings <FeatureAi, AiWeights>(
                        new AlgorithmSetting <AiWeights> {
                        Name = "Dr Mario - Engine"
                    });
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine($"Error: retrying in a sec");
                    Thread.Sleep(1000);
                    continue;
                }

                var gameManager = new GameManager(20, 10);
                gameManager.AddBacterias(15, 3);
                var         ai           = new AiEngine(new FeatureAi(algorithmSettings.Weights));
                IEnumerator moveIterator = null;
                AI.Move     aiMove       = null;
                var         blockNumber  = -1;
                while (!gameManager.GameState.IsGameOver())
                {
                    if (uiEnabled)
                    {
                        PrintState(gameManager, moves, aiMove);
                    }

                    Thread.Sleep(2);

                    gameManager.OnGameLoopStep();

                    if (moveIterator != null && moveIterator.MoveNext())
                    {
                        gameManager.MoveBlock((Move)moveIterator.Current);
                        moves.Push((Move)moveIterator.Current);
                        continue;
                    }

                    // Make sure we only calculate best move once per spawned block.
                    if (blockNumber != gameManager.GameStats.PillsSpawned)
                    {
                        aiMove       = ai.GetNextMove(gameManager.BoardManager);
                        moveIterator = aiMove.Moves.GetEnumerator();
                        blockNumber  = gameManager.GameStats.PillsSpawned;
                    }

                    if (gameManager.Bacterias.Count < BacteriaCount)
                    {
                        var color = gameManager.Bacterias.GroupBy(x => x.Color).OrderByDescending(o => o.Count()).First().Key;
                        gameManager.AddBacteria(color);
                    }
                }

                if (uiEnabled)
                {
                    Console.Clear();
                    Console.Write("Game Over {0}", gameManager.GameStats.Fitness);
                    Console.WriteLine();
                    Console.WriteLine();
                }
                else
                {
                    Console.Write("{0}, ", gameManager.GameStats.Fitness);
                }

                try
                {
                    httpclient.PostStats(new GameResult <AiWeights>(algorithmSettings)
                    {
                        PillsSpawned = gameManager.GameStats.PillsSpawned,
                        Bacterias    = gameManager.GameStats.TotalBacteriaClearings,
                        Pills        = gameManager.GameStats.TotalPillClearings,
                        Fitness      = gameManager.GameStats.Fitness
                    });
                    gameCount++;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Thread.Sleep(1000);
                }

                Thread.Sleep(50);
                if (uiEnabled)
                {
                    Thread.Sleep(5000);
                }
            }
        }