Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        protected override void OnProcess(Action.IAction action)
        {
            //LoggerManager.Debug("Clear TaskStorage.Storage");
            LoggerManager.Debug(action.AutomationActionData);

            this.ClearData();
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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));
            }
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        protected override void OnProcess(IAction action)
        {
            BrowserAction pageAction = action as BrowserAction;

            webBrowser.Navigate(pageAction.Url);

            LoggerManager.Debug(action.AutomationActionData);
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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();
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
        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();
            }
        }
Ejemplo n.º 18
0
        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);
            }
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        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);
            }
        }
Ejemplo n.º 21
0
        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);
            }
        }
Ejemplo n.º 22
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 23
0
        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);
            }
        }
Ejemplo n.º 24
0
        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);
            }
        }
Ejemplo n.º 25
0
 protected override void OnProcess(Action.IAction action)
 {
     LoggerManager.Debug(action.AutomationActionData);
 }
Ejemplo n.º 26
0
 public void PoiSearch_SearchFailure(string errorInfo)
 {
     LoggerManager.Debug(errorInfo);
     m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.PoiSearch_SearchFailure, errorInfo);
 }
Ejemplo n.º 27
0
 public void PoiSearch_SearchSuccess(string jsonResult)
 {
     LoggerManager.Debug(jsonResult);
     m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.PoiSearch_SearchSuccess, jsonResult);
 }
Ejemplo n.º 28
0
 public void Photo_SelectPhotoDone(string path)
 {
     LoggerManager.Debug(path);
     m_PlatformMsgManageModule.TriggerPlatformMessage(PlatformMessageManageModule.Photo_SelectPhotoDone, path);
 }
Ejemplo n.º 29
0
 /// <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);
 }
Ejemplo n.º 30
0
        protected void DebugElement(HtmlElement element)
        {
#if DEBUG
            LoggerManager.Debug(LoggerManager.FormatElement(element));
#endif
        }