static void Main(string[] args) { var profile = new DefaultProfile { APIKey = "", APISecret = "" }; var client = new DefaultApiClient(profile); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); IExample detect = new FaceDetectExample(); detect.Run(client); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds + " ms"); //IExample compare = new FaceCompareExample(); //compare.Run(client); //var request = new CreateFaceSetRequest //{ // DisplayName = "Test", //}; //var response = client.GetResponse(request); //var request = new AddFaceToFaceSetRequest //{ // FaceSetToken = "c50c0ef5c877b1184fc2899c54721226", // FaceTokens = new System.Collections.Generic.List<string>() { "043111b20a7d6b29498991c8ff4071f0" }, //}; //var response = client.GetResponse(request); Console.ReadLine(); }
public void NotifyPaid(OPC_Sale saleOrder, bool enbaleCashingTimeRange, TimeSpan bein, TimeSpan end) { if (enbaleCashingTimeRange && !IsInCashingTimeRange(bein, end)) { return; } Logger.InfoFormat("Notify paid to it sale order no:{0}", saleOrder.SaleOrderNo); var apiClient = new DefaultApiClient(); var rsp = apiClient.Post(new OrderNotifyRequest() { Data = new PaidOrderNotificationEntity(saleOrder).CreateNotifiedEntity() }, true); if (rsp == null) { NotifyFailed(saleOrder, SaleOrderNotificationStatus.PaidFailed, apiClient.ErrorList()); return; } if (!rsp.Status) { Logger.Error(rsp.Data); Logger.Error(rsp.Message); var errors = new List <string> { rsp.Data, rsp.Message }; errors.AddRange(apiClient.ErrorList().Where(x => !string.IsNullOrEmpty(x))); NotifyFailed(saleOrder, SaleOrderNotificationStatus.PaidFailed, errors); return; } SaleOrderNotified(saleOrder, SaleOrderNotificationStatus.Paid); }
private void button7_Click(object sender, EventArgs e) { var appId = tb_appId.Text.Trim(); var appSecret = tb_appSecret.Text.Trim(); ApiAccessTokenManager.Instance.SetAppIdentity(appId, appSecret); IApiClient client = new DefaultApiClient(); var request = new MediaUploadRequest { AccessToken = ApiAccessTokenManager.Instance.GetCurrentToken(), MediaType = GetMediaType(), FilePath = textBox1.Text }; var response = client.Execute(request); if (response.IsError) { MessageBox.Show("错误:" + response.ErrorMessage); } else { MessageBox.Show("保存成功!mediaid:" + response.MediaId); } }
public void GetAccessTokenCore() { var appid = new AppIdentication("wx7fc05579394bd02c", "26f8f072c53e97d0033e3589e7de4e84"); var request = new AccessTokenRequest(appid); IApiClient client = new DefaultApiClient(); var response = client.Execute(request); Console.WriteLine(response.ToString()); }
public void TestMethod1() { IApiClient client = new DefaultApiClient("http://apis.7moor.com", "xxxx", "xxxx"); //ºô³ö CallDialoutRequest callDialoutRequest = new CallDialoutRequest("8002", "18888888888"); CallDialoutResponse callDialoutResponse = client.Execute(callDialoutRequest); Assert.IsNull(callDialoutResponse); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainMenuView); System.Threading.ThreadPool.SetMinThreads(30, 30); //Arrange var authenticationOptions = new AuthenticationOptions() { BaseUri = new Uri("http://www.glueware.nl/klootzakken/kz/") }; var authenticationService = new AuthenticationService(authenticationOptions); var apiClientOptions = new ApiClientOptions() { BaseUri = new Uri("http://www.glueware.nl/klootzakken/kzapi/") }; var apiClient = new DefaultApiClient(authenticationService, apiClientOptions); var lobbyStatusService = new LobbyStatusService(apiClient); var lobbyActionService = new LobbyActionService(apiClient); //Act string randomString = Guid.NewGuid().ToString("n").Substring(0, 8); var isCreateGameSucces = await lobbyActionService.CreateLobbyAsync(randomString); var lobbies = await lobbyStatusService.GetLobbiesAsync(); var createdLobby = lobbies.Find(l => l.Name.Equals(randomString)); var joinedToLobby = await lobbyActionService.JoinLobbyAsync(createdLobby.Id); var myLobbyies = await lobbyStatusService.GetMyLobbiesAsync(); var justJoinedMyLobby = myLobbyies.Find(l => l.Name.Equals(randomString)); var gameIsStarted = await lobbyActionService.StartGameForLobbyAsync(createdLobby.Id); //Assert myGames = new List <string> { "GetLobbiesAsync() - " + randomString.Equals(createdLobby.Name).ToString(), "GetMyLobbiesAsync() - " + randomString.Equals(justJoinedMyLobby.Name).ToString(), "CreateLobbyAsync() - " + isCreateGameSucces.ToString(), "JoinLobbyAsync() - " + joinedToLobby.ToString(), "StartGameForLobbyAsync() - " + gameIsStarted.ToString() }; myGamesListView = FindViewById <ListView>(Resource.Id.myGamesListView); myGamesListView.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myGames); Button createGame = FindViewById <Button>(Resource.Id.btnCreateGame); createGame.Click += delegate { StartActivity(typeof(MainActivity)); }; }
public void NotifyPaid(OPC_RMA saleRMA) { var apiClient = new DefaultApiClient(); var rsp = apiClient.Post(new OrderNotifyRequest { Data = new PaidRMANotificationEntity(saleRMA).CreateNotifiedEntity() }); if (!rsp.Status) { Logger.Error(rsp.Data); Logger.Error(rsp.Message); return; } SaleRMAPaidNotified(saleRMA); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainMenuView); var authenticationOptions = new AuthenticationOptions() { BaseUri = new Uri("http://10.0.2.2:5000/") }; var authenticationService = new AuthenticationService(authenticationOptions); var apiClientOptions = new ApiClientOptions() { BaseUri = new Uri("http://10.0.2.2:5000/") }; var apiClient = new DefaultApiClient(authenticationService, apiClientOptions); var lobbyStatusService = new LobbyStatusService(apiClient); var lobbyActionService = new LobbyActionService(apiClient); bool isCreatingLobbySucces = false; List <LobbyView> lobbyViews = null; try { isCreatingLobbySucces = await lobbyActionService.CreateLobbyAsync("dani2Lobby"); lobbyViews = await lobbyStatusService.GetLobbiesAsync(); } catch (Exception e) { Console.Write(e); } myGamesListView = FindViewById <ListView>(Resource.Id.myGamesListView); myGames = new List <string> { isCreatingLobbySucces.ToString() }; myGamesListView.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myGames); Button createGame = FindViewById <Button>(Resource.Id.btnCreateGame); createGame.Click += delegate { StartActivity(typeof(MainActivity)); //TODO: make a new activity for creating new game }; }
public void TestMethod1() { var client = new DefaultApiClient("http://guide.intime.com.cn:8008/production-o2o-rs/api/", "intime", "intime"); var reponse = client.Post(new GetProductsRequest() { Data = new GetProductsRequestData() { PageIndex = 1, LastUpdate = "2013-11-11", PageSize = 20 } }); client.Post(new GetProductsRequest() { Data = new GetProductsRequestData() { PageIndex = 1, LastUpdate = "2013-11-15", PageSize = 20 } }); client.Post(new GetStoresRequest() { Data = new GetStoresRequestData() { PageIndex = 1, PageSize = 20 } }); client.Post(new GetProductImagesRequest() { Data = new GetProductImagesRequestData() { PageIndex = 1, PageSize = 20, LastUpdate = "2013-11-15" } }); String message = reponse.Message; }
public void NotifyCreate(OPC_Sale saleOrder) { var entity = new CreateOrderNotificationEntity(saleOrder).CreateNotifiedEntity(); var apiClient = new DefaultApiClient(); try { var rsp = apiClient.Post(new OrderNotifyRequest() { Data = entity }, true); if (rsp == null) { Logger.Error("通知订单失败,信息部返回NULL"); NotifyFailed(saleOrder, SaleOrderNotificationStatus.CreateFailed, apiClient.ErrorList()); return; } if (!rsp.Status) { Logger.Error(rsp.Data); Logger.Error(rsp.Message); var errors = new List <string> { rsp.Data, rsp.Message }; errors.AddRange(apiClient.ErrorList().Where(x => !string.IsNullOrEmpty(x))); NotifyFailed(saleOrder, SaleOrderNotificationStatus.CreateFailed, errors); return; } } catch (Exception e) { Logger.Error(e); NotifyFailed(saleOrder, SaleOrderNotificationStatus.ExceptionThrow, new[] { e.Message }); return; } SaleOrderNotified(saleOrder, SaleOrderNotificationStatus.Create); }
private void button5_Click(object sender, EventArgs e) { var appId = tb_appId.Text.Trim(); var appSecret = tb_appSecret.Text.Trim(); if (String.IsNullOrEmpty(appId) || String.IsNullOrEmpty(appSecret)) { MessageBox.Show("请输入appId和appSecret"); return; } if (Rows == null || !Rows.Any()) { MessageBox.Show("请添加菜单"); return; } ApiAccessTokenManager.Instance.SetAppIdentity(appId, appSecret); IApiClient client = new DefaultApiClient(); var request = new MenuCreateRequest() { AccessToken = ApiAccessTokenManager.Instance.GetCurrentToken(), Buttons = BuildButton() }; var response = client.Execute(request); if (response.IsError) { MessageBox.Show(response.ToString()); return; } else { MessageBox.Show("菜单生成成功,一般有24小时缓存时间,也可以直接取消关注再关注直接查看效果"); } }
public void ProcessRequest(HttpContext context) { var accesstoken = CookiesHelper.GetCookie(accesstokenKey); SnsOAuthAccessTokenResponse AccessToken = null; var m_client = new DefaultApiClient(); var m_appIdent = new AppIdentication(wxappid, wxappsecret); string State = context.Request["state"]; string jumpUrl = "index.html"; try { if (accesstoken == null) { string code = context.Request["Code"]; var request = new SnsOAuthAccessTokenRequest { AppID = m_appIdent.AppID, AppSecret = m_appIdent.AppSecret, Code = code }; AccessToken = m_client.Execute(request); if (AccessToken.IsError) { throw new Exception("获取网页授权accesstoken失败。" + JsonHelper.ReBuilder(request) + "\r\n" + AccessToken.ErrorMessage); } CookiesHelper.AddCookie("webpage_accesstoken", JsonHelper.ReBuilder(AccessToken), DateTime.Now.AddSeconds(AccessToken.ExpiresIn - 600)); } else { AccessToken = JsonHelper.Build <SnsOAuthAccessTokenResponse>(accesstoken.Value); } string unionid = AccessToken.UnionId; if (String.IsNullOrEmpty(unionid)) { unionid = AccessToken.OpenId; } string openid = AccessToken.OpenId; var query = new RequestOperation <string>(); query.Header = new HeaderInfo() { DeviceID = 5, DisplayName = "customer", UserID = 1 }; query.Body = unionid; var service = new CustomerBP(); var data = service.LoginByWechatAccount(query); //不存在此用户 if (data.ErrCode == 1) { var wexinInfo = new SnsUserInfoRequest { OAuthToken = AccessToken.AccessToken, OpenId = AccessToken.OpenId, Lang = Language.CN }; var userinfo_res = m_client.Execute(wexinInfo); if (userinfo_res.IsError) { throw new Exception("获取用户信息失败2。" + JsonHelper.ReBuilder(wexinInfo) + "\r\n" + JsonHelper.ReBuilder(userinfo_res)); } #region 注册 string url = HttpUtility.UrlDecode(State); int invateUserId = 0; if (!string.IsNullOrEmpty(State)) { url = domian + unescape(url); invateUserId = getInveteUser(url); } var register = new RequestOperation <RegisterData>(); register.Header = query.Header; register.Body = new RegisterData(); register.Body.Account = ""; register.Body.WechatAccount = unionid; register.Body.QQAccount = ""; register.Body.Face = userinfo_res.HeadImageUrl; register.Body.NickName = register.Body.Name = userinfo_res.NickName; register.Body.Password = "******"; var register_res = service.Register(register); if (register_res.ErrCode != 0) { throw new Exception("注册用户失败:" + register_res.Message); } LoginManage.SaveUserWeixinOpenId(userinfo_res.OpenId); LoginManage.SaveUserInfo(register_res.Body.UserID); if (!string.IsNullOrEmpty(State)) { jumpUrl = replaceInveteUserParam(url); } #endregion } else { //不准修改,此处用于微信支付!!! LoginManage.SaveUserWeixinOpenId(AccessToken.OpenId); LoginManage.SaveUserInfo(data.Body.UserID); if (!string.IsNullOrEmpty(State)) { string url = domian + HttpUtility.UrlDecode(State); jumpUrl = replaceInveteUserParam(url); } } } catch (Exception ex) { Logger.WriteException("【微信网页授权】", ex, ""); } context.Response.Redirect(jumpUrl); }