private void OnWebRequestAgentFailure(WebRequestAgent sender, string errorMessage) { if (m_WebRequestFailureEventHandler != null) { m_WebRequestFailureEventHandler(this, new WebRequestFailureEventArgs(sender.Task.SerialId, sender.Task.WebRequestUri, errorMessage, sender.Task.UserData)); } }
private void OnWebRequestAgentStart(WebRequestAgent sender) { if (m_WebRequestStartEventHandler != null) { m_WebRequestStartEventHandler(this, new WebRequestStartEventArgs(sender.Task.SerialId, sender.Task.WebRequestUri, sender.Task.UserData)); } }
private void OnWebRequestAgentSuccess(WebRequestAgent sender, byte[] webResponseBytes) { if (m_WebRequestSuccessEventHandler != null) { m_WebRequestSuccessEventHandler(this, new WebRequestSuccessEventArgs(sender.Task.SerialId, sender.Task.WebRequestUri, webResponseBytes, sender.Task.UserData)); } }
public override string Business(params object[] args) { return(OnBusiness(o => { var s = String.Empty; if (args[(args.Length - 1)].ToString() == "1") { if ("HisUrl2".ConfigValue().IsNullOrEmptyOfVar()) { throw new Exception("appSettings 缺少 HisUrl2 的值"); } //return ToolsContainer.Post("HisUrl2".ConfigValue(), o[1].ToString()); return WebRequestAgent.Post("HisUrl2".ConfigValue(), o[1].ToString()); } else { var x = _HISClient.Invoke("Etrack_ProcInterface", o[0].ToString(), s); if (x[1].ToString().IsNullOrEmptyOfVar()) { throw new Exception("HIS错误:" + x[1].ToString()); } return x[1].ToString(); } }, args)); }
public void Initialize() { WebRequestAgent agent = new WebRequestAgent(); agent.SetEventManager(m_EventManager); m_TaskPool.SetAgent(agent); }
private void OnWebRequestAgentFailure(WebRequestAgent sender, string errorMessage) { if (m_WebRequestFailureEventHandler != null) { WebRequestFailureEventArgs webRequestFailureEventArgs = WebRequestFailureEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, errorMessage, sender.Task.UserData); m_WebRequestFailureEventHandler(this, webRequestFailureEventArgs); ReferencePool.Release(webRequestFailureEventArgs); } }
private void OnWebRequestAgentSuccess(WebRequestAgent sender, byte[] webResponseBytes) { if (m_WebRequestSuccessEventHandler != null) { WebRequestSuccessEventArgs webRequestSuccessEventArgs = WebRequestSuccessEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, webResponseBytes, sender.Task.UserData); m_WebRequestSuccessEventHandler(this, webRequestSuccessEventArgs); ReferencePool.Release(webRequestSuccessEventArgs); } }
private void OnWebRequestAgentStart(WebRequestAgent sender) { if (m_WebRequestStartEventHandler != null) { WebRequestStartEventArgs webRequestStartEventArgs = WebRequestStartEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, sender.Task.UserData); m_WebRequestStartEventHandler(this, webRequestStartEventArgs); ReferencePool.Release(webRequestStartEventArgs); } }
/// <summary> /// 增加 Web 请求代理辅助器。 /// </summary> /// <param name="webRequestAgentHelper">要增加的 Web 请求代理辅助器。</param> public void AddWebRequestAgentHelper(IWebRequestAgentHelper webRequestAgentHelper) { WebRequestAgent agent = new WebRequestAgent(webRequestAgentHelper); agent.WebRequestAgentStart += OnWebRequestAgentStart; agent.WebRequestAgentSuccess += OnWebRequestAgentSuccess; agent.WebRequestAgentFailure += OnWebRequestAgentFailure; m_TaskPool.AddAgent(agent); }
private void OnWebRequestAgentError(WebRequestAgent sender, string errMsg) { m_Task.Status = WebRequestTaskStatus.Error; m_Task.Done = true; if (m_EventManager != null) { m_EventManager.Fire(this, WebRequestFailureEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, errMsg, sender.Task.UserData)); } }
private void OnWebRequestAgentSuccess(WebRequestAgent sender) { m_Task.Status = WebRequestTaskStatus.Done; if (m_EventManager != null) { m_EventManager.Fire(this, WebRequestSuccessEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, m_UnityWebRequest.downloadHandler.data, sender.Task.UserData)); } m_Task.Done = true; }
private void CombineDownloadList(JsonNode root, Dictionary <string, DownState> downloaded) { m_waitingList.Clear(); m_root = root; JsonNode curVer = FileManager.bundles; m_writer = new StreamWriter(m_temPath + "download.list", false); var assets = (Dictionary <string, JsonNode>)root["BundleManifest"]; var eor = assets.GetEnumerator(); while (eor.MoveNext()) { DownState state; if (downloaded.TryGetValue(eor.Current.Value["BundleName"].ToString(), out state)) { if (state.Hash == eor.Current.Value["Hash"].ToString()) { if (state.IsDone) { m_writer.Write(eor.Current.Value["BundleName"].ToString() + ":" + state.Hash + ":1\n"); } else { m_writer.Write(eor.Current.Value["BundleName"].ToString() + ":" + state.Hash + "\n"); m_waitingList.Enqueue(eor.Current.Value); } continue; } File.Delete(m_temPath + eor.Current.Value["BundleName"].ToString()); } if (curVer[eor.Current.Key].IsTable() && curVer[eor.Current.Key]["Hash"].ToString() == eor.Current.Value["Hash"].ToString()) { continue; } m_waitingList.Enqueue(eor.Current.Value); } eor.Dispose(); if (m_webAgent == null) { m_webAgent = new WebRequestAgent(); } m_webAgent.onDownloadSuccess = StartDown; m_webAgent.onDownloadFailed = () => { GLog.E("Down Error"); }; StartDown(); }
private void PaymentRequest() { try { string ApiKey = "apikey"; //BOLD.Pay Bussiness ApiKey string Username = "******"; //BOLD.Pay Administrator Username string CustIp = "1.2.3.4"; //Get customer devices IP address string PymtMethod = "4"; //1: Online Banking, 2: Credit Card, 3: E-Wallet, 4: All payment methods available in BOLD.Pay, 5: Over-The-Counter string CurrencyCode = "1"; //1: MYR string Amount = lblTotal.Text; //Payment Amount string Description = "Product 1, 2, 3 and 4"; //Order Description string CustName = txtFirstName.Text + " " + txtLastName.Text; //Customer's name string CustEmail = txtEmail.Text.Trim(); //Email address (format: [email protected]) string CustPhone = txtPhoneNumber.Text.Trim(); //Customer Phone Number string OrderNumber = "ON00001"; //Reference number / Invoice number for this order. string PayId = DateTime.Now.ToFileTime().ToString(); //Unique PayID per transaction string CallBackUrl = "http://callbackurl.aspx"; //Browser redirect URL which receives payment response from BOLD.Pay API when transaction is completed string NotificationUrl = "http://notificationurl.aspx"; //Server-to-server URL as an additional link to merchant’s website to be informed of transaction status string AccessToken = Username + PymtMethod + Amount + CustIp + PayId + CallBackUrl + NotificationUrl + ApiKey; AccessToken = AccessToken.ToUpper().MD5Hash(); string boldPayUrl = "https://pay.etracker.cc/BoldPayApi/PaymentRequest"; StringBuilder param = new StringBuilder(); param.Append("?AccessToken=").Append(AccessToken); param.Append("&APIKey=").Append(ApiKey); param.Append("&Username="******"&CustIP=").Append(CustIp); param.Append("&PymtMethod=").Append(PymtMethod); param.Append("&CurrencyCode=").Append(CurrencyCode); param.Append("&Amount=").Append(Amount); param.Append("&Description=").Append(Description); param.Append("&CustName=").Append(CustName); param.Append("&CustEmail=").Append(CustEmail); param.Append("&CustPhone=").Append(CustPhone); param.Append("&OrderNumber=").Append(OrderNumber); param.Append("&PayID=").Append(PayId); param.Append("&CallBackUrl=").Append(CallBackUrl); param.Append("&NotificationUrl=").Append(NotificationUrl); boldPayUrl = boldPayUrl + param; Response.Redirect(WebRequestAgent.HttpGet(boldPayUrl, false)); } catch (Exception ex) { } }
private void DownLoadManifest(Callback_0 onSuccess) { if (m_webAgent == null) { m_webAgent = new WebRequestAgent(); } if (File.Exists(m_temPath + Config.BundleManifest)) { File.Delete(m_temPath + Config.BundleManifest); } long length = m_webAgent.GetLength(m_remoteUrl + Config.BundleManifest); m_webAgent.onDownloadSuccess = onSuccess; m_webAgent.onDownloadFailed = () => { GLog.E("下载manifest失败,提示重试"); }; StartCoroutine(m_webAgent.Download(m_remoteUrl + Config.BundleManifest, m_temPath + Config.BundleManifest, length)); }