示例#1
0
        public async void RefillTokensUser()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://demo.comte.re");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(this.Api.token.token_type, this._api.token.access_token);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync("/api/user/" + this.Api.user.email + "/refill");

                string str = await response.Content.ReadAsStringAsync();

                Debug.WriteLine(str);


                if (response.IsSuccessStatusCode)
                {
                    this.Api    = JsonConvert.DeserializeObject <Api>(str);
                    this.dialog = new MessageDialog("Votre recharge vous a été livré, vous disposez de :" + this.Api.user.stack + "tokens");
                    BadTextBox(this.dialog);
                    CurrentStack = this.Api.user.stack;
                }
                else
                {
                    Debug.WriteLine(str);
                    ErrorApi erAp = new ErrorApi();
                    JsonSerializerSettings settings = new JsonSerializerSettings();
                    settings.NullValueHandling = NullValueHandling.Ignore;
                    erAp        = JsonConvert.DeserializeObject <ErrorApi>(str, settings);
                    this.dialog = new MessageDialog(erAp.Message);
                    BadTextBox(this.dialog);
                }
            }
        }
示例#2
0
        // Sit on table Api
        public async void SitOnTableApi(int id)
        {
            Double _minBetTable = 0;

            foreach (var item in ListTable)
            {
                if (item.Id == id)
                {
                    _minBetTable = item.Min_bet;
                }
            }

            if (this.Api.user.stack >= _minBetTable)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://demo.comte.re");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", this._api.token.access_token);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage response = await client.GetAsync("/api/user/" + this.Api.user.email + "/table/" + id + "/sit");

                    //Debug.WriteLine(response);
                    string res = await response.Content.ReadAsStringAsync();

                    //Debug.WriteLine(res);



                    if (response.IsSuccessStatusCode)
                    {
                        TableToGameNav navParam = null;
                        foreach (var item in _listTable)
                        {
                            if (item.Id == id)
                            {
                                navParam = new TableToGameNav(this.Api, item);
                            }
                        }

                        currentFrame.Navigate(typeof(GameView), navParam);
                    }
                    else if (response.IsSuccessStatusCode != true)
                    {
                        ErrorApi erAp = new ErrorApi();
                        erAp = JsonConvert.DeserializeObject <ErrorApi>(res);
                        if (erAp.Error_code == "user_already_on_table")
                        {
                            LeaveTable(id);
                        }
                    }
                }
            }
            else
            {
                this.dialog = new MessageDialog("Votre Stack est insufisant pour cette table");
                BadTextBox(this.dialog);
            }
        }
 public EncodingsApi(IBitmovinApiClientFactory apiClientFactory)
 {
     Finished               = new FinishedApi(apiClientFactory);
     Error                  = new ErrorApi(apiClientFactory);
     TransferError          = new TransferErrorApi(apiClientFactory);
     LiveInputStreamChanged = new LiveInputStreamChangedApi(apiClientFactory);
     EncodingStatusChanged  = new EncodingStatusChangedApi(apiClientFactory);
 }
 private void SetupApis()
 {
     Error = new ErrorApi {
         Client = this
     };
     Account = new AccountApi {
         Client = this
     };
     Application = new ApplicationApi {
         Client = this
     };
     AvailableNumber = new AvailableNumberApi {
         Client = this
     };
     Bridge = new BridgeApi {
         Client = this
     };
     Domain = new DomainApi {
         Client = this
     };
     Call = new CallApi {
         Client = this
     };
     Conference = new ConferenceApi {
         Client = this
     };
     Message = new MessageApi {
         Client = this
     };
     NumberInfo = new NumberInfoApi {
         Client = this
     };
     PhoneNumber = new PhoneNumberApi {
         Client = this
     };
     Recording = new RecordingApi {
         Client = this
     };
     Transcription = new TranscriptionApi {
         Client = this
     };
     Media = new MediaApi {
         Client = this
     };
     Endpoint = new EndpointApi {
         Client = this
     };
     V2 = new ApiV2 {
         Message = new Bandwidth.Net.ApiV2.MessageApi {
             Client = this
         }
     };
 }
示例#5
0
        // Function connect with call api
        public async void Connect(String json)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://demo.comte.re/");

                var itemJson = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync("/api/auth/login", itemJson);

                String _response = await response.Content.ReadAsStringAsync();

                //Debug.WriteLine(response.Content.ReadAsStringAsync().Result);
                if (response.IsSuccessStatusCode)
                {
                    this.Api = new Api();
                    this.Api = JsonConvert.DeserializeObject <Api>(_response);
                    Debug.WriteLine(_response);
                    Debug.WriteLine(this.Api.user.stack);
                    currentFrame.Navigate(typeof(ListTable), this.Api);
                }
                else if (response.IsSuccessStatusCode != true)
                {
                    Debug.WriteLine(_response);
                    ErrorApi erAp = new ErrorApi();
                    _response  = _response.Remove(_response.Length - 57);
                    _response += "\"}";
                    JsonSerializerSettings settings = new JsonSerializerSettings();
                    settings.NullValueHandling = NullValueHandling.Ignore;
                    erAp = JsonConvert.DeserializeObject <ErrorApi>(_response, settings);
                    if (erAp.Error_code == "login_data_fails")
                    {
                        this.dialog = new MessageDialog("Données non conformes aux attentes");
                        BadTextBox(this.dialog);
                    }
                    else if (erAp.Error_code == "bad_credentials")
                    {
                        this.dialog = new MessageDialog("Mauvais identifiants");
                        BadTextBox(this.dialog);
                    }
                    else if (erAp.Error_code == "login_no_result")
                    {
                        this.dialog = new MessageDialog("Pas d'utilisateur trouvé");
                        BadTextBox(this.dialog);
                    }
                }
            }
        }
示例#6
0
        public ActionResult <ErrorApi> PostJira([FromBody] Jira value)
        {
            ErrorApi errApi;

            try
            {
                Jira jiraDel = this._context.Jiras.Where(jira => jira.username == value.username).First();
                errApi = new ErrorApi(405, "Ese usuario Jira ya esta enlazado a otro usuario.");
            }
            catch (Exception ex)
            {
                this._context.Jiras.Add(value);
                this._context.SaveChanges();
                errApi = new ErrorApi(200, "Usuario de Jira enlazado al usuario.");
            }
            return(errApi);
        }
示例#7
0
        public ActionResult <ErrorApi> PutJira(long id, [FromBody] Jira value)
        {
            ErrorApi errApi;

            try
            {
                Jira jiraUpdate = this._context.Jiras.Where(jira => jira.username == value.username).First();
                if (jiraUpdate != null)
                {
                    // Si no se modifica el username, deberia encontrarlo, pero con el idUser pasado
                    if (jiraUpdate.idUser != id)
                    {
                        errApi = new ErrorApi(404, "Ese usuario Jira ya esta enlazado a otro usuario.");
                    }
                    else
                    {
                        jiraUpdate.username    = value.username;
                        jiraUpdate.password    = value.password;
                        jiraUpdate.url         = value.url;
                        jiraUpdate.proyect     = value.proyect;
                        jiraUpdate.component   = value.component;
                        jiraUpdate.descripcion = value.descripcion;
                        jiraUpdate.issue_type  = Issue.explotacion;
                        this._context.SaveChanges();
                        errApi = new ErrorApi(200, "Usuario Jira modificado.");
                    }
                }
                else
                {
                    errApi = new ErrorApi(400, "Error del servidodr.");
                }
            }
            catch (Exception ex)
            {
                Jira jiraUpdate = this._context.Jiras.Where(jira => jira.idUser == id).First();;
                jiraUpdate.username  = value.username;
                jiraUpdate.password  = value.password;
                jiraUpdate.url       = value.url;
                jiraUpdate.proyect   = value.proyect;
                jiraUpdate.component = value.component;
                this._context.SaveChanges();
                errApi = new ErrorApi(200, "Usuario Jira modificado.");
            }
            return(errApi);
        }
        public void OnException(ExceptionContext context)
        {
            var error = new ErrorApi();

            if (_env.IsDevelopment())
            {
                error.Message = context.Exception.Message;
                error.Detail  = context.Exception.StackTrace;
            }
            else
            {
                error.Message = "A server error has occured";
                error.Detail  = context.Exception.StackTrace;
            }
            context.Result = new ObjectResult(error)
            {
                StatusCode = 500
            };
        }
示例#9
0
        public async Task <ResultApi <IEnumerable <Beer> > > GetAllBeer(int page, int perPage)
        {
            ResultApi <IEnumerable <Beer> > res = new ResultApi <IEnumerable <Beer> >();

            string url = $"{this.Configuration["ApiServices:BeerApi"]}/beers?page={page}&per_page={perPage}";

            var request = CreateRequest(HttpMethod.Get, url);

            this.Logger.LogInformation($"[{request.Method.Method}] {request.RequestUri.AbsoluteUri}");

            var client   = this.HttpClient.CreateClient();
            var response = await client.GetAsync(request.RequestUri);

            if (!response.IsSuccessStatusCode)
            {
                if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    var strContentError = await response.Content.ReadAsStringAsync();

                    ErrorApi errorApi = JsonSerializer.Deserialize <ErrorApi>(strContentError);
                    return(new ResultApi <IEnumerable <Beer> >
                    {
                        ErrorApi = errorApi
                    });
                }

                string logError = $"{response.StatusCode}|{response.Content}";
                this.Logger.LogError(logError);
                throw new Exception(logError);
            }

            var strContent = await response.Content.ReadAsStringAsync();

            this.Logger.LogInformation($"{response.StatusCode}");
            IEnumerable <Beer> beers = JsonSerializer.Deserialize <IEnumerable <Beer> >(strContent);

            return(new ResultApi <IEnumerable <Beer> >
            {
                Data = beers
            });
        }
示例#10
0
        public ActionResult <ErrorApi> Post([FromBody] User value)
        {
            ErrorApi valueReturn;

            try
            {
                User userEx = this._context.Users.Where(user => user.username == value.username).First();
                if (userEx != null)
                {
                    valueReturn = new ErrorApi(405, "El usuario ya existe.");
                    return(valueReturn);
                }
            }
            // Si lo pilla es que Users esta vacia, ergo no existe
            catch (Exception ex) { }
            value.password = Encrypt.Hash(value.password);
            value.role     = value.role == 0? Role.admin : Role.user;
            this._context.Users.Add(value);
            this._context.SaveChanges();
            valueReturn = new ErrorApi(200, "Usuario creado con éxito.");
            return(valueReturn);
        }
示例#11
0
        /// <summary>
        /// Reports a player error.
        /// </summary>
        /// <param name="errorCode">Player's error numerical code</param>
        /// <param name="code">View code retrieved from the data call</param>
        /// <param name="msg">Player’s error message.</param>
        /// <param name="resource">Vídeo resource URL</param>
        /// <param name="system">Your Nice PeopleAtWork account code that indicates Youbora which customer account you are sending the data to. This parameter will be provided by NicePeopleAtWork, if you don't have it yet, please contact your Customer Engineer or Support Agent</param>
        /// <param name="live">Boolean variable to identify if the video is a live (true) or an on demand (false) stream. Many of our plugins have a method integrated that lets the customer, when integrating the plugin, use a method to set this property</param>
        /// <param name="properties">JSON media properties (the same ones described in the start call)</param>
        /// <param name="user">User identifier. If the user is unknown, send a blank parameter or with a default username</param>
        /// <param name="referer">Browser's URL where the player is being loaded (window.location)</param>
        /// <param name="bitrate">bitrate (bps)</param>
        /// <param name="pingTime">pt tag from data response</param>
        /// <param name="pluginVersion">The version of the plugin in the x.x.x_pluginCode format. This parameter lets you to have a version control of new deployed plugins and see which users are using an older version (cached in the system), so you can force them to clean their cache and download the new version</param>
        /// <param name="extraParams">Custom Data feature</param>
        /// <param name="duration"></param>
        /// <param name="cdn">Code that indicates what CDN’s name must be shown for a view</param>
        /// <param name="isp">String that indicates the name of the user’s ISP</param>
        /// <param name="ip">String that defines the user’s IP</param>
        /// <param name="complete">Complete Action</param>
        public static void Error(
            string errorCode,
            string code,
            string msg,
            string resource,
            string system,
            bool live,
            string properties,
            string user,
            string referer,
            double bitrate,
            int pingTime,
            string pluginVersion,
            long duration,
            string extraParams,
            Action <string> complete)
        {
            var url = ErrorApi.Error(Host, errorCode, msg, code, resource, system, live, properties, user, referer,
                                     bitrate, pingTime,
                                     pluginVersion, duration, extraParams);

            ApiClient.Post(url, complete);
        }
示例#12
0
        public ActionResult <ErrorApi> Post([FromBody] User value)
        {
            ErrorApi mess;

            try
            {
                User userLog = this._context.Users.Where(user => user.username == value.username).First();
                if (userLog.password == Encrypt.Hash(value.password))
                {
                    JwtSecurityToken token = BuildToken(userLog);
                    return(Ok(new ErrorApi(200, new JwtSecurityTokenHandler().WriteToken(token), userLog.id, userLog.role)));
                }
                else
                {
                    mess = new ErrorApi(401, "Password incorrecta");
                }
            }
            catch (Exception ex)
            {
                mess = new ErrorApi(404, "No existe ningun usuario con ese nombre");
            }
            return(mess);
        }
示例#13
0
 public ResultApi()
 {
     Data     = default(T);
     ErrorApi = null;
 }
示例#14
0
 public EncodingsApi(IBitmovinApiClientFactory apiClientFactory)
 {
     _apiClient             = apiClientFactory.CreateClient <IEncodingsApiClient>();
     LiveInputStreamChanged = new LiveInputStreamChangedApi(apiClientFactory);
     Error = new ErrorApi(apiClientFactory);
 }
 public ManifestApi(IBitmovinApiClientFactory apiClientFactory)
 {
     _apiClient = apiClientFactory.CreateClient <IManifestApiClient>();
     Error      = new ErrorApi(apiClientFactory);
     Finished   = new FinishedApi(apiClientFactory);
 }
示例#16
0
 public EncodingsApi(IBitmovinApiClientFactory apiClientFactory)
 {
     Finished      = new FinishedApi(apiClientFactory);
     Error         = new ErrorApi(apiClientFactory);
     TransferError = new TransferErrorApi(apiClientFactory);
 }