static void Main() { HttpAPI.SetSecurityProtocol(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form_Home()); }
public async Task _01_POST_GERARCARNE_SEMID() { var container = new Container(cfg => { cfg.Scan(scanner => { scanner.AssemblyContainingType <BuscarTodasCobrancasCommand>(); scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>)); scanner.ConnectImplementationsToTypesClosing(typeof(INotificationHandler <>)); }); cfg.For <ServiceFactory>().Use <ServiceFactory>(ctx => ctx.GetInstance); cfg.For <IMediator>().Use <Mediator>(); }); var mediator = container.GetInstance <IMediator>(); string content = JsonConvert.SerializeObject(Fakes.CarneSemIdRequestFakeIt(), new JsonSerializerSettings { ContractResolver = new LowercaseContractResolver() }); var http = new HttpAPI() { EndPoint = "/api/v2/ec/transactions/lot", Host = "sandboxapi.qg2.com.br", Protocol = "http", Method = "POST", Police = new HttpPolice() { Retry = new HttpPoliceRetry() { MaxRetryAttempts = 3, PauseBetweenFailures = TimeSpan.FromSeconds(3) } }, Content = content }; http.Headers.Add("cache-control", "no-cache"); http.Headers.Add("x-access-token", _token); var response = await mediator .Send(new BuscarTodasCobrancasCommand() { Http = http }); Assert.True(response != null && response.Count > 0); }
void onClickSubmit(GameObject go) { totalChange = 0; if (ValidateField()) { int gender = toggleMale.value == true ? 0 : 1; DataUser userInfo = data.info.info; string emailChange = email.value.Trim(); string phoneChange = phoneNumber.value.Trim(); string fullNameChange = fullName.value.Trim(); string addressChange = address.value.Trim(); if (!fullNameChange.Equals(userInfo.firstName) || userInfo.gender != gender || !address.value.Trim().Equals(userInfo.address)) { totalChange++; APIUser.ChangeUseInformation(fullNameChange, "", "", gender, addressChange, "", OnSubmitChangeInfoCallBack); } if ((!string.IsNullOrEmpty(emailChange) && !emailChange.Equals(userInfo.email)) || (!string.IsNullOrEmpty(phoneChange) && !phoneChange.Equals(userInfo.mobile))) { totalChange++; APIUser.ChangeUseInformationSpecial(emailChange, phoneChange, OnSubmitChangeInfoCallBack); } if (isChangedAvatar) { totalChange++; if (string.IsNullOrEmpty(defaultAvatar)) { HttpAPI.ChangeUseAvatar(this, ((Texture2D)avatar.mainTexture).EncodeToPNG(), OnSubmitChangeInfoCallBack); } else { APIGeneric.SaveDefaultAvatar(defaultAvatar, OnSubmitChangeInfoCallBack); } } if (totalChange == 0) { DialogService.Instance.ShowDialog(new DialogMessage("Thông báo", "Không có thông tin gì thay đổi.")); } } }
public async Task GerarToken_Responde() { var container = new Container(cfg => { cfg.Scan(scanner => { scanner.AssemblyContainingType <GerarTokenCommand>(); scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>)); scanner.ConnectImplementationsToTypesClosing(typeof(INotificationHandler <>)); }); cfg.For <ServiceFactory>().Use <ServiceFactory>(ctx => ctx.GetInstance); cfg.For <IMediator>().Use <Mediator>(); }); var mediator = container.GetInstance <IMediator>(); var http = new HttpAPI() { EndPoint = "/sso/login", Host = "k1jvqp3o2c.execute-api.sa-east-1.amazonaws.com", Protocol = "https", Method = "POST", Police = new HttpPolice() { Retry = new HttpPoliceRetry() { MaxRetryAttempts = 3, PauseBetweenFailures = TimeSpan.FromSeconds(3) } }, Content = "{\"username\": \"[email protected]\", \"password\": \"Admin123#...\"}" }; http.Headers.Add("cache-control", "no-cache"); http.Headers.Add("x-access-authorization", "61d9a504-c096-403e-b0f2-46b524fae1bf"); var response = await mediator .Send(new GerarTokenCommand() { Http = http }); Assert.True(response.Status == 200); Assert.DoesNotContain("Missing Authentication Token", response.Message); }
public async Task _01_BuscarTodasCobrancas_Responde() { var container = new Container(cfg => { cfg.Scan(scanner => { scanner.AssemblyContainingType <BuscarTodasCobrancasCommand>(); scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>)); scanner.ConnectImplementationsToTypesClosing(typeof(INotificationHandler <>)); }); cfg.For <ServiceFactory>().Use <ServiceFactory>(ctx => ctx.GetInstance); cfg.For <IMediator>().Use <Mediator>(); }); var mediator = container.GetInstance <IMediator>(); var http = new HttpAPI() { EndPoint = "/api/v2/ec/sellers/sales?period=200", Host = "sandboxapi.qg2.com.br", Protocol = "http", Method = "GET", Police = new HttpPolice() { Retry = new HttpPoliceRetry() { MaxRetryAttempts = 3, PauseBetweenFailures = TimeSpan.FromSeconds(3) } }, Content = "" }; http.Headers.Add("cache-control", "no-cache"); http.Headers.Add("x-access-token", _token); var response = await mediator .Send(new BuscarTodasCobrancasCommand() { Http = http }); Assert.True(response != null && response.Count > 0); }
public MainWindow() { InitializeComponent(); string marketAll = HttpAPI.GetMarketAll(); List <MarketInfo> all = JsonConvert.DeserializeObject <List <MarketInfo> >(marketAll); Console.WriteLine(marketAll); string[] markets = new string[1]; markets[0] = "KRW-BTC"; ObservableCollection <Ticker> tickerList = JsonConvert.DeserializeObject <ObservableCollection <Ticker> >(HttpAPI.GetTicker(markets)); List <Account> accountList = JsonConvert.DeserializeObject <List <Account> >(HttpAPI.GetAccount()); List <Account> accountList2 = JsonConvert.DeserializeObject <List <Account> >(HttpAPI.GetAccount()); string data = HttpAPI.GetOrderChance(markets); Console.WriteLine(data); OrderChance orderChance = JsonConvert.DeserializeObject <OrderChance>(HttpAPI.GetOrderChance(markets)); }
public async Task BuscarTodosLugares_Response() { var http = new HttpAPI() { EndPoint = "/api/v1/places", Host = "api.clickbus.com.br", Protocol = "http", Method = "GET", Police = new HttpPolice() { Retry = new HttpPoliceRetry() { MaxRetryAttempts = 3, PauseBetweenFailures = TimeSpan.FromSeconds(3) } }, Content = "" }; http.Headers.Add("cache-control", "no-cache"); http.Headers.Add("x-access-token", _token); }
/// <summary> /// 单个文件上传 /// </summary> /// <param name="newBucket"></param> /// <param name="path"></param> /// <param name="newOss"></param> private void SingleFileUpload(IOss newOss, string newBucket, string path) { var resume = JsonConvert.DeserializeObject <FormaterResume>(File.ReadAllText(path)); dynamic response; var account = new ResumeRefrence { Id = resume.Reference.Id, Source = resume.Reference.Source }; #region 准备上传简历到数据库 try { response = HttpAPI.PrepareUploadResume(JsonConvert.SerializeObject(account)); if (response.Code.ToString() != "0") { this.AsyncSetLog(this.tbx_Log, $"准备上传简历API,响应信息:{JsonConvert.SerializeObject(response)}"); pathQueue.Enqueue(path); return; } } catch (Exception ex) { pathQueue.Enqueue(path); this.AsyncSetLog(this.tbx_Log, $"{DateTime.Now} 准备上传简历到数据库异常,异常消息:{ex.Message}"); return; } #endregion #region 简历到数据库 try { response = HttpAPI.UploadResume(JsonConvert.SerializeObject(resume)); if (response.Code.ToString() != "0") { var failpath = ConfigurationManager.AppSettings["51Job_UploadFailFiles_Path"] + companyName + Path.GetFileName(path); if (File.Exists(failpath)) { File.Delete(failpath); } File.Move(path, failpath); this.AsyncSetLog(this.tbx_Log, $"上传简历失败!响应信息:{JsonConvert.SerializeObject(response)}"); return; } else { this.AsyncSetLog(this.tbx_Log, $"上传简历成功!已上传:{Interlocked.Increment(ref count)},还剩余:{pathQueue.Count} 份待上传!"); } } catch (Exception ex) { pathQueue.Enqueue(path); this.AsyncSetLog(this.tbx_Log, $"{DateTime.Now} 上传简历到数据库异常,异常消息:{ex.Message}"); return; } finally { HttpAPI.FinishUploadResume(JsonConvert.SerializeObject(account)); } #endregion #region 简历到 OSS var tag = response.Reference.Tag.ToString(); var id = response.Reference.ResumeId.ToString(); var cellphone = response.Reference.Cellphone.ToString(); var email = response.Reference.Email.ToString(); if (tag == "C" || tag == "U") { if (cellphone != "0") { resume.Cellphone = cellphone; resume.Email = email; } using (var stream = new MemoryStream(GZip.Compress(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(resume))))) { try { newOss.PutObject(newBucket, $"{ConfigurationManager.AppSettings["Oss.New.ResumePath"]}{id}", stream); } catch (Exception ex) { this.AsyncSetLog(this.tbx_Log, "上传 OSS 失败!异常信息:" + ex.Message); retryResumeQueue.Enqueue(new Tuple <string, FormaterResume, string>(id, resume, path)); return; } } } var uploadSuccessPath = ConfigurationManager.AppSettings["51Job_UploadSuccessFiles_Path"] + companyName + Path.GetFileName(path); if (File.Exists(uploadSuccessPath)) { File.Delete(uploadSuccessPath); } File.Move(path, uploadSuccessPath); #endregion }
/// <summary> /// 单个文件上传 /// </summary> /// <param name="newBucket"></param> /// <param name="path"></param> /// <param name="newOss"></param> private void SingleFileUpload(IOss newOss, string newBucket, string path) { var resume = JsonConvert.DeserializeObject <Resume>(File.ReadAllText(path)); dynamic response; string tag; var account = new ResumeRefrence { Id = resume.Reference.Id, Source = resume.Reference.Source }; #region 准备上传简历到数据库 try { response = HttpAPI.PrepareUploadResume(JsonConvert.SerializeObject(account)); if (response.Code.ToString() != "0") { this.AsyncSetLog(this.tbx_Log, $"准备上传简历API,响应信息:{JsonConvert.SerializeObject(response)}"); HttpAPI.FinishUploadResume(JsonConvert.SerializeObject(account)); pathQueue.Enqueue(path); return; } } catch (Exception ex) { pathQueue.Enqueue(path); this.AsyncSetLog(this.tbx_Log, $"{DateTime.Now} 准备上传简历到数据库异常,异常消息:{ex.Message}"); HttpAPI.FinishUploadResume(JsonConvert.SerializeObject(account)); return; } #endregion #region 简历到数据库 try { var times = 0; while (true) { response = HttpAPI.UploadResume(JsonConvert.SerializeObject(resume)); if (response.Code.ToString() != "0" && times++ == 0) { HttpAPI.FinishUploadResume(JsonConvert.SerializeObject(account)); continue; } break; } tag = response.Reference.Tag.ToString(); if (response.Code.ToString() != "0") { var failpath = ConfigurationManager.AppSettings["Zhaopin_UploadFailFiles_Path"] + companyName + Path.GetFileName(path); if (File.Exists(failpath)) { File.Delete(failpath); } File.Move(path, failpath); this.AsyncSetLog(this.tbx_Log, $"上传简历失败!响应信息:{JsonConvert.SerializeObject(response)}"); return; } else { if (tag == "C") { Interlocked.Increment(ref insertCount); } if (tag == "U") { Interlocked.Increment(ref updateCount); } this.AsyncSetLog(this.tbx_Log, $"上传简历成功!已上传:{Interlocked.Increment(ref successCount)} C=>{insertCount} U=>{updateCount} 还剩余:{pathQueue.Count} 份待上传!"); } } catch (Exception ex) { pathQueue.Enqueue(path); this.AsyncSetLog(this.tbx_Log, $"{DateTime.Now} 上传简历到数据库异常,异常消息:{ex.Message}"); return; } finally { HttpAPI.FinishUploadResume(JsonConvert.SerializeObject(account)); } #endregion #region 简历到 OSS var id = response.Reference.ResumeId.ToString(); if (tag == "C" || tag == "U") { using (var stream = new MemoryStream(GZip.Compress(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(resume))))) { try { newOss.PutObject(newBucket, $"{ConfigurationManager.AppSettings["Oss.New.ResumePath"]}{id}", stream); } catch (Exception ex) { this.AsyncSetLog(this.tbx_Log, "上传 OSS 失败!异常信息:" + ex.Message); retryResumeQueue.Enqueue(new Tuple <string, Resume, string>(id, resume, path)); return; } } } var uploadSuccessPath = ConfigurationManager.AppSettings["Zhaopin_UploadSuccessFiles_Path"] + companyName; if (!Directory.Exists(uploadSuccessPath)) { Directory.CreateDirectory(uploadSuccessPath); } uploadSuccessPath += Path.GetFileName(path); if (File.Exists(uploadSuccessPath)) { File.Delete(uploadSuccessPath); } File.Move(path, uploadSuccessPath); #endregion }
private void UpdateTickerList() { var marketList = GetMarketList(); List <string> markets = new List <string>(); for (int i = 0; i < marketList.Count; i++) { if (marketList[i].market.ToUpper().Contains("KRW")) { markets.Add(marketList[i].market); } } TickerList = JsonConvert.DeserializeObject <ObservableCollection <Ticker> >(HttpAPI.GetTicker(markets.ToArray())); }
private List <MarketInfo> GetMarketList() { string marketAll = HttpAPI.GetMarketAll(); return(JsonConvert.DeserializeObject <List <MarketInfo> >(marketAll)); }