public HttpResponseMessage FindGameAccount(PayloadApi p) { LogClass.SaveCustomerLog("FindGameAccount: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <FindAgencyEntity>(publisherInfo.data.ToString()); result.data = managerModel.AgencyModel.FindGameAccount(data.param, data.topN); } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR FindGameAccount: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public HttpResponseMessage DeleteFailTransactionCard(PayloadApi p) { LogClass.SaveCustomerLog("DeleteCashOutCard: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <DeleteFailTransactionCard>(publisherInfo.data.ToString()); string msg = ""; result.status = managerModel.GameAcountModel.DELETE_FAIL_TRANSACTION_CARD(data, ref msg); result.msg = msg; } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR DeleteFailTransactionCard: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public HttpResponseMessage LockAccountGame(PayloadApi p) { LogClass.SaveCustomerLog("LockAccountGame: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <LockAccountGameEnity>(publisherInfo.data.ToString()); string msg = ""; result.status = managerModel.GameAcountModel.LOCK_ACCOUNT_GAME(data, ref msg); result.msg = msg; } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR LockAccountGame: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public HttpResponseMessage UpdateDisplay_Agency(PayloadApi p) { LogClass.SaveCustomerLog("UpdateDisplay_Agency: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <UpdateDisplayAgencyEntity>(publisherInfo.data.ToString()); string msg = ""; result.status = managerModel.AgencyModel.UpdateDisplay_Agency(data, ref msg); result.msg = msg; } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR UpdateDisplay_Agency: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public HttpResponseMessage ResetPasswordAgency(PayloadApi p) { LogClass.SaveCustomerLog("ResetPasswordAgency: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <ResetPasswordAgencyEntity>(publisherInfo.data.ToString()); string msg = ""; string passwordNew = ""; result.status = managerModel.AgencyModel.RessetPasswordAgency(data.phone, data.otp, ref msg, ref passwordNew); result.msg = msg; if (result.status == 1) { SMS.SendMessage(data.phone, passwordNew + " la mat khau moi cua Ban."); } } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR ResetPasswordAgency: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public HttpResponseMessage TransferMoneyToUser(PayloadApi p) { LogClass.SaveCustomerLog("TransferMoneyToUser: "******""; string otp = ""; string phone = ""; result.status = managerModel.AgencyModel.TransferMoneyToUser(data, ref msg, ref otp, ref phone); result.msg = msg; if (result.status == 2) { SMS.SendMessage(phone, "Ma OTP xac thuc GD la " + otp + ", hieu luc 3 phut.Chi tiet GD: Chuyen khoan cho user so tien " + UtilClass.formatMoney((int)data.amount) + " VND."); } } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR TransferMoneyToUser: " + ex, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
public IActionResult disableContext([FromBody] ContextInput form) { var result = new ResultApi(); var configFiles = ConfigService.Get(form.Name); var otmService = new OtmContext(configFiles, Logger); _contexts.Add(form.Name, otmService); try { foreach (var ctx in _contexts.Values) { ctx.Initialize(); form.Enabled = ctx.Stop(); ContextService.CreateOrEditContext(form); } result.result = true; } catch (Exception e) { result.result = false; result.message = e.Message; } return(Ok(result)); }
public async Task <List <Employee> > getListEmployeeAsync(FiltrEmployee filtrEmpl) { var listEmployee = new List <Employee>(); var resultApi = new ResultApi(); HttpClient client = new HttpClient(); string req = urlEmployeeApi + "?Surname=" + filtrEmpl.Surname + "&Name=" + filtrEmpl.Name + "&Middle_name=" + filtrEmpl.Middle_name + "&countInPage=" + filtrEmpl.countInPage + "&numberPage=" + filtrEmpl.numberPage; HttpResponseMessage response = await client.GetAsync(req); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); resultApi = JsonConvert.DeserializeObject <ResultApi>(responseBody); if (resultApi.code >= 0) { listEmployee = resultApi.lstEmployee; } return(listEmployee); }
public HttpResponseMessage ActivePhoneAgency(PayloadApi p) { LogClass.SaveCustomerLog("ActivePhoneAgency: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <ActivePhoneAgency>(publisherInfo.data.ToString()); string msg = ""; string otp = ""; result.status = managerModel.AgencyModel.ActivePhoneAgency(data, ref msg, ref otp); result.msg = msg; if (result.status == 2) { SMS.SendMessage(data.phone, "Ma OTP xac thuc kich hoat sdt la " + otp + ", hieu luc 3 phut"); } } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR ActivePhoneAgency: " + ex, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } return(Request.CreateResponse(result)); }
static void Main(string[] args) { RequestAPI request = new RequestAPI(); ResultApi resultado = new ResultApi(); decimal valor, resultadoconversao; string op; Console.WriteLine("Digite o tipo de moeda que deseja converter"); Console.WriteLine("\nUSD Dolar"); op = Console.ReadLine(); Console.WriteLine("Digite o valor em Reais"); valor = decimal.Parse(Console.ReadLine()); switch (op) { case "USD": resultado = request.Request($"all/{op}", Method.GET); resultadoconversao = decimal.Parse(resultado.USD.Cotacao) * valor; Console.WriteLine($"O Resultado é :R$ {resultadoconversao:N2} na data de : {resultado.USD.DataCotacao.ToString("dd/MM/yyyy HH:mm")}"); break; default: break; } }
/// <summary> /// 获取科室集合 /// </summary> /// <param name="req"></param> /// <returns></returns> public ResultApi <List <Dept> > GetDepts() { var result = new ResultApi <List <Dept> >(); result.Data = dbContext.Depts.ToList(); return(result); }
public IActionResult TestConnectionS7([FromBody] DeviceInput input) { var result = new ResultApi(); try { var client = new S7Client() { PduSizeRequested = 960 }; client.ConnectTo(input.host, input.slot, input.rack); if (client.Connected) { client.Disconnect(); result.result = true; } else { result.result = false; } } catch (Exception e) { result.result = false; result.message = e.Message; } return(Ok(result)); }
public async Task <bool> DeleteAsync(int id, string recurso = "") { if (id == 0) { return(false); } string url = String.IsNullOrEmpty(recurso) ? this._url : String.Concat(this._url, "/", recurso); this._logger.LogDebug("##### DeleteAsync #####"); this._logger.LogDebug(url); HttpResponseMessage response = await _clientHttp.DeleteAsync(string.Concat(url, $"/{id}")); if (response.IsSuccessStatusCode) { if (response.Content != null) { var responseContent = await response.Content.ReadAsStringAsync(); ResultApi resultApi = JsonConvert.DeserializeObject <ResultApi>(responseContent); return(resultApi.status); } } return(false); }
public HttpResponseMessage GetAgencyInfo(PayloadApi p) { LogClass.SaveCustomerLog("GetAgencyInfo: " + JsonConvert.SerializeObject(p)); ResultApi result = new ResultApi(); try { var publisherInfo = publisher.CheckPublickey(p, version); if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) { ManagerModel managerModel = new ManagerModel(); var data = JsonConvert.DeserializeObject <getAgencyInfoEntity>(publisherInfo.data.ToString()); int code = -1; string msg = ""; var d = managerModel.AgencyModel.GetAgencyByID(data.uwinID, ref code, ref msg); LogClass.SaveCustomerLog("AgencyInfo: " + JsonConvert.SerializeObject(d)); result.status = (int)ERROR_CODDE.SUCCESS; result.data = Encryptor.EncryptString(JsonConvert.SerializeObject(d), publisherInfo.secreckey); } else { result = publisherInfo; } } catch (Exception ex) { LogClass.SaveError("ERROR GetAgencyInfo: " + ex.Message, ex, true); result.status = (int)ERROR_CODDE.ERROR_EX; result.msg = ex.Message; } LogClass.SaveCustomerLog("return GetAgencyInfo: " + JsonConvert.SerializeObject(result)); return(Request.CreateResponse(result)); }
public ResultApi updateEmployee(int id, Employee empl) { ResultApi resultUpdateEmplouee = new ResultApi(); string sp_iud_empliyee = "iud_employee"; int ret = 0; string info = string.Empty; using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { SqlCommand command = new SqlCommand(sp_iud_empliyee, connection); command.CommandType = CommandType.StoredProcedure; SqlParameter sp_iud = new SqlParameter("@iud", SqlDbType.Int); sp_iud.Value = 2; sp_iud.Direction = ParameterDirection.Input; SqlParameter sp_employee_id = new SqlParameter("@employee_id", SqlDbType.Int); sp_employee_id.Value = empl.employee_id; sp_employee_id.Direction = ParameterDirection.Input; SqlParameter sp_surname = new SqlParameter("@surname", System.Data.SqlDbType.NVarChar); sp_surname.Value = empl.surname; sp_surname.Direction = System.Data.ParameterDirection.Input; SqlParameter sp_name = new SqlParameter("@name", System.Data.SqlDbType.NVarChar); //sp_name.DbType = System.Data.DbType.String;? sp_name.Value = empl.name; sp_name.Direction = System.Data.ParameterDirection.Input; SqlParameter sp_middleName = new SqlParameter("@middle_name", System.Data.SqlDbType.NVarChar); sp_middleName.Value = empl.middle_name; sp_middleName.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(sp_iud); command.Parameters.Add(sp_employee_id); command.Parameters.Add(sp_surname); command.Parameters.Add(sp_name); command.Parameters.Add(sp_middleName); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ret = Convert.ToInt32(reader.GetValue(0)); info = Convert.ToString(reader.GetValue(1)); } } command.Connection.Close(); } resultUpdateEmplouee.code = ret; resultUpdateEmplouee.info = info; return(resultUpdateEmplouee); }
public ResultApi Get(int id) { var result = new ResultApi(); var employeeResult = db.getEmployee(id); result.employee = employeeResult.employee; result.code = 0; result.info = ""; return(result); }
private async void btnModifyEmployee_Click(object sender, RoutedEventArgs e) { Logic.HttpClientHR httpClientHR = new Logic.HttpClientHR(); ResultApi resultCreatedEmployee = new ResultApi(); string txtEmplyeeId = string.Empty; Employee newEmpl = new Employee(); txtEmplyeeId = txtemployee_id.Text; if (txtEmplyeeId == "") { txtEmplyeeId = "0"; } newEmpl.employee_id = Convert.ToInt32(txtEmplyeeId); newEmpl.name = txtName.Text; newEmpl.surname = txtSurname.Text; newEmpl.middle_name = txtMiddleName.Text; newEmpl.birthday = Convert.ToDateTime(txtDateBidthDay.SelectedDate); if (newEmpl.employee_id > 0) { resultCreatedEmployee = await httpClientHR.changedEmployeeAsync(newEmpl); if (resultCreatedEmployee == null && resultCreatedEmployee.code == null) { MessageBox.Show("Ошибка при сохранении изменений. "); } else if (resultCreatedEmployee.code == 0) { MessageBox.Show("Сохранено"); tabListEmployee.IsSelected = true; tabEmployee.Visibility = Visibility.Hidden; } else { MessageBox.Show("Ошибка при сохранении изменений. \n" + resultCreatedEmployee.info); } } else { resultCreatedEmployee = await httpClientHR.createNewEmployeeAsunc(newEmpl); if (resultCreatedEmployee.code == 0 && resultCreatedEmployee.employee.employee_id > 0) { txtemployee_id.Text = resultCreatedEmployee.employee.employee_id.ToString(); MessageBox.Show("Сохранено. "); tabListEmployee.IsSelected = true; tabEmployee.Visibility = Visibility.Hidden; } else { MessageBox.Show("Ошибка создания сотрудника. \n" + resultCreatedEmployee.info); } } }
public ActionResult Search(string term) { var result = new ResultApi <RestaurantListViewModel> { Dados = _restaurantAppService.Search(term) .Select(x => new RestaurantListViewModel { Name = x.Name, RestaurantId = x.RestaurantId }) }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { var result = new ResultApi <DishListViewModel> { Dados = _dishAppService.Get() .Select(x => new DishListViewModel() { Name = x.Name, Restaurant = x.Restaurant.Name, DishId = x.DishId, Price = x.Price }) }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public IActionResult Delete([FromBody] DataPointInput name) { var result = new ResultApi(); try { ConfigService.DeleteDataPoint(name); result.result = true; } catch (Exception e) { result.result = false; result.message = e.Message; } return(Ok(result)); }
public ActionResult Save(DishAddViewModel model) { var result = new ResultApi <DishAddViewModel>(); try { _dishAppService.Add(new Dish(model.Name, model.Price, model.RestaurantId)); } catch (Exception e) { result.Sucesso = false; result.Mensagem = e.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <ResultApi> createNewEmployeeAsunc(Employee newEmployee) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(urlEmployeeApi); var contentJson = JsonConvert.SerializeObject(newEmployee); var data = new StringContent(contentJson, Encoding.UTF8, "application/json"); var responce = await httpClient.PostAsync(httpClient.BaseAddress, data); string resultStr = responce.Content.ReadAsStringAsync().Result; ResultApi resultApi = (ResultApi)JsonConvert.DeserializeObject(resultStr, typeof(ResultApi)); return(resultApi); }
public ActionResult Save(RestaurantAddViewModel model) { var result = new ResultApi <RestaurantListViewModel>(); try { _restaurantAppService.Add(new Restaurant(model.Name)); } catch (Exception e) { result.Sucesso = false; result.Mensagem = e.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ResultApi getEmployee(int employee_id) { ResultApi resultApi = new ResultApi(); Employee empl = new Employee(); string prc_get_employee_by_id = "get_employee_by_id"; using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { SqlCommand command = new SqlCommand(prc_get_employee_by_id, connection); command.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sp_employee_id = new SqlParameter("@id", System.Data.SqlDbType.Int); sp_employee_id.ParameterName = "@id"; sp_employee_id.Value = employee_id; sp_employee_id.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(sp_employee_id); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { empl.employee_id = Convert.ToInt32(reader.GetValue(0)); empl.surname = Convert.ToString(reader.GetValue(1)); empl.name = Convert.ToString(reader.GetValue(2)); empl.middle_name = Convert.ToString(reader.GetValue(3)); empl.birthday = reader.GetValue(4) == DBNull.Value ? default(DateTime) : Convert.ToDateTime(reader.GetValue(4)); } } command.Connection.Close(); } if (empl != null) { resultApi.code = 0; resultApi.employee = empl; } else { resultApi.code = -1; resultApi.info = "Ошибка поиска"; } return(resultApi); }
public ResultApi updateEmployee(int employee_id, Employee empl) { ResultApi result = new ResultApi(); using (ApplicationContext db = new ApplicationContext()) { db.Update(empl); db.SaveChanges(); } result.employee = empl; result.code = 0; result.info = ""; return(result); }
private Task HandleExceptionAsync(HttpContext context, Exception ex) { ResultApi result = new ResultApi { IsSuccess = false, Path = context.Request.Path.HasValue ? context.Request.Path.Value : "", Method = context.Request.Method }; bool errorBecauseOfValidationException = false; switch (ex) { case ValidationException validationException: result.StatusCode = (int)HttpStatusCode.BadRequest; result.Payload = validationException.Failures; result.Message = validationException.Message; errorBecauseOfValidationException = true; break; default: result.StatusCode = (int)HttpStatusCode.InternalServerError; result.Message = ex.Message; if (ex.InnerException != null) { result.InnerMessage = ex.InnerException.Message; } break; } context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)HttpStatusCode.OK; var jsonSetting = new JsonSerializerOptions { DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; if (errorBecauseOfValidationException) { jsonSetting.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never; } return(context.Response.WriteAsync(JsonSerializer.Serialize(result, jsonSetting))); }
public IActionResult Post([FromBody] DataPointConfig form) { var result = new ResultApi(); try { ConfigService.CreateDatapoint(form); result.result = true; } catch (Exception e) { result.result = false; result.message = e.Message; } return(Ok(result)); }
public ActionResult Delete(int id) { var result = new ResultApi <DishListViewModel>(); try { var dish = _dishAppService.GetById(id); _dishAppService.Remove(dish); } catch (Exception e) { result.Sucesso = false; result.Mensagem = e.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <ResultApi> changedEmployeeAsync(Employee empl) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(urlEmployeeApi); var contentJson = JsonConvert.SerializeObject(empl); var data = new StringContent(contentJson, Encoding.UTF8, "application/json"); var responce = await httpClient.PutAsync(urlEmployeeApi + "/" + empl.employee_id.ToString(), data); string resultStr = await responce.Content.ReadAsStringAsync(); ResultApi resultApi = (ResultApi)JsonConvert.DeserializeObject(resultStr, typeof(ResultApi)); return(resultApi); }
public IActionResult Post([FromBody] ContextInput form) { var result = new ResultApi(); try { ContextService.CreateOrEditContext(form); result.result = true; } catch (Exception e) { result.result = false; result.message = e.Message; } return(Ok(result)); }