Ejemplo n.º 1
0
 private void NTMinerLogo_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount == 2)
     {
         if (NTMinerRoot.IsBrandSpecified)
         {
             return;
         }
         BrandTag.ShowWindow();
         e.Handled = true;
     }
 }
Ejemplo n.º 2
0
 public override void Link()
 {
     VirtualRoot.BuildCmdPath <ShowDialogWindowCommand>(action: message => {
         UIThread.Execute(() => {
             DialogWindow.ShowDialog(new DialogWindowViewModel(message: message.Message, title: message.Title, onYes: message.OnYes, icon: message.Icon));
         });
     });
     VirtualRoot.BuildCmdPath <ShowQQGroupQrCodeCommand>(action: message => {
         UIThread.Execute(() => {
             QQGroupQrCode.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowCalcCommand>(action: message => {
         UIThread.Execute(() => {
             Calc.ShowWindow(message.CoinVm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowLocalIpsCommand>(action: message => {
         UIThread.Execute(() => {
             LocalIpConfig.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowEthNoDevFeeCommand>(action: message => {
         UIThread.Execute(() => {
             EthNoDevFeeEdit.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowCalcConfigCommand>(action: message => {
         UIThread.Execute(() => {
             CalcConfig.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowMinerClientsWindowCommand>(action: message => {
         UIThread.Execute(() => {
             MinerClientsWindow.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowNTMinerUpdaterConfigCommand>(action: message => {
         UIThread.Execute(() => {
             NTMinerUpdaterConfig.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowAboutPageCommand>(action: message => {
         UIThread.Execute(() => {
             AboutPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowKernelOutputPageCommand>(action: message => {
         UIThread.Execute(() => {
             KernelOutputPage.ShowWindow(message.SelectedKernelOutputVm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowKernelInputPageCommand>(action: message => {
         UIThread.Execute(() => {
             KernelInputPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowTagBrandCommand>(action: message => {
         if (NTMinerRoot.IsBrandSpecified)
         {
             return;
         }
         BrandTag.ShowWindow();
     });
     VirtualRoot.BuildCmdPath <ShowCoinPageCommand>(action: message => {
         UIThread.Execute(() => {
             CoinPage.ShowWindow(message.CurrentCoin, message.TabType);
         });
     });
     VirtualRoot.BuildCmdPath <ShowGroupPageCommand>(action: message => {
         UIThread.Execute(() => {
             GroupPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowSysDicPageCommand>(action: message => {
         UIThread.Execute(() => {
             SysDicPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowVirtualMemoryCommand>(action: message => {
         UIThread.Execute(() => {
             VirtualMemory.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowRestartWindowsCommand>(action: message => {
         UIThread.Execute(() => {
             RestartWindows.ShowDialog();
         });
     });
     VirtualRoot.BuildCmdPath <ShowNotificationSampleCommand>(action: message => {
         UIThread.Execute(() => {
             NotificationSample.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowPropertyCommand>(action: message => {
         UIThread.Execute(() => {
             Property.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowChartsWindowCommand>(action: message => {
         UIThread.Execute(() => {
             ChartsWindow.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowOverClockDataPageCommand>(action: message => {
         UIThread.Execute(() => {
             OverClockDataPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowNTMinerWalletPageCommand>(action: message => {
         UIThread.Execute(() => {
             NTMinerWalletPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowMessagePathIdsCommand>(action: message => {
         UIThread.Execute(() => {
             MessagePathIds.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowUserPageCommand>(action: message => {
         UIThread.Execute(() => {
             UserPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowRemoteDesktopLoginDialogCommand>(action: message => {
         RemoteDesktopLogin.ShowWindow(message.Vm);
     });
     VirtualRoot.BuildCmdPath <ShowKernelsWindowCommand>(action: message => {
         UIThread.Execute(() => {
             KernelsWindow.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowKernelDownloaderCommand>(action: message => {
         UIThread.Execute(() => {
             KernelDownloading.ShowWindow(message.KernelId, message.DownloadComplete);
         });
     });
     VirtualRoot.BuildCmdPath <EnvironmentVariableEditCommand>(action: message => {
         UIThread.Execute(() => {
             EnvironmentVariableEdit.ShowWindow(message.CoinKernelVm, message.EnvironmentVariable);
         });
     });
     VirtualRoot.BuildCmdPath <InputSegmentEditCommand>(action: message => {
         UIThread.Execute(() => {
             InputSegmentEdit.ShowWindow(message.CoinKernelVm, message.Segment);
         });
     });
     VirtualRoot.BuildCmdPath <CoinKernelEditCommand>(action: message => {
         UIThread.Execute(() => {
             CoinKernelEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <CoinEditCommand>(action: message => {
         UIThread.Execute(() => {
             CoinEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ColumnsShowEditCommand>(action: message => {
         UIThread.Execute(() => {
             ColumnsShowEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ShowContainerWindowCommand>(action: message => {
         UIThread.Execute(() => {
             ContainerWindow window = ContainerWindow.GetWindow(message.Vm);
             window?.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowSpeedChartsCommand>(action: message => {
         UIThread.Execute(() => {
             SpeedCharts.ShowWindow(message.GpuSpeedVm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowFileWriterPageCommand>(action: message => {
         UIThread.Execute(() => {
             FileWriterPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <FileWriterEditCommand>(action: message => {
         UIThread.Execute(() => {
             FileWriterEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ShowFragmentWriterPageCommand>(action: message => {
         UIThread.Execute(() => {
             FragmentWriterPage.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <FragmentWriterEditCommand>(action: message => {
         UIThread.Execute(() => {
             FragmentWriterEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <GroupEditCommand>(action: message => {
         UIThread.Execute(() => {
             GroupEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <KernelInputEditCommand>(action: message => {
         UIThread.Execute(() => {
             KernelInputEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <KernelOutputFilterEditCommand>(action: message => {
         UIThread.Execute(() => {
             KernelOutputFilterEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <KernelOutputTranslaterEditCommand>(action: message => {
         UIThread.Execute(() => {
             KernelOutputTranslaterEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <KernelOutputEditCommand>(action: message => {
         UIThread.Execute(() => {
             KernelOutputEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ShowPackagesWindowCommand>(action: message => {
         UIThread.Execute(() => {
             PackagesWindow.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <KernelEditCommand>(action: message => {
         UIThread.Execute(() => {
             KernelEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ShowLogColorCommand>(action: message => {
         UIThread.Execute(() => {
             LogColor.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <ShowMinerClientSettingCommand>(action: message => {
         UIThread.Execute(() => {
             MinerClientSetting.ShowWindow(message.Vm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowMinerNamesSeterCommand>(action: message => {
         UIThread.Execute(() => {
             MinerNamesSeter.ShowWindow(message.Vm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowGpuProfilesPageCommand>(action: message => {
         UIThread.Execute(() => {
             GpuProfilesPage.ShowWindow(message.MinerClientsWindowVm);
         });
     });
     VirtualRoot.BuildCmdPath <ShowMinerClientAddCommand>(action: message => {
         UIThread.Execute(() => {
             MinerClientAdd.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <MinerGroupEditCommand>(action: message => {
         UIThread.Execute(() => {
             MinerGroupEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <NTMinerWalletEditCommand>(action: message => {
         UIThread.Execute(() => {
             NTMinerWalletEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <MineWorkEditCommand>(action: message => {
         UIThread.Execute(() => {
             MineWorkEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <OverClockDataEditCommand>(action: message => {
         UIThread.Execute(() => {
             OverClockDataEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <PackageEditCommand>(action: message => {
         UIThread.Execute(() => {
             PackageEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <PoolKernelEditCommand>(action: message => {
         UIThread.Execute(() => {
             PoolKernelEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <PoolEditCommand>(action: message => {
         UIThread.Execute(() => {
             PoolEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <ShowControlCenterHostConfigCommand>(action: message => {
         UIThread.Execute(() => {
             ControlCenterHostConfig.ShowWindow();
         });
     });
     VirtualRoot.BuildCmdPath <SysDicItemEditCommand>(action: message => {
         UIThread.Execute(() => {
             SysDicItemEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <SysDicEditCommand>(action: message => {
         UIThread.Execute(() => {
             SysDicEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <UserEditCommand>(action: message => {
         UIThread.Execute(() => {
             UserEdit.ShowWindow(message.FormType, message.Source);
         });
     });
     VirtualRoot.BuildCmdPath <WalletEditCommand>(action: message => {
         UIThread.Execute(() => {
             WalletEdit.ShowWindow(message.FormType, message.Source);
         });
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 执行内容解析
        /// </summary>
        ///<param name="webArgs"> </param>
        /// <param name="content">要解析的内容</param>
        /// <returns>返回需要的字段对应的字典</returns>
        public override Dictionary <string, object> ResolveSearchPageContent(BaseFetchWebPageArgument webArgs, string content)
        {
            var resultBag = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(content))
            {
                if (content.Contains("环境有异常"))
                {
                    PluginContext.Logger.Error("天猫查询被进行蜘蛛验证!关键词:" + webArgs.KeyWord);
                    return(resultBag);
                }
                if (content.Contains("member/login"))
                {
                    PluginContext.Logger.Error("天猫查询结果页面被强制跳转到了登录页!关键词:" + webArgs.KeyWord);
                    return(resultBag);
                }
            }


            try
            {
                //创建html 文档对象
                HtmlParser htmlParser   = new HtmlParser();
                var        htmlDoc      = htmlParser.Parse(content);
                var        div_AttrsDom = htmlDoc.QuerySelector("div.j_NavAttrs");

                if (webArgs.IsNeedResolveHeaderTags == true && null != div_AttrsDom)
                {
                    #region 品牌解析
                    var lstBrands = new List <BrandTag>();
                    var brandDom  = div_AttrsDom.QuerySelector("div.j_Brand");
                    if (null != brandDom)
                    {
                        //从属性区域解析dom-品牌内容
                        var brandULDom = brandDom.QuerySelector("div.attrValues>ul");//ulDomArray[0];//

                        if (null != brandULDom)
                        {
                            var regex_MatchBrandId = new Regex(@"brand=(\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            var li_ADomArray       = brandULDom.QuerySelectorAll("li>a");
                            foreach (var itemADom in li_ADomArray)
                            {
                                var model = new BrandTag();
                                model.Platform    = SupportPlatformEnum.Tmall;
                                model.FilterField = "brand";//使用的过滤字段参数
                                var urlBrand = itemADom.GetAttribute("href");
                                if (!string.IsNullOrEmpty(urlBrand) && urlBrand.Contains("brand="))
                                {
                                    model.BrandId = regex_MatchBrandId.Match(urlBrand).Groups[1].Value;//new//品牌id   href="?brand=110910&amp;q=%B4%F3%C3%D7&amp;sort=s&amp;style=g&amp;from=sn_1_brand-qp&amp;spm=a220m.1000858.1000720.1.348abe64rj5JVg#J_crumbs
                                }
                                model.BrandName = itemADom.GetAttribute("title");
                                model.CharIndex = PinYin.GetFirstLetter(model.BrandName);
                                lstBrands.Add(model);
                            }
                        }
                    }
                    resultBag.Add("Brands", lstBrands);

                    #endregion

                    // tags 解析
                    //var lstTags = new List<KeyWordTag> {
                    //new KeyWordTag {
                    //    Platform = NTCPMessage.EntityPackage.SupportPlatformEnum.Tmall,
                    //    TagName = "大衣", Value = "dayi", FilterFiled = "sku"
                    //} };
                    var ulDomArray = div_AttrsDom.QuerySelectorAll("div.attrValues>ul");

                    var lstTags = new List <KeyWordTagGroup>();
                    if (null != div_AttrsDom)
                    {
                        var blockList = new BlockingCollection <KeyWordTagGroup>();

                        //分类 or 属性;品牌是第一个,其他属性是后续
                        int startIdx = brandDom == null ? 0 : 1;// //是否存在品牌的判断

                        var taskArray = new Task[ulDomArray.Length - startIdx];
                        int counter   = 0;


                        for (int i = startIdx; i < ulDomArray.Length; i++)
                        {
                            int cursor = i;

                            var taskResolveAEmelems = Task.Factory.StartNew(() =>
                            {
                                var itemUl = ulDomArray[cursor];

                                //找到归属的组
                                var attrKeyDom   = itemUl.ParentElement.ParentElement.QuerySelector("div.attrKey");
                                string groupName = "";
                                if (null != attrKeyDom)
                                {
                                    groupName = attrKeyDom.TextContent.Replace("\n", "").Trim();
                                }

                                var tagGroup = new KeyWordTagGroup(groupName);

                                var childLiADomArray = itemUl.QuerySelectorAll("li>a");
                                foreach (var itemADom in childLiADomArray)
                                {
                                    var modelTag           = new KeyWordTag();
                                    modelTag.Platform      = SupportPlatformEnum.Tmall;
                                    modelTag.TagName       = itemADom.TextContent.Replace("\n", "");//标签名称
                                    modelTag.GroupShowName = groupName;

                                    //////----解析 a标签开始-------
                                    //////检查 a 的href 中的参数;cat 或者prop
                                    string hrefValue = itemADom.GetAttribute("href");
                                    if (!string.IsNullOrEmpty(hrefValue))
                                    {
                                        var urlParas = HttpUtility.ParseQueryString(hrefValue, Encoding.UTF8);
                                        if (null != urlParas)
                                        {
                                            if (hrefValue.IndexOf("cat=") > -1)
                                            {
                                                //1 cat
                                                string catValue      = urlParas["cat"];
                                                modelTag.FilterFiled = "cat";
                                                modelTag.Value       = catValue;
                                            }
                                            else if (hrefValue.IndexOf("prop=") > -1)
                                            {
                                                //2 prop
                                                string propValue     = urlParas["prop"];
                                                modelTag.FilterFiled = "prop";
                                                modelTag.Value       = propValue;
                                            }
                                        }
                                    }
                                    tagGroup.Tags.Add(modelTag);
                                }

                                //----解析 a标签完毕-------
                                blockList.Add(tagGroup);
                            });
                            //将并行任务放到数组
                            taskArray[counter] = taskResolveAEmelems;
                            counter           += 1;
                        }
                        var safeTaskArray = taskArray.Where(x => null != x).ToArray();
                        Task.WaitAll(safeTaskArray);
                        lstTags = blockList.ToList();
                    }
                    resultBag.Add("Tags", lstTags);
                }

                #region products  解析
                //ProductBaseCollection lstProducts = new ProductBaseCollection()
                //{
                //    new TmallProduct { ItemId=1,Title="测试大衣"}
                //};
                var lstProducts = new ProductBaseCollection();
                //多任务并行解析商品
                //BlockingCollection<TmallProduct> blockingList_Products = new BlockingCollection<TmallProduct>();
                ConcurrentDictionary <string, ProductOrdered <TmallProduct> > blockingList_Products = new ConcurrentDictionary <string, ProductOrdered <TmallProduct> >();

                var div_J_ItemListDom = htmlDoc.QuerySelector("div#J_ItemList");
                if (null != div_J_ItemListDom)
                {
                    var div_productDomArray = div_J_ItemListDom.QuerySelectorAll("div.product");
                    if (null != div_productDomArray && div_productDomArray.Any())
                    {
                        var pids = div_productDomArray
                                   .Select(x => { return(x.GetAttribute("data-id")); });
                        //设定排序对象
                        int counter_pid = 0;
                        foreach (var itemPid in pids)
                        {
                            if (null != itemPid)
                            {
                                blockingList_Products.TryAdd(itemPid, new ProductOrdered <TmallProduct> {
                                    UniqKey = itemPid, IndexOrder = counter_pid
                                });
                                counter_pid++;
                            }
                        }

                        //并行解析 并保留原序列
                        div_productDomArray.AsParallel()
                        .ForAll((itemProductDom) =>
                        {
                            //解析一个商品的节点
                            TmallProduct modelProduct = this.ResolverProductDom(itemProductDom);
                            if (null != modelProduct && modelProduct.ItemId > 0)
                            {
                                var orderedObj     = blockingList_Products[modelProduct.ItemId.ToString()];
                                orderedObj.Product = modelProduct;
                            }
                        });

                        //进行排序
                        var productsList = blockingList_Products
                                           .Where(x => x.Value != null)
                                           .OrderBy(x => x.Value.IndexOrder)
                                           .Select(x => x.Value.Product);
                        lstProducts.AddRange(productsList);
                    }
                }
                resultBag.Add("Products", lstProducts);

                #endregion
            }
            catch (Exception ex)
            {
                PluginContext.Logger.Error(ex);
            }
            return(resultBag);// string.Concat("has process input :" + content);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 执行内容解析
        /// </summary>
        ///<param name="webArgs"></param>
        /// <param name="content">要解析的内容</param>
        /// <returns>返回需要的字段对应的字典</returns>
        public override Dictionary <string, object> ResolveSearchPageContent(BaseFetchWebPageArgument webArgs, string content)
        {
            var resultBag = new Dictionary <string, object>();

            try
            {
                string jsonData = string.Empty;

                if (content.IndexOf("g_page_config") < 0)
                {
                    return(null);//无效的页面结果数据
                }


                //send request for load other data of first search page
                Task <string> tskSilcedJsonpContent = null;
                if (webArgs.PageIndex == 0)
                {
                    tskSilcedJsonpContent = Task.Factory.StartNew(() =>
                    {
                        string jsonpContent = "";
                        ////1 打开tcp 链接
                        ////2 发送参数
                        ////3 解析结果
                        if (!webArgs.SystemAttachParas.ContainsKey("SoapTcpConnectionString"))
                        {
                            return(jsonpContent);
                        }
                        var connStrConfig = webArgs.SystemAttachParas["SoapTcpConnectionString"] as WebCrawlerConnection;
                        if (null == connStrConfig)
                        {
                            return(jsonpContent);
                        }
                        //重写解析地址-首页的分片jsonp地址
                        string urlOfSlicedJsonp = this.ResolveSlicedSearchPageSilcedUrl(webArgs);
                        webArgs.ResolvedUrl     = new ResolvedSearchUrlWithParas {
                            Url = urlOfSlicedJsonp
                        };
                        using (var conn = new SoapTcpConnection(connStrConfig))
                        {
                            if (conn.State == ConnectionState.Closed)
                            {
                                conn.Open();
                            }

                            //发送soap
                            var soapCmd = new SoapMessage()
                            {
                                Head = CommandConstants.CMD_FetchPage
                            };
                            soapCmd.Body      = JsonConvert.SerializeObject(webArgs);
                            var dataContainer = conn.SendSoapMessage(soapCmd);
                            if (null != dataContainer && dataContainer.Status == 1)
                            {
                                jsonpContent = dataContainer.Result;
                            }
                            else
                            {
                                StringBuilder errMsg = new StringBuilder("抓取网页请求失败!参数:");
                                errMsg.Append(soapCmd.Body);
                                if (null != dataContainer && !string.IsNullOrEmpty(dataContainer.ErrorMsg))
                                {
                                    errMsg.Append(";服务端错误消息:")
                                    .Append(dataContainer.ErrorMsg);
                                }
                                PluginContext.Logger.Error(errMsg.ToString());
                            }
                        }

                        return(jsonpContent);
                    });
                }


                int startPos      = content.IndexOf("g_page_config");
                int endPos        = content.IndexOf("g_srp_loadCss") - startPos;
                var secondContent = content.Substring(startPos, endPos);
                int secStartPos   = secondContent.IndexOf('{');
                int secEndPos     = secondContent.IndexOf("};") - secStartPos + 1;
                jsonData = secondContent.Substring(secStartPos, secEndPos);



                TaobaoPageJsonResut pageJsonObj = JsonConvert.DeserializeObject <TaobaoPageJsonResut>(jsonData);
                if (null == pageJsonObj)
                {
                    return(null);
                }

                if (webArgs.IsNeedResolveHeaderTags == true)
                {
                    var navNode = pageJsonObj.mods.nav;
                    if (null != navNode && null != navNode.data)
                    {
                        var commonNode = navNode.data.common;
                        var advNode    = navNode.data.adv;

                        //解析common节点
                        if (null != commonNode && commonNode.Any())
                        {
                            //1 检测是否有品牌,有的话 解析品牌
                            #region 品牌解析


                            var brandNode = commonNode.FirstOrDefault(x => x.text == "品牌" && x.sub != null);
                            if (null != brandNode && brandNode.sub != null)
                            {
                                var lstBrands = new List <BrandTag>();
                                foreach (var subItem in brandNode.sub)
                                {
                                    var model = new BrandTag();
                                    model.Platform    = SupportPlatformEnum.Taobao;
                                    model.FilterField = "ppath";//使用的过滤字段参数

                                    model.BrandId   = subItem.value;
                                    model.BrandName = subItem.text;
                                    model.CharIndex = PinYin.GetFirstLetter(model.BrandName);
                                    lstBrands.Add(model);
                                }
                                //解析完毕品牌
                                resultBag.Add("Brands", lstBrands);
                            }

                            #endregion
                        }


                        //2其他筛选节点的分析

                        #region tags 解析


                        var lstTags = new List <KeyWordTagGroup>();

                        var otherFilterNode1 = commonNode.Where(x => x.text != "品牌" && x.sub != null);
                        foreach (var itemNode in otherFilterNode1)
                        {
                            //找到归属的组
                            string groupName = itemNode.text;
                            ProcessTags(lstTags, itemNode.sub, groupName);
                        }
                        ////////if (null!= advNode)----高级筛选不要了
                        ////////{
                        ////////    //advNode 的解析
                        ////////    foreach (var itemNode in advNode)
                        ////////    {
                        ////////        //找到归属的组
                        ////////        string groupName = itemNode.text;
                        ////////        ProcessTags(lstTags, itemNode.sub, groupName);
                        ////////    }
                        ////////}

                        resultBag.Add("Tags", lstTags);

                        #endregion
                    }
                }

                #region products  解析
                var lstProducts = new ProductBaseCollection();
                resultBag.Add("Products", lstProducts);

                var itemListNode = pageJsonObj.mods.itemlist;
                if (null != itemListNode && itemListNode.data != null && null != itemListNode.data.auctions)
                {
                    foreach (var itemProduct in itemListNode.data.auctions)
                    {
                        TaobaoProduct modelProduct = this.ResolverProductDom(itemProduct);

                        if (null != modelProduct)
                        {
                            lstProducts.Add(modelProduct);
                        }
                    }
                }

                //淘宝的搜索列表 - 第一页的数据是进行了分片的,在加载html ;36条数据, 后续会进行一次jsonp的请求;加载12条数据
                if (webArgs.PageIndex == 0 && null != tskSilcedJsonpContent)
                {
                    string jsonpContent = tskSilcedJsonpContent.Result;
                    if (!string.IsNullOrEmpty(jsonpContent) && jsonpContent.Contains("API.CustomizedApi"))
                    {
                        int    startIdx         = jsonpContent.IndexOf(':') + 1;
                        int    endIdx           = jsonpContent.Length - startIdx - 3;
                        string pureJsonContent  = jsonpContent.Substring(startIdx, endIdx);
                        var    slicedJsonpResut = JsonConvert.DeserializeObject <TaobaoSlicedJsonpResut>(pureJsonContent);


                        if (null != slicedJsonpResut)
                        {
                            var itemList = slicedJsonpResut.itemlist;
                            if (null != itemList && itemList.auctions != null)
                            {
                                foreach (var itemProduct in itemList.auctions)
                                {
                                    TaobaoProduct modelProduct = this.ResolverProductDom(itemProduct);

                                    if (null != modelProduct)
                                    {
                                        lstProducts.Add(modelProduct);
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                PluginContext.Logger.Error(ex);
            }
            return(resultBag);// string.Concat("has process input :" + content);
        }
Ejemplo n.º 5
0
        public override void BuildPaths()
        {
            var location = this.GetType();

            VirtualRoot.AddCmdPath <ShowDialogWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    DialogWindow.ShowSoftDialog(new DialogWindowViewModel(message: message.Message, title: message.Title, onYes: message.OnYes, icon: message.Icon));
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowCalcCommand>(action: message => {
                UIThread.Execute(() => {
                    Calc.ShowWindow(message.CoinVm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowLocalIpsCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerClientUcs.LocalIpConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowAboutPageCommand>(action: message => {
                UIThread.Execute(() => {
                    AboutPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowKernelOutputPageCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelOutputPage.ShowWindow(message.SelectedKernelOutputVm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowKernelInputPageCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelInputPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowTagBrandCommand>(action: message => {
                if (NTMinerContext.IsBrandSpecified)
                {
                    return;
                }
                UIThread.Execute(() => {
                    BrandTag.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowCoinPageCommand>(action: message => {
                UIThread.Execute(() => {
                    CoinPage.ShowWindow(message.CurrentCoin, message.TabType);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowCoinGroupsCommand>(action: message => {
                UIThread.Execute(() => {
                    CoinGroupPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowSysDicPageCommand>(action: message => {
                UIThread.Execute(() => {
                    SysDicPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowVirtualMemoryCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerClientUcs.VirtualMemory.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowRestartWindowsCommand>(action: message => {
                UIThread.Execute(() => {
                    RestartWindows.ShowDialog(new RestartWindowsViewModel(message.CountDownSeconds));
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowNotificationSampleCommand>(action: message => {
                UIThread.Execute(() => {
                    NotificationSample.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowPropertyCommand>(action: message => {
                UIThread.Execute(() => {
                    Property.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMessagePathIdsCommand>(action: message => {
                UIThread.Execute(() => {
                    MessagePathIds.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowKernelsWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelsWindow.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowKernelDownloaderCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelDownloading.ShowWindow(message.KernelId, message.DownloadComplete);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditEnvironmentVariableCommand>(action: message => {
                UIThread.Execute(() => {
                    EnvironmentVariableEdit.ShowWindow(message.CoinKernelVm, message.EnvironmentVariable);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditInputSegmentCommand>(action: message => {
                UIThread.Execute(() => {
                    InputSegmentEdit.ShowWindow(message.CoinKernelVm, message.Segment);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditCoinKernelCommand>(action: message => {
                UIThread.Execute(() => {
                    CoinKernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditCoinCommand>(action: message => {
                UIThread.Execute(() => {
                    CoinEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowSpeedChartsCommand>(action: message => {
                UIThread.Execute(() => {
                    SpeedCharts.ShowWindow(message.GpuSpeedVm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowFileWriterPageCommand>(action: message => {
                UIThread.Execute(() => {
                    FileWriterPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditFileWriterCommand>(action: message => {
                UIThread.Execute(() => {
                    FileWriterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowFragmentWriterPageCommand>(action: message => {
                UIThread.Execute(() => {
                    FragmentWriterPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditFragmentWriterCommand>(action: message => {
                UIThread.Execute(() => {
                    FragmentWriterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditGroupCommand>(action: message => {
                UIThread.Execute(() => {
                    GroupEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditServerMessageCommand>(action: message => {
                UIThread.Execute(() => {
                    ServerMessageEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditKernelInputCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelInputEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditKernelOutputKeywordCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelOutputKeywordEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditKernelOutputTranslaterCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelOutputTranslaterEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditKernelOutputCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelOutputEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowPackagesWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    PackagesWindow.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditKernelCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditPackageCommand>(action: message => {
                UIThread.Execute(() => {
                    PackageEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditPoolKernelCommand>(action: message => {
                UIThread.Execute(() => {
                    PoolKernelEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditPoolCommand>(action: message => {
                UIThread.Execute(() => {
                    PoolEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditSysDicItemCommand>(action: message => {
                UIThread.Execute(() => {
                    SysDicItemEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditSysDicCommand>(action: message => {
                UIThread.Execute(() => {
                    SysDicEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowKernelOutputKeywordsCommand>(action: message => {
                UIThread.Execute(() => {
                    KernelOutputKeywords.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowSignUpPageCommand>(action: message => {
                UIThread.Execute(() => {
                    SignUpPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditWalletCommand>(action: message => {
                UIThread.Execute(() => {
                    WalletEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);

            #region MinerStudio
            VirtualRoot.AddCmdPath <ShowQQGroupQrCodeCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.QQGroupQrCode.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowCalcConfigCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.CalcConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerClientsWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioViews.MinerClientsWindow.ShowWindow(message.IsToggle);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowNTMinerUpdaterConfigCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerUpdaterConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerClientFinderConfigCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientFinderConfig.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowChartsWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioViews.ChartsWindow.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowOverClockDataPageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.OverClockDataPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerStudioVirtualMemoryCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.VirtualMemory.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerStudioLocalIpsCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.LocalIpConfig.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowNTMinerWalletPageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerWalletPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowUserPageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.UserPage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowGpuNamePageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.GpuNameCounts.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowChangePassword>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.ChangePassword.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowWsServerNodePageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.WsServerNodePage.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowRemoteDesktopLoginDialogCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.RemoteDesktopLogin.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerClientSettingCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientSetting.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerNamesSeterCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerNamesSeter.ShowWindow(message.Vm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowGpuProfilesPageCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.GpuProfilesPage.ShowWindow(message.MinerClientsWindowVm);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <ShowMinerClientAddCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerClientAdd.ShowWindow();
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditMinerGroupCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MinerGroupEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditNTMinerWalletCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.NTMinerWalletEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditMineWorkCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.MineWorkEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditOverClockDataCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.OverClockDataEdit.ShowWindow(message.FormType, message.Source);
                });
            }, location: location);
            VirtualRoot.AddCmdPath <EditColumnsShowCommand>(action: message => {
                UIThread.Execute(() => {
                    MinerStudioUcs.ColumnsShowEdit.ShowWindow(message.Source);
                });
            }, location: location);
            #endregion
        }