示例#1
0
        private static void CalcDeltaExps()
        {
            _deltaExps.Clear();
            _progress = 0;
            float len   = _expsOld.Count;
            int   count = 0;

            foreach (ContentExpEntry ets in _expsOld)                                                                   //对于历史数据中的每个经验条目
            {
                IEnumerable <ContentExpEntry> ic = _expsNew.Where(t => t.ExpName == ets.ExpName && t.Date == ets.Date); //寻找经验名称相等的条目
                if (ic.Any())
                {
                    string          shortName;
                    ContentExpEntry ft = ic.First();    //ft即所寻获的条目
                    if (ft.ExpName.Length > 10)
                    {
                        shortName = ft.ExpName.Substring(0, 10) + "...";
                    }
                    else
                    {
                        shortName = ft.ExpName;
                    }
                    ContentExpEntry eet = new ContentExpEntry(shortName, "", ft.View - ets.View, ft.Vote - ets.Vote, 0, ets.Date); //浏览量做差
                    _deltaExps.Add(eet);
                    ft.ViewIncrease = ft.View - ets.View;                                                                          //浏览量做差,保存
                }
                count++;
                _progress = count / len;
            }
        }
示例#2
0
        public static void CondenseExps(
            ObservableCollection <ContentExpEntry> expsNew)
        {
            int parts        = 40;
            int newExpLength = expsNew.Count();

            _condensedExps.Clear();
            if (newExpLength < parts)
            {
                foreach (ContentExpEntry ets in expsNew)
                {
                    _condensedExps.Add(ets);
                }
            }
            else
            {
                int             plen        = newExpLength / parts;
                int             currentp    = 0;
                int             totalCount  = 0;
                int             maxView     = 0;
                string          maxTitle    = "";
                ContentExpEntry currentExpC = null;
                foreach (ContentExpEntry ets in expsNew)
                {
                    if (currentp == 0)
                    {
                        currentExpC      = new ContentExpEntry("", "", 0, 0, 0, "");
                        maxView          = ets.View;
                        maxTitle         = ets.ExpName;
                        currentExpC.Date = ets.Date;
                    }

                    currentExpC.Vote    += ets.Vote;
                    currentExpC.View    += ets.View;
                    currentExpC.Collect += ets.Collect;

                    if (ets.View > maxView)
                    {
                        maxView  = ets.View;
                        maxTitle = ets.ExpName;
                    }

                    currentp++;
                    totalCount++;

                    if (currentp == plen || totalCount == newExpLength)
                    {
                        currentExpC.Date    = currentExpC.Date + "~" + ets.Date;
                        currentExpC.ExpName = currentExpC.Date + " " + currentp + "篇, 合计:";
                        _condensedExps.Add(currentExpC);
                        currentp = 0;
                    }
                }
            }
        }
示例#3
0
        private static void CalcDeltaExps()
        {
            _deltaExps.Clear();
            _progress = 0;
            float len   = _expsOld.Count;
            int   count = 0;

            string[] urlSeperator = { ".com/" };


            Hashtable h = new Hashtable();

            foreach (ContentExpEntry ets in _expsNew)
            {
                string key = ets.Url.Split(urlSeperator, StringSplitOptions.None)[1];
                if (h.ContainsKey(key))
                {
                    _isErrorInCalcDeltaExps = true;
                }
                else
                {
                    h.Add(key, ets);
                }
            }

            foreach (ContentExpEntry ets in _expsOld)   //对于历史数据中的每个经验条目
            {
                string          key = ets.Url.Split(urlSeperator, StringSplitOptions.None)[1];
                ContentExpEntry ft  = null;
                if (h.Contains(key))
                {
                    ft = (ContentExpEntry)h[key];
                }

                if (ft != null)
                {
                    string shortName;
                    if (ft.ExpName.Length > 10)
                    {
                        shortName = ft.ExpName.Substring(0, 10) + "...";
                    }
                    else
                    {
                        shortName = ft.ExpName;
                    }
                    ContentExpEntry eet = new ContentExpEntry(shortName, "", ft.View - ets.View, ft.Vote - ets.Vote, 0, ets.Date); //浏览量做差
                    _deltaExps.Add(eet);
                    ft.ViewIncrease = ft.View - ets.View;                                                                          //浏览量做差,保存
                }
                count++;
                _progress = count / len;
            }
        }