public static List <BaseProject> Parse(SolutionInfo solutionInfo)
 {
     return(ReProjects.Matches(solutionInfo.Text)
            .Cast <Match>()
            .Select(m => BaseProject.Create(m.Groups["Guid"].Value, m.Groups["Name"].Value, m.Groups["Project"].Value, new ProjectInfo(solutionInfo, m.Groups["Package"].Value, m.Groups["All"].Value)))
            .ToList());
 }
Esempio n. 2
0
    public BaseProject(int[] costs, int[] capacities, int[] buildingRounds, int[] requiredPoints, int[] requiredWhitehouse,
        string projectName, GameStats stats, string pType, BaseProject[] dependence = null, int[] extraPointsList = null, int[] discounts = null, int[] builder = null, int newProjectLevel = 0)
    {
        _costs                = costs;
         _capacities           = capacities;
         _buildingRounds       = buildingRounds;
         _requiredPoints       = requiredPoints;
         _requiredWhitehouse   = requiredWhitehouse;

        if(discounts != null)
        {
            _discounts = discounts;
        }

        if (builder != null)
        {
            _builder = builder;
        }

        if (extraPointsList != null)
        {
            _extraPointsList = extraPointsList;
        }

        projectType = pType;
        gameStats = stats;
        _projectName = projectName;
        _dependence = dependence;

        projectLevel = newProjectLevel;
    }
Esempio n. 3
0
        public static RailPlan Load(string path, Dictionary <Guid, TrackBase> trackDict)
        {
            RailPlan railPlan = BaseProject.Load <RailPlan>(path);

            // link tracks
            foreach (RailBase item in railPlan.Rails)
            {
                if (item is RailItem railItem)
                {
                    // set track
                    railItem.Track = trackDict[railItem.TrackId];
                    // set dock points
                    railItem.DockPoints.ForEach((railDockPoint, index) =>
                    {
                        railDockPoint.Update(railItem, railItem.Track.DockPoints[index]);
                    });
                }
            }
            // link dock points
            var list = railPlan.Rails.SelectMany(r => r.DockPoints).Where(dp => dp.DockedWithId != Guid.Empty).ToList();

            foreach (RailDockPoint dp in list)
            {
                RailDockPoint x = list.Single(i => i.Id == dp.DockedWithId);
                x.Dock(dp);
            }
            return(railPlan);
        }
Esempio n. 4
0
        public static BaseProject ConvertToBase(this Project model, IMapper _mapper)
        {
            BaseProject updated = _mapper.Map <Project, BaseProject>(model);

            updated.TotalComments = model.Comments.Count;
            updated.Rating        = model.Comments.Aggregate(0.0, (acc, comment) => acc + comment.Rating);
            updated.Duration      = (model.EndDate - model.StartDate).Days;
            updated.Category      = model.Category.Convert <Category, CategoryBaseWithCheck>(_mapper);
            return(updated);
        }
Esempio n. 5
0
        public void startWorkWith(string directory)
        {
            StartLongProgress();
            workingDirectory = directory;

            WorkingTextBlock.Text = "작업 중: " + Path.GetFileName(directory);
            project = BaseProject.IdentificationProject(directory);

            ProjectTypeTextBlock.Text = "프로젝트 타입 : " + project.Name;

            ExtractStringButton.IsEnabled   = project.Extractor.SupportExtract;
            ApplyStringButton.IsEnabled     = project.Extractor.SupportApply;
            ExtractorOptionButton.IsEnabled = project.Extractor.HasWindow;

            if (File.Exists(AutoSavePath))
            {
                if (MessageBox.Show("예기치 못한 종료전에 저장된 자동 저장 파일이 남아있습니다. 이 파일로 작업합니까?", "HT Studio", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    project.Extractor.LoadTranslateStrings(AutoSavePath);
                }
                try
                {
                    File.Delete(AutoSavePath);
                }
                catch
                {
                }
            }

            foreach (TranslateString str in project.Extractor.TranslateStrings)
            {
                StringListBox.Items.Add(str);
                if (str.Machine.Trim() != "")
                {
                    machineCount++;
                }

                if (str.Hand.Trim() != "")
                {
                    handCount++;
                }
            }
            UpdateTranslateState();

            if (StringListBox.Items.Count > 0)
            {
                StringListBox.SelectedIndex = project.LastWorkIndex;
            }
            ActivateHandCheckBox.IsChecked = project.InHandTranslateMode;

            FinishLongProgress();
        }
Esempio n. 6
0
 public RPGMVDieselmineExtractor(BaseProject project) : base(project)
 {
 }
        //TODO: parse nested projects

        /*
         * private static readonly Regex ReNestSection = new Regex(@"(?<ProjGuid>\{\S*?\})\s=\s(?<DirGuid>\{\S*?\})", RegexOptions.Multiline | RegexOptions.Compiled);
         *
         * public static NestedProject Parse(ProjectDirectory[] projects, string slnText)
         * {
         *  Project.ParseConfigs(ref projects, ReConfSection.Match(slnText).Groups["Section"].Value);
         *  return new VsProjectConfiguration(projects);
         * }*/

        public ProjectRelationInfo(BaseProject project, ProjectDirectory dir)
        {
            this.project = project;
            this.dir     = dir;
        }
Esempio n. 8
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList  list = new List <ItemInfo>();
            string html = string.Empty;
            string cookiestr = string.Empty;
            string viewState = string.Empty;
            int    pageInt = 1, sqlCount = 1;
            string eventValidation = string.Empty;

            try
            {
                html = this.ToolWebSite.GetHtmlByUrl(SiteUrl, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                return(list);
            }
            Parser   parser   = new Parser(new Lexer(html));
            NodeList pageList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("td"), new HasAttributeFilter("class", "statusBar")));

            if (pageList != null && pageList.Count > 0)
            {
                try
                {
                    string temp = pageList.AsString().GetRegexBegEnd("找到", "条");
                    pageInt = (Convert.ToInt32(temp) + 20 - 1) / 20;
                }
                catch { pageInt = 1; }
            }
            for (int i = 1; i <= pageInt; i++)
            {
                if (i > 1)
                {
                    string id = ToolHtml.GetHtmlInputValue(html, "id");
                    NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] {
                        "ec_i",
                        "topicChrList_20070702_crd",
                        "topicChrList_20070702_f_a",
                        "topicChrList_20070702_p",
                        "topicChrList_20070702_s_name",
                        "topicChrList_20070702_s_topName",
                        "id",
                        "method",
                        "__ec_pages",
                        "topicChrList_20070702_rd",
                        "topicChrList_20070702_f_name",
                        "topicChrList_20070702_f_topName",
                        "topicChrList_20070702_f_ldate"
                    },
                                                                                      new string[] {
                        "topicChrList_20070702",
                        "20",
                        "",
                        i.ToString(),
                        "",
                        "",
                        id,
                        "view",
                        i.ToString(),
                        "20",
                        "", "", ""
                    });
                    try
                    {
                        html = this.ToolWebSite.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8);
                    }
                    catch { continue; }
                }
                parser = new Parser(new Lexer(html));
                NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "topicChrList_20070702_table")));
                if (nodeList != null && nodeList.Count > 0)
                {
                    TableTag table = nodeList[0] as TableTag;
                    for (int j = 3; j < table.RowCount; j++)
                    {
                        TableRow tr = table.Rows[j];
                        string   itemCode = string.Empty, itemName = string.Empty, buildUnit = string.Empty, address = string.Empty,
                                 investMent = string.Empty, buildKind = string.Empty, investKink = string.Empty, linkMan = string.Empty,
                                 linkmanTel = string.Empty, itemDesc = string.Empty, apprNo = string.Empty, apprDate = string.Empty,
                                 apprUnit = string.Empty, apprResult = string.Empty, landapprNo = string.Empty, landplanNo = string.Empty, buildDate = string.Empty, infoSource = string.Empty, url = string.Empty,
                                 textCode = string.Empty, licCode = string.Empty, msgType = string.Empty, ctxHtml = string.Empty;

                        string listName = string.Empty;
                        listName  = tr.Columns[1].ToNodePlainString();
                        buildDate = tr.Columns[3].ToNodePlainString().GetDateRegex();

                        url = "http://www.szzfcg.cn" + tr.Columns[1].GetATagHref();

                        string htlDtl = string.Empty;
                        try
                        {
                            htlDtl = this.ToolWebSite.GetHtmlByUrl(url, Encoding.UTF8);
                        }
                        catch
                        {
                            continue;
                        }
                        parser = new Parser(new Lexer(htlDtl));
                        NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "tab")));
                        if (dtlNode != null && dtlNode.Count > 0)
                        {
                            ctxHtml    = dtlNode.AsHtml();
                            infoSource = ctxHtml.ToCtxString();

                            string   ctx      = string.Empty;
                            TableTag dtlTable = dtlNode[0] as TableTag;
                            for (int k = 0; k < dtlTable.RowCount; k++)
                            {
                                for (int d = 0; d < dtlTable.Rows[k].ColumnCount; d++)
                                {
                                    if ((d + 1) % 2 == 0)
                                    {
                                        ctx += dtlTable.Rows[k].Columns[d].ToNodePlainString() + "\r\n";
                                    }
                                    else
                                    {
                                        ctx += dtlTable.Rows[k].Columns[d].ToNodePlainString() + ":";
                                    }
                                }
                            }
                            itemName = ctx.GetRegex("项目名称,工程名称,名称");
                            if (string.IsNullOrEmpty(itemName))
                            {
                                itemName = listName;
                            }

                            buildUnit  = ctx.GetRegex("采购人名称");
                            investMent = ctx.GetRegex("财政预算限额(元)");
                            investMent = investMent.GetMoney();

                            msgType = "深圳政府采购";
                            ItemInfo info = ToolDb.GenItemInfo(itemCode, itemName, buildUnit, address, investMent, buildKind, investKink, linkMan, linkmanTel, itemDesc, apprNo, apprDate, apprUnit, apprResult, landapprNo, landplanNo, buildDate, "广东省", "深圳市区", infoSource, url, textCode, licCode, msgType, ctxHtml);

                            sqlCount++;
                            if (!crawlAll && sqlCount >= this.MaxCount)
                            {
                                return(list);
                            }

                            if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate))
                            {
                                BaseProject prj = new BaseProject();
                                prj.Id         = ToolDb.NewGuid;
                                prj.PrjCode    = info.ItemCode;
                                prj.PrjName    = info.ItemName;
                                prj.BuildUnit  = info.BuildUnit;
                                prj.BuildTime  = info.BuildDate;
                                prj.Createtime = info.CreateTime;
                                prj.PrjAddress = info.Address;
                                prj.InfoSource = info.InfoSource;
                                prj.MsgType    = info.MsgType;
                                prj.Province   = info.Province;
                                prj.City       = info.City;
                                prj.Url        = info.Url;

                                ToolDb.SaveEntity(prj, "Url", this.ExistsUpdate);
                            }
                        }
                    }
                }
            }
            return(list);
        }
        //TODO: parse nested projects
        /*
        private static readonly Regex ReNestSection = new Regex(@"(?<ProjGuid>\{\S*?\})\s=\s(?<DirGuid>\{\S*?\})", RegexOptions.Multiline | RegexOptions.Compiled);

        public static NestedProject Parse(ProjectDirectory[] projects, string slnText)
        {
            Project.ParseConfigs(ref projects, ReConfSection.Match(slnText).Groups["Section"].Value);
            return new VsProjectConfiguration(projects);
        }*/
        public ProjectRelationInfo(BaseProject project, ProjectDirectory dir)
        {
            this.project = project;
            this.dir = dir;
        }
Esempio n. 10
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList  list            = new ArrayList();
            string htl             = string.Empty;
            string cookiestr       = string.Empty;
            string viewState       = string.Empty;
            int    page            = 1;
            string eventValidation = string.Empty;

            try
            {
                htl = this.ToolWebSite.GetHtmlByUrl(this.ToolWebSite.UrlEncode(SiteUrl), Encoding.UTF8, ref cookiestr);
            }
            catch (Exception ex)
            {
                return(list);
            }
            Parser   parser  = new Parser(new Lexer(htl));
            NodeList tdNodes = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("id", "PageNumControl1_lbltotal")));

            if (tdNodes.Count > 0)
            {
                try
                {
                    page = int.Parse(tdNodes[0].ToPlainTextString().Trim());
                }
                catch { return(list); }
            }
            for (int i = 1; i <= page; i++)
            {
                if (i > 1)
                {
                    viewState       = this.ToolWebSite.GetAspNetViewState(htl);
                    eventValidation = this.ToolWebSite.GetAspNetEventValidation(htl);
                    NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] {
                        "__EVENTTARGET",
                        "__EVENTARGUMENT",
                        "__LASTFOCUS",
                        "__VIEWSTATE",
                        "txtPrj_ID",
                        "txtPrj_Name", "Chk_Query", "Radiobuttonlist1", "PageNumControl1$gotopage", "PageNumControl1$NEXTpage", "__EVENTVALIDATION",
                    }, new string[] {
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        viewState,
                        string.Empty,
                        string.Empty,
                        "0", "0", "", "下一页", eventValidation
                    });
                    try
                    {
                        htl = this.ToolWebSite.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8, ref cookiestr);
                    }
                    catch (Exception ex) { continue; }
                }
                parser = new Parser(new Lexer(htl));
                NodeList tableNodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "dgConstBid")));
                if (tableNodeList != null && tableNodeList.Count > 0)
                {
                    TableTag table = (TableTag)tableNodeList[0];
                    for (int j = 1; j < table.RowCount; j++)
                    {
                        string pUrl = string.Empty, pInfoSource = string.Empty, pBeginDate = string.Empty, pBuilTime = string.Empty, pEndDate = string.Empty, pConstUnit = string.Empty, pSuperUnit = string.Empty, pDesignUnit = string.Empty, pProspUnit = string.Empty, pInviteArea = string.Empty, pBuildArea = string.Empty, pPrjClass = string.Empty, pProClassLevel = string.Empty, pChargeDept = string.Empty, pPrjAddress = string.Empty, pBuildUnit = string.Empty, pPrjCode = string.Empty, PrjName = string.Empty, pCreatetime = string.Empty;
                        Winista.Text.HtmlParser.Tags.TableRow tr = table.Rows[j];
                        PrjName    = tr.Columns[3].ToPlainTextString().Trim();
                        pBuildUnit = tr.Columns[4].ToPlainTextString().Trim();
                        ATag   aTag = tr.Columns[2].SearchFor(typeof(ATag), true)[0] as ATag;
                        string link = aTag.Link.Replace("GoDetail('", "").Replace("')", "").Replace(";", "");
                        pUrl = "http://www.cb.gov.cn/sgxk/Details.aspx?NID=" + link;// +"&xxlxbh=&PRJ_TYPE=0";
                        string htmldetail = string.Empty;
                        try
                        {
                            htmldetail = this.ToolWebSite.GetHtmlByUrl(this.ToolWebSite.UrlEncode(pUrl), Encoding.UTF8).Replace("<br>", "\r\n");
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        Parser   parserdetail = new Parser(new Lexer(htmldetail));
                        NodeList dtnode       = parserdetail.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "Table8")));
                        if (dtnode != null && dtnode.Count > 0)
                        {
                            string   ctx      = string.Empty;
                            string   ctx1     = string.Empty;
                            string   dateStr  = string.Empty;
                            TableTag tableTwo = (TableTag)dtnode[0];
                            for (int k = 0; k < tableTwo.RowCount; k++)
                            {
                                Winista.Text.HtmlParser.Tags.TableRow trTwo = tableTwo.Rows[k];
                                for (int z = 0; z < trTwo.ColumnCount; z++)
                                {
                                    dateStr = trTwo.Columns[z].ToPlainTextString().Replace("\t", "").Replace("<br>", "\r\n").Replace("&nbsp;", "").Replace("<br/>", "\r\n").Trim();
                                    ctx    += trTwo.Columns[z].ToPlainTextString().Replace("\t", "").Replace("<br>", "\r\n").Replace("&nbsp;", "").Replace("<br/>", "\r\n").Replace(" ", "").Trim();
                                }
                                ctx += "\r\n";
                            }

                            ctx1        = dtnode.AsString().Replace("&nbsp;", "").Replace("\t", "").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Trim();
                            pInfoSource = ctx1;

                            pPrjCode = ctx.GetRegex("工程序号");

                            Regex regPrjAddr = new Regex(@"(工程地点|工程地址)(:|:)[^\r\n]+\r\n");
                            pPrjAddress = regPrjAddr.Match(ctx).Value.Replace("工程地址", "").Replace("工程地点", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regChargeDept = new Regex(@"主管部门(:|:)[^\r\n]+\r\n");
                            pChargeDept = regChargeDept.Match(ctx).Value.Replace("主管部门", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regProClassLevel = new Regex(@"工程类别等级(:|:)[^\r\n]+\r\n");
                            pProClassLevel = regProClassLevel.Match(ctx).Value.Replace("工程类别等级", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regPrjClass = new Regex(@"(工程类型|工程类别)(:|:)[^\r\n]+\r\n");
                            pPrjClass = regPrjClass.Match(ctx).Value.Replace("工程类别", "").Replace("工程类型", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regBuildUnit = new Regex(@"(招标面积|本次招标面积)(:|:)[^\r\n]+\r\n");
                            pInviteArea = regBuildUnit.Match(ctx).Value.Replace("本次招标面积", "").Replace("招标面积", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regpInviteArea = new Regex(@"建筑总面积(:|:)[^\r\n]+\r\n");
                            pBuildArea = regpInviteArea.Match(ctx).Value.Replace("建筑总面积", "").Replace(":", "").Replace(":", "").Trim();

                            pConstUnit = ctx.GetRegex("施工单位");
                            if (pConstUnit == "/")
                            {
                                pConstUnit = string.Empty;
                            }
                            pSuperUnit = ctx.GetRegex("监理单位");
                            if (pSuperUnit == "/")
                            {
                                pSuperUnit = string.Empty;
                            }
                            pDesignUnit = ctx.GetRegex("设计单位");
                            if (pDesignUnit == "/")
                            {
                                pDesignUnit = string.Empty;
                            }
                            pProspUnit = ctx.GetRegex("勘察单位");
                            if (pProspUnit == "/")
                            {
                                pProspUnit = string.Empty;
                            }

                            pBeginDate = dateStr.GetRegex("计划开工日期").GetDateRegex();
                            pEndDate   = dateStr.GetRegex("计划竣工日期").GetDateRegex();

                            BaseProject info = ToolDb.GenBaseProject("广东省", pUrl, "深圳市龙岗区", pInfoSource, pBuilTime, pBeginDate, pEndDate, pConstUnit, pSuperUnit, pDesignUnit, pProspUnit, pInviteArea,
                                                                     pBuildArea, pPrjClass, pProClassLevel, pChargeDept, pPrjAddress, pBuildUnit, pPrjCode, PrjName, pCreatetime, "深圳市龙岗区住房和建设局");

                            list.Add(info);
                            if (!crawlAll && list.Count >= this.MaxCount)
                            {
                                return(list);
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 11
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList  list            = new List <BaseProject>();
            string htl             = string.Empty;
            string cookiestr       = string.Empty;
            string viewState       = string.Empty;
            int    pageInt         = 1;
            string eventValidation = string.Empty;

            try
            {
                htl = this.ToolWebSite.GetHtmlByUrl(SiteUrl, Encoding.Default);
            }
            catch (Exception ex)
            {
                return(list);
            }
            Parser   parser   = new Parser(new Lexer(htl));
            NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("a"), new HasAttributeFilter("id", "lx")));

            if (pageNode != null && pageNode.Count > 0)
            {
                try
                {
                    string temp = pageNode.GetATagHref().GetRegexBegEnd("page=", "&");
                    pageInt = int.Parse(temp);
                }
                catch
                {
                }
            }
            for (int i = 1; i <= pageInt; i++)
            {
                if (i > 1)
                {
                    try
                    {
                        htl = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl + "&page=" + i.ToString(), Encoding.Default);
                    }
                    catch
                    {
                        continue;
                    }
                }
                parser = new Parser(new Lexer(htl));
                NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "bean")));
                if (nodeList != null && nodeList.Count > 0)
                {
                    TableTag table = nodeList[0] as TableTag;
                    for (int j = 1; j < table.RowCount; j++)
                    {
                        string pUrl = string.Empty, pInfoSource = string.Empty,
                               pBeginDate = string.Empty, pBuilTime = string.Empty,
                               pEndDate = string.Empty, pConstUnit = string.Empty,
                               pSuperUnit = string.Empty, pDesignUnit = string.Empty,
                               pProspUnit = string.Empty, pInviteArea = string.Empty,
                               pBuildArea = string.Empty, pPrjClass = string.Empty,
                               pProClassLevel = string.Empty, pChargeDept = string.Empty,
                               pPrjAddress = string.Empty, pBuildUnit = string.Empty,
                               pPrjCode = string.Empty, PrjName = string.Empty, pCreatetime = string.Empty;

                        TableRow tr = table.Rows[j];
                        pPrjCode   = tr.Columns[1].GetATag().LinkText;
                        PrjName    = tr.Columns[2].ToNodePlainString();
                        pBuildUnit = tr.Columns[3].ToNodePlainString();
                        pBuilTime  = tr.Columns[4].ToPlainTextString().GetDateRegex();
                        pUrl       = "http://61.144.226.2:8001/web/zjfbAction.do?method=view&id=" + pPrjCode;
                        string htmldtl = string.Empty;
                        try
                        {
                            htmldtl = this.ToolWebSite.GetHtmlByUrl(pUrl, Encoding.Default);
                        }
                        catch
                        {
                            continue;
                        }
                        parser = new Parser(new Lexer(htmldtl.Replace("th", "td")));
                        NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "infoTableL")));
                        if (dtlNode != null && dtlNode.Count > 0)
                        {
                            TableTag dtlTable = dtlNode[0] as TableTag;
                            for (int k = 0; k < dtlTable.RowCount; k++)
                            {
                                for (int d = 0; d < dtlTable.Rows[k].ColumnCount; d++)
                                {
                                    string temp = dtlTable.Rows[k].Columns[d].ToNodePlainString().Replace(":", "").Replace(":", "");
                                    if (d == 0)
                                    {
                                        pInfoSource += temp += ":";
                                    }
                                    else
                                    {
                                        pInfoSource += temp += "\r\n";
                                    }
                                }
                            }

                            pPrjAddress    = pInfoSource.GetRegex("工程地址,工程地点");
                            pChargeDept    = pInfoSource.GetRegex("主管部门");
                            pProClassLevel = pInfoSource.GetRegex("工程类别等级");
                            pPrjClass      = pInfoSource.GetRegex("工程类别");
                            pInviteArea    = pInfoSource.GetRegex("招标面积,本次招标面积");
                            pBuildArea     = pInfoSource.GetRegex("建筑总面积");
                            pProspUnit     = pInfoSource.GetRegex("勘察单位");
                            pDesignUnit    = pInfoSource.GetRegex("设计单位");
                            pSuperUnit     = pInfoSource.GetRegex("监理单位");
                            pBeginDate     = pInfoSource.GetRegex("计划开工日期");
                            pEndDate       = pInfoSource.GetRegex("计划竣工日期");

                            BaseProject info = ToolDb.GenBaseProject("广东省", pUrl, "深圳市区", pInfoSource, pBuilTime, pBeginDate, pEndDate, pConstUnit, pSuperUnit, pDesignUnit, pProspUnit, pInviteArea,
                                                                     pBuildArea, pPrjClass, pProClassLevel, pChargeDept, pPrjAddress, pBuildUnit, pPrjCode, PrjName, pCreatetime, "深圳市住房和建设局");

                            list.Add(info);
                            if (!crawlAll && list.Count >= this.MaxCount)
                            {
                                return(list);
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 12
0
 public RPGMVExtractor(BaseProject project) : base(project)
 {
     LoadOption();
 }
Esempio n. 13
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            string newUrl = "http://projreg.szjs.gov.cn/web/webService/getProjectList.json";
            IList  list = new List <ItemInfo>();
            string htl = string.Empty;
            string cookiestr = string.Empty;
            string viewState = string.Empty;
            int    sqlCount = 1, count = 1;
            string eventValidation = string.Empty;

            try
            {
                NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "page", "rows" },
                                                                                  new string[] { "1", this.MaxCount.ToString() });
                htl = this.ToolWebSite.GetHtmlByUrl(newUrl, nvc);
            }
            catch (Exception ex)
            {
                return(list);
            }
            JavaScriptSerializer        serializer  = new JavaScriptSerializer();
            Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(htl);

            foreach (KeyValuePair <string, object> obj in smsTypeJson)
            {
                if (obj.Key == "total")
                {
                    continue;
                }
                object[] array = (object[])obj.Value;
                foreach (object arrValue in array)
                {
                    string itemCode = string.Empty, itemName = string.Empty, buildUnit = string.Empty, address = string.Empty,
                                investMent = string.Empty, buildKind = string.Empty, investKink = string.Empty, linkMan = string.Empty,
                                linkmanTel = string.Empty, itemDesc = string.Empty, apprNo = string.Empty, apprDate = string.Empty,
                                apprUnit = string.Empty, apprResult = string.Empty, landapprNo = string.Empty, landplanNo = string.Empty, buildDate = string.Empty, infoSource = string.Empty, url = string.Empty, textCode = string.Empty, licCode = string.Empty, msgType = string.Empty;
                    Dictionary <string, object> dic = (Dictionary <string, object>)arrValue;

                    itemCode  = Convert.ToString(dic["pronumber"]);
                    itemName  = Convert.ToString(dic["proname"]);
                    buildUnit = Convert.ToString(dic["constructionunit"]);
                    buildDate = Convert.ToString(dic["registertime"]);

                    string id = dic["id"].ToString();

                    url = "http://projreg.szjs.gov.cn/web/project.jsp?id=" + id;

                    string dtlUrl  = "http://projreg.szjs.gov.cn/web/webService/getProjectInfo.json";
                    string htmldtl = string.Empty;
                    try
                    {
                        NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "id" },
                                                                                          new string[] { id });
                        htmldtl = this.ToolWebSite.GetHtmlByUrl(dtlUrl, nvc);
                    }
                    catch { continue; }

                    JavaScriptSerializer        serializerNew = new JavaScriptSerializer();
                    Dictionary <string, object> dtlDic        = (Dictionary <string, object>)serializer.DeserializeObject(htmldtl);

                    textCode   = Convert.ToString(dtlDic["plannumber"]);
                    address    = Convert.ToString(dtlDic["projaddress"]);
                    investMent = Convert.ToString(dtlDic["totalinvestment"]);
                    licCode    = Convert.ToString(dtlDic["landplanningpermission"]);

                    infoSource = string.Format("项目编号:{0}\r\n项目名称:{1}\r\n报建地址:{2}\r\n建设单位:{3}\r\n计划总投资:{4}\r\n计划立项文号:{5}\r\n规划许可号:{6}\r\n报建时间:{7}", itemCode, itemName, address, buildUnit, investMent, textCode, licCode, buildDate);

                    string ctxHtml = string.Format("项目编号:{0}<br/>项目名称:{1}<br/>报建地址:{2}<br/>建设单位:{3}<br/>计划总投资:{4}<br/>计划立项文号:{5}<br/>规划许可号:{6}<br/>报建时间:{7}", itemCode, itemName, address, buildUnit, investMent, textCode, licCode, buildDate);



                    msgType = "深圳市住房和建设局";
                    ItemInfo info = ToolDb.GenItemInfo(itemCode, itemName, buildUnit, address, investMent, buildKind, investKink, linkMan, linkmanTel, itemDesc, apprNo, apprDate, apprUnit, apprResult, landapprNo, landplanNo, buildDate, "广东省", "深圳市区", infoSource, url, textCode, licCode, msgType, ctxHtml);

                    sqlCount++;
                    if (!crawlAll && sqlCount >= this.MaxCount)
                    {
                        return(list);
                    }

                    count++;
                    if (count >= 100)
                    {
                        count = 1;
                        Thread.Sleep(600 * 1000);
                    }

                    if (ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate))
                    {
                        BaseProject prj = new BaseProject();
                        prj.Id         = ToolDb.NewGuid;
                        prj.PrjCode    = info.ItemCode;
                        prj.PrjName    = info.ItemName;
                        prj.BuildUnit  = info.BuildUnit;
                        prj.BuildTime  = info.BuildDate;
                        prj.Createtime = info.CreateTime;
                        prj.PrjAddress = info.Address;
                        prj.InfoSource = info.InfoSource;
                        prj.MsgType    = info.MsgType;
                        prj.Province   = info.Province;
                        prj.City       = info.City;
                        prj.Url        = info.Url;

                        ToolDb.SaveEntity(prj, "Url", this.ExistsUpdate);
                    }
                }
            }
            return(list);
        }
Esempio n. 14
0
 private bool Solvent(BaseProject baseProject)
 {
     if (coins >= (baseProject.Cost() - discount))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 15
0
    private void FillBaseProjectList()
    {
        whitehouse = new BaseProject(Whitehouse.Costs, Whitehouse.Capacities, Whitehouse.BuildingRounds, Whitehouse.RequiredPoints, Whitehouse.RequiredWhitehouse, "Whitehouse", this, BaseProject.citizienProject, null, null, null, null, 1);
        baseProjects.Add(whitehouse);

        houses = new BaseProject(Houses.Costs, Houses.Capacities, Houses.BuildingRounds, Houses.RequiredPoints, Houses.RequiredWhitehouse, Houses.staticProjectName, this, BaseProject.citizienProject, new BaseProject[] { whitehouse });
        baseProjects.Add(houses);

        street = new BaseProject(Street.Costs, Street.Capacities, Street.BuildingRounds, Street.RequiredPoints, Street.RequiredWhitehouse, "Street", this, BaseProject.capacityProject, new BaseProject[] { whitehouse });
        baseProjects.Add(street);

        carpool = new BaseProject(Carpool.Costs, Carpool.Capacities, Carpool.BuildingRounds, Carpool.RequiredPoints, Carpool.RequiredWhitehouse, "Carpool", this, BaseProject.capacityProject, new BaseProject[] { street }, Carpool.extraPointsList);
        baseProjects.Add(carpool);

        cycletrack = new BaseProject(CycleTrack.Costs, CycleTrack.Capacities, CycleTrack.BuildingRounds, CycleTrack.RequiredPoints, CycleTrack.RequiredWhitehouse, CycleTrack.staticProjectName, this, BaseProject.capacityProject, new BaseProject[] { whitehouse }, CycleTrack.extraPointsList);
        baseProjects.Add(cycletrack);

        industry = new BaseProject(Industry.Costs, Industry.Capacities, Industry.BuildingRounds, Industry.RequiredPoints, Industry.RequiredWhitehouse, "Industry", this, BaseProject.capacityProject, new BaseProject[] { whitehouse }, null, Industry.discounts, Industry.builders);
        baseProjects.Add(industry);

        station = new BaseProject(Station.Costs, Station.Capacities, Station.BuildingRounds, Station.RequiredPoints, Station.RequiredWhitehouse, "Station", this, BaseProject.capacityProject, new BaseProject[] { whitehouse });
        baseProjects.Add(station);

        bus = new BaseProject(Bus.Costs, Bus.Capacities, Bus.BuildingRounds, Bus.RequiredPoints, Bus.RequiredWhitehouse, "Bus", this, BaseProject.capacityProject, new BaseProject[] { whitehouse, station }, new int[] { 1});
        baseProjects.Add(bus);

        train = new BaseProject(Train.Costs, Train.Capacities, Train.BuildingRounds, Train.RequiredPoints, Train.RequiredWhitehouse, "Train", this, BaseProject.capacityProject, new BaseProject[] { whitehouse, station }, new int[] {2 });
        baseProjects.Add(train);
    }
Esempio n. 16
0
 public bool CanBuyBaseProject(BaseProject baseProject)
 {
     bool debug = false;
     if (baseProject.Rounds() != BaseProject.outOfRange)
     {
         //Debug.Log("project: "+ baseProject.projectName+ " constructing: "+ baseProject.constructing);
         if (!baseProject.constructing)
         {
             if (baseProject.MetRequirements())
             {
                 if (Solvent(baseProject))
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             else
             {
                 if(baseProject.projectName == "Carpssool")
                 {
                     Debug.Log("dont meet requirements");
                 }
                 return false;
             }
         }
         else
         {
             if (debug)
             {
                 Debug.Log("You cant upgrade this project at the moment because it is still under construction!");
             }
             return false;
         }
     }
     else
     {
         if (debug)
         {
             Debug.Log("Project is at maximum upgrade!");
         }
         return false;
     }
 }
Esempio n. 17
0
 public void BuyProject(BaseProject p)
 {
     p.BuyProject();
 }
Esempio n. 18
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList  list            = new ArrayList();
            string htl             = string.Empty;
            string cookiestr       = string.Empty;
            string viewState       = string.Empty;
            int    page            = 1;
            string eventValidation = string.Empty;

            try
            {
                htl = this.ToolWebSite.GetHtmlByUrl(SiteUrl, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                return(list);
            }
            if (htl.Contains("RowCount"))
            {
                try
                {
                    int     index   = htl.IndexOf("RowCount");
                    string  pageStr = htl.Substring(index, htl.Length - index).Replace("RowCount", "").Replace("}", "").Replace(":", "").Replace("\"", "");
                    decimal b       = decimal.Parse(pageStr) / 20;
                    if (b.ToString().Contains("."))
                    {
                        page = Convert.ToInt32(b) + 1;
                    }
                    else
                    {
                        page = Convert.ToInt32(b);
                    }
                }
                catch { }
            }
            for (int i = 1; i <= page; i++)
            {
                if (i > 1)
                {
                    try
                    {
                        htl = this.ToolWebSite.GetHtmlByUrl("http://www.szjs.gov.cn/build/build.ashx?_=1356597320333&menu=%E9%A1%B9%E7%9B%AE%E4%BF%A1%E6%81%AF&type=%E7%9B%B4%E6%8E%A5%E5%8F%91%E5%8C%85&pageSize=20&pageIndex=" + i.ToString() + "&prjName=&timp=333", Encoding.UTF8);
                    }
                    catch
                    {
                        continue;
                    }
                }
                JavaScriptSerializer        serializer  = new JavaScriptSerializer();
                Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(htl);
                foreach (KeyValuePair <string, object> obj in smsTypeJson)
                {
                    if (obj.Key != "DataList")
                    {
                        continue;
                    }
                    object[] array = (object[])obj.Value;
                    foreach (object obj2 in array)
                    {
                        Dictionary <string, object> dicSmsType = (Dictionary <string, object>)obj2;
                        string pUrl = string.Empty, pInfoSource = string.Empty,
                               pBeginDate = string.Empty, pBuilTime = string.Empty,
                               pEndDate = string.Empty, pConstUnit = string.Empty,
                               pSuperUnit = string.Empty, pDesignUnit = string.Empty,
                               pProspUnit = string.Empty, pInviteArea = string.Empty,
                               pBuildArea = string.Empty, pPrjClass = string.Empty,
                               pProClassLevel = string.Empty, pChargeDept = string.Empty,
                               pPrjAddress = string.Empty, pBuildUnit = string.Empty,
                               pPrjCode = string.Empty, PrjName = string.Empty, pCreatetime = string.Empty;
                        try
                        {
                            pPrjCode   = Convert.ToString(dicSmsType["PrjId"]);
                            PrjName    = Convert.ToString(dicSmsType["PrjName"]);
                            pBuildUnit = Convert.ToString(dicSmsType["ConstOrg"]);
                            pBuilTime  = Convert.ToString(dicSmsType["Bjrq"]);
                            pUrl       = "http://www.szjs.gov.cn/build/gcxm_detail.aspx?id=" + pPrjCode;
                            string htmldetail = string.Empty;
                            try
                            {
                                htmldetail = this.ToolWebSite.GetHtmlByUrl(pUrl, Encoding.UTF8, ref cookiestr).Trim();
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            Parser   parser   = new Parser(new Lexer(htmldetail));
                            NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "js-table mar-l-4")));
                            if (nodeList != null && nodeList.Count > 0)
                            {
                                TableTag table = nodeList[0] as TableTag;
                                for (int j = 0; j < table.RowCount; j++)
                                {
                                    TableRow dr  = table.Rows[j];
                                    string   ctx = string.Empty;
                                    for (int k = 0; k < dr.ColumnCount; k++)
                                    {
                                        ctx += dr.Columns[k].ToPlainTextString().Trim().Replace(" ", "").Replace("\r", "").Replace("\n", "");
                                    }
                                    pInfoSource += ctx + "\r\n";
                                }
                                Regex regPrjAddr = new Regex(@"(工程地点|工程地址)(:|:)[^\r\n]+\r\n");
                                pPrjAddress = regPrjAddr.Match(pInfoSource).Value.Replace("工程地址", "").Replace("工程地点", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regChargeDept = new Regex(@"主管部门(:|:)[^\r\n]+\r\n");
                                pChargeDept = regChargeDept.Match(pInfoSource).Value.Replace("主管部门", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regProClassLevel = new Regex(@"工程类别等级(:|:)[^\r\n]+\r\n");
                                pProClassLevel = regProClassLevel.Match(pInfoSource).Value.Replace("工程类别等级", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regConst = new Regex(@"施工单位(:|:)[^\r\n]+\r\n");
                                pConstUnit = regConst.Match(pInfoSource).Value.Replace("施工单位", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regPrjClass = new Regex(@"(工程类型|工程类别)(:|:)[^\r\n]+\r\n");
                                pPrjClass = regPrjClass.Match(pInfoSource).Value.Replace("工程类别", "").Replace("工程类型", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regBuildUnit = new Regex(@"(招标面积|本次招标面积)(:|:)[^\r\n]+\r\n");
                                pInviteArea = regBuildUnit.Match(pInfoSource).Value.Replace("本次招标面积", "").Replace("招标面积", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpInviteArea = new Regex(@"建筑总面积(:|:)[^\r\n]+\r\n");
                                pBuildArea = regpInviteArea.Match(pInfoSource).Value.Replace("建筑总面积", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpProspUnit = new Regex(@"勘查单位(:|:)[^\r\n]+\r\n");
                                pProspUnit = regpProspUnit.Match(pInfoSource).Value.Replace("勘查单位", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpDesignUnit = new Regex(@"设计单位(:|:)[^\r\n]+\r\n");
                                pDesignUnit = regpDesignUnit.Match(pInfoSource).Value.Replace("设计单位", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpSuperUnit = new Regex(@"监理单位(:|:)[^\r\n]+\r\n");
                                pSuperUnit = regpSuperUnit.Match(pInfoSource).Value.Replace("监理单位", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpBeginDate = new Regex(@"(计划开工日期|预计开工日期)(:|:)[^\r\n]+\r\n");
                                pBeginDate = regpBeginDate.Match(pInfoSource).Value.Replace("计划开工日期", "").Replace("预计开工日期", "").Replace(":", "").Replace(":", "").Trim();

                                Regex regpEndDate = new Regex(@"(计划竣工日期|预计竣工日期)(:|:)[^\r\n]+\r\n");
                                pEndDate = regpEndDate.Match(pInfoSource).Value.Replace("计划竣工日期", "").Replace("预计竣工日期", "").Replace(":", "").Replace(":", "").Trim();

                                if (!string.IsNullOrEmpty(pBeginDate))
                                {
                                    try
                                    {
                                        int    date = pBeginDate.IndexOf("-");
                                        string time = pBeginDate.Substring(0, pBeginDate.Length - date - 5);
                                        if (time.Contains("0") || time.Contains("9"))
                                        {
                                            pBeginDate = "";
                                        }
                                    }
                                    catch { }
                                }
                                if (!string.IsNullOrEmpty(pEndDate))
                                {
                                    try
                                    {
                                        int    date = pEndDate.IndexOf("-");
                                        string time = pEndDate.Substring(0, pEndDate.Length - date - 5);
                                        if (time.Contains("0") || time.Contains("9"))
                                        {
                                            pEndDate = "";
                                        }
                                    }
                                    catch { }
                                }

                                BaseProject info = ToolDb.GenBaseProject("广东省", pUrl, "深圳市区", pInfoSource, pBuilTime, pBeginDate, pEndDate, pConstUnit, pSuperUnit, pDesignUnit, pProspUnit, pInviteArea,
                                                                         pBuildArea, pPrjClass, pProClassLevel, pChargeDept, pPrjAddress, pBuildUnit, pPrjCode, PrjName, pCreatetime, "深圳市住房和建设局");

                                list.Add(info);
                                if (!crawlAll && list.Count >= this.MaxCount)
                                {
                                    return(list);
                                }
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 19
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            string newUrl = "http://projreg.szjs.gov.cn/web/webService/getEngList.json";
            IList  list = new List <BaseProject>();
            string htl = string.Empty;
            string cookiestr = string.Empty;
            string viewState = string.Empty;
            int    count = 1, pageInt = 1;
            string eventValidation = string.Empty;
            JavaScriptSerializer        serializer  = new JavaScriptSerializer();
            Dictionary <string, object> smsTypeJson = null;

            try
            {
                NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "page", "rows" },
                                                                                  new string[] { "1", "500" });

                htl = this.ToolWebSite.GetHtmlByUrl(newUrl, nvc);

                smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(htl);

                int totalCount = Convert.ToInt32(smsTypeJson["total"]);

                pageInt = totalCount / 500 + 1;
            }
            catch (Exception ex)
            {
                return(list);
            }

            for (int i = 1; i <= pageInt; i++)
            {
                if (i > 1)
                {
                    try
                    {
                        NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "page", "rows" },
                                                                                          new string[] { i.ToString(), "500" });

                        htl = this.ToolWebSite.GetHtmlByUrl(newUrl, nvc);

                        serializer  = new JavaScriptSerializer();
                        smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(htl);
                    }
                    catch { continue; }
                }
                foreach (KeyValuePair <string, object> obj in smsTypeJson)
                {
                    if (obj.Key == "total")
                    {
                        continue;
                    }
                    object[] array = (object[])obj.Value;
                    foreach (object arrValue in array)
                    {
                        string pUrl = string.Empty, pInfoSource = string.Empty,
                                    pBeginDate = string.Empty, pBuilTime = string.Empty,
                                    pEndDate = string.Empty, pConstUnit = string.Empty,
                                    pSuperUnit = string.Empty, pDesignUnit = string.Empty,
                                    pProspUnit = string.Empty, pInviteArea = string.Empty,
                                    pBuildArea = string.Empty, pPrjClass = string.Empty,
                                    pProClassLevel = string.Empty, pChargeDept = string.Empty,
                                    pPrjAddress = string.Empty, pBuildUnit = string.Empty,
                                    pPrjCode = string.Empty, PrjName = string.Empty, pCreatetime = string.Empty;

                        Dictionary <string, object> dic = (Dictionary <string, object>)arrValue;

                        string id = Convert.ToString(dic["id"]);
                        pPrjCode   = Convert.ToString(dic["engnumber"]);
                        PrjName    = Convert.ToString(dic["engname"]);
                        pBuildUnit = Convert.ToString(dic["constructionunit"]);
                        pBuilTime  = Convert.ToString(dic["registertime"]);



                        pUrl = "http://projreg.szjs.gov.cn/web/eng.jsp?id=" + pPrjCode;
                        string dtlUrl  = "http://projreg.szjs.gov.cn/web/webService/getEngInfo.json";
                        string htmldtl = string.Empty;
                        try
                        {
                            NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "id" },
                                                                                              new string[] { id });
                            htmldtl = this.ToolWebSite.GetHtmlByUrl(dtlUrl, nvc);
                        }
                        catch (Exception ex)
                        {
                            continue;
                        }

                        JavaScriptSerializer        serializerNew = new JavaScriptSerializer();
                        Dictionary <string, object> dtlDic        = (Dictionary <string, object>)serializer.DeserializeObject(htmldtl);

                        pInfoSource = string.Format("工程编号:{0}\r\n工程名称:{1}\r\n工程地址:{2}\r\n主管部门:{3}\r\n工程类别等级:{4}\r\n工程类别:{5}\r\n建筑总面积:{6}\r\n红线面积:{7}\r\n勘察单位:{8}\r\n设计单位:{9}\r\n监理单位:{10}\r\n合同开工日期:{11}\r\n合同竣工日期:{12}",
                                                    pPrjCode,
                                                    PrjName,
                                                    Convert.ToString(dtlDic["engaddress"]),
                                                    Convert.ToString(dtlDic["prodepartment"]),
                                                    Convert.ToString(dtlDic["englevel"]),
                                                    Convert.ToString(dtlDic["professiontype"]),
                                                    Convert.ToString(dtlDic["grossarea"]),
                                                    Convert.ToString(dtlDic["redlinearea"]),
                                                    Convert.ToString(dtlDic["survey"]),
                                                    Convert.ToString(dtlDic["design"]),
                                                    Convert.ToString(dtlDic["supervision"]),
                                                    Convert.ToString(dtlDic["starttime"]),
                                                    Convert.ToString(dtlDic["finishtime"]));

                        pPrjAddress    = pInfoSource.GetRegex("工程地址");
                        pChargeDept    = pInfoSource.GetRegex("主管部门");
                        pProClassLevel = pInfoSource.GetRegex("工程类别等级");
                        pPrjClass      = pInfoSource.GetRegex("工程类别");
                        pInviteArea    = pInfoSource.GetRegex("红线面积");
                        pBuildArea     = pInfoSource.GetRegex("建筑总面积");
                        pProspUnit     = pInfoSource.GetRegex("勘察单位");
                        pDesignUnit    = pInfoSource.GetRegex("设计单位");
                        pSuperUnit     = pInfoSource.GetRegex("监理单位");
                        pBeginDate     = pInfoSource.GetRegex("合同开工日期");
                        pEndDate       = pInfoSource.GetRegex("合同竣工日期");

                        BaseProject info = ToolDb.GenBaseProject("广东省", pUrl, "深圳市区", pInfoSource, pBuilTime, pBeginDate, pEndDate, pConstUnit, pSuperUnit, pDesignUnit, pProspUnit, pInviteArea,
                                                                 pBuildArea, pPrjClass, pProClassLevel, pChargeDept, pPrjAddress, pBuildUnit, pPrjCode, PrjName, pCreatetime, "深圳市住房和建设局");

                        list.Add(info);
                        if (!crawlAll && list.Count >= this.MaxCount)
                        {
                            return(list);
                        }

                        count++;
                        if (count >= 100)
                        {
                            count = 1;
                            Thread.Sleep(600 * 1000);
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 20
0
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList  list            = new ArrayList();
            string htl             = string.Empty;
            string cookiestr       = string.Empty;
            string viewState       = string.Empty;
            int    page            = 1;
            string eventValidation = string.Empty;

            try
            {
                htl = this.ToolWebSite.GetHtmlByUrl(this.ToolWebSite.UrlEncode(SiteUrl), Encoding.UTF8, ref cookiestr);
            }
            catch (Exception ex)
            {
                return(list);
            }
            Parser   parser  = new Parser(new Lexer(htl));
            NodeList tdNodes = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("id", "ctl00_Main_paging_LblPageCount")));

            if (tdNodes.Count > 0)
            {
                try
                {
                    page = int.Parse(tdNodes[0].ToPlainTextString().Trim());
                }
                catch { return(list); }
            }
            for (int i = 1; i <= page; i++)
            {
                if (i > 1)
                {
                    if (i < 3)
                    {
                        viewState       = this.ToolWebSite.GetAspNetViewState(htl);
                        eventValidation = this.ToolWebSite.GetAspNetEventValidation(htl);
                    }
                    NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] {
                        "ctl00$ScriptManager1",
                        "__EVENTTARGET",
                        "__EVENTARGUMENT",
                        "ctl00$Main$ddl_type",
                        "ctl00$Main$txt_Title",
                        "ctl00$Main$paging$txtPageIndex",
                        "__VIEWSTATE",
                        "__VIEWSTATEENCRYPTED",
                        "__EVENTVALIDATION",
                        "__ASYNCPOST",
                        "ctl00$Main$paging$btnForward.x",
                        "ctl00$Main$paging$btnForward.y"
                    }, new string[] {
                        "ctl00$UpdatePanel1|ctl00$Main$paging$btnForward",
                        string.Empty,
                        string.Empty,
                        "1",
                        string.Empty,
                        i.ToString(),
                        viewState, "", eventValidation, "true", "8", "9"
                    });
                    try
                    {
                        htl = this.ToolWebSite.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8);
                    }
                    catch (Exception ex) { continue; }
                }
                parser = new Parser(new Lexer(htl));
                NodeList tableList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "ctl00_Main_GV_New")));
                if (tableList != null && tableList.Count > 0)
                {
                    TableTag table = (TableTag)tableList[0];
                    for (int j = 1; j < table.RowCount; j++)
                    {
                        string pUrl = string.Empty, pInfoSource = string.Empty, pBeginDate = string.Empty,
                               pBuilTime = string.Empty, pEndDate = string.Empty, pConstUnit = string.Empty,
                               pSuperUnit = string.Empty, pDesignUnit = string.Empty, pProspUnit = string.Empty,
                               pInviteArea = string.Empty, pBuildArea = string.Empty, pPrjClass = string.Empty,
                               pProClassLevel = string.Empty, pChargeDept = string.Empty, pPrjAddress = string.Empty,
                               pBuildUnit = string.Empty, pPrjCode = string.Empty, PrjName = string.Empty,
                               pCreatetime = string.Empty;
                        TableRow tr        = table.Rows[j];
                        PrjName    = tr.Columns[2].ToPlainTextString().Trim();
                        pBuildUnit = tr.Columns[3].ToPlainTextString().Trim();
                        string aLink = string.Empty;
                        ATag   aTag  = new ATag();
                        try
                        {
                            aLink  = tr.ToHtml().Replace("ondblclick", "href").Replace("<tr", "<a");
                            aLink  = aLink.Remove(aLink.IndexOf("<td")) + "</a>";
                            parser = new Parser(new Lexer(aLink));
                            NodeFilter a     = new TagNameFilter("a");
                            NodeList   aList = parser.ExtractAllNodesThatMatch(a);
                            if (aList != null && aList.Count > 0)
                            {
                                aTag = aList.SearchFor(typeof(ATag), true)[0] as ATag;
                            }
                            if (aTag.Link.Contains("PrjManager") || aTag.Link.Contains("View"))
                            {
                                pUrl = aTag.Link.Remove(aTag.Link.IndexOf("View")).Replace("&amp;", "&") + "View";
                                int index = pUrl.IndexOf("PrjManager");
                                pUrl = "http://www.szbajs.gov.cn/SiteManage/" + pUrl.Substring(index, pUrl.Length - index);
                            }
                            else
                            {
                                continue;
                            }
                        }
                        catch (Exception ex) { continue; }
                        string htmldetail = string.Empty;
                        try
                        {
                            htmldetail = this.ToolWebSite.GetHtmlByUrl(this.ToolWebSite.UrlEncode(pUrl), Encoding.UTF8);
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        Parser   parserdetail = new Parser(new Lexer(htmldetail));
                        NodeList dtnode       = parserdetail.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "data_con")));
                        if (dtnode.Count > 0 && dtnode != null)
                        {
                            pInfoSource = dtnode.AsString().Replace(" ", "");
                            Regex regPrjAddr = new Regex(@"(工程地点|工程地址)(:|:)[^\r\n]+\r\n");
                            pPrjAddress = regPrjAddr.Match(pInfoSource).Value.Replace("工程地址", "").Replace("工程地点", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regpProspUnit = new Regex(@"勘查单位(:|:)[^\r\n]+\r\n");
                            pProspUnit = regpProspUnit.Match(pInfoSource).Value.Replace("勘查单位", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regpDesignUnit = new Regex(@"设计单位(:|:)[^\r\n]+\r\n");
                            pDesignUnit = regpDesignUnit.Match(pInfoSource).Value.Replace("设计单位", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regpSuperUnit = new Regex(@"监理单位(:|:)[^\r\n]+\r\n");
                            pSuperUnit = regpSuperUnit.Match(pInfoSource).Value.Replace("监理单位", "").Replace(":", "").Replace(":", "").Trim();

                            Regex regConst = new Regex(@"施工单位(:|:)[^\r\n]+\r\n");
                            pConstUnit = regConst.Match(pInfoSource).Value.Replace("施工单位", "").Replace(":", "").Replace(":", "").Trim();
                            if (string.IsNullOrEmpty(pChargeDept))
                            {
                                pChargeDept = "宝安区建设局";
                            }
                            BaseProject info = ToolDb.GenBaseProject("广东省", pUrl, "深圳市宝安区", pInfoSource, pBuilTime, pBeginDate, pEndDate, pConstUnit, pSuperUnit, pDesignUnit, pProspUnit, pInviteArea,
                                                                     pBuildArea, pPrjClass, pProClassLevel, pChargeDept, pPrjAddress, pBuildUnit, pPrjCode, PrjName, pCreatetime, "深圳市宝安区建设局");

                            list.Add(info);
                            if (!crawlAll && list.Count >= this.MaxCount)
                            {
                                return(list);
                            }
                        }
                    }
                }
            }
            return(list);
        }
 // GET: CodeMain
 public ActionResult Index(BaseProject.Admin.ViewModels.CodeMain.Index  searchViewModel)
 {
     service.ProcessIndexViewModel(searchViewModel);
     return View(searchViewModel);
 }
Esempio n. 22
0
 public TesExtractor(BaseProject project) : base(project)
 {
 }
Esempio n. 23
0
 public ClientModule(BaseProject project, string code)
     : base(project, code)
 {
 }