protected override string DoImpl()
        {
            var parentKey      = this.ExecutedCommand.Parameters["ID"].ToString();
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();

            var parent = this.Automator.ElementsRegistry.GetRegisteredElement(parentKey);

            AutomationElement[] elements;

            if (searchStrategy.Equals("xpath"))
            {
                elements = ByXpath.FindAllByXPath(searchValue, parent.FlaUIElement);
            }
            else
            {
                var condition = ByHelper.GetStrategy(searchStrategy, searchValue);

                elements = parent.FlaUIElement.FindAllDescendants(condition);
            }

            var flaUiDriverElementList = elements
                                         .Select <AutomationElement, FlaUIDriverElement>((Func <AutomationElement, FlaUIDriverElement>)(x => new FlaUIDriverElement(x)))
                                         .ToList <FlaUIDriverElement>();

            var registeredKeys = this.Automator.ElementsRegistry.RegisterElements(flaUiDriverElementList);

            var registeredObjects = registeredKeys.Select(e => new JsonElementContent(e));

            return(this.JsonResponse(ResponseStatus.Success, registeredObjects));
        }
        protected override string DoImpl()
        {
            var dataGridKey    = this.ExecutedCommand.Parameters["ID"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();

            var strategy = ByHelper.GetStrategy(searchStrategy, searchValue);

            var comboBox = this.Automator.ElementsRegistry.GetRegisteredElement(dataGridKey).ToComboBox();

            CruciatusElement element;

            try
            {
                element = comboBox.ScrollTo(strategy);
            }
            catch (CruciatusException exception)
            {
                return(this.JsonResponse(ResponseStatus.NoSuchElement, exception));
            }

            var elementKey = this.Automator.ElementsRegistry.RegisterElement(element);

            return(this.JsonResponse(ResponseStatus.Success, new JsonElementContent(elementKey)));
        }
Example #3
0
        public IEnumerable <string> FindElements(CruciatusElement parent, string searchStrategy, string searchValue)
        {
            var strategy = ByHelper.GetStrategy(searchStrategy, searchValue);
            var elements = parent.FindElements(strategy);

            return(this.RegisterElements(elements));
        }
Example #4
0
        protected override string DoImpl()
        {
            var parentKey      = this.ExecutedCommand.Parameters["ID"].ToString();
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();

            var parent = this.Automator.ElementsRegistry.GetRegisteredElement(parentKey);

            AutomationElement element;

            if (searchStrategy.Equals("xpath"))
            {
                element = ByXpath.FindFirstByXPath(searchValue, parent.FlaUIElement);
            }
            else
            {
                var condition = ByHelper.GetStrategy(searchStrategy, searchValue);

                element = parent.FlaUIElement.FindFirstDescendant(condition);
            }

            if (element == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }

            var registeredKey    = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(element));
            var registeredObject = new JsonElementContent(registeredKey);

            return(this.JsonResponse(ResponseStatus.Success, registeredObject));
        }
Example #5
0
        private static DateTime?OpenTime      = null; //开奖时间

        public static void QqSsc()
        {
            try
            {
                //http://api.b1cp.com/t?p=json&t=qqffc&token=FF446B723EB25993
                //http://www.b1cp.com/api?p=json&t=txffc&limit=1&token=00fb782bad8e5241
                Log.Debug("开始腾迅分分彩...");

                SysLotteryModel sysLottery = _lotteryDal.GetSysLotteryByCode("qqffc");

                if (sysLottery == null || string.IsNullOrEmpty(sysLottery.ApiUrl))
                {
                    throw new Exception("无效的API配置");
                }

                //Stopwatch sw = new Stopwatch();
                //sw.Start(); //  开始监视代码运行时间

                //如果上期开奖时间大于1分钟
                if (OpenTime.HasValue && OpenTime.Value.AddSeconds(60) > DateTime.Now)
                {
                    return;
                }

                //string url = "http://api.b1cp.com/t?p=json&t=txffc&token=776E371D7EF404E4";
                //IList<ByLottery> data = ByHelper.GetLotteryData(url);
                IList <ByLottery> data = ByHelper.GetLotteryData(sysLottery.ApiUrl);

                //sw.Stop(); //  停止监视
                //Log.DebugFormat("获取腾迅分分彩花费时间: {0}毫秒", sw.Elapsed.Milliseconds);

                foreach (ByLottery lot in data)
                {
                    string openTime = lot.opentime;
                    string openCode = lot.opencode;
                    string expect   = lot.expect; //期号

                    expect = expect.Substring(0, 8) + "-" + expect.Substring(8);

                    //存储开奖号码
                    if (_dal.Update(1005, expect, openCode, openTime, openCode))
                    {
                        OpenTime = Convert.ToDateTime(openTime);  //开奖时间
                        Public.SaveLotteryData2File(1005);        //存储开奖号码到JSON/XML文件
                        LotteryCheck.RunOfIssueNum(1005, expect); //处理开奖信息
                    }
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("腾讯分分彩异常: {0}", ex);
                //new LogExceptionDAL().Save("采集异常", "腾讯分分彩获取开奖数据出错,错误代码:" + ex.Message);
            }
        }
Example #6
0
        public string FindElement(CruciatusElement parent, string searchStrategy, string searchValue)
        {
            var strategy = ByHelper.GetStrategy(searchStrategy, searchValue);
            var element  = parent.FindElement(strategy);

            if (element == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }

            return(this.RegisterElement(element));
        }
Example #7
0
        protected override string DoImpl()
        {
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();

            var strategy = ByHelper.GetStrategy(searchStrategy, searchValue);
            var elements = CruciatusFactory.Root.FindElements(strategy);

            var registeredKeys    = this.Automators.ElementsRegistry.RegisterElements(elements);
            var registeredObjects = registeredKeys.Select(e => new JsonElementContent(e));

            return(this.JsonResponse(ResponseStatus.Success, registeredObjects));
        }
        /// <summary>
        /// 更新彩票数据
        /// </summary>
        /// <param name="code">彩票编码</param>
        public static void UpdateData(object code = null)
        {
            try
            {
                //http://api.b1cp.com/t?p=json&t=qqffc&token=FF446B723EB25993
                //http://www.b1cp.com/api?p=json&t=txffc&limit=1&token=00fb782bad8e5241
                //Log.Debug("开始QqSsc...");

                //if (code == "ssl")
                //{
                //    string test = "";
                //}

                SysLotteryModel sysLottery = _lotteryDal.GetSysLotteryByCode(code.ToString());

                Log.DebugFormat("获取开奖信息: {0} {1}", sysLottery.Title, sysLottery.Code);
                if (sysLottery == null || string.IsNullOrEmpty(sysLottery.ApiUrl))
                {
                    throw new Exception("无效的API配置");
                }

                int lotId = sysLottery.Id; //彩票Id
                IList <ByLottery> data = ByHelper.GetLotteryData(sysLottery.ApiUrl);

                foreach (ByLottery lot in data)
                {
                    string openTime = lot.opentime;
                    string openCode = lot.opencode;
                    string expect   = lot.expect; //期号

                    expect = GetExpect(code.ToString(), expect);

                    if (_dal.Update(lotId, expect, openCode, openTime, openCode))
                    {
                        Public.SaveLotteryData2File(lotId);
                        LotteryCheck.RunOfIssueNum(lotId, expect);
                        Log.DebugFormat("发布开奖信息: {0} {1}", sysLottery.Title, openCode);
                    }

                    Log.DebugFormat("开奖信息详细: {0} {1} {2}", sysLottery.Title, expect, openCode);
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("官方彩票异常: {0} {1}", code != null ? code.ToString() : "奖种无效", ex);
                //new LogExceptionDAL().Save("采集异常", "腾讯分分彩获取开奖数据出错,错误代码:" + ex.Message);
            }
        }
        protected override string DoImpl()
        {
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();

            var strategy = ByHelper.GetStrategy(searchStrategy, searchValue);
            var element  = CruciatusFactory.Root.FindElement(strategy);

            if (element == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }

            var registeredKey    = this.Automators.ElementsRegistry.RegisterElement(element);
            var registeredObject = new JsonElementContent(registeredKey);

            return(this.JsonResponse(ResponseStatus.Success, registeredObject));
        }
        protected override string DoImpl()
        {
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();


            AutomationElement activeWindow = DriverManager.GetActiveWindow();

            AutomationElement[] elements;

            if (searchStrategy.Equals("xpath"))
            {
                if (searchValue.StartsWith("#"))
                {
                    searchValue  = searchValue.TrimStart('#');
                    activeWindow = activeWindow.Automation.GetDesktop();
                }

                elements = ByXpath.FindAllByXPath(searchValue, activeWindow);
            }
            else
            {
                var condition = ByHelper.GetStrategy(searchStrategy, searchValue);

                elements = activeWindow.FindAllDescendants(condition);
            }

            if (elements == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }


            var flaUiDriverElementList = elements
                                         .Select <AutomationElement, FlaUIDriverElement>((Func <AutomationElement, FlaUIDriverElement>)(x => new FlaUIDriverElement(x)))
                                         .ToList <FlaUIDriverElement>();

            var registeredKeys = this.Automator.ElementsRegistry.RegisterElements(flaUiDriverElementList);

            var registeredObjects = registeredKeys.Select(e => new JsonElementContent(e));

            return(this.JsonResponse(ResponseStatus.Success, registeredObjects));
        }
        protected override string DoImpl()
        {
            var searchValue    = this.ExecutedCommand.Parameters["value"].ToString();
            var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString();


            AutomationElement activeWindow = DriverManager.GetActiveWindow();

            AutomationElement element;

            if (searchStrategy.Equals("xpath"))
            {
                if (searchValue.StartsWith("#"))
                {
                    searchValue  = searchValue.TrimStart('#');
                    activeWindow = activeWindow.Automation.GetDesktop();
                }

                element = ByXpath.FindFirstByXPath(searchValue, activeWindow);
            }
            else
            {
                var condition = ByHelper.GetStrategy(searchStrategy, searchValue);

                element = activeWindow.FindFirstDescendant(condition);
            }

            if (element == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }

            var registeredKey    = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(element));
            var registeredObject = new JsonElementContent(registeredKey);

            return(this.JsonResponse(ResponseStatus.Success, registeredObject));
        }