static void Main011(string[] args) { var info = new { pageIndex = 1, pageSize = 10, projectCode = "ff8080817682f02601768933e2540009", buildCorpCode = "91420100177738297E" }; JObject result = null; try { HjApi api = new HjApi() { Endpoint = "open/api/get", Method = "Project.Query", Version = "1.0" }; result = HjApiCaller.CallOpenApi(api, info); } catch (Exception e) { throw; } Console.WriteLine(result?.ToString()); }
/// <summary> /// 查询上传结果。 /// </summary> /// <param name="requestSerialCode"></param> private void QueryResult(string requestSerialCode) { string result = ""; string status = "01"; string code = "0"; string message = "调用成功"; #region 轮询上传结果 TimerCallback callback = (state) => { #region 查询上传处理结果 HjApi api = new HjApi() { Endpoint = "open/api/async", Method = "Async", Version = "2.1" }; var res = HjApiCaller.CallOpenApi(api, new { requestSerialCode }); #endregion string sts = res["data"]["status"]?.ToString(); if (invokeCount == maxCount || AsyncProcessStatus.处理成功.Description().Equals(sts)) { // 查询完成 result = res["data"]["result"]?.ToString(); status = res["data"]["status"]?.ToString(); code = res["code"]?.ToString(); message = res["message"]?.ToString(); invokeCount = 0; autoEvent.Set(); } }; var stateTimer = new Timer(callback, requestSerialCode, 1000, 1000); autoEvent.WaitOne(); stateTimer.Dispose(); #endregion //#region 封装上传结果 //UploadCompletedEventArgs e = new UploadCompletedEventArgs //{ // Result = result, // Status = status, // Code = code, // Message = message //}; //OnUploadCompleted(e); //#endregion }
static void Main(string[] args) { SetConsoleWindowVisibility(Visible); notifyIcon.DoubleClick += (s, e) => { Visible = !Visible; SetConsoleWindowVisibility(Visible); }; notifyIcon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); notifyIcon.Visible = true; notifyIcon.Text = "实名制信息推送程序【鄂州市劳保】"; // 初始化上传标段参数 if (!HjApiCaller.TryInit()) { Environment.Exit(0); } try { Task.Factory .StartNew(StartUpload) .ContinueWith(t => { anyExceptions = (t.Exception != null); Application.Exit(); }); } catch (Exception e) { LogUtils4Error.Logger.Error(e.Message); } finally { Application.Run(); notifyIcon.Visible = false; // 1、日志记录完成 LogUtils4Debug.Logger.Debug($"================={ HjApiCaller.ProjectName },已上传完成!================="); LogUtils.Logger.Info($"{ HjApiCaller.ProjectName },{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") },上传完成并{ (anyExceptions ? "有" : "无")}异常发生"); DBHelperMySQL.Dispose(); // 2、打开新的程序 var p = Process.Start(Assembly.GetExecutingAssembly().Location); Environment.Exit(0); } }
/// <summary> /// 异步上传数据。 /// </summary> /// <param name="info"></param> private string UploadAsync(EnterpriseInfo info) { string requestSerialCode = null; try { HjApi api = new HjApi() { Endpoint = "open/api/get", Method = "Corp.Upload", Version = "2.1" }; var result = HjApiCaller.CallOpenApi(api, info); requestSerialCode = result["data"]["requestSerialCode"]?.ToString(); } catch (Exception e) { throw; } return(requestSerialCode); }
public void Execute() { this.Output = HjApiCaller.CallOpenApi(this.api, this.input); }