示例#1
0
        /// <summary>
        /// 新建专案
        /// 专案就是可以创建生产线的地方
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuGroupPlotNew_Click(object sender, EventArgs e)
        {
            if (treeV.SelectedNode != null)
            {
                OpenPlot sPlot = OpenPlot.CreatePlot();
                sPlot.Path = treeV.SelectedNode.Tag.ToString();

                FrmPlotInfo sFrmPlotInfo = new FrmPlotInfo(sPlot, true);
                if (sFrmPlotInfo.ShowDialog() == DialogResult.OK)
                {
                    string sFileName = treeV.SelectedNode.Tag.ToString() + "\\" + sPlot.Name + ".opp";
                    //保存专案到本地文件
                    if (CrawlServer.SaveAs(sFileName, sPlot))
                    {
                        TreeNode sNode = new TreeNode(sPlot.Name, 2, 2);
                        sNode.Tag = sPlot;
                        //在给专案树Tag赋值完,将专案添加到缓冲池
                        CrawlServer.AddPlot2Pool(sPlot);
                        treeV.SelectedNode.Nodes.Add(sNode);
                        //专案树字典
                        mTreeNodeDic[sFileName] = sNode;
                        treeV.SelectedNode      = sNode;
                    }
                }
            }
        }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CrawlServer.InitServer(Application.StartupPath);

            Application.Run(new FrmServer());
        }
示例#3
0
 /// <summary>
 /// 添加网页生产线
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MenuPlotLine添加网页生产线_Click(object sender, EventArgs e)
 {
     if (treeV.SelectedNode != null && treeV.SelectedNode.ImageIndex == 2)
     {
         OpenPlot              sPlot     = (OpenPlot)treeV.SelectedNode.Tag;
         PlotWaterLine         sPlotLine = sPlot.CreateWaterLine(false, "网页生产线");
         FrmPlotWaterLineGuide sFrmPlotWaterLineGuide = new FrmPlotWaterLineGuide(sPlotLine);
         if (sFrmPlotWaterLineGuide.ShowDialog() == DialogResult.OK)
         {
             sPlotLine.Plot = sPlot;
             LoadPlotWaterLineItem(sPlotLine);
             CrawlServer.Save(sPlot);
         }
         else
         {
             //sPlot.Remove(sPlotLine);
         }
     }
 }
示例#4
0
        /// <summary>
        /// 加载专案文件
        /// </summary>
        /// <param name="pPath"></param>
        /// <param name="pNode"></param>
        /// <param name="pNodeDic"></param>
        public void LoadFile(string pPath, TreeNode pNode, Dictionary <string, TreeNode> pNodeDic)
        {
            string[] sFiles = DirFileHelper.GetFileNames(pPath);
            int      k      = pPath.Length + 1;

            if (sFiles != null)
            {
                for (int i = 0; i < sFiles.Length; i++)
                {
                    OpenPlot sPlot = CrawlServer.Open(sFiles[i]);
                    if (sPlot == null)
                    {
                        continue;
                    }
                    TreeNode sNode = new TreeNode(sPlot.Name, 2, 2);
                    sNode.Tag = sPlot;
                    CrawlServer.AddPlot2Pool(sPlot);
                    pNodeDic[sFiles[i]] = sNode;
                    pNode.Nodes.Add(sNode);
                }
            }
        }
示例#5
0
        public LwbResult LwbEach(LwbInput pLwbInput)
        {
            //参数为null,不合法,返回null
            if (pLwbInput == null)
            {
                return(new LwbResult(LwbResultType.QueryNull));
            }

            //获取调用者的Ip,并将Ip整数化
            OperationContext              context    = OperationContext.Current;
            MessageProperties             properties = context.IncomingMessageProperties;
            RemoteEndpointMessageProperty endpoint   = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

            uint sIntIp = IpV4Converter.ToInt((string)endpoint.Address ?? "127.0.0.1");

            try
            {
                if (pLwbInput.Type == (int)CrawlCmd.获取生产线任务列表)
                {
                    var sInput获取生产线任务列表 = pLwbInput.Data as Input获取生产线任务列表;
                    if (sInput获取生产线任务列表 == null)
                    {
                        return(new LwbResult(LwbResultType.Error, "获取生产线任务列表-传入实体类格式有误"));
                    }

                    Dictionary <string, string> sDic = new Dictionary <string, string>();
                    List <string> sIn列表 = sInput获取生产线任务列表.RuningTaskHost;

                    if (sIn列表 != null && sIn列表.Count > 0)
                    {
                        sIn列表.ForEach(t => sDic[t.ToString()] = t);
                    }

                    return(new LwbResult(LwbResultType.Success,
                                         "获取生产线任务列表成功",
                                         CrawlServer.GetCrawlTasks(sDic, sIntIp, sInput获取生产线任务列表.TaskMax)));
                }
                else if (pLwbInput.Type == (int)CrawlCmd.发送爬行任务)
                {
                    var sCrawlResult = pLwbInput.Data as CrawlResult;
                    if (sCrawlResult == null)
                    {
                        return(new LwbResult(LwbResultType.Error, "获取爬虫回送任务失败"));
                    }

                    //sCrawlResult.IP = sIntIp;

                    CrawlServer.ReceiveCrawlResult(sCrawlResult);

                    return(new LwbResult(LwbResultType.Success, "获取爬虫回送任务成功"));
                }
                else
                {
                    return(new LwbResult(LwbResultType.Error, "获取生产线任务列表-传入【Type】有误"));
                }
            }
            catch (Exception ee)
            {
                return(new LwbResult(LwbResultType.Error, ee.Message));
            }
        }