protected override void OnProcess(Action.IAction action) { SendKeyAction sendKeyAction = action as SendKeyAction; if (sendKeyAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); HtmlElement element = this.GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } this.Call <HtmlElement>(delegate(HtmlElement e) { e.Focus(); SendKey(sendKeyAction); }, element); }
protected override void OnProcess(Action.IAction action) { KeyboardAction keyboardAction = action as KeyboardAction; if (keyboardAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); HtmlElement element = this.GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } if (keyboardAction.KeyDown) { this.Call <HtmlElement>(Down, element); } if (keyboardAction.KeyUp) { this.Call <HtmlElement>(Up, element); } }
public override bool Add(OutSideMapEntity entity) { var description = "添加外部地址映射表"; try { var sql = @"INSERT INTO OutSideMap(OutSideUrl,OutSideUrlMd5,UrlType,CreatedTime) VALUES(@OutSideUrl,@OutSideUrlMd5,@UrlType,getdate());"; IDataParameter[] parameters = { new SqlParameter("@OutSideUrl", SqlDbType.NVarChar, 1024) { Value = entity.OutSideUrl }, new SqlParameter("@OutSideUrlMd5", SqlDbType.VarChar, 32) { Value = entity.OutSideUrlMd5 }, new SqlParameter("@UrlType", SqlDbType.Int, 4) { Value = entity.UrlType } }; LoggerManager.Debug(GetType().Name, $"{description},sql:{sql}{Environment.NewLine}参数:{entity.SerializeToJSON()}"); return(DataBaseManager.MainDb().ExecuteNonQuery(sql, parameters).CInt(0, false) > 0); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
protected override void OnProcess(IAction action) { base.OnProcess(action); LoggerManager.Debug(action.AutomationActionData); TextAction textAction = action as TextAction; HtmlElement element = GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } string value = null; if (!string.IsNullOrEmpty(textAction.Attrbute)) { value = element.GetAttribute(textAction.Attrbute); } if (!string.IsNullOrEmpty(textAction.AttrbuteRegex)) { Match match = Regex.Match(value, textAction.AttrbuteRegex, RegexOptions.IgnoreCase); if (match.Success) { value = match.Groups[1].Value; } } this.SaveData <string>(textAction.TextSaveKey, value); }
protected override void OnProcess(Action.IAction action) { //LoggerManager.Debug("Clear TaskStorage.Storage"); LoggerManager.Debug(action.AutomationActionData); this.ClearData(); }
private void FindXPath(FindAction findElementAction) { if (string.IsNullOrEmpty(findElementAction.XPath)) { return; } LoggerManager.Debug("FindElementTask FindXPath"); HtmlElement element = this.GetData(findElementAction) as HtmlElement; if (element == null) { HtmlDocument document = GetHtmlDocument(findElementAction); if (document == null) { LoggerManager.Debug("FindElementTask HtmlDocument document Error"); return; } element = document.Body; } element = HtmlHelp.SelectHtmlNode(findElementAction.XPath, element); this.SaveData(findElementAction, element); }
private void FindClassName(FindAction findElementAction) { if (string.IsNullOrEmpty(findElementAction.ClassName)) { return; } LoggerManager.Debug("FindElementTask FindClassName"); wholeWordRegex = new Regex(string.Format("\\b{0}\\b", findElementAction.ClassName)); HtmlElement element = this.GetData(findElementAction) as HtmlElement; if (element == null) { HtmlDocument document = GetHtmlDocument(findElementAction); if (document == null) { LoggerManager.Debug("FindElementTask HtmlDocument document Error"); return; } element = document.Body; this.SaveData(findElementAction, FindClassRecusive(element, findElementAction.ClassName)); } else { this.SaveData(findElementAction, FindClassRecusive(element, findElementAction.ClassName)); } }
private void FindID(FindAction findElementAction) { if (!string.IsNullOrEmpty(findElementAction.ID)) { LoggerManager.Debug("FindElementTask FindID"); HtmlElement element = this.GetData(findElementAction) as HtmlElement; if (element == null) { HtmlDocument document = GetHtmlDocument(findElementAction); if (document == null) { LoggerManager.Debug("FindElementTask HtmlDocument document Error"); return; } element = document.GetElementById(findElementAction.ID); } else { element = FindIDRecusive(element, findElementAction.ID); } this.SaveData(findElementAction, element); } }
protected override void OnProcess(IAction action) { BrowserAction pageAction = action as BrowserAction; webBrowser.Navigate(pageAction.Url); LoggerManager.Debug(action.AutomationActionData); }
protected async Task ShutdownAriaIfNoLinksLeft() { var status = await Aria.GetGlobalStat(); var linksInAria = status.NumActive + status.NumStopped + status.NumWaiting; if (linksInAria != 0 || Storage.LinkCount != 0) { return; } LoggerManager.Debug("No links left in storage. Shutting aria down..."); await Aria.Shutdown(); }
protected override void OnProcess(Action.IAction action) { base.OnProcess(action); AttributeAction attributeAction = action as AttributeAction; if (attributeAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); SetValue(attributeAction); }
protected override void OnProcess(Action.IAction action) { TimerAction timerAction = action as TimerAction; if (timerAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); if (endDate == DateTime.MinValue) { endDate = DateTime.Now.AddSeconds(timerAction.Seconds); } }
protected async Task RemoveDownloadResult(string gid) { try { await Aria.RemoveDownloadResult(gid); LoggerManager.Debug($"Removed gid #{gid}"); } catch (Exception ex) { LoggerManager.Error(ex, "Error removing download result!"); } finally { await ShutdownAriaIfNoLinksLeft(); } }
protected override void OnProcess(Action.IAction action) { WaitAction waitAction = action as WaitAction; if (waitAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); if (waitAction.Seconds > 0) { Sleep(waitAction.Seconds * 1000); } if (waitAction.Milliseconds > 0) { Sleep(waitAction.Milliseconds); } }
protected override void OnProcess(Action.IAction action) { ScriptAction scriptAction = action as ScriptAction; if (scriptAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); if (!string.IsNullOrEmpty(scriptAction.ScriptContent)) { object[] args = new object[1]; args[0] = scriptAction.ScriptContent; this.Call <WebBrowserEx>(delegate(WebBrowserEx ex) { ex.Document.InvokeScript("eval", args); }, this.webBrowser); } }
public override bool Exist(long id) { var description = "检查外部地址映射表是否存在"; try { var sql = @"IF EXISTS(SELECT Id FROM OutSideMap with(nolock) WHERE ID=@Id) BEGIN SELECT 1 END ELSE BEGIN SELECT 0 END"; IDataParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt, 8) { Value = id }, }; LoggerManager.Debug(GetType().Name, $"{description},sql:{sql}{Environment.NewLine}参数:id={id}"); return(DataBaseManager.MainDb().ExecuteScalar(sql, parameters).CInt(0, false) > 0); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
protected override void OnProcess(Action.IAction action) { LoggerManager.Debug(action.AutomationActionData); ClearHistoryAction clearHistoryAction = action as ClearHistoryAction; if (clearHistoryAction.ClearHistoryType == ClearHistoryType.Cookie) { Win32API.IE_ClearCookie(); } else if (clearHistoryAction.ClearHistoryType == ClearHistoryType.History) { Win32API.IE_ClearHistory(); } else if (clearHistoryAction.ClearHistoryType == ClearHistoryType.All) { Win32API.IE_ClearAll(); } else if (clearHistoryAction.ClearHistoryType == ClearHistoryType.AllPlus) { Win32API.IE_ClearAllPlus(); } }
protected override void OnProcess(IAction action) { FindAction findElementAction = action as FindAction; if (findElementAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); if (findElementAction.Combine) { FindContidion(findElementAction); } else { FindID(findElementAction); FindClassName(findElementAction); FindUrl(findElementAction); FindXPath(findElementAction); } }
public override bool Delete(long id) { var description = "根据id删除外部地址映射表"; try { var sql = @"DELETE OutSideMap WHERE Id=@Id"; IDataParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt, 8) { Value = id }, }; LoggerManager.Debug(GetType().Name, $"{description}sql:{sql}{Environment.NewLine}参数:id={id}"); return(DataBaseManager.MainDb().ExecuteNonQuery(sql, parameters).CInt(0, false) > 0); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
public OutSideMapEntity GetByOutSideUrlMd5(string outSideUrlMd5) { var description = "根据外部地址查询映射表"; try { var sql = @"SELECT * FROM OutSideMap WITH(NOLOCK) WHERE OutSideUrlMd5=@OutSideUrlMd5"; IDataParameter[] parameters = { new SqlParameter("@OutSideUrlMd5", SqlDbType.VarChar) { Value = outSideUrlMd5 }, }; LoggerManager.Debug(GetType().Name, $"{description}sql:{sql}{Environment.NewLine}参数:outSideUrlMd5={outSideUrlMd5}"); return(RPoney.Data.ModelConvertHelper <OutSideMapEntity> .ToModel(DataBaseManager.MainDb().ExecuteFillDataTable(sql, parameters))); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(null); } }
public override OutSideMapEntity Get(long id) { var description = "根据id查询外部地址映射表"; try { var sql = @"SELECT * FROM OutSideMap WITH(NOLOCK) WHERE Id=@Id"; IDataParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt, 8) { Value = id }, }; LoggerManager.Debug(GetType().Name, $"{description}sql:{sql}{Environment.NewLine}参数:id={id}"); return(RPoney.Data.ModelConvertHelper <OutSideMapEntity> .ToModel(DataBaseManager.MainDb().ExecuteFillDataTable(sql, parameters))); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(null); } }
private void FindUrl(FindAction findElementAction) { if (string.IsNullOrEmpty(findElementAction.Url)) { return; } LoggerManager.Debug("FindElementTask FindUrl"); HtmlElement element = this.GetData(findElementAction) as HtmlElement; if (element == null) { HtmlDocument document = GetHtmlDocument(findElementAction); if (document == null) { LoggerManager.Debug("FindElementTask HtmlDocument document Error"); return; } element = document.Body; } HtmlElementCollection elementCollection = element.GetElementsByTagName("a"); if (elementCollection != null && elementCollection.Count > 0) { foreach (HtmlElement find in elementCollection) { if (find.GetAttribute("href") == findElementAction.Url) { this.SaveData(findElementAction, find); break; } } } }
protected override void OnProcess(IAction action) { base.OnProcess(action); HtmlElement element = this.GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } LoggerManager.Debug(action.AutomationActionData); ClickAction clickAction = action as ClickAction; if (clickAction == null) { return; } if (clickAction.Click) { LoggerManager.Debug("Trigger Click"); this.Call <HtmlElement>(Click, element); } if (clickAction.ClickNew) { LoggerManager.Debug("Trigger ClickNew"); this.Call <HtmlElement>(ClickNew, element); } if (clickAction.MouseClick) { LoggerManager.Debug("Trigger MouseClick"); this.Call <HtmlElement>(MouseClick, element); } }
public override bool Update(OutSideMapEntity entity) { var description = "更新外部地址映射表"; try { var sql = @"UPDATE OutSideMap SET OutSideUrl=@OutSideUrl, OutSideUrlMd5=@OutSideUrlMd5, UrlType=@UrlType, WHERE Id=@Id ; "; IDataParameter[] parameters = { new SqlParameter("@OutSideUrl", SqlDbType.NVarChar, 1024) { Value = entity.OutSideUrl }, new SqlParameter("@OutSideUrlMd5", SqlDbType.VarChar, 32) { Value = entity.OutSideUrlMd5 }, new SqlParameter("@UrlType", SqlDbType.Int, 4) { Value = entity.UrlType } }; LoggerManager.Debug(GetType().Name, $"{description},sql:{sql}{Environment.NewLine}参数:{entity.SerializeToJSON()}"); return(DataBaseManager.MainDb().ExecuteNonQuery(sql, parameters).CInt(0, false) > 0); } catch (Exception ex) { LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
protected override void OnProcess(Action.IAction action) { LoggerManager.Debug(action.AutomationActionData); }
public void PoiSearch_SearchFailure(string errorInfo) { LoggerManager.Debug(errorInfo); m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.PoiSearch_SearchFailure, errorInfo); }
public void PoiSearch_SearchSuccess(string jsonResult) { LoggerManager.Debug(jsonResult); m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.PoiSearch_SearchSuccess, jsonResult); }
public void Photo_SelectPhotoDone(string path) { LoggerManager.Debug(path); m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.Photo_SelectPhotoDone, path); }
/// <summary> /// 当android端检查到网络变化的时候,会发送通知,networkName为网络连接类型名,有四种不同的类型名 /// wifi : WiFi网络 /// ethernet : 有线网络 /// mobile : 移动网络 /// unavailable : 不可用的网络连接 /// </summary> /// <param name="networkName"></param> public void Network_NetworkChanged(string networkName) { LoggerManager.Debug(networkName); m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.Network_NetworkChanged, networkName); }
protected void DebugElement(HtmlElement element) { #if DEBUG LoggerManager.Debug(LoggerManager.FormatElement(element)); #endif }