예제 #1
0
 public static void ReportState(SpiderResult result)
 {
     using (var factory = new ChannelFactory<ISpiderClientToManageClient>(new NetNamedPipeBinding() { MaxReceivedMessageSize = int.MaxValue }, new EndpointAddress("net.pipe://127.0.0.1/Server")))
     {
         ISpiderClientToManageClient manageClientToManageSpiderClientChannel = factory.CreateChannel();
         try
         {
             manageClientToManageSpiderClientChannel.TransferData(result);
         }
         catch (TimeoutException)
         {
             (manageClientToManageSpiderClientChannel as ICommunicationObject).Abort();
             throw;
         }
         catch (CommunicationException)
         {
             (manageClientToManageSpiderClientChannel as ICommunicationObject).Abort();
             throw;
         }
         finally
         {
             CloseChannel((ICommunicationObject)manageClientToManageSpiderClientChannel);
         }
     }
 }
예제 #2
0
        public void TransferData(SpiderResult result)
        {
            //MessageBox.Show(result.Url);
            if (currentTaskCount==0)
            {
                totalTask = result.TaskCount;
            }
            totalTime += result.Elapse;

            currentTaskCount++;
            toolStripStatusLabel.Text = result.Url;
            //this.Text = result.Url;
            if (this.toolStripProgressBar.Maximum != result.TaskCount)
            {
                this.toolStripProgressBar.Maximum = result.TaskCount;
                //this.toolStripProgressBar.Step = result.TaskCount;
                this.toolStripProgressBar.Minimum = 0;
                this.toolStripProgressBar.Width = 200;
            }

            if (currentTaskCount%result.TaskCount==0)
            {
               totalTask += result.TaskCount;
            }
            this.Text = result.Title;
            this.toolStripProgressBar.Text = result.Current + "/" + result.TaskCount + "/" + this.totalTask + "/平均:" + totalTime / currentTaskCount+"/当前"+result.Elapse+"";
            this.toolStripProgressBar.Value = result.Current;

            SpiderManager.SpiderProductDetail(new SpiderProductInfo(){ECPlatformId = 1,HtmlSource = result.HtmlSource});
            //File.WriteAllText("z:\\" + result.Title + ".html", result.HtmlSource, Encoding.GetEncoding(result.Charset));
        }