public ResultDto SetLinkStatus(string user_id, string id, byte?status)
        {
            ResultDto result = new ResultDto();

            var builder = Builders <IW2S_ImgSearchLink> .Filter;
            var filter  = builder.Eq(x => x._id, new ObjectId(id));

            var col = MongoDBHelper.Instance.GetIW2S_ImgSearchLinks();
            IW2S_ImgSearchLink linkUrlPrj = col.Find(filter).Project(x => new IW2S_ImgSearchLink
            {
                LinkUrl   = x.LinkUrl,
                ProjectId = x.ProjectId
            }).FirstOrDefault();
            var updfilter = builder.Eq(x => x.LinkUrl, linkUrlPrj.LinkUrl) & builder.Eq(x => x.ProjectId, linkUrlPrj.ProjectId);
            var update    = new UpdateDocument {
                { "$set", new QueryDocument {
                      { "DataCleanStatus", status }
                  } }
            };

            col.UpdateMany(updfilter, update);

            if (status == 1)
            {
                IW2S_OperateLog log = new IW2S_OperateLog
                {
                    CreatedAt        = DateTime.Now.AddHours(8),
                    ProjectId        = linkUrlPrj.ProjectId,
                    ShareOperateType = (int)ShareOperateType.CollectConfig,
                    UserId           = new ObjectId(user_id),
                    SiteSource       = (int)SiteSource.BaiduImg
                };
                MongoDBHelper.Instance.GetIW2S_OperateLogs().InsertOne(log);
            }

            result.IsSuccess = true;
            return(result);
        }
예제 #2
0
        private void HanleTagData(IW2S_ImgSearchTask tsk, string title, string href, string abs, string domain, string src, int rank)
        {
            string realUrl = null, detailHtml = null;


            if (!string.IsNullOrWhiteSpace(href))
            {
                //Encoding enc = Encoding.UTF8;
                //detailHtml = HtmlQueryHelper.GetContent(href, 8000, ref enc, out realUrl);
                var tuplehtml = get_htmlUrl(href);
                if (tuplehtml != null && !string.IsNullOrEmpty(tuplehtml.Item1))
                {
                    realUrl = tuplehtml.Item1;
                }
                if (tuplehtml != null && !string.IsNullOrEmpty(tuplehtml.Item2))
                {
                    detailHtml = tuplehtml.Item2;
                }
                if (!string.IsNullOrEmpty(realUrl) && string.IsNullOrEmpty(domain))
                {
                    domain = GetDomain(realUrl);
                }
            }
            if (!string.IsNullOrEmpty(detailHtml) && detailHtml.Contains("document.getElementById(\"link\").click()"))
            {
                var gourl = detailHtml.GetFirstHref2();
                if (!string.IsNullOrEmpty(gourl))
                {
                    var tuplehtml = get_htmlUrl(gourl);
                    if (tuplehtml != null && !string.IsNullOrEmpty(tuplehtml.Item1))
                    {
                        realUrl = tuplehtml.Item1;
                    }
                    if (tuplehtml != null && !string.IsNullOrEmpty(tuplehtml.Item2))
                    {
                        detailHtml = tuplehtml.Item2;
                    }
                    if (!string.IsNullOrEmpty(realUrl) && string.IsNullOrEmpty(domain))
                    {
                        domain = GetDomain(realUrl);
                    }
                }
            }
            if (string.IsNullOrEmpty(realUrl))
            {
                realUrl = href;
            }
            if (string.IsNullOrEmpty(detailHtml))
            {
                return;
            }

            Regex reg = new Regex("(20\\d{2}[-/]\\d{1,2}[-/]\\d{1,2})|(20\\d{2}年\\d{1,2}月\\d{1,2}日)");
            Match m   = reg.Match(detailHtml);
            //MatchCollection cols = reg.Matches(item.Html);
            string time = "";

            if (m.Groups.Count > 0)
            {
                time = m.Groups[0].Value;
            }


            IW2S_ImgSearchLink l1 = new IW2S_ImgSearchLink
            {
                UsrId     = tsk.UsrId,
                Domain    = domain,
                TopDomain = GetLevel1Domain(domain),
                Src       = src,
                LinkUrl   = href,

                BizId = "{0}{1}".FormatStr(href, tsk._id.ToString()).ToObjectId(),
                IW2S_ImgSearchTaskId = tsk._id,
                CreatedAt            = DateTime.UtcNow.AddHours(8),
                Description          = abs,
                Title = title,

                ProjectId   = tsk.ProjectId,
                PublishTime = time,

                Rank = rank
            };



            save_level1_links(new List <IW2S_ImgSearchLink> {
                l1
            }, tsk);
        }