예제 #1
0
        public void GetCurrentUserCount()
        {
            while (true)
            {
                Thread.Sleep(10000);
                var total = 0;
                try
                {
                    var server = Connection.GetServer(_redisCfg, 6379);
                    var db     = Connection.GetDatabase();
                    var keys   = server.Keys();

                    foreach (var key in keys.AsQueryable())
                    {
                        var value = db.StringGet(key).ToString();
                        var arr   = value.Split('_');
                        if (!arr[0].Equals("1999"))
                        {
                            continue;
                        }
                        total++;
                    }
                }
                catch (Exception ex)
                {
                    AppLogger.Error($"{ex.Message} {ex.StackTrace}");
                }
                UpdateUi.UpdateLoginUser(total);
            }
        }
예제 #2
0
        //获取分页列表
        private void GetPagedListView()
        {
            var context   = new MySqlContext();
            var orders    = context.TbOrders;
            var cartGo    = context.TbCartGoes;
            var goods     = context.TbGoods;
            var orderInfo = from c in (from order in orders join go in cartGo on order.OrderId equals go.OrderId
                                       select new { Code = go.StockCode, Count = go.BuyCnt }) group c by c.Code into g select new { Code = g.Key, Cnt = g.Sum(p => p.Count) };
            var total = (from p in orderInfo
                         join good in goods on p.Code equals good.Code
                         select new { Name = good.Name, Code = good.Code, InNumber = good.Numbers, OutNumber = p.Cnt }).Count();
            var totalNumber = total / PageShowNumber + total % PageShowNumber == 0 ? 0 : 1;

            _currentPageIndex = _currentPageIndex > totalNumber ? 1 : _currentPageIndex;

            var result = (from p in (from c in (from order in orders
                                                join go in cartGo on order.OrderId equals go.OrderId
                                                select new { Code = go.StockCode, Count = go.BuyCnt })
                                     group c by c.Code into g
                                     select new { Code = g.Key, Cnt = g.Sum(p => p.Count) })
                          join good in goods on p.Code equals good.Code orderby p.Code
                          select new { Name = good.Name, Code = good.Code, InNumber = good.Numbers, OutNumber = p.Cnt }).Skip((_currentPageIndex - 1) * PageShowNumber).Take(PageShowNumber);
            var listRes = new List <ListShowModel>();

            listRes.AddRange(result.Select(x => new ListShowModel
            {
                Name      = x.Name,
                Code      = x.Code,
                InNumber  = x.InNumber,
                OutNumber = x.OutNumber
            }));
            UpdateUi.PostUpdateListView(listRes);
            _currentPageIndex++;
        }
예제 #3
0
        /// <summary>
        /// Updates the label text asynchronous.
        /// </summary>
        private void UpdateLabelTextAsync()
        {
            UpdateUi functionUi = UpdateLabelControl;

            //do work which doesn't involve UI controls.
            //.....
            //.....
            //.....
            //.....
            //Now we have to update UI control so special handling required.
            //InvokeRequired == true means you are on a non-UI thread.
            if (lblTotal.InvokeRequired)
            {
                lblTotal.BeginInvoke(functionUi);
            }
        }
예제 #4
0
 public void GetCurrentOrderNumber()
 {
     while (true)
     {
         Thread.Sleep(OrderStaticsTimeDelay);
         try
         {
             var orders    = new MySqlContext().TbOrders;
             var startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
             var endTime   = new DateTime(startTime.Year, startTime.Month, startTime.AddDays(1).Day, 0, 0, 0);
             var cnt       = orders.AsQueryable().Count(x => x.CreateTime >= startTime && x.CreateTime < endTime);
             UpdateUi.Post(cnt);
         }
         catch (Exception ex)
         {
             AppLogger.Error($"{ex.Message} {ex.StackTrace}");
         }
     }
 }
예제 #5
0
        public void Update(long nfirstHit, long nlastHit, long ntotalDamage, Dictionary <Entity, EntityInfo> nentities,
                           List <PlayerInfo> nstats, Entity ncurrentBoss)
        {
            UpdateUi changeUi =
                delegate(long firstHit, long lastHit, long totalDamage, Dictionary <Entity, EntityInfo> entities,
                         List <PlayerInfo> stats, Entity currentBoss)
            {
                StayTopMost();
                var entitiesStats = entities.ToList().OrderByDescending(e => e.Value.LastHit).ToList();
                var encounterList = new LinkedList <Entity>();
                foreach (var entityStats in entitiesStats)
                {
                    encounterList.AddLast(entityStats.Key);
                }
                UpdateComboboxEncounter(encounterList, currentBoss);
                _entityStats.Update(entities);
                var visiblePlayerStats = new HashSet <PlayerInfo>();
                var counter            = 0;
                foreach (var playerStats in stats)
                {
                    PlayerStats playerStatsControl;
                    Controls.TryGetValue(playerStats, out playerStatsControl);
                    if (playerStats.Dealt.Damage == 0 && playerStats.Received.Hits == 0)
                    {
                        continue;
                    }
                    visiblePlayerStats.Add(playerStats);
                    if (playerStatsControl != null)
                    {
                        continue;
                    }
                    playerStatsControl = new PlayerStats(playerStats);
                    Controls.Add(playerStats, playerStatsControl);

                    if (counter == 9)
                    {
                        break;
                    }
                    counter++;
                }

                var invisibleControls = Controls.Where(x => !visiblePlayerStats.Contains(x.Key)).ToList();
                foreach (var invisibleControl in invisibleControls)
                {
                    Controls[invisibleControl.Key].CloseSkills();
                    Controls.Remove(invisibleControl.Key);
                }

                TotalDamage.Content = FormatHelpers.Instance.FormatValue(totalDamage);
                var intervalvalue = lastHit - firstHit;
                var interval      = TimeSpan.FromSeconds(intervalvalue);
                Timer.Content = interval.ToString(@"mm\:ss");

                Players.Items.Clear();
                var sortedDict = from entry in Controls
                                 orderby
                                 stats[stats.IndexOf(entry.Value.PlayerInfo)].Dealt.DamageFraction(totalDamage) descending
                                 select entry;
                foreach (var item in sortedDict)
                {
                    Players.Items.Add(item.Value);
                    var data = stats.IndexOf(item.Value.PlayerInfo);

                    item.Value.Repaint(stats[data], totalDamage, firstHit, lastHit);
                }

                Height = Controls.Count * 29 + CloseMeter.ActualHeight;

                if (BasicTeraData.Instance.WindowData.InvisibleUI)
                {
                    Visibility = Controls.Count > 0 ? Visibility.Visible : Visibility.Hidden;
                }
            };

            Dispatcher.Invoke(changeUi, nfirstHit, nlastHit, ntotalDamage, nentities, nstats, ncurrentBoss);
        }
예제 #6
0
 private void EnableUi()
 {
     UpdateUi?.Invoke(true);
 }
예제 #7
0
 private void DisableUi()
 {
     UpdateUi?.Invoke(false);
 }
예제 #8
0
 public Client(UpdateUi updateUiMethod)
 {
     UpdateDelegate = updateUiMethod;
 }