public bool Log(string txt) { if (string.IsNullOrWhiteSpace(txt)) { return(true); } try { lock (_objLock) { if (_form != null) { _form.ExcuteRecord(txt); } _sb.AppendLine(string.Format(" -->[{0}] [{1},{2}]:{3}", DateTime.Now.ToString("HH:mm:ss.fff"), Thread.CurrentThread.ManagedThreadId.ToString().PadLeft(2, '0'), System.Diagnostics.Process.GetCurrentProcess().Id.ToString().PadLeft(5, '0'), txt)); return(true); } } catch (Exception ex) { new FlashLogger("流程").Fatal("ProcessBase.RecordLog() 出现错误:" + ex.ToString()); } return(false); }
public override void StartRequest() { _form.ExcuteRecord("test"); dynamic c = JsonConvert.DeserializeObject <object>(_request.Param.ToString()); if (c.Type == 1) { try { var cc = (string)c.Js; _form.ExecuteScript(cc); } catch (Exception e) { processBase.SetResult(new ResultModel() { IsSuccess = false, Result = e.ToString() }); return; } } else if (c.Type == 2) { try { var cc = _form.EvaluateScriptAsync((string)c.Js); } catch (Exception e) { processBase.SetResult(new ResultModel() { IsSuccess = false, Result = e.ToString() }); return; } } else if (c.Type == 3) { try { var cc = _form.GetCurrentCookie((string)c.Url); processBase.SetResult(new ResultModel() { IsSuccess = false, Result = cc }); return; } catch (Exception e) { processBase.SetResult(new ResultModel() { IsSuccess = false, Result = e.ToString() }); return; } } else if (c.Type == 4) { try { var url = (string)c.Url; var cookie = (string)c.Cookie; _form.SetCookie(url, cookie); processBase.SetResult(new ResultModel() { IsSuccess = false, Result = "成功" }); return; } catch (Exception e) { processBase.SetResult(new ResultModel() { IsSuccess = false, Result = e.ToString() }); return; } } // //获取网页代码 //var result = this.browser.GetSourceAsync().Result; else if (c.Type == 5) { try { //获取网页代码 _form.Test(null); processBase.SetResult(new ResultModel() { IsSuccess = false, Result = null }); } catch (Exception e) { processBase.SetResult(new ResultModel() { IsSuccess = false, Result = e.ToString() }); return; } } processBase.SetResult(new ResultModel() { IsSuccess = false, Result = "{\"test\":\"登陆失败\"}" }); }