Example #1
0
    protected void BtnInfo_Click(object sender, EventArgs e)
    {
        var BtnInfo = sender as Button;
        var GvRow   = BtnInfo.NamingContainer as GridViewRow;

        LblInfo.InnerText = GvRow.DataKey("Info");
        UpInfo.Update();
        RegistraScriptSoloPostBack(this, "$('#DivInfo').modal('show');");
    }
        public List <UpInfo> UpsOnline2Local(List <UpInfo> online)
        {
            for (int i = 0; i < online.Count; i++)
            {
                UpInfo tmp = online[i];
                tmp.faceImg   = Path.GetFileName(tmp.faceImg);
                tmp.roomCover = Path.GetFileName(tmp.roomCover);
                online[i]     = tmp;
            }

            return(online);
        }
Example #3
0
        static public void DownloadUpInfo(UpInfo up)
        {
            string faceFile = Path.Combine(Path.FacesDirectory, Path.GetFileName(up.faceImg));

            if (!File.Exists(faceFile))
            {
                DownloadImage(up.faceImg);
            }
            string coverFilename = Path.Combine(Path.CoversDirectory, Path.GetFileName(up.roomCover).Split('?')[0]);

            if (!File.Exists(coverFilename))
            {
                DownloadImage(up.roomCover, coverFilename);
            }
        }
Example #4
0
            protected override UpInfo <TItem> BeforePopDependency(Stack <TDependency> currentPath, int expectedPathMatchIndex,
                                                                  AbstractPathMatch <TDependency, TItem> pathMatchOrNull, bool isEnd,
                                                                  Ignore here, UpInfo <TItem> upSum, UpInfo <TItem> childUp)
            {
                upSum.UnionWith(childUp);

                TDependency top          = currentPath.Peek();
                var         key          = new ItemAndInt(top.UsedItem, expectedPathMatchIndex);
                bool        isEndOfCycle = _onPath.Contains(key);

                if (isEnd || isEndOfCycle)
                {
                    upSum.Add(top.UsedItem);
                }
                return(upSum);
            }
Example #5
0
            public List <FromTo <TItem, TDependency> > Traverse(IEnumerable <TDependency> dependencies, ItemMatch pathAnchor,
                                                                bool pathAnchorIsCountMatch, AbstractPathMatch <TDependency, TItem>[] expectedPathMatches)
            {
                Dictionary <TItem, TDependency[]> incidentDependencies = _backwards
                    ? AbstractItem <TItem> .CollectIncomingDependenciesMap(dependencies)
                    : AbstractItem <TItem> .CollectOutgoingDependenciesMap(dependencies);

                _seenInnerPathStarts.Clear();
                Counts.Clear();
                _onPath.Clear();

                TItem[] uniqueStartItems = (pathAnchor == null
                    ? incidentDependencies.Keys
                    : incidentDependencies.Keys.Where(i => pathAnchor.Matches(i).Success)).ToArray();
                AbstractPathMatch <TDependency, TItem> endMatch;

                AbstractPathMatch <TDependency, TItem>[] innerMatches;
                int n = expectedPathMatches.Length;

                if (n == 0)
                {
                    endMatch     = null;
                    innerMatches = expectedPathMatches;
                }
                else
                {
                    endMatch     = expectedPathMatches[n - 1];
                    innerMatches = expectedPathMatches.Take(n - 1).ToArray();
                }

                var result = new List <FromTo <TItem, TDependency> >();

                foreach (var item in uniqueStartItems.OrderBy(i => i.Name))
                {
                    if (_seenInnerPathStarts.Add(item))
                    {
                        UpInfo <TItem> up = Traverse(root: item,
                                                     incidentDependencies: incidentDependencies, expectedInnerPathMatches: innerMatches,
                                                     endMatch: endMatch, down: new DownInfo(pathAnchorIsCountMatch ? item : null));
                        result.AddRange(up.EndItems.Select(i => new FromTo <TItem, TDependency>(item, i)));
                    }
                }
                return(result);
            }
Example #6
0
            protected override bool ShouldVisitSuccessors(TItem tail, Stack <TDependency> currentPath,
                                                          int expectedPathMatchIndex, out UpInfo <TItem> initUpSum)
            {
                initUpSum = new UpInfo <TItem>();
                var onPathItem = new ItemAndInt(tail, expectedPathMatchIndex);

                if (currentPath.Count == 0)
                {
                    // Behind head
                    _onPath.Add(onPathItem);
                    return(true);
                }
                else if (currentPath.Count >= _maxPathLength)
                {
                    // We have reached the checking limit - no further graph traversal
                    return(false);
                }
                else
                {
                    // Check for loop
                    bool tailNewOnPath = _onPath.Add(onPathItem);
                    return(tailNewOnPath);
                }
            }
Example #7
0
 public void UnionWith(UpInfo <TItem> childUp)
 {
     EndItems.UnionWith(childUp.EndItems);
 }
Example #8
0
 protected override UpInfo <TItem> AfterVisitingSuccessors(bool visitSuccessors, TItem tail,
                                                           Stack <TDependency> currentPath, int expectedPathMatchIndex, UpInfo <TItem> upSum)
 {
     if (visitSuccessors)
     {
         // We visit the children - tail was therefore definitely not in _onPath - so we can safely remove it!
         var key = new ItemAndInt(tail, expectedPathMatchIndex);
         _onPath.Remove(key);
     }
     return(upSum);
 }
        /// <summary>
        /// 取关
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="count"></param>
        public void UnfollowBatched(string groupName, int count)
        {
            _logger.LogInformation("【分组名】{group}", groupName);

            //根据分组名称获取tag
            TagDto tag   = GetTag(groupName);
            int?   tagId = tag?.Tagid;
            int    total = tag?.Count ?? 0;

            if (!tagId.HasValue)
            {
                _logger.LogWarning("分组名称不存在");
                return;
            }

            if (total == 0)
            {
                _logger.LogWarning("分组下不存在up");
                return;
            }

            if (count == -1)
            {
                count = total;
            }

            _logger.LogInformation("【分组下共有】{count}人", total);
            _logger.LogInformation("【目标取关】{count}人" + Environment.NewLine, count);

            //计算共几页
            int totalPage = (int)Math.Ceiling(total / (double)20);

            //从最后一页开始获取
            var req = new GetSpecialFollowingsRequest(long.Parse(_cookie.UserId), tagId.Value)
            {
                Pn = totalPage
            };
            List <UpInfo> followings = _relationApi.GetFollowingsByTag(req)
                                       .GetAwaiter().GetResult()
                                       .Data;

            followings.Reverse();

            var targetList = new List <UpInfo>();

            if (count <= followings.Count)
            {
                targetList = followings.Take(count).ToList();
            }
            else
            {
                int pn = totalPage;
                while (targetList.Count < count)
                {
                    targetList.AddRange(followings);

                    //获取前一页
                    pn -= 1;
                    if (pn <= 0)
                    {
                        break;
                    }
                    req.Pn     = pn;
                    followings = _relationApi.GetFollowingsByTag(req)
                                 .GetAwaiter().GetResult()
                                 .Data;
                    followings.Reverse();
                }
            }

            _logger.LogInformation("开始取关..." + Environment.NewLine);
            int success = 0;

            for (int i = 1; i <= targetList.Count && i <= count; i++)
            {
                UpInfo info = targetList[i - 1];

                _logger.LogInformation("【序号】{num}", i);
                _logger.LogInformation("【UP】{up}", info.Uname);

                string modifyReferer = string.Format(RelationApiConstant.ModifyReferer, _cookie.UserId, tagId);
                var    modifyReq     = new ModifyRelationRequest(info.Mid, _cookie.BiliJct);
                var    re            = _relationApi.ModifyRelation(modifyReq, modifyReferer)
                                       .GetAwaiter().GetResult();

                if (re.Code == 0)
                {
                    _logger.LogInformation("【取关结果】成功" + Environment.NewLine);
                    success++;
                }
                else
                {
                    _logger.LogInformation("【取关结果】失败");
                    _logger.LogInformation("【原因】{msg}" + Environment.NewLine, re.Message);
                }
            }

            _logger.LogInformation("【本次共取关】{count}人", success);

            //计算剩余
            tag = GetTag(groupName);
            _logger.LogInformation("【分组下剩余】{count}人", tag?.Count ?? 0);
        }